mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
implement tablet tool devices
This commit is contained in:
parent
0dc3aecfd4
commit
df0ee7f25f
5 changed files with 69 additions and 9 deletions
|
@ -30,6 +30,7 @@ void handle_tablet_tool_axis(struct libinput_event *event,
|
||||||
struct libinput_event_tablet_tool *tevent =
|
struct libinput_event_tablet_tool *tevent =
|
||||||
libinput_event_get_tablet_tool_event(event);
|
libinput_event_get_tablet_tool_event(event);
|
||||||
struct wlr_event_tablet_tool_axis wlr_event = { 0 };
|
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_sec = libinput_event_tablet_tool_get_time(tevent);
|
||||||
wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(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);
|
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 =
|
struct libinput_event_tablet_tool *tevent =
|
||||||
libinput_event_get_tablet_tool_event(event);
|
libinput_event_get_tablet_tool_event(event);
|
||||||
struct wlr_event_tablet_tool_proximity wlr_event = { 0 };
|
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_sec = libinput_event_tablet_tool_get_time(tevent);
|
||||||
wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
|
wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
|
||||||
switch (libinput_event_tablet_tool_get_proximity_state(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 =
|
struct libinput_event_tablet_tool *tevent =
|
||||||
libinput_event_get_tablet_tool_event(event);
|
libinput_event_get_tablet_tool_event(event);
|
||||||
struct wlr_event_tablet_tool_tip wlr_event = { 0 };
|
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_sec = libinput_event_tablet_tool_get_time(tevent);
|
||||||
wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
|
wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
|
||||||
switch (libinput_event_tablet_tool_get_tip_state(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 =
|
struct libinput_event_tablet_tool *tevent =
|
||||||
libinput_event_get_tablet_tool_event(event);
|
libinput_event_get_tablet_tool_event(event);
|
||||||
struct wlr_event_tablet_tool_button wlr_event = { 0 };
|
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_sec = libinput_event_tablet_tool_get_time(tevent);
|
||||||
wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
|
wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
|
||||||
wlr_event.button = libinput_event_tablet_tool_get_button(tevent);
|
wlr_event.button = libinput_event_tablet_tool_get_button(tevent);
|
||||||
|
|
|
@ -175,9 +175,9 @@ static void handle_input_add(struct compositor_state *state, struct
|
||||||
wlr_input_device *device) {
|
wlr_input_device *device) {
|
||||||
struct sample_state *sample = state->data;
|
struct sample_state *sample = state->data;
|
||||||
|
|
||||||
// TODO handle other input devices
|
|
||||||
if (device->type == WLR_INPUT_DEVICE_POINTER ||
|
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;
|
struct sample_input_device *s_device;
|
||||||
s_device = calloc(1, sizeof(struct sample_input_device));
|
s_device = calloc(1, sizeof(struct sample_input_device));
|
||||||
s_device->device = device;
|
s_device->device = device;
|
||||||
|
|
|
@ -25,6 +25,11 @@ struct wlr_cursor {
|
||||||
struct wl_signal touch_down;
|
struct wl_signal touch_down;
|
||||||
struct wl_signal touch_motion;
|
struct wl_signal touch_motion;
|
||||||
struct wl_signal touch_cancel;
|
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;
|
} events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ enum wlr_tablet_tool_axes {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_event_tablet_tool_axis {
|
struct wlr_event_tablet_tool_axis {
|
||||||
|
struct wlr_input_device *device;
|
||||||
uint32_t time_sec;
|
uint32_t time_sec;
|
||||||
uint64_t time_usec;
|
uint64_t time_usec;
|
||||||
uint32_t updated_axes;
|
uint32_t updated_axes;
|
||||||
|
@ -51,6 +52,7 @@ enum wlr_tablet_tool_proximity_state {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_event_tablet_tool_proximity {
|
struct wlr_event_tablet_tool_proximity {
|
||||||
|
struct wlr_input_device *device;
|
||||||
uint32_t time_sec;
|
uint32_t time_sec;
|
||||||
uint64_t time_usec;
|
uint64_t time_usec;
|
||||||
double x, y;
|
double x, y;
|
||||||
|
@ -64,6 +66,7 @@ enum wlr_tablet_tool_tip_state {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_event_tablet_tool_tip {
|
struct wlr_event_tablet_tool_tip {
|
||||||
|
struct wlr_input_device *device;
|
||||||
uint32_t time_sec;
|
uint32_t time_sec;
|
||||||
uint64_t time_usec;
|
uint64_t time_usec;
|
||||||
double x, y;
|
double x, y;
|
||||||
|
@ -72,6 +75,7 @@ struct wlr_event_tablet_tool_tip {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_event_tablet_tool_button {
|
struct wlr_event_tablet_tool_button {
|
||||||
|
struct wlr_input_device *device;
|
||||||
uint32_t time_sec;
|
uint32_t time_sec;
|
||||||
uint64_t time_usec;
|
uint64_t time_usec;
|
||||||
uint32_t button;
|
uint32_t button;
|
||||||
|
|
|
@ -24,6 +24,11 @@ struct wlr_cursor_device {
|
||||||
struct wl_listener touch_up;
|
struct wl_listener touch_up;
|
||||||
struct wl_listener touch_motion;
|
struct wl_listener touch_motion;
|
||||||
struct wl_listener touch_cancel;
|
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 {
|
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_motion);
|
||||||
wl_signal_init(&cur->events.touch_cancel);
|
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->x = 100;
|
||||||
cur->y = 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);
|
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,
|
void wlr_cursor_attach_input_device(struct wlr_cursor *cur,
|
||||||
struct wlr_input_device *dev) {
|
struct wlr_input_device *dev) {
|
||||||
if (dev->type != WLR_INPUT_DEVICE_POINTER &&
|
if (dev->type != WLR_INPUT_DEVICE_POINTER &&
|
||||||
|
@ -289,13 +328,6 @@ void wlr_cursor_attach_input_device(struct wlr_cursor *cur,
|
||||||
return;
|
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
|
// make sure it is not already attached
|
||||||
struct wlr_cursor_device *_dev;
|
struct wlr_cursor_device *_dev;
|
||||||
wl_list_for_each(_dev, &cur->state->devices, link) {
|
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);
|
wl_signal_add(&dev->touch->events.cancel, &device->touch_cancel);
|
||||||
device->touch_cancel.notify = handle_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);
|
wl_list_insert(&cur->state->devices, &device->link);
|
||||||
|
|
Loading…
Reference in a new issue