Shove it into the generic dispatch interface so we don't entangle evdev and
fallback.

Signed-off-by: Peter Hutterer <[email protected]>
---
 src/evdev-mt-touchpad.c |  1 +
 src/evdev-tablet-pad.c  |  1 +
 src/evdev-tablet.c      |  1 +
 src/evdev.c             | 14 +++++++++++++-
 src/evdev.h             |  5 +++++
 5 files changed, 21 insertions(+), 1 deletion(-)

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 fbbcae09..5025fff3 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -1871,6 +1871,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 b2149eff..3a122ffd 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:
@@ -1735,6 +1746,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 407ebb14..d2aa85bd 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 {
-- 
2.13.5

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to