aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-06-14 14:50:09 -0400
committerDrew DeVault <sir@cmpwn.com>2017-06-14 14:50:09 -0400
commit3f24f8a1bee10fb3aadf8c57ca107fe5aaa7cffa (patch)
tree923093315e92cc5351644b145dbad74b4317d9dd /backend
parentd6905f86cb9d430e0ba05c6a066ed350761116d1 (diff)
Flesh out touch events and add demo
Diffstat (limited to 'backend')
-rw-r--r--backend/libinput/events.c15
-rw-r--r--backend/libinput/touch.c78
2 files changed, 93 insertions, 0 deletions
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index 4af8082f..f8413dae 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -139,6 +139,21 @@ void wlr_libinput_event(struct wlr_backend_state *state,
case LIBINPUT_EVENT_POINTER_AXIS:
handle_pointer_axis(event, device);
break;
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ handle_touch_down(event, device);
+ break;
+ case LIBINPUT_EVENT_TOUCH_UP:
+ handle_touch_up(event, device);
+ break;
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ handle_touch_motion(event, device);
+ break;
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
+ handle_touch_cancel(event, device);
+ break;
+ case LIBINPUT_EVENT_TOUCH_FRAME:
+ // no-op (at least for now)
+ break;
default:
wlr_log(L_DEBUG, "Unknown libinput event %d", event_type);
break;
diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c
index 55e8609a..02c9cfef 100644
--- a/backend/libinput/touch.c
+++ b/backend/libinput/touch.c
@@ -13,3 +13,81 @@ struct wlr_touch *wlr_libinput_touch_create(
assert(device);
return wlr_touch_create(NULL, NULL);
}
+
+void handle_touch_down(struct libinput_event *event,
+ struct libinput_device *device) {
+ struct wlr_input_device *dev =
+ get_appropriate_device(WLR_INPUT_DEVICE_TOUCH, device);
+ if (!dev) {
+ wlr_log(L_DEBUG, "Got a touch event for a device with no touch?");
+ return;
+ }
+ struct libinput_event_touch *tevent =
+ libinput_event_get_touch_event(event);
+ struct wlr_touch_down *wlr_event =
+ calloc(1, sizeof(struct wlr_touch_down));
+ 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);
+ wlr_event->x_mm = libinput_event_touch_get_x(tevent);
+ wlr_event->y_mm = libinput_event_touch_get_y(tevent);
+ libinput_device_get_size(device, &wlr_event->width_mm, &wlr_event->height_mm);
+ wl_signal_emit(&dev->touch->events.down, wlr_event);
+}
+
+void handle_touch_up(struct libinput_event *event,
+ struct libinput_device *device) {
+ struct wlr_input_device *dev =
+ get_appropriate_device(WLR_INPUT_DEVICE_TOUCH, device);
+ if (!dev) {
+ wlr_log(L_DEBUG, "Got a touch event for a device with no touch?");
+ return;
+ }
+ struct libinput_event_touch *tevent =
+ libinput_event_get_touch_event(event);
+ struct wlr_touch_up *wlr_event =
+ calloc(1, sizeof(struct wlr_touch_up));
+ 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);
+ wl_signal_emit(&dev->touch->events.up, wlr_event);
+}
+
+void handle_touch_motion(struct libinput_event *event,
+ struct libinput_device *device) {
+ struct wlr_input_device *dev =
+ get_appropriate_device(WLR_INPUT_DEVICE_TOUCH, device);
+ if (!dev) {
+ wlr_log(L_DEBUG, "Got a touch event for a device with no touch?");
+ return;
+ }
+ struct libinput_event_touch *tevent =
+ libinput_event_get_touch_event(event);
+ struct wlr_touch_motion *wlr_event =
+ calloc(1, sizeof(struct wlr_touch_motion));
+ 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);
+ wlr_event->x_mm = libinput_event_touch_get_x(tevent);
+ wlr_event->y_mm = libinput_event_touch_get_y(tevent);
+ libinput_device_get_size(device, &wlr_event->width_mm, &wlr_event->height_mm);
+ wl_signal_emit(&dev->touch->events.motion, wlr_event);
+}
+
+void handle_touch_cancel(struct libinput_event *event,
+ struct libinput_device *device) {
+ struct wlr_input_device *dev =
+ get_appropriate_device(WLR_INPUT_DEVICE_TOUCH, device);
+ if (!dev) {
+ wlr_log(L_DEBUG, "Got a touch event for a device with no touch?");
+ return;
+ }
+ struct libinput_event_touch *tevent =
+ libinput_event_get_touch_event(event);
+ struct wlr_touch_cancel *wlr_event =
+ calloc(1, sizeof(struct wlr_touch_cancel));
+ 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);
+ wl_signal_emit(&dev->touch->events.cancel, wlr_event);
+}