genode_c_api: key-press/release and relative-motion events

Issue #4543
This commit is contained in:
Christian Helmuth 2022-06-24 14:44:56 +02:00
parent 393766a931
commit 4550ec4716
2 changed files with 30 additions and 0 deletions

View File

@ -1,6 +1,7 @@
/*
* \brief C interface to Genode's event session
* \author Norman Feske
* \author Christian Helmuth
* \date 2021-09-29
*/
@ -62,9 +63,16 @@ struct genode_event_submit;
/**
* Interface called by 'genode_event_generator_t' to submit events
*
* Note, keycode values must conform to os/include/input/keycodes.h.
*/
struct genode_event_submit
{
void (*press) (struct genode_event_submit *, unsigned keycode);
void (*release) (struct genode_event_submit *, unsigned keycode);
void (*rel_motion) (struct genode_event_submit *, int x, int y);
void (*touch) (struct genode_event_submit *,
struct genode_event_touch_args const *);

View File

@ -1,6 +1,7 @@
/*
* \brief C interface to Genode's event session
* \author Norman Feske
* \author Christian Helmuth
* \date 2021-09-29
*/
@ -72,6 +73,24 @@ namespace {
fn(static_cast<Submit *>(myself)->batch);
}
static void _press(struct genode_event_submit *myself, unsigned keycode)
{
_with_batch(myself, [&] (Event::Session_client::Batch &batch) {
batch.submit(Input::Press { Input::Keycode(keycode) }); });
}
static void _release(struct genode_event_submit *myself, unsigned keycode)
{
_with_batch(myself, [&] (Event::Session_client::Batch &batch) {
batch.submit(Input::Release { Input::Keycode(keycode) }); });
}
static void _rel_motion(struct genode_event_submit *myself, int x, int y)
{
_with_batch(myself, [&] (Event::Session_client::Batch &batch) {
batch.submit(Input::Relative_motion { x, y }); });
}
static void _touch(struct genode_event_submit *myself,
struct genode_event_touch_args const *args)
{
@ -94,6 +113,9 @@ namespace {
:
batch(batch)
{
press = _press;
release = _release;
rel_motion = _rel_motion;
touch = _touch;
touch_release = _touch_release;
};