From d6905f86cb9d430e0ba05c6a066ed350761116d1 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 14 Jun 2017 11:40:03 -0400 Subject: Allocate wlr_touch devices --- backend/CMakeLists.txt | 1 + backend/libinput/backend.c | 2 +- backend/libinput/events.c | 17 +++++++++++------ backend/libinput/touch.c | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 backend/libinput/touch.c (limited to 'backend') diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index b8df9373..8272e039 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -18,6 +18,7 @@ add_library(wlr-backend libinput/events.c libinput/keyboard.c libinput/pointer.c + libinput/touch.c multi/backend.c backend.c diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index 9b0a6d8c..82ba44a6 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -102,7 +102,7 @@ struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, goto error_state; } - if (!(state->keyboards = list_create())) { + if (!(state->devices = list_create())) { wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno)); goto error_backend; } diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 5ef58a3e..4af8082f 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -33,7 +33,8 @@ static struct wlr_input_device_impl input_device_impl = { .destroy = wlr_libinput_device_destroy }; -static struct wlr_input_device *allocate_device(struct libinput_device *device, +static struct wlr_input_device *allocate_device( + struct wlr_backend_state *state, struct libinput_device *device, list_t *devices, enum wlr_input_device_type type) { int vendor = libinput_device_get_id_vendor(device); int product = libinput_device_get_id_product(device); @@ -46,6 +47,7 @@ static struct wlr_input_device *allocate_device(struct libinput_device *device, type, &input_device_impl, devstate, name, vendor, product); list_add(devices, wlr_device); + list_add(state->devices, wlr_device); return wlr_device; } @@ -65,19 +67,22 @@ static void handle_device_added(struct wlr_backend_state *state, wlr_log(L_DEBUG, "Added %s [%d:%d]", name, vendor, product); if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) { - struct wlr_input_device *wlr_device = allocate_device(device, devices, - WLR_INPUT_DEVICE_KEYBOARD); + struct wlr_input_device *wlr_device = allocate_device(state, + device, devices, WLR_INPUT_DEVICE_KEYBOARD); wlr_device->keyboard = wlr_libinput_keyboard_create(device); wl_signal_emit(&state->backend->events.input_add, wlr_device); } if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER)) { - struct wlr_input_device *wlr_device = allocate_device(device, devices, - WLR_INPUT_DEVICE_POINTER); + struct wlr_input_device *wlr_device = allocate_device(state, + device, devices, WLR_INPUT_DEVICE_POINTER); wlr_device->pointer = wlr_libinput_pointer_create(device); wl_signal_emit(&state->backend->events.input_add, wlr_device); } if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH)) { - // TODO + struct wlr_input_device *wlr_device = allocate_device(state, + device, devices, WLR_INPUT_DEVICE_TOUCH); + wlr_device->touch = wlr_libinput_touch_create(device); + wl_signal_emit(&state->backend->events.input_add, wlr_device); } if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_TOOL)) { // TODO diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c new file mode 100644 index 00000000..55e8609a --- /dev/null +++ b/backend/libinput/touch.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include +#include +#include +#include "backend/libinput.h" +#include "common/log.h" +#include "types.h" + +struct wlr_touch *wlr_libinput_touch_create( + struct libinput_device *device) { + assert(device); + return wlr_touch_create(NULL, NULL); +} -- cgit v1.2.3