diff --git a/docs/en/pimoroni_trackball.md b/docs/en/pimoroni_trackball.md index a2af166a2..b08ce9f3b 100644 --- a/docs/en/pimoroni_trackball.md +++ b/docs/en/pimoroni_trackball.md @@ -31,12 +31,12 @@ trackball = Trackball( # optional: set rotation angle of the trackball breakout board, default is 1 angle_offset=1.6, handlers=[ - # act like an encoder, input arrow keys + # act like an encoder, input arrow keys, enter when pressed KeyHandler(KC.UP, KC.RIGHT, KC.DOWN, KC.LEFT, KC.ENTER), - # on layer 1 and above use the default pointing behavior - PointingHandler(), - # use ScrollDirection.NATURAL (default) or REVERSE to change the scrolling direction - ScrollHandler(scroll_direction=ScrollDirection.NATURAL) + # on layer 1 and above use the default pointing behavior, left click when pressed + PointingHandler(on_press=KC.MB_LMB), + # use ScrollDirection.NATURAL (default) or REVERSE to change the scrolling direction, left click when pressed + ScrollHandler(scroll_direction=ScrollDirection.NATURAL, on_press=KC.MB_LMB) ] ) diff --git a/kmk/modules/pimoroni_trackball.py b/kmk/modules/pimoroni_trackball.py index 7fb2d60ab..0b6538851 100644 --- a/kmk/modules/pimoroni_trackball.py +++ b/kmk/modules/pimoroni_trackball.py @@ -76,6 +76,9 @@ def handle(self, keyboard, trackball, x, y, switch, state): class PointingHandler(TrackballHandler): + def __init__(self, on_press=KC.MB_LMB): + self.on_press = on_press + def handle(self, keyboard, trackball, x, y, switch, state): if x: AX.X.move(keyboard, x) @@ -83,12 +86,13 @@ def handle(self, keyboard, trackball, x, y, switch, state): AX.Y.move(keyboard, y) if switch == 1: # Button changed state - keyboard.pre_process_key(KC.MB_LMB, is_pressed=state) + keyboard.pre_process_key(self.on_press, is_pressed=state) class ScrollHandler(TrackballHandler): - def __init__(self, scroll_direction=ScrollDirection.NATURAL): + def __init__(self, scroll_direction=ScrollDirection.NATURAL, on_press=KC.MB_LMB): self.scroll_direction = scroll_direction + self.on_press = on_press def handle(self, keyboard, trackball, x, y, switch, state): if self.scroll_direction == ScrollDirection.REVERSE: @@ -98,7 +102,7 @@ def handle(self, keyboard, trackball, x, y, switch, state): AX.W.move(keyboard, y) if switch == 1: # Button changed state - keyboard.pre_process_key(KC.MB_LMB, is_pressed=state) + keyboard.pre_process_key(self.on_press, is_pressed=state) class KeyHandler(TrackballHandler):