mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
storage commit #2
This commit is contained in:
parent
4947295c8f
commit
77bac448cc
5 changed files with 138 additions and 188 deletions
|
|
@ -8,7 +8,60 @@
|
|||
#include "backend/libinput.h"
|
||||
#include "util/signal.h"
|
||||
|
||||
struct wlr_tablet_pad *create_libinput_tablet_pad(
|
||||
static void add_pad_group_from_libinput(struct wlr_tablet_pad *pad,
|
||||
struct libinput_device *device, unsigned int index) {
|
||||
struct libinput_tablet_pad_mode_group *li_group =
|
||||
libinput_device_tablet_pad_get_mode_group(device, index);
|
||||
struct wlr_tablet_pad_group_v2 *group =
|
||||
calloc(1, sizeof(struct wlr_tablet_pad_group_v2));
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < pad->ring_count; ++i) {
|
||||
if (libinput_tablet_pad_mode_group_has_ring(li_group, i)) {
|
||||
++group->ring_count;
|
||||
}
|
||||
}
|
||||
group->rings = calloc(sizeof(int), group->ring_count);
|
||||
size_t ring = 0;
|
||||
for (size_t i = 0; i < pad->ring_count; ++i) {
|
||||
if (libinput_tablet_pad_mode_group_has_ring(li_group, i)) {
|
||||
group->rings[ring++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < pad->strip_count; ++i) {
|
||||
if (libinput_tablet_pad_mode_group_has_strip(li_group, i)) {
|
||||
++group->strip_count;
|
||||
}
|
||||
}
|
||||
group->strips = calloc(sizeof(int), group->strip_count);
|
||||
size_t strip = 0;
|
||||
for (size_t i = 0; i < pad->strip_count; ++i) {
|
||||
if (libinput_tablet_pad_mode_group_has_strip(li_group, i)) {
|
||||
group->strips[strip++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < pad->button_count; ++i) {
|
||||
if (libinput_tablet_pad_mode_group_has_button(li_group, i)) {
|
||||
++group->button_count;
|
||||
}
|
||||
}
|
||||
group->buttons = calloc(sizeof(int), group->button_count);
|
||||
size_t button = 0;
|
||||
for (size_t i = 0; i < pad->button_count; ++i) {
|
||||
if (libinput_tablet_pad_mode_group_has_button(li_group, i)) {
|
||||
group->buttons[button++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
group->mode_count = libinput_tablet_pad_mode_group_get_num_modes(li_group);
|
||||
wl_list_insert(&pad->groups, &group->link);
|
||||
}
|
||||
|
||||
struct wlr_tablet_pad *libinput_tablet_pad_create(
|
||||
struct libinput_device *libinput_dev) {
|
||||
assert(libinput_dev);
|
||||
struct wlr_tablet_pad *wlr_tablet_pad = calloc(1, sizeof(struct wlr_tablet_pad));
|
||||
|
|
@ -16,6 +69,22 @@ struct wlr_tablet_pad *create_libinput_tablet_pad(
|
|||
wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_pad");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wlr_tablet_pad->button_count =
|
||||
libinput_device_tablet_pad_get_num_buttons(libinput_dev);
|
||||
wlr_tablet_pad->ring_count =
|
||||
libinput_device_tablet_pad_get_num_rings(libinput_dev);
|
||||
wlr_tablet_pad->strip_count =
|
||||
libinput_device_tablet_pad_get_num_strips(libinput_dev);
|
||||
|
||||
//struct udev_device *udev = libinput_device_get_udev_device(libinput_dev);
|
||||
//add_tablet_path(&pad->paths, udev_device_get_syspath(udev));
|
||||
|
||||
int groups = libinput_device_tablet_pad_get_num_mode_groups(libinput_dev);
|
||||
for (int i = 0; i < groups; ++i) {
|
||||
add_pad_group_from_libinput(wlr_tablet_pad, libinput_dev, i);
|
||||
}
|
||||
|
||||
wlr_tablet_pad_init(wlr_tablet_pad, NULL);
|
||||
return wlr_tablet_pad;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue