Skip to content

Commit

Permalink
pad: support dial modeswitch buttons
Browse files Browse the repository at this point in the history
This requires unreleased updates to libwacom [1], currently hiding
behind an ifdef so we don't require that particular version.

[1] linuxwacom/libwacom#805

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
  • Loading branch information
whot committed Oct 31, 2024
1 parent 90e9c9f commit 384e946
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ have_libwacom = get_option('libwacom')
config_h.set10('HAVE_LIBWACOM', have_libwacom)
if have_libwacom
dep_libwacom = dependency('libwacom', version : '>= 0.27')
if cc.has_header_symbol('libwacom/libwacom.h', 'WACOM_BUTTON_DIAL_MODESWITCH',
dependencies : dep_libwacom)
config_h.set('HAVE_LIBWACOM_BUTTON_DIAL_MODESWITCH', '1')
endif
else
dep_libwacom = declare_dependency()
endif
Expand Down
24 changes: 23 additions & 1 deletion src/evdev-tablet-pad-leds.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ pad_add_mode_group(struct pad_dispatch *pad,
int button_index,
uint32_t ring_mask,
uint32_t strip_mask,
uint32_t dial_mask,
bool create_leds)
{
struct libinput *li = pad_libinput_context(pad);
Expand All @@ -285,6 +286,7 @@ pad_add_mode_group(struct pad_dispatch *pad,
goto out;
group->base.ring_mask = ring_mask;
group->base.strip_mask = strip_mask;
group->base.dial_mask = dial_mask;
group->base.button_mask |= bit(button_index);

rc = pad_led_group_add_toggle_button(group, button_index);
Expand Down Expand Up @@ -362,6 +364,14 @@ pad_fetch_group_index(struct pad_dispatch *pad,
case WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH:
group_index = 1;
break;
#ifdef HAVE_LIBWACOM_BUTTON_DIAL_MODESWITCH
case WACOM_BUTTON_DIAL_MODESWITCH:
group_index = 0;
break;
case WACOM_BUTTON_DIAL2_MODESWITCH:
group_index = 1;
break;
#endif
}

return group_index;
Expand Down Expand Up @@ -418,6 +428,7 @@ pad_init_leds_from_libwacom(struct pad_dispatch *pad,
int nmodes = 0;
uint32_t ring_mask = 0;
uint32_t strip_mask = 0;
uint32_t dial_mask = 0;
bool have_status_led = false;

if ((flags & WACOM_BUTTON_MODESWITCH) == 0)
Expand All @@ -442,6 +453,16 @@ pad_init_leds_from_libwacom(struct pad_dispatch *pad,
nmodes = libwacom_get_strips_num_modes(wacom);
strip_mask = 0x2;
break;
#ifdef HAVE_LIBWACOM_BUTTON_DIAL_MODESWITCH
case WACOM_BUTTON_DIAL_MODESWITCH:
nmodes = libwacom_get_dial_num_modes(wacom);
dial_mask = 0x1;
break;
case WACOM_BUTTON_DIAL2_MODESWITCH:
nmodes = libwacom_get_dial2_num_modes(wacom);
dial_mask = 0x2;
break;
#endif
default:
evdev_log_error(pad->device,
"unable to init pad mode group: button %c has multiple modeswitch flags 0x%x\n",
Expand All @@ -453,7 +474,8 @@ pad_init_leds_from_libwacom(struct pad_dispatch *pad,
struct libinput_tablet_pad_mode_group *group = pad_get_mode_group(pad, group_index);
if (!group) {
rc = pad_add_mode_group(pad, device, group_index, nmodes, b,
ring_mask, strip_mask, have_status_led);
ring_mask, strip_mask, dial_mask,
have_status_led);
} else {
struct pad_led_group *led_group = (struct pad_led_group *)group;
/* Multiple toggle buttons (Wacom MobileStudio Pro 16) */
Expand Down

0 comments on commit 384e946

Please sign in to comment.