From 28081b76891ddbbb825dee6c202037d78aa8f164 Mon Sep 17 00:00:00 2001 From: Cole Mickens Date: Sun, 17 Jan 2016 02:53:37 -0800 Subject: libinput --- sway/handlers.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'sway/handlers.c') diff --git a/sway/handlers.c b/sway/handlers.c index 60bfac87..b1c0e26a 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,8 @@ #include "extensions.h" #include "criteria.h" #include "ipc-server.h" +#include "list.h" +#include "input.h" // Event should be sent to client #define EVENT_PASSTHROUGH false @@ -30,6 +33,37 @@ /* Handles */ +static bool handle_input_created(struct libinput_device *device) { + const char *identifier = libinput_dev_unique_id(device); + sway_log(L_INFO, "Found input device (%s)", identifier); + + list_add(input_devices, device); + + struct input_config *ic = NULL; + int i; + for (i = 0; i < config->input_configs->length; ++i) { + struct input_config *cur = config->input_configs->items[i]; + if (strcasecmp(identifier, cur->identifier) == 0) { + ic = cur; + break; + } + } + + apply_input_config(ic, device); + return true; +} + +static void handle_input_destroyed(struct libinput_device *device) { + int i; + list_t *list = input_devices; + for (i = 0; i < list->length; ++i) { + if(((struct libinput_device *)list->items[i]) == device) { + list_del(list, i); + break; + } + } +} + static bool handle_output_created(wlc_handle output) { swayc_t *op = new_output(output); @@ -660,5 +694,9 @@ struct wlc_interface interface = { }, .compositor = { .ready = handle_wlc_ready + }, + .input = { + .created = handle_input_created, + .destroyed = handle_input_destroyed } }; -- cgit v1.2.3