diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index a2b97c97..af3e8907 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -2261,6 +2261,7 @@ static struct evdev_dispatch_interface tp_interface = { .device_resumed = tp_interface_device_added, /* treat as add */ .post_added = NULL, .toggle_touch = tp_interface_toggle_touch, + .get_switch_state = NULL, }; static void diff --git a/src/evdev-tablet-pad.c b/src/evdev-tablet-pad.c index 00db4c29..82604d70 100644 --- a/src/evdev-tablet-pad.c +++ b/src/evdev-tablet-pad.c @@ -514,6 +514,7 @@ static struct evdev_dispatch_interface pad_interface = { .device_resumed = NULL, .post_added = NULL, .toggle_touch = NULL, + .get_switch_state = NULL, }; static void diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 462e8e40..d672484e 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -1882,6 +1882,7 @@ static struct evdev_dispatch_interface tablet_interface = { .device_resumed = NULL, .post_added = tablet_check_initial_proximity, .toggle_touch = NULL, + .get_switch_state = NULL, }; static void diff --git a/src/evdev.c b/src/evdev.c index 4ceaac41..1631f88b 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -189,7 +189,18 @@ enum libinput_switch_state evdev_device_switch_get_state(struct evdev_device *device, enum libinput_switch sw) { - struct fallback_dispatch *dispatch = fallback_dispatch(device->dispatch); + struct evdev_dispatch *dispatch = device->dispatch; + + assert(dispatch->interface->get_switch_state); + + return dispatch->interface->get_switch_state(dispatch, sw); +} + +static enum libinput_switch_state +fallback_get_switch_state(struct evdev_dispatch *evdev_dispatch, + enum libinput_switch sw) +{ + struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch); switch (sw) { case LIBINPUT_SWITCH_TABLET_MODE: @@ -1774,6 +1785,7 @@ struct evdev_dispatch_interface fallback_interface = { .device_resumed = fallback_interface_device_added, /* treat as add */ .post_added = fallback_sync_initial_state, .toggle_touch = fallback_toggle_touch, + .get_switch_state = fallback_get_switch_state, }; static uint32_t diff --git a/src/evdev.h b/src/evdev.h index 57113e64..b1cc2a75 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -313,6 +313,11 @@ struct evdev_dispatch_interface { void (*toggle_touch)(struct evdev_dispatch *dispatch, struct evdev_device *device, bool enable); + + /* Return the state of the given switch */ + enum libinput_switch_state + (*get_switch_state)(struct evdev_dispatch *dispatch, + enum libinput_switch which); }; enum evdev_dispatch_type {