aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-08-28 08:42:39 -0400
committerTony Crisci <tony@dubstepdish.com>2017-08-28 10:23:14 -0400
commitdf0ee7f25ff628360f38d87b8a74daaa2cc742a8 (patch)
treebc19522dd936ae5f4da83bd0f143218b91fa2a61
parent0dc3aecfd4db39953503ccdc82ab44ace03c7f44 (diff)
implement tablet tool devices
-rw-r--r--backend/libinput/tablet_tool.c4
-rw-r--r--examples/pointer.c4
-rw-r--r--include/wlr/types/wlr_cursor.h5
-rw-r--r--include/wlr/types/wlr_tablet_tool.h4
-rw-r--r--types/wlr_cursor.c61
5 files changed, 69 insertions, 9 deletions
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);