Add reverse scrolling mode to the Pimoroni Trackball module

Signed-off-by: Salvatore La Bua <slabua@gmail.com>
This commit is contained in:
Salvatore La Bua 2022-07-21 21:26:24 +09:00 committed by xs5871
parent ecfbca82a6
commit f674ac6b13
2 changed files with 8 additions and 1 deletions

View File

@ -32,7 +32,8 @@ trackball = Trackball(i2c, mode=TrackballMode.MOUSE_MODE, handlers=[
KeyHandler(KC.UP, KC.RIGHT, KC.DOWN, KC.LEFT, KC.ENTER),
# on layer 1 and above use the default pointing behavior
PointingHandler(),
ScrollHandler()
# use scrolling='natural' (default) or 'reverse' to change the scrolling direction
ScrollHandler(scrolling='natural')
])
# now you can use these KeyCodes:

View File

@ -96,7 +96,13 @@ class PointingHandler(TrackballHandler):
class ScrollHandler(TrackballHandler):
def __init__(self, scrolling='natural'):
self.scrolling = scrolling
def handle(self, keyboard, trackball, x, y, switch, state):
if self.scrolling == 'reverse':
y = -y
pointing_device = trackball.pointing_device
pointing_device.report_w[0] = 0xFF & y
pointing_device.hid_pending = y != 0