Skip to content

Commit

Permalink
Add support for 2-dimensional scrolling with touch pads
Browse files Browse the repository at this point in the history
Signed-off-by: Spaceship Operations <[email protected]>
  • Loading branch information
SpaceshipOperations committed Jan 15, 2024
1 parent 477d88b commit 051777f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/keybind.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ static const struct key_binding default_bindings[] = {
{ .key = XKB_KEY_Right, .action = kb_step_right },
{ .key = XKB_KEY_Up, .action = kb_step_up },
{ .key = XKB_KEY_Down, .action = kb_step_down },
{ .key = XKB_KEY_KP_Left, .action = kb_step_left },
{ .key = XKB_KEY_KP_Right, .action = kb_step_right },
{ .key = XKB_KEY_KP_Up, .action = kb_step_up },
{ .key = XKB_KEY_KP_Down, .action = kb_step_down },
{ .key = XKB_KEY_equal, .action = kb_zoom, .params = "+10" },
{ .key = XKB_KEY_plus, .action = kb_zoom, .params = "+10" },
{ .key = XKB_KEY_minus, .action = kb_zoom, .params = "-10" },
Expand Down
6 changes: 5 additions & 1 deletion src/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@ static void on_pointer_button(void* data, struct wl_pointer* wl_pointer,
static void on_pointer_axis(void* data, struct wl_pointer* wl_pointer,
uint32_t time, uint32_t axis, wl_fixed_t value)
{
xkb_keysym_t key = value > 0 ? XKB_KEY_SunPageDown : XKB_KEY_SunPageUp;
xkb_keysym_t key;
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
key = value > 0 ? XKB_KEY_KP_Right : XKB_KEY_KP_Left;
else
key = value > 0 ? XKB_KEY_KP_Down : XKB_KEY_KP_Up;
viewer_on_keyboard(key);
}

Expand Down

0 comments on commit 051777f

Please sign in to comment.