From 98f4cdfccb7d2ace2929bca45f0479b3472b96ac Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 24 Aug 2017 14:35:55 -0400 Subject: implement wlr_cursor_map_input_to_output --- backend/libinput/pointer.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'backend/libinput') diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index 8bda205d..005c9516 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -30,6 +30,7 @@ void handle_pointer_motion(struct libinput_event *event, struct libinput_event_pointer *pevent = libinput_event_get_pointer_event(event); struct wlr_event_pointer_motion wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_pointer_get_time(pevent); wlr_event.time_usec = libinput_event_pointer_get_time_usec(pevent); wlr_event.delta_x = libinput_event_pointer_get_dx(pevent); @@ -48,6 +49,7 @@ void handle_pointer_motion_abs(struct libinput_event *event, struct libinput_event_pointer *pevent = libinput_event_get_pointer_event(event); struct wlr_event_pointer_motion_absolute wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_pointer_get_time(pevent); wlr_event.time_usec = libinput_event_pointer_get_time_usec(pevent); wlr_event.x_mm = libinput_event_pointer_get_absolute_x(pevent); @@ -67,6 +69,7 @@ void handle_pointer_button(struct libinput_event *event, struct libinput_event_pointer *pevent = libinput_event_get_pointer_event(event); struct wlr_event_pointer_button wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_pointer_get_time(pevent); wlr_event.time_usec = libinput_event_pointer_get_time_usec(pevent); wlr_event.button = libinput_event_pointer_get_button(pevent); @@ -92,6 +95,7 @@ void handle_pointer_axis(struct libinput_event *event, struct libinput_event_pointer *pevent = libinput_event_get_pointer_event(event); struct wlr_event_pointer_axis wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_pointer_get_time(pevent); wlr_event.time_usec = libinput_event_pointer_get_time_usec(pevent); switch (libinput_event_pointer_get_axis_source(pevent)) { -- cgit v1.2.3 From c91469767631c84375678f3428a43c355d2c9742 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 27 Aug 2017 11:44:55 -0400 Subject: add device to touch events --- backend/libinput/touch.c | 4 ++++ include/wlr/types/wlr_touch.h | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'backend/libinput') diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c index 9e08d028..2f300482 100644 --- a/backend/libinput/touch.c +++ b/backend/libinput/touch.c @@ -30,6 +30,7 @@ void handle_touch_down(struct libinput_event *event, struct libinput_event_touch *tevent = libinput_event_get_touch_event(event); struct wlr_event_touch_down wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_touch_get_time(tevent); wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent); wlr_event.slot = libinput_event_touch_get_slot(tevent); @@ -50,6 +51,7 @@ void handle_touch_up(struct libinput_event *event, struct libinput_event_touch *tevent = libinput_event_get_touch_event(event); struct wlr_event_touch_up wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_touch_get_time(tevent); wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent); wlr_event.slot = libinput_event_touch_get_slot(tevent); @@ -67,6 +69,7 @@ void handle_touch_motion(struct libinput_event *event, struct libinput_event_touch *tevent = libinput_event_get_touch_event(event); struct wlr_event_touch_motion wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_touch_get_time(tevent); wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent); wlr_event.slot = libinput_event_touch_get_slot(tevent); @@ -87,6 +90,7 @@ void handle_touch_cancel(struct libinput_event *event, struct libinput_event_touch *tevent = libinput_event_get_touch_event(event); struct wlr_event_touch_cancel wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_touch_get_time(tevent); wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent); wlr_event.slot = libinput_event_touch_get_slot(tevent); diff --git a/include/wlr/types/wlr_touch.h b/include/wlr/types/wlr_touch.h index 93069fcb..1a27cad3 100644 --- a/include/wlr/types/wlr_touch.h +++ b/include/wlr/types/wlr_touch.h @@ -19,6 +19,7 @@ struct wlr_touch { }; struct wlr_event_touch_down { + struct wlr_input_device *device; uint32_t time_sec; uint64_t time_usec; int32_t slot; @@ -27,12 +28,14 @@ struct wlr_event_touch_down { }; struct wlr_event_touch_up { + struct wlr_input_device *device; uint32_t time_sec; uint64_t time_usec; int32_t slot; }; struct wlr_event_touch_motion { + struct wlr_input_device *device; uint32_t time_sec; uint64_t time_usec; int32_t slot; @@ -41,6 +44,7 @@ struct wlr_event_touch_motion { }; struct wlr_event_touch_cancel { + struct wlr_input_device *device; uint32_t time_sec; uint64_t time_usec; int32_t slot; -- cgit v1.2.3 From df0ee7f25ff628360f38d87b8a74daaa2cc742a8 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Mon, 28 Aug 2017 08:42:39 -0400 Subject: implement tablet tool devices --- backend/libinput/tablet_tool.c | 4 +++ examples/pointer.c | 4 +-- include/wlr/types/wlr_cursor.h | 5 +++ include/wlr/types/wlr_tablet_tool.h | 4 +++ types/wlr_cursor.c | 61 ++++++++++++++++++++++++++++++++----- 5 files changed, 69 insertions(+), 9 deletions(-) (limited to 'backend/libinput') diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 8b3d34ed..472e8506 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -30,6 +30,7 @@ void handle_tablet_tool_axis(struct libinput_event *event, struct libinput_event_tablet_tool *tevent = libinput_event_get_tablet_tool_event(event); struct wlr_event_tablet_tool_axis wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_tablet_tool_get_time(tevent); wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent); libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm); @@ -83,6 +84,7 @@ void handle_tablet_tool_proximity(struct libinput_event *event, struct libinput_event_tablet_tool *tevent = libinput_event_get_tablet_tool_event(event); struct wlr_event_tablet_tool_proximity wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_tablet_tool_get_time(tevent); wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent); switch (libinput_event_tablet_tool_get_proximity_state(tevent)) { @@ -109,6 +111,7 @@ void handle_tablet_tool_tip(struct libinput_event *event, struct libinput_event_tablet_tool *tevent = libinput_event_get_tablet_tool_event(event); struct wlr_event_tablet_tool_tip wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_tablet_tool_get_time(tevent); wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent); switch (libinput_event_tablet_tool_get_tip_state(tevent)) { @@ -134,6 +137,7 @@ void handle_tablet_tool_button(struct libinput_event *event, struct libinput_event_tablet_tool *tevent = libinput_event_get_tablet_tool_event(event); struct wlr_event_tablet_tool_button wlr_event = { 0 }; + wlr_event.device = wlr_dev; wlr_event.time_sec = libinput_event_tablet_tool_get_time(tevent); wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent); wlr_event.button = libinput_event_tablet_tool_get_button(tevent); diff --git a/examples/pointer.c b/examples/pointer.c index 98b4735a..3863c0e8 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -175,9 +175,9 @@ static void handle_input_add(struct compositor_state *state, struct wlr_input_device *device) { struct sample_state *sample = state->data; - // TODO handle other input devices if (device->type == WLR_INPUT_DEVICE_POINTER || - device->type == WLR_INPUT_DEVICE_TOUCH) { + device->type == WLR_INPUT_DEVICE_TOUCH || + device->type == WLR_INPUT_DEVICE_TABLET_TOOL) { struct sample_input_device *s_device; s_device = calloc(1, sizeof(struct sample_input_device)); s_device->device = device; diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h index 4ba7b25f..35c2ff8e 100644 --- a/include/wlr/types/wlr_cursor.h +++ b/include/wlr/types/wlr_cursor.h @@ -25,6 +25,11 @@ struct wlr_cursor { struct wl_signal touch_down; struct wl_signal touch_motion; struct wl_signal touch_cancel; + + struct wl_signal tablet_tool_axis; + struct wl_signal tablet_tool_proximity; + struct wl_signal tablet_tool_tip; + struct wl_signal tablet_tool_button; } events; }; diff --git a/include/wlr/types/wlr_tablet_tool.h b/include/wlr/types/wlr_tablet_tool.h index dcb9c191..98fd82c0 100644 --- a/include/wlr/types/wlr_tablet_tool.h +++ b/include/wlr/types/wlr_tablet_tool.h @@ -32,6 +32,7 @@ enum wlr_tablet_tool_axes { }; struct wlr_event_tablet_tool_axis { + struct wlr_input_device *device; uint32_t time_sec; uint64_t time_usec; uint32_t updated_axes; @@ -51,6 +52,7 @@ enum wlr_tablet_tool_proximity_state { }; struct wlr_event_tablet_tool_proximity { + struct wlr_input_device *device; uint32_t time_sec; uint64_t time_usec; double x, y; @@ -64,6 +66,7 @@ enum wlr_tablet_tool_tip_state { }; struct wlr_event_tablet_tool_tip { + struct wlr_input_device *device; uint32_t time_sec; uint64_t time_usec; double x, y; @@ -72,6 +75,7 @@ struct wlr_event_tablet_tool_tip { }; struct wlr_event_tablet_tool_button { + struct wlr_input_device *device; uint32_t time_sec; uint64_t time_usec; uint32_t button; diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index f183e64a..c62fba9b 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -24,6 +24,11 @@ struct wlr_cursor_device { struct wl_listener touch_up; struct wl_listener touch_motion; struct wl_listener touch_cancel; + + struct wl_listener tablet_tool_axis; + struct wl_listener tablet_tool_proximity; + struct wl_listener tablet_tool_tip; + struct wl_listener tablet_tool_button; }; struct wlr_cursor_state { @@ -63,6 +68,12 @@ struct wlr_cursor *wlr_cursor_init() { wl_signal_init(&cur->events.touch_motion); wl_signal_init(&cur->events.touch_cancel); + // tablet tool signals + wl_signal_init(&cur->events.tablet_tool_tip); + wl_signal_init(&cur->events.tablet_tool_axis); + wl_signal_init(&cur->events.tablet_tool_button); + wl_signal_init(&cur->events.tablet_tool_proximity); + cur->x = 100; cur->y = 100; @@ -279,6 +290,34 @@ static void handle_touch_cancel(struct wl_listener *listener, void *data) { wl_signal_emit(&device->cursor->events.touch_cancel, event); } +static void handle_tablet_tool_tip(struct wl_listener *listener, void *data) { + struct wlr_event_tablet_tool_tip *event = data; + struct wlr_cursor_device *device; + device = wl_container_of(listener, device, tablet_tool_tip); + wl_signal_emit(&device->cursor->events.tablet_tool_tip, event); +} + +static void handle_tablet_tool_axis(struct wl_listener *listener, void *data) { + struct wlr_event_tablet_tool_axis *event = data; + struct wlr_cursor_device *device; + device = wl_container_of(listener, device, tablet_tool_axis); + wl_signal_emit(&device->cursor->events.tablet_tool_axis, event); +} + +static void handle_tablet_tool_button(struct wl_listener *listener, void *data) { + struct wlr_event_tablet_tool_button *event = data; + struct wlr_cursor_device *device; + device = wl_container_of(listener, device, tablet_tool_button); + wl_signal_emit(&device->cursor->events.tablet_tool_button, event); +} + +static void handle_tablet_tool_proximity(struct wl_listener *listener, void *data) { + struct wlr_event_tablet_tool_proximity *event = data; + struct wlr_cursor_device *device; + device = wl_container_of(listener, device, tablet_tool_proximity); + wl_signal_emit(&device->cursor->events.tablet_tool_proximity, event); +} + void wlr_cursor_attach_input_device(struct wlr_cursor *cur, struct wlr_input_device *dev) { if (dev->type != WLR_INPUT_DEVICE_POINTER && @@ -289,13 +328,6 @@ void wlr_cursor_attach_input_device(struct wlr_cursor *cur, return; } - // TODO support other device types - if (dev->type != WLR_INPUT_DEVICE_POINTER && - dev->type != WLR_INPUT_DEVICE_TOUCH) { - wlr_log(L_ERROR, "TODO: support tablet tool devices"); - return; - } - // make sure it is not already attached struct wlr_cursor_device *_dev; wl_list_for_each(_dev, &cur->state->devices, link) { @@ -340,6 +372,21 @@ void wlr_cursor_attach_input_device(struct wlr_cursor *cur, wl_signal_add(&dev->touch->events.cancel, &device->touch_cancel); device->touch_cancel.notify = handle_touch_cancel; + } else if (dev->type == WLR_INPUT_DEVICE_TABLET_TOOL) { + wl_signal_add(&dev->tablet_tool->events.tip, &device->tablet_tool_tip); + device->tablet_tool_tip.notify = handle_tablet_tool_tip; + + wl_signal_add(&dev->tablet_tool->events.proximity, + &device->tablet_tool_proximity); + device->tablet_tool_proximity.notify = handle_tablet_tool_proximity; + + wl_signal_add(&dev->tablet_tool->events.axis, + &device->tablet_tool_axis); + device->tablet_tool_axis.notify = handle_tablet_tool_axis; + + wl_signal_add(&dev->tablet_tool->events.button, + &device->tablet_tool_button); + device->tablet_tool_button.notify = handle_tablet_tool_button; } wl_list_insert(&cur->state->devices, &device->link); -- cgit v1.2.3