Skip to content

Commit 5bcec78

Browse files
Update pimoroni_trackball.py (#1014)
1 parent b9bd8b5 commit 5bcec78

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

docs/en/pimoroni_trackball.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ trackball = Trackball(
3131
# optional: set rotation angle of the trackball breakout board, default is 1
3232
angle_offset=1.6,
3333
handlers=[
34-
# act like an encoder, input arrow keys
34+
# act like an encoder, input arrow keys, enter when pressed
3535
KeyHandler(KC.UP, KC.RIGHT, KC.DOWN, KC.LEFT, KC.ENTER),
36-
# on layer 1 and above use the default pointing behavior
37-
PointingHandler(),
38-
# use ScrollDirection.NATURAL (default) or REVERSE to change the scrolling direction
39-
ScrollHandler(scroll_direction=ScrollDirection.NATURAL)
36+
# on layer 1 and above use the default pointing behavior, left click when pressed
37+
PointingHandler(on_press=KC.MB_LMB),
38+
# use ScrollDirection.NATURAL (default) or REVERSE to change the scrolling direction, left click when pressed
39+
ScrollHandler(scroll_direction=ScrollDirection.NATURAL, on_press=KC.MB_LMB)
4040
]
4141
)
4242

kmk/modules/pimoroni_trackball.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,23 @@ def handle(self, keyboard, trackball, x, y, switch, state):
7676

7777

7878
class PointingHandler(TrackballHandler):
79+
def __init__(self, on_press=KC.MB_LMB):
80+
self.on_press = on_press
81+
7982
def handle(self, keyboard, trackball, x, y, switch, state):
8083
if x:
8184
AX.X.move(keyboard, x)
8285
if y:
8386
AX.Y.move(keyboard, y)
8487

8588
if switch == 1: # Button changed state
86-
keyboard.pre_process_key(KC.MB_LMB, is_pressed=state)
89+
keyboard.pre_process_key(self.on_press, is_pressed=state)
8790

8891

8992
class ScrollHandler(TrackballHandler):
90-
def __init__(self, scroll_direction=ScrollDirection.NATURAL):
93+
def __init__(self, scroll_direction=ScrollDirection.NATURAL, on_press=KC.MB_LMB):
9194
self.scroll_direction = scroll_direction
95+
self.on_press = on_press
9296

9397
def handle(self, keyboard, trackball, x, y, switch, state):
9498
if self.scroll_direction == ScrollDirection.REVERSE:
@@ -98,7 +102,7 @@ def handle(self, keyboard, trackball, x, y, switch, state):
98102
AX.W.move(keyboard, y)
99103

100104
if switch == 1: # Button changed state
101-
keyboard.pre_process_key(KC.MB_LMB, is_pressed=state)
105+
keyboard.pre_process_key(self.on_press, is_pressed=state)
102106

103107

104108
class KeyHandler(TrackballHandler):

0 commit comments

Comments
 (0)