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 <spaceshipoperations@gmail.com>
  • Loading branch information
SpaceshipOperations committed Jan 15, 2024
1 parent 477d88b commit 69fb0b2
Show file tree
Hide file tree
Showing 2 changed files with 19 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
16 changes: 15 additions & 1 deletion src/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
#define BTN_LEFT 0x110 // from <linux/input-event-codes.h>
#endif

#ifndef WL_POINTER_AXIS_ENUM
#define WL_POINTER_AXIS_ENUM
// from <wayland-client-protocol.h>
enum wl_pointer_axis {
WL_POINTER_AXIS_VERTICAL_SCROLL = 0,
WL_POINTER_AXIS_HORIZONTAL_SCROLL = 1,
};
#endif


/** Loop state */
enum state {
state_ok,
Expand Down Expand Up @@ -349,7 +359,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 69fb0b2

Please sign in to comment.