From 2a3c62b4d28ec7a69473e9c18c42f1ed26c74bbf Mon Sep 17 00:00:00 2001 From: Ryan Walklin Date: Wed, 14 Nov 2018 23:24:55 +0000 Subject: [WIP][DONTMERGE]Add support for libinput_switch input devices These are used primarily by laptops to signal the state of the lid (open/closed) and tablet mode if supported, based on ACPI events. --- backend/libinput/events.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'backend/libinput/events.c') diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 9ce62d6f..a7a6c114 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -169,7 +169,17 @@ static void handle_device_added(struct wlr_libinput_backend *backend, } if (libinput_device_has_capability( libinput_dev, LIBINPUT_DEVICE_CAP_SWITCH)) { - // TODO + struct wlr_input_device *wlr_dev = allocate_device(backend, + libinput_dev, wlr_devices, WLR_INPUT_DEVICE_SWITCH); + if (!wlr_dev) { + goto fail; + } + wlr_dev->lid_switch = create_libinput_switch(libinput_dev); + if (!wlr_dev->lid_switch) { + free(wlr_dev); + goto fail; + } + wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev); } if (!wl_list_empty(wlr_devices)) { @@ -274,6 +284,9 @@ void handle_libinput_event(struct wlr_libinput_backend *backend, case LIBINPUT_EVENT_TABLET_PAD_STRIP: handle_tablet_pad_strip(event, libinput_dev); break; + case LIBINPUT_EVENT_SWITCH_TOGGLE: + handle_switch_toggle(event, libinput_dev); + break; default: wlr_log(WLR_DEBUG, "Unknown libinput event %d", event_type); break; -- cgit v1.2.3