evdev: abstract the get_switch_state method

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2017-09-19 13:45:22 +10:00
parent 6c7dd36398
commit 27eff1ac03
5 changed files with 21 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 {