Linux – Scrolling with a WACOM tablet pen

hardwarelinuxwacomxorg

I've got a wacom pen with a button. How can I trigger scrolling when moving the pen with the button pressed?

According to xev, below, the triggering events are MotionNotify with state 0x200.

If this isn't done trivially, an idea I have is to build a service to read these events from somewhere and transform them into other events. This way, I can define gestures, as well. With this approach:

  • Where can I read them?
  • How can I write events back?
  • Are there libraries to detect gestures?
MotionNotify event, serial 33, synthetic NO, window 0xc00001,
    root 0x2ce, subw 0x0, time 695630659, (349,181), root:(1255,185),
    state 0x0, is_hint 0, same_screen YES

ButtonPress event, serial 33, synthetic NO, window 0xc00001,
    root 0x2ce, subw 0x0, time 695630659, (349,181), root:(1255,185),
    state 0x0, button 2, same_screen YES

MotionNotify event, serial 33, synthetic NO, window 0xc00001,
    root 0x2ce, subw 0x0, time 695630667, (348,183), root:(1254,187),
    state 0x200, is_hint 0, same_screen YES

MotionNotify event, serial 33, synthetic NO, window 0xc00001,
    root 0x2ce, subw 0x0, time 695630675, (347,184), root:(1253,188),
    state 0x200, is_hint 0, same_screen YES

...

MotionNotify event, serial 33, synthetic NO, window 0xc00001,
    root 0x2ce, subw 0x0, time 695632069, (327,486), root:(1233,490),
    state 0x200, is_hint 0, same_screen YES

ButtonRelease event, serial 33, synthetic NO, window 0xc00001,
    root 0x2ce, subw 0x0, time 695632069, (327,486), root:(1233,490),
    state 0x200, button 2, same_screen YES

Best Answer

I ran into a much simpler variant of this problem: translating the extra keys on my mouse into keyboard/mouse-button combinations, to allow binding them in the window manager to move/resize windows. Perhaps my code can serve you as a starting point:

https://gist.github.com/CyberShadow/ae30a8d9f86c170c2451c3dd7edb649c

The gist of the idea is that it captures input events from my mouse's /dev/input/... device, optionally modifies them, and writes them back out to /dev/uinput.