From 99b5af56cc5d3bfab450b70027e40af3fc1d6dad Mon Sep 17 00:00:00 2001 From: Henrik Muehe Date: Sun, 3 May 2026 16:12:42 +0200 Subject: [PATCH] Jog: bind right back buttons (R1/R2) to A axis hold-to-jog The default USB pendant config exposed A only via the right stick X axis (ABS_RX). Most Onefinity-shipped pendants only have one usable stick, so A was effectively unreachable. Map BTN_TR (0x137, upper-right back) to A+ and BTN_TR2 (0x139, lower-right back) to A- while held. Speed scaling matches the sticks (1/128, 1/32, 1/4, 1x via X/A/B/Y). R1 was the vertical-axis-lock toggle; horizontal lock on L1 is preserved, vertical lock is dropped to free R1. --- src/py/bbctrl/Jog.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/py/bbctrl/Jog.py b/src/py/bbctrl/Jog.py index c4544e2..591a12d 100644 --- a/src/py/bbctrl/Jog.py +++ b/src/py/bbctrl/Jog.py @@ -51,12 +51,18 @@ class Jog(inevent.JogHandler): "dir": [1, -1, -1, 1], "arrows": [ABS_HAT0X, ABS_HAT0Y], "speed": [0x133, 0x130, 0x131, 0x134], - "lock": [0x136, 0x137], + "lock": [0x136], # L1 = horiz-lock; R1/R2 now A axis + # Right back triggers drive the A axis while held: + # BTN_TR (0x137, upper-right) -> A+ + # BTN_TR2 (0x139, lower-right) -> A- + "a_pos": 0x137, + "a_neg": 0x139, } } super().__init__(config) + self.a_button = 0 # -1, 0, +1 from R1/R2 hold state self.v = [0.0] * 4 self.lastV = self.v self.callback() @@ -64,6 +70,27 @@ class Jog(inevent.JogHandler): self.processor = inevent.InEvent(ctrl.ioloop, self, types = ['js']) + def event(self, event, state, dev_name): + cfg = self.get_config(dev_name) + a_changed = False + + if event.type == EV_KEY: + old = self.a_button + if event.code == cfg.get('a_pos'): + self.a_button = 1 if event.value else ( + 0 if self.a_button == 1 else self.a_button) + elif event.code == cfg.get('a_neg'): + self.a_button = -1 if event.value else ( + 0 if self.a_button == -1 else self.a_button) + if self.a_button != old: a_changed = True + + super().event(event, state, dev_name) + + # JogHandler.event() only fires changed() when stick axes move. + # Force a recompute when R1/R2 hold state flips. + if a_changed: self.changed() + + def up(self): self.ctrl.lcd.page_up() def down(self): self.ctrl.lcd.page_down() def left(self): self.ctrl.lcd.page_left() @@ -91,3 +118,7 @@ class Jog(inevent.JogHandler): if self.speed == 3: scale = 1.0 / 4.0 self.v = [x * scale for x in self.axes] + + # R1/R2 buttons override the A axis (axes[3]) while held. + if self.a_button: + self.v[3] = self.a_button * scale