From 011a31cb9199570195ec8000c94d20e3ee6909de Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Sun, 2 Aug 2026 22:57:08 +0200 Subject: [PATCH 01/74] docs: add Steam Controller v2 (2025) HID protocol notes + capture harness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverse-engineered the new Steam Controller's main gamepad HID report (0x42) from live captures of real hardware via its wireless Puck (28de:1304). Documents the full byte layout: 4-byte button bitfield (incl. capacitive stick/pad/grip touch and analog+digital triggers), two analog sticks, two trackpads with pressure, and 16-bit triggers. Notes that the IMU is disabled by default and the controller defaults to lizard mode; both the command channel (lizard-off, gyro-on) and the IMU stream remain to be reverse-engineered. Adds tools/sc2-probe/, the read-only hidraw capture harness used to produce these findings. Co-Authored-By: Claude Opus 4.8 docs: add v2 command channel (from Steam usbmon capture) Sniffed Steam's USB traffic while it configured the controller and decoded the host->device command protocol: SET_REPORT (0x21/0x09) with wValue=0x03 (feature) / 0x02 (output), wIndex=interface (per slot), 64-byte [reportID, packetType, length, params] payloads. Opcodes match sc_dongle.py's SCPacketType: 0x81 CLEAR_MAPPINGS (lizard disable, resent as heartbeat), 0x8E LIZARD_MODE, 0x87 CONFIGURE/LED, 0xAE GET_SERIAL, 0xC1 SET_AUDIO_INDICES, plus v2-only key/value config (0xED "user/wireless_transport", "esb/bond"). LED level confirmed as 87 03 2d . Gyro-enable register still TBD. Co-Authored-By: Claude Opus 4.8 docs: confirm gyro enable command and IMU location Live experiment (rotate controller, toggle gyro): the byte after `87 0f 30` is the gyro/accel enable -- 0x18 on, 0x00 off -- and once enabled the IMU streams in report 0x42 at offsets ~31-53 (bytes 31-53 go from static to 60-256 distinct values when moving). Matches what Steam sends. The driver's configure() already emits 0x18; parse_input still zeroes the gyro fields pending decode of the accel/gyro/quaternion sub-layout. Co-Authored-By: Claude Opus 4.8 sc2: scaffold the new Steam Controller (v2) driver New scc/drivers/sc2.py implementing the reverse-engineered v2 protocol: report 0x42 parsing (buttons, two sticks, two pads with pressure, analog + digital triggers, d-pad, grips/paddles, capacitive touch), mapped to SCButtons; the wireless Puck (0x1304) as a 4-slot dongle; and the v2 command transport (SET_REPORT to feature report 0x01 per interface) with CLEAR_MAPPINGS unlizard heartbeat + replayed CONFIGURE/LED blocks. Modeled on steamdeck.py (parsing/mapping) and sc_dongle.py (multi-slot + commands). Gyro enable, haptics, real GET_SERIAL read-back, the wired (0x1302)/Bluetooth (0x1303) transports, GUI assets and live testing are still TODO (marked inline). tests/test_sc2.py locks the 0x42 layout with synthetic frames (no hardware needed); 11 tests pass. Co-Authored-By: Claude Opus 4.8 sc2: lenient input transfer for mixed-length reports Live bring-up validated the protocol (lizard-off via CLEAR_MAPPINGS, buttons/sticks/triggers/pads all decode correctly on real hardware), but exposed an integration bug: the puck's interrupt-IN endpoint multiplexes reports of several sizes (0x42=54B, plus shorter 0x43/0x44/0x7b). The shared USBDevice.set_input_interrupt drops and stops resubmitting any report whose length != the requested size, which would freeze input on the first short report. Replace it with a per-driver lenient transfer that requests the full 64-byte max packet, accepts any length, filters by report ID in parse_input, and always resubmits. Co-Authored-By: Claude Opus 4.8 sc2: enable driver + fix live bring-up bugs End-to-end bring-up in scc-daemon on real hardware now works: the puck is detected, the controller registers, lizard mode is disabled, and button / stick / pad / trigger input reaches uinput (verified digital -> BTN_* and analog -> ABS_X/Y). Fixes found during bring-up: - enable the driver by default (config.py "drivers": add "sc2": True); it was skipped as a disabled driver. - SET_REPORT length: command builders no longer pre-pad to 64; send_control prepends the 0x01 report-ID byte and clamps to exactly 64 bytes. A 65-byte transfer was stalling the device (LIBUSB_ERROR_PIPE) on the first command. - override disconnected() as a no-op (the inherited SCController version touches a dongle-only _available_serials attribute and crashed on unplug). Co-Authored-By: Claude Opus 4.8 sc2: decode and parse the IMU (accel / quaternion / gyro) Captured isolated rotations with the gyro enabled and decoded report 0x42's IMU block (offsets 30-53): 30-33 timestamp, 34-39 accelerometer (Z holds ~1g at rest), 40-47 orientation quaternion (w~32767 at rest), 48-53 gyro pitch/roll/yaw. Verified each gyro axis dominates only its own motion (pitch->@48, roll->@50, yaw->@52) and accel_z tracks gravity. parse_input now fills accel_x/y/z, gpitch/groll/gyaw and q1..q4 from these offsets instead of zeroing them; configure() already enables the gyro. Accel X/Y labels and IMU signs remain provisional (polarity TBD). Adds IMU assertions to the parser test (12 tests pass). Co-Authored-By: Claude Opus 4.8 sc2: map the 4th system button (View) The controller has four system buttons, not three: the View button (⧉, top-left) was untested and unmapped. Found at off3 bit 0x40 (it also emits a lizard keyboard report). Mapped View -> BACK, and moved QuickAccess (…) from BACK to DOTS so the four map cleanly to C / START / BACK / DOTS (Steam / Menu / View / QuickAccess). off3 is now fully mapped. Co-Authored-By: Claude Opus 4.8 sc2: fix gyro pitch polarity (verified live) Loaded a gyro->mouse profile in scc-daemon and checked cursor direction: yaw is natural (right->right) but pitch was inverted (up->down). Negated gpitch in parse_input so pitch-up aims up; re-verified live (up->up, right->right). Gyro roll sign remains untested/provisional. Co-Authored-By: Claude Opus 4.8 sc2: implement click haptics (output report 0x82) Captured Steam's trackpad haptic feedback and decoded the rumble command: output report 0x82 = [0x82, side, effect, amplitude] on the interrupt-OUT endpoint (number == interface). side 0/1/2 = left/right/both, effect 0x01 = click (0x02 longer), amplitude 0x00(medium)..0xff(strong). The device stalls this report over SET_REPORT control, so feedback() submits an interrupt-OUT transfer instead. Verified live via the daemon's Feedback command: right/left/both clicks land on the correct side. It's a per-call click (fits pad/scroll detents); continuous variable rumble, if supported, would use a yet-uncaptured report. Co-Authored-By: Claude Opus 4.8 sc2: support the wired (USB-C, 0x1302) transport The cabled controller enumerates as a single HID interface 0 (interrupt IN 0x81 / OUT 0x01, no CDC) with the same report descriptor and 0x42 report as the puck, so everything reuses. Refactor the USB device into a shared SC2Device base (lenient interrupt-IN, SET_REPORT/feature-0x01 commands, interrupt-OUT haptics, controller bookkeeping) with SC2Puck (4 slots) and SC2Wired (interface 0) subclasses, and give SC2Controller an explicit out-endpoint (puck OUT ep == interface; wired OUT ep == 1). Register 0x1302. Verified live over USB-C: detection, registration, buttons/sticks input, and L/R/both haptics all work. Co-Authored-By: Claude Opus 4.8 sc2: GUI controller config (images/sc2.config.json) get_gui_config_file() now returns "sc2.config.json" so the GUI renders the controller with its real buttons/axes/gyro. The v2's controls match the Steam Deck, so the config mirrors deck.config.json and reuses the "deck" background image for now (a dedicated controller-images/sc2.svg is TODO). Verified the daemon advertises it: "Controller: sc2 19 sc2.config.json". The core SC/Deck drivers have no GUI enable/disable toggle (always on), so sc2 follows suit -- no global_settings change needed. Co-Authored-By: Claude Opus 4.8 --- scc/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scc/config.py b/scc/config.py index dd1cfaf45..b651030ee 100644 --- a/scc/config.py +++ b/scc/config.py @@ -33,6 +33,7 @@ class Config: "sc_by_cable": True, "sc_by_bt": True, "steamdeck": True, + "sc2": True, # new Steam Controller (2026) "fake": False, # Used for developement "hiddrv": True, "evdevdrv": True, From 33410da727a16272d562a41c1c32674858f2d48e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 15 Jun 2026 04:33:18 +0200 Subject: [PATCH 02/74] gui: offer all 4 grips + right-stick press in modeshift combo chooser The modeshift "combination" list only had Left/Right Grip -- the original SC's two back buttons. The Deck and the new Steam Controller have four back buttons (L4/R4 -> LGRIP/RGRIP, L5/R5 -> LGRIP2/RGRIP2) and a right stick (R3 -> RSTICKPRESS). Add LGRIP2, RGRIP2 and RSTICKPRESS to the chooser so those can be used as modeshift combinations. Benefits the Deck too. Co-Authored-By: Claude Opus 4.8 --- scc/gui/modeshift_editor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scc/gui/modeshift_editor.py b/scc/gui/modeshift_editor.py index df79e41e6..7c4d75534 100644 --- a/scc/gui/modeshift_editor.py +++ b/scc/gui/modeshift_editor.py @@ -34,6 +34,8 @@ class ModeshiftEditor(Editor): (None, None), (SCButtons.LGRIP, _("Left Grip")), (SCButtons.RGRIP, _("Right Grip")), + (SCButtons.LGRIP2, _("Left Grip 2")), + (SCButtons.RGRIP2, _("Right Grip 2")), (SCButtons.LB, _("Left Bumper")), (SCButtons.RB, _("Right Bumper")), (None, None), From ff914902a50112d914247cca66093cf200c47153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 15 Jun 2026 04:41:43 +0200 Subject: [PATCH 03/74] gui: add 2nd grips + right-stick press to remaining button choosers Same gap as the modeshift chooser: the d-pad-emulation source picker (ae/dpad.glade), the special-action button picker (ae/special_action.glade) and the controller-settings picker (controller_settings.glade) only listed Left/Right Grip and Stick Press. Add Left/Right Grip 2 (LGRIP2/RGRIP2 = the L5/R5 back buttons) and Right Stick Press (RSTICKPRESS) so every binding dialog offers the full Deck / new-Steam-Controller button set. Co-Authored-By: Claude Opus 4.8 --- glade/ae/dpad.glade | 8 ++++++++ glade/ae/special_action.glade | 8 ++++++++ glade/controller_settings.glade | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/glade/ae/dpad.glade b/glade/ae/dpad.glade index b2f674f6d..46ba056b3 100644 --- a/glade/ae/dpad.glade +++ b/glade/ae/dpad.glade @@ -86,6 +86,14 @@ Right Grip RGRIP + + Left Grip 2 + LGRIP2 + + + Right Grip 2 + RGRIP2 + - x diff --git a/glade/ae/special_action.glade b/glade/ae/special_action.glade index f5b2368f5..e5149b4d9 100644 --- a/glade/ae/special_action.glade +++ b/glade/ae/special_action.glade @@ -127,6 +127,14 @@ Right Grip RGRIP + + Left Grip 2 + LGRIP2 + + + Right Grip 2 + RGRIP2 + - x diff --git a/glade/controller_settings.glade b/glade/controller_settings.glade index 778ff96b4..adb5f77bd 100644 --- a/glade/controller_settings.glade +++ b/glade/controller_settings.glade @@ -77,6 +77,14 @@ Right Grip RGRIP + + Left Grip 2 + LGRIP2 + + + Right Grip 2 + RGRIP2 + - x From e32676ef6af585415319579372a91435c1f6a152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 15 Jun 2026 05:32:37 +0200 Subject: [PATCH 04/74] sc2/gui: bind capacitive stick touch; label left stick Two gaps the original SC's button set didn't cover: - The capacitive stick-touch sensors had no SCButtons constants, so the decoded bits (LStick = off5 0x01, RStick = off4 0x10) were unmapped (the Deck leaves them out for the same reason). Add SCButtons.LSTICKTOUCH / RSTICKTOUCH (free bits 16/17), map them in the v2 driver, and add "Left/Right Stick Touched" to all four button choosers (modeshift + ae/dpad, ae/special_action, controller_settings). - Now that there's a "Right Stick Pressed", relabel the old "Stick Pressed" / "Stick Press" to "Left Stick Pressed" / "Left Stick Press". Driver mapping unit-tested; full suite (157) passes. (The Steam Deck driver could now map its stick-touch bits too, via the same constants.) Co-Authored-By: Claude Opus 4.8 --- glade/ae/dpad.glade | 8 ++++++++ glade/ae/special_action.glade | 8 ++++++++ glade/controller_settings.glade | 8 ++++++++ scc/gui/modeshift_editor.py | 2 ++ 4 files changed, 26 insertions(+) diff --git a/glade/ae/dpad.glade b/glade/ae/dpad.glade index 46ba056b3..ab7216f67 100644 --- a/glade/ae/dpad.glade +++ b/glade/ae/dpad.glade @@ -126,6 +126,14 @@ Right Stick Press RSTICKPRESS + + Left Stick Touched + LSTICKTOUCH + + + Right Stick Touched + RSTICKTOUCH + Left Pad Press LPAD diff --git a/glade/ae/special_action.glade b/glade/ae/special_action.glade index e5149b4d9..06f7c8cf0 100644 --- a/glade/ae/special_action.glade +++ b/glade/ae/special_action.glade @@ -167,6 +167,14 @@ Right Stick Press RSTICKPRESS + + Left Stick Touched + LSTICKTOUCH + + + Right Stick Touched + RSTICKTOUCH + Left Pad Press LPAD diff --git a/glade/controller_settings.glade b/glade/controller_settings.glade index adb5f77bd..3f2e40ad7 100644 --- a/glade/controller_settings.glade +++ b/glade/controller_settings.glade @@ -117,6 +117,14 @@ Right Stick Press RSTICKPRESS + + Left Stick Touched + LSTICKTOUCH + + + Right Stick Touched + RSTICKTOUCH + Left Pad Press LPAD diff --git a/scc/gui/modeshift_editor.py b/scc/gui/modeshift_editor.py index 7c4d75534..02695515a 100644 --- a/scc/gui/modeshift_editor.py +++ b/scc/gui/modeshift_editor.py @@ -50,6 +50,8 @@ class ModeshiftEditor(Editor): (SCButtons.RPAD, _("Right Pad Pressed")), (SCButtons.LPADTOUCH, _("Left Pad Touched")), (SCButtons.RPADTOUCH, _("Right Pad Touched")), + (SCButtons.LSTICKTOUCH, _("Left Stick Touched")), + (SCButtons.RSTICKTOUCH, _("Right Stick Touched")), ) def __init__(self, app, callback): From 953fc91643a00bad47f96851382219ccad8c2ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 15 Jun 2026 05:41:23 +0200 Subject: [PATCH 05/74] steamdeck: map capacitive stick touch (parity with v2) The Deck reports stick-touch (DeckButton.LSTICKTOUCH/RSTICKTOUCH) but they were left unmapped because SCButtons had no equivalent. Now that SCButtons.LSTICKTOUCH/RSTICKTOUCH exist (added for the new controller), map the Deck's bits too, so "Left/Right Stick Touched" works on the Deck as well. The shared mapper/action and GUI-chooser fixes already cover the Deck. Co-Authored-By: Claude Opus 4.8 --- scc/drivers/steamdeck.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scc/drivers/steamdeck.py b/scc/drivers/steamdeck.py index e28198178..c6c21e719 100644 --- a/scc/drivers/steamdeck.py +++ b/scc/drivers/steamdeck.py @@ -221,8 +221,8 @@ def _on_input(self, endpoint: int, data: bytearray) -> None: 0 | ((self._input.buttons & DIRECTLY_TRANSLATABLE_BUTTONS) << 8) | map_button(self._input, DeckButton.DOTS, SCButtons.DOTS) - # | map_button(self._input, DeckButton.RSTICKTOUCH, ....) // not mapped - # | map_button(self._input, DeckButton.LSTICKTOUCH, ....) // not mapped + | map_button(self._input, DeckButton.RSTICKTOUCH, SCButtons.RSTICKTOUCH) + | map_button(self._input, DeckButton.LSTICKTOUCH, SCButtons.LSTICKTOUCH) | map_button(self._input, DeckButton.LSTICKPRESS, SCButtons.STICKPRESS) | map_button(self._input, DeckButton.RSTICKPRESS, SCButtons.RSTICKPRESS) | map_button(self._input, DeckButton.LGRIP2, SCButtons.LGRIP2) From cfcbfe108f9dfc3af62beb0d66b9239cb63dfe03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 15 Jun 2026 05:41:23 +0200 Subject: [PATCH 06/74] sc2/gui: bind capacitive handle grip sensing (Steam Controller only) The new Steam Controller (like the v1) has capacitive sensors on the handles -- distinct from the L4/L5/R4/R5 grip buttons -- which the Steam Deck lacks. Decoded as off5 0x20 (left) / 0x10 (right). Add SCButtons.LGRIPTOUCH/RGRIPTOUCH (free bits 18/19), map them in the v2 driver, and add "Left/Right Grip Sensing" to all four button choosers (modeshift + ae/dpad, ae/special_action, controller_settings). These read "on" whenever the handles are held, which suits grip-activated modeshifts. Driver mapping unit-tested; full suite (158) passes. Co-Authored-By: Claude Opus 4.8 gui: rename grip-sensing labels to "Grip Touched" Match the thumbstick-sensor labels ("Left/Right Stick Touched"): the capacitive handle grips are now "Left/Right Grip Touched" in all four button choosers. Label only; the LGRIPTOUCH/RGRIPTOUCH constants are unchanged. Co-Authored-By: Claude Opus 4.8 --- glade/ae/dpad.glade | 8 ++++++++ glade/ae/special_action.glade | 8 ++++++++ glade/controller_settings.glade | 8 ++++++++ scc/gui/modeshift_editor.py | 2 ++ 4 files changed, 26 insertions(+) diff --git a/glade/ae/dpad.glade b/glade/ae/dpad.glade index ab7216f67..4a45820a2 100644 --- a/glade/ae/dpad.glade +++ b/glade/ae/dpad.glade @@ -134,6 +134,14 @@ Right Stick Touched RSTICKTOUCH + + Left Grip Touched + LGRIPTOUCH + + + Right Grip Touched + RGRIPTOUCH + Left Pad Press LPAD diff --git a/glade/ae/special_action.glade b/glade/ae/special_action.glade index 06f7c8cf0..e981a3791 100644 --- a/glade/ae/special_action.glade +++ b/glade/ae/special_action.glade @@ -175,6 +175,14 @@ Right Stick Touched RSTICKTOUCH + + Left Grip Touched + LGRIPTOUCH + + + Right Grip Touched + RGRIPTOUCH + Left Pad Press LPAD diff --git a/glade/controller_settings.glade b/glade/controller_settings.glade index 3f2e40ad7..fd46e43db 100644 --- a/glade/controller_settings.glade +++ b/glade/controller_settings.glade @@ -125,6 +125,14 @@ Right Stick Touched RSTICKTOUCH + + Left Grip Touched + LGRIPTOUCH + + + Right Grip Touched + RGRIPTOUCH + Left Pad Press LPAD diff --git a/scc/gui/modeshift_editor.py b/scc/gui/modeshift_editor.py index 02695515a..5de5f4c49 100644 --- a/scc/gui/modeshift_editor.py +++ b/scc/gui/modeshift_editor.py @@ -52,6 +52,8 @@ class ModeshiftEditor(Editor): (SCButtons.RPADTOUCH, _("Right Pad Touched")), (SCButtons.LSTICKTOUCH, _("Left Stick Touched")), (SCButtons.RSTICKTOUCH, _("Right Stick Touched")), + (SCButtons.LGRIPTOUCH, _("Left Grip Touched")), + (SCButtons.RGRIPTOUCH, _("Right Grip Touched")), ) def __init__(self, app, callback): From d4243cef8feca62e63066f7c47884233a5450f52 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Sun, 2 Aug 2026 22:58:58 +0200 Subject: [PATCH 07/74] gui: dedicated v2 (Steam Controller 2025) image + stick-touch/grip-sensor bindings Replace the borrowed Steam Deck GUI image with dedicated v2 artwork and add first-class support for the controller's capacitive sensors. Controller image & assets (generated by tools/gen_sc2_image.py from tools/sc2-source.svg + tools/sc2-assets/): - controller-images/sc2.svg: traced v2 body, blank face buttons, control-name ids so sticks/pads/dpad/bumpers/grips highlight on hover, darker body. - button-images/sc2_*.svg: v2 face-button overlay glyphs lifted from the art (monochrome ABXY, round Steam, single dots, view/menu) - no duplication. - images/sc2/*.svg: v2-specific side-panel icons (leaned-square pads, real view/menu, oval L4/R4/L5/R5 paddles, grip-touch silhouettes). - sc2.config.json points at all of the above. Capacitive sensors: - Stick-touch: new "Touch" tab in the stick's pressed-action editor (ModeshiftEditor) binds LSTICKTOUCH/RSTICKTOUCH; shown only for the stick press, hidden elsewhere. - Grip-touch: exposed on the controller face (curved handle overlay, green on hover) and as buttons in the side-panel grid. - Both usable as conditions in mode-shift combinations. Fixes: - Per-controller side-panel icon override (images//.svg), leaving v1/Deck untouched. - Right-stick (and center-pad) "pressed action" now opens the editor (RSTICK->RSTICKPRESS, CPAD->CPADPRESS). - set_action no longer throws when saving a button with no on-screen widget (the touch sensors). README: note v2 support + the stick-touch/grip-sensor binding & combinations. Co-Authored-By: Claude Opus 4.8 docs: correct Steam Controller 2 release year to 2026 in README Matches the year correction already applied to the code comments/config. Co-Authored-By: Claude Opus 4.8 --- README.md | 1 + glade/app.glade | 42 +++++++++++++--- glade/modeshift_editor.glade | 95 ++++++++++++++++++++++++++++++++++++ scc/gui/app.py | 19 +++++++- scc/gui/binding_editor.py | 5 +- scc/gui/modeshift_editor.py | 53 +++++++++++++++++++- 6 files changed, 204 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6dcd5a638..f36dfb1f9 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ User-mode driver, mapper and GTK3 based GUI for Steam Controller, DS4 and many o - Connect multiple controllers at the same time - Supports profiles switchable in GUI or with controller button - Stick, Pads and Gyroscope input +- Steam Controller 2 (2026) support, including its capacitive stick-touch and grip sensors — bind actions to them directly, or use them as conditions in mode-shift combinations - Haptic Feedback and in-game Rumble support - OSD, Menus, On-Screen Keyboard for desktop *and* in games. - Automatic profile switching based on active window. diff --git a/glade/app.glade b/glade/app.glade index 08cd62ee0..81ca3edfa 100644 --- a/glade/app.glade +++ b/glade/app.glade @@ -644,8 +644,9 @@ - + 170 + True True True @@ -659,9 +660,8 @@ - + 170 - True True True @@ -735,8 +735,9 @@ - + 170 + True True True @@ -750,9 +751,8 @@ - + 170 - True True True @@ -809,6 +809,21 @@ False 12 bottom + + + 220 + True + True + + + + + + False + True + 0 + + 220 @@ -900,6 +915,21 @@ 6 + + + 220 + True + True + + + + + + False + True + 8 + + 0 diff --git a/glade/modeshift_editor.glade b/glade/modeshift_editor.glade index c9268994c..d17f192b7 100644 --- a/glade/modeshift_editor.glade +++ b/glade/modeshift_editor.glade @@ -658,6 +658,101 @@ False + + + True + False + vertical + + + True + False + 10 + 10 + 10 + 5 + 15 + + + 150 + True + False + When touched + 0 + + + 0 + 0 + + + + + True + True + True + True + + + + 1 + 0 + + + + + True + True + True + + + + True + False + gtk-clear + + + + + 2 + 0 + + + + + False + True + 0 + + + + + True + False + 10 + True + Action triggered when the capacitive sensor under the stick is touched (no press needed). + True + + + False + True + 1 + + + + + + + True + False + True + Touch + + + 3 + False + + 0 diff --git a/scc/gui/app.py b/scc/gui/app.py index f9ae0820f..026358d1d 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -215,6 +215,8 @@ def apply_gui_config_buttons(self, config) -> None: btDPAD = self.builder.get_object("btDPAD") btGYRO = self.builder.get_object("btGYRO") btC = self.builder.get_object("btC") + btLGRIPTOUCH = self.builder.get_object("btLGRIPTOUCH") + btRGRIPTOUCH = self.builder.get_object("btRGRIPTOUCH") buttons = ControllerImage.get_names(config.get("buttons", {})) axes = ControllerImage.get_names(config.get("axes", {})) @@ -226,10 +228,18 @@ def apply_gui_config_buttons(self, config) -> None: if w: w.set_sensitive(nameof(b) in buttons) # Buttons (as GTK Widgets) + # A controller may ship its own side-panel icons under + # images//.svg (e.g. images/sc2/); use them when + # present, else fall back to the shared default icon. + bg = config.get("gui", {}).get("background") for b in self.button_widgets: try: w = self.button_widgets[b] icon, trash = ControllerManager.get_button_icon(config, b, True) + if bg: + cand = os.path.join(self.imagepath, bg, nameof(b) + ".svg") + if os.path.exists(cand): + icon = cand w.icon.set_from_file(icon) except Exception: pass @@ -252,8 +262,9 @@ def apply_gui_config_buttons(self, config) -> None: # TODO: Maybe actual detection w.set_sensitive(gyros) - for w in (btC, btCPAD, btDPAD, btGYRO): - w.set_visible(w.get_sensitive()) + for w in (btC, btCPAD, btDPAD, btGYRO, btLGRIPTOUCH, btRGRIPTOUCH): + if w: + w.set_visible(w.get_sensitive()) # Re-layout if needed expected_layout = "default" @@ -550,6 +561,10 @@ def on_mnuEditPress_activate(self, *a): id = self.context_menu_for if id == STICK: id = nameof(SCButtons.STICKPRESS) + elif id == Profile.RSTICK: + id = nameof(SCButtons.RSTICKPRESS) + elif id == Profile.CPAD: + id = nameof(SCButtons.CPADPRESS) self.show_editor(getattr(SCButtons, id)) def on_mnuGlobalSettings_activate(self, *a): diff --git a/scc/gui/binding_editor.py b/scc/gui/binding_editor.py index b1469d89a..3bd737fcc 100644 --- a/scc/gui/binding_editor.py +++ b/scc/gui/binding_editor.py @@ -84,7 +84,10 @@ def set_action(self, profile, id, action): self.button_widgets[id.name].update() elif id in BUTTONS: before, profile.buttons[id] = profile.buttons[id], action - self.button_widgets[id].update() + # Some buttons (e.g. the stick-touch sensors, set via the Touch tab) + # have no on-screen widget; just store the action for those. + if id in self.button_widgets: + self.button_widgets[id].update() elif id in TRIGGERS: # TODO: Use LT and RT in profile as well side = LEFT if id == "LT" else RIGHT diff --git a/scc/gui/modeshift_editor.py b/scc/gui/modeshift_editor.py index 5de5f4c49..1ba6bf205 100644 --- a/scc/gui/modeshift_editor.py +++ b/scc/gui/modeshift_editor.py @@ -66,6 +66,10 @@ def __init__(self, app, callback): self.current_page = 0 self.actions = ([], [], []) self.nomods = [NoAction(), NoAction(), NoAction()] + # Touch tab: bound to the capacitive stick-touch sensor (a separate + # button), only shown when editing a stick-press action. + self.touch_id = None + self.touch_action = NoAction() self.setup_widgets() def setup_widgets(self): @@ -246,9 +250,16 @@ def on_chosen(id, action): def on_ntbMore_switch_page(self, ntb, box, index): self.current_page = index + cb = self.builder.get_object("cbButtonChooser") + add = self.builder.get_object("btAddAction") + if index >= len(self.actions): + # Touch tab: no mode-shift grid / button chooser here + cb.set_sensitive(False) + add.set_sensitive(False) + return self._fill_button_chooser() - self.builder.get_object("cbButtonChooser").set_sensitive(box.get_sensitive()) - self.builder.get_object("btAddAction").set_sensitive(box.get_sensitive()) + cb.set_sensitive(box.get_sensitive()) + add.set_sensitive(box.get_sensitive()) def on_nomodbt_clicked(self, button, *a): actionButton = self.action_widgets[self.current_page][1] @@ -266,6 +277,20 @@ def on_nomodclear_clicked(self, button, *a): actionButton = self.action_widgets[self.current_page][1] actionButton.set_label(self.nomods[self.current_page].describe(self.mode)) + def on_btTouch_clicked(self, *a): + """'Touch' tab: edit the action bound to the stick-touch sensor.""" + def on_chosen(id, action): + self.touch_action = action + self.builder.get_object("btTouch").set_label(action.describe(self.mode)) + + ae = self._choose_editor(self.touch_action, on_chosen) + ae.set_input(self.touch_id, self.touch_action, mode=Action.AC_BUTTON) + ae.show(self.window) + + def on_btClearTouch_clicked(self, *a): + self.touch_action = NoAction() + self.builder.get_object("btTouch").set_label(self.touch_action.describe(self.mode)) + def on_btAddAction_clicked(self, *a): cbButtonChooser = self.builder.get_object("cbButtonChooser") item = cbButtonChooser.get_model().get_value(cbButtonChooser.get_active_iter(), 0) @@ -309,6 +334,9 @@ def on_btOK_clicked(self, *a): """Handler for OK button""" if self.ac_callback is not None: self.ac_callback(self.id, self._make_action()) + if self.touch_id is not None: + # Touch tab maps to a separate input (the stick-touch sensor) + self.ac_callback(self.touch_id, self.touch_action) self.close() def _make_action(self): @@ -415,3 +443,24 @@ def set_input(self, id, action, mode=None): if mode != Action.AC_BUTTON: for w in ("vbHold", "vbDoubleClick", "lblHold", "lblDoubleClick"): self.builder.get_object(w).set_sensitive(False) + + # Touch tab: only for the stick-press inputs; binds the capacitive + # stick-touch sensor (a separate button). Hidden for everything else. + # (Editor.show() uses window.show(), not show_all, so hiding sticks.) + touch_for = {SCButtons.STICKPRESS: SCButtons.LSTICKTOUCH, + SCButtons.RSTICKPRESS: SCButtons.RSTICKTOUCH} + self.touch_id = touch_for.get(id) if id in SCButtons.__members__.values() else None + vbTouch = self.builder.get_object("vbTouch") + lblTouch = self.builder.get_object("lblTouch") + if self.touch_id is not None: + try: + self.touch_action = self.app.current.buttons[self.touch_id] or NoAction() + except (KeyError, TypeError): + self.touch_action = NoAction() + self.builder.get_object("btTouch").set_label(self.touch_action.describe(self.mode)) + vbTouch.set_visible(True) + lblTouch.set_visible(True) + else: + self.touch_action = NoAction() + vbTouch.set_visible(False) + lblTouch.set_visible(False) From b1f06fd5634105e6d975783cc29f3ab4480d8596 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Sun, 19 Jul 2026 21:41:24 +0200 Subject: [PATCH 08/74] fix: Ignore X11 errors - Install a no-op Xlib error handler (xwrappers) so a stray X protocol error (e.g. a window that vanishes mid-query) no longer aborts the process. --- scc/lib/xwrappers.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scc/lib/xwrappers.py b/scc/lib/xwrappers.py index 26107ec3d..fb559ef16 100644 --- a/scc/lib/xwrappers.py +++ b/scc/lib/xwrappers.py @@ -18,6 +18,7 @@ from ctypes import ( CDLL, + CFUNCTYPE, POINTER, Structure, byref, @@ -50,6 +51,21 @@ def _load_lib(*names): libX11 = _load_lib("libX11.so", "libX11.so.6") libXext = _load_lib("libXext.so", "libXext.so.6") +# By default Xlib aborts the whole process on an X protocol error (e.g. BadWindow +# when querying a stale/invalid window id - which happens under XWayland, where +# the focused window may not be an X window). Install a no-op error handler so the +# offending call fails quietly (callers already cope with missing data) instead of +# killing the process (this previously crashed scc-osd-daemon from Autoswitch). +_XErrorHandler = CFUNCTYPE(c_int, c_void_p, c_void_p) + + +def _ignore_x_error(display, error): + return 0 + + +_x_error_handler = _XErrorHandler(_ignore_x_error) # keep a reference so it isn't GC'd +libX11.XSetErrorHandler(_x_error_handler) + # Types XID = c_ulong From e248a10aad1604db55dfe9dcffa5c2b98a70691f Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Sun, 19 Jul 2026 21:42:25 +0200 Subject: [PATCH 09/74] fix: Catch failing generators and log them instead of crashing the menu - MenuData.generate now logs and skips a failing generator instead of letting it take down the whole menu. --- scc/menu_data.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scc/menu_data.py b/scc/menu_data.py index 5b37ba217..bf19371ae 100644 --- a/scc/menu_data.py +++ b/scc/menu_data.py @@ -5,6 +5,9 @@ import json import os +import logging + +log = logging.getLogger("menu_data") from scc.actions import Action from scc.tools import _ @@ -25,7 +28,10 @@ def generate(self, menuhandler): items = [] for i in self: if isinstance(i, MenuGenerator): - items.extend(i.generate(menuhandler)) + try: + items.extend(i.generate(menuhandler)) + except Exception: + log.exception("Menu generator %r failed", getattr(i, "GENERATOR_NAME", i)) else: items.append(i) return MenuData(*items) From 428afcdd089a425648e877b7a2500ca9968f2ba3 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Sun, 19 Jul 2026 21:43:49 +0200 Subject: [PATCH 10/74] fix: Let long vertical menu lists scroll - Long vertical menus now scroll. The item list is wrapped in a ScrolledWindow capped to the monitor height (sized after the items are packed, since the box is empty when it's wrapped and a GtkFixed won't re-expand it), and the viewport scrolls to keep the selection visible (incl. layer-shell/Wayland). Grid/radial menus opt out via scroll_wrap(). --- scc/osd/grid_menu.py | 3 +++ scc/osd/menu.py | 61 +++++++++++++++++++++++++++++++++++++++++- scc/osd/radial_menu.py | 3 +++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/scc/osd/grid_menu.py b/scc/osd/grid_menu.py index 1c608cef9..31aa73299 100644 --- a/scc/osd/grid_menu.py +++ b/scc/osd/grid_menu.py @@ -25,6 +25,9 @@ def __init__(self, cls="osd-menu"): Menu.__init__(self, cls) self.ipr = 1 # items per row + def scroll_wrap(self, parent): + return parent # grid menus manage their own fixed layout + def create_parent(self): g = Gtk.Grid() g.set_name("osd-menu") diff --git a/scc/osd/menu.py b/scc/osd/menu.py index dedfaa491..a551d57b2 100644 --- a/scc/osd/menu.py +++ b/scc/osd/menu.py @@ -55,7 +55,7 @@ def __init__(self, cls="osd-menu", layer=None): self.parent = self.create_parent() self.f = Gtk.Fixed() - self.f.add(self.parent) + self.f.add(self.scroll_wrap(self.parent)) self.add(self.f) self._submenu = None @@ -82,6 +82,63 @@ def create_parent(self): v.set_name("osd-menu") return v + def scroll_wrap(self, parent): + """Wrap the vertical item list in a scrolled viewport capped to the screen + height, so very long menus (e.g. hundreds of profiles) don't run off-screen. + Overridden to a no-op by grid/radial/horizontal menus.""" + sw = Gtk.ScrolledWindow() + sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) + try: + sw.set_shadow_type(Gtk.ShadowType.NONE) + except Exception: + pass + sw.add(parent) + self._scrollwindow = sw + return sw + + def _max_menu_height(self): + """Largest the menu may grow before scrolling (monitor height minus margin).""" + try: + display = Gdk.Display.get_default() + monitor = display.get_primary_monitor() or display.get_monitor(0) + return max(240, monitor.get_geometry().height - 80) + except Exception: + return 720 + + def _fit_scroll(self): + """Size the scrolled viewport to the packed items, capped to the screen. + The item box is empty when scroll_wrap() runs and a GtkFixed won't expand + the viewport afterwards, so the size is set here once items are present.""" + sw = getattr(self, "_scrollwindow", None) + if sw is None: + return + self.parent.show_all() + nath = self.parent.get_preferred_height()[1] + natw = self.parent.get_preferred_width()[1] + cap = self._max_menu_height() + if nath > cap: + sw.set_size_request(natw + 24, cap) + else: + sw.set_size_request(natw, nath) + + def _ensure_visible(self, widget): + """Scroll the viewport (if any) so the selected item stays on screen.""" + sw = getattr(self, "_scrollwindow", None) + if sw is None or widget is None: + return + adj = sw.get_vadjustment() + if adj is None: + return + alloc = widget.get_allocation() + page = adj.get_page_size() + if alloc.height <= 0 or page <= 0: + return + val = adj.get_value() + if alloc.y < val: + adj.set_value(alloc.y) + elif alloc.y + alloc.height > val + page: + adj.set_value(alloc.y + alloc.height - page) + def pack_items(self, parent, items): for item in items: parent.pack_start(item.widget, True, True, 0) @@ -293,6 +350,7 @@ def select(self, index): self.controller.feedback(*self.feedback) self._selected = self.items[index] self._selected.widget.set_name(self._selected.widget.get_name() + "-selected") + self._ensure_visible(self._selected.widget) GLib.timeout_add(2, self._check_on_screen_position) return True return False @@ -342,6 +400,7 @@ def run(self): def show(self, *a): if not self.select(0): self.next_item(1) + self._fit_scroll() OSDWindow.show(self, *a) GLib.timeout_add(1, self._check_on_screen_position, True) diff --git a/scc/osd/radial_menu.py b/scc/osd/radial_menu.py index 39d9dfba5..0c841183f 100644 --- a/scc/osd/radial_menu.py +++ b/scc/osd/radial_menu.py @@ -51,6 +51,9 @@ def __init__(self) -> None: self.set_app_paintable(True) self.connect("draw", self._on_draw_clip_circle) + def scroll_wrap(self, parent): + return parent # radial menu draws items on an SVG; no scroll viewport + def create_parent(self) -> SVGWidget: background = os.path.join(get_share_path(), "images", "radial-menu.svg") self.b = SVGWidget(background) From 46771b4320f5ca1f09d6dcb6b36229f5e7e98b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 19 Jun 2026 00:07:43 +0200 Subject: [PATCH 11/74] osd: per-controller binding display with a v2 (Steam Controller 2025) layout "Display Current Bindings" always rendered the fixed v1 binding-display.svg template and a hardcoded 5-box layout built for the v1 control set, so it showed the v1 controller regardless of which one was connected, and its boxes overflowed the screen on busier profiles. - binding_display.py now resolves a per-controller image: an explicit gui.binding_display, else binding-display-.svg (e.g. binding-display-sc2.svg), else the generic template. The window is built once the connected controller is known (on_daemon_connected) so it can pick the right image, and it draws that controller's current profile right away. - The Generator box layout is per-controller now. The original 5-box layout is kept verbatim as the v1 fallback (_build_v1); a LAYOUTS table drives others. LAYOUTS["sc2"] is the Steam Deck-style v2 set: six boxes (system, left/right shoulder, left/right thumb, face) covering two sticks, a D-pad, two pads, four system buttons and the back paddles + grip-squeeze. Every control is listed but only bound ones draw a line, and a box with no bound controls is hidden - so grip-squeeze and the touch/press variants show up only when actually bound. - Boxes auto-fit: a per-box max_height plus font auto-scaling shrinks a crowded box (e.g. a stick bound to a big radial) so all its lines stay inside it, fixing the overflow. - tools/gen_binding_display.py generates images/binding-display-sc2.svg from the restyled controller art (tools/binding-display-sc2-art.svg) inlined verbatim, plus the AREA_* anchors of the GUI image, placing the six markers_ connector groups. Edit the art asset in Inkscape and re-run to regenerate. Co-Authored-By: Claude Opus 4.8 --- images/binding-display-sc2.svg | 38 +++++ scc/osd/binding_display.py | 259 +++++++++++++++++++++++++++--- tools/binding-display-sc2-art.svg | 38 +++++ tools/gen_binding_display.py | 150 +++++++++++++++++ 4 files changed, 462 insertions(+), 23 deletions(-) create mode 100644 images/binding-display-sc2.svg create mode 100644 tools/binding-display-sc2-art.svg create mode 100644 tools/gen_binding_display.py diff --git a/images/binding-display-sc2.svg b/images/binding-display-sc2.svg new file mode 100644 index 000000000..2baf69256 --- /dev/null +++ b/images/binding-display-sc2.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + X \ No newline at end of file diff --git a/scc/osd/binding_display.py b/scc/osd/binding_display.py index f79f3c94a..e8d46a87b 100644 --- a/scc/osd/binding_display.py +++ b/scc/osd/binding_display.py @@ -9,6 +9,7 @@ import base64 import logging import os +import re import sys from enum import IntEnum from typing import Self @@ -17,7 +18,7 @@ from scc.actions import Action, AxisAction, DPadAction, MouseAction, MultiAction, XYAction from scc.config import Config -from scc.constants import SCButtons +from scc.constants import DPAD, LEFT, RIGHT, SCButtons from scc.gui.daemon_manager import DaemonManager from scc.gui.svg_widget import SVGEditor, SVGWidget from scc.modifiers import DoubleclickModifier, ModeModifier @@ -45,6 +46,7 @@ def __init__(self, config=None): self.group = None self.limits = {} self.background = None + self._layout_key = None # gui "background" name -> per-controller LAYOUTS self._eh_ids = [] self._stick = 0, 0 @@ -53,8 +55,22 @@ def __init__(self, config=None): self.c.set_name("osd-keyboard-container") def on_profile_changed(self, daemon: DaemonManager, filename: str): - profile = Profile(TalkingActionParser()).load(filename) - Generator(SVGEditor(self.background), profile) + self._draw_profile(filename) + + def _draw_profile(self, filename): + """(Re)draws the binding boxes for the given profile onto the current + background. No-op until the background image has been built, which + happens in on_daemon_connected() once the connected controller (and + thus which per-controller image to load) is known. + """ + if self.background is None or not filename: + return + try: + profile = Profile(TalkingActionParser()).load(filename) + except Exception: + log.exception("Failed to load profile %s", filename) + return + Generator(SVGEditor(self.background), profile, self._layout_key) def use_daemon(self, d): """Allows (re)using already existing DaemonManager instance in same process.""" @@ -114,6 +130,16 @@ def success(*a): self.on_failed_to_lock("Controller not connected") return + # The binding-display image is per-controller, so it can only be + # resolved now that we know which controller is connected. show() left + # the window unbuilt; build it here and draw the profile the controller + # already has (the daemon may have reported the profile before the + # window existed, so relying on the profile-changed signal alone would + # leave the boxes blank until the next profile change). + if self.background is None: + self._build_and_show(self._resolve_image(c)) + self._draw_profile(c.get_profile()) + self._eh_ids += [ (c, c.connect("event", self.on_event)), (c, c.connect("lost", self.on_controller_lost)), @@ -123,6 +149,53 @@ def success(*a): locks = ["RB", "LB", self.args.cancel_with] c.lock(success, self.on_failed_to_lock, *locks) + def _resolve_image(self, controller): + """Picks the binding-display SVG for the connected controller. + + Order of preference: + 1. an explicit image given on the command line + 2. "binding_display" filename set in the controller's gui config + 3. convention: binding-display-.svg + (looked up in ~/.config/scc first, then the bundled images dir) + 4. the generic binding-display.svg (user override, then bundled) + The generic fallback keeps controllers without a dedicated layout + working - they just render on the old template, as before. + """ + images_path = os.path.join(get_share_path(), "images") + config_path = get_config_path() + candidates = [] + # 1. explicit command-line image (default equals self.bdisplay) + cli = getattr(self.args, "image", None) + if cli and cli != self.bdisplay: + candidates.append(cli) + # 2./3. per-controller, from the controller's gui config + try: + config = controller.load_gui_config(images_path) + except Exception: + log.exception("Failed to load controller gui config") + config = None + gui = (config or {}).get("gui") or {} + explicit = gui.get("binding_display") + if explicit: + if "/" in explicit: + candidates.append(explicit) + else: + candidates.append(os.path.join(config_path, explicit)) + candidates.append(os.path.join(images_path, explicit)) + background = gui.get("background") + self._layout_key = background # selects the per-controller box layout + if background: + fname = "binding-display-%s.svg" % (background,) + candidates.append(os.path.join(config_path, fname)) + candidates.append(os.path.join(images_path, fname)) + # 4. generic fallback (already user-override-then-bundled) + candidates.append(self.bdisplay) + for path in candidates: + if path and os.path.exists(path): + log.debug("Using binding-display image: %s", path) + return path + return self.bdisplay + def quit(self, code=-1): if self.get_controller(): self.get_controller().unlock_all() @@ -132,13 +205,21 @@ def quit(self, code=-1): OSDWindow.quit(self, code) def show(self, *a): - if self.background is None: - self.realize() - self.background = SVGWidget(self.args.image, init_hilighted=True) - self.c.add(self.background) - self.add(self.c) - - OSDWindow.show(self, *a) + # The background image is per-controller and only known once the daemon + # reports the connected controller, so the real show is deferred to + # on_daemon_connected() -> _build_and_show(). Until the background + # exists this is a no-op (run() calls show() before the daemon is up). + if self.background is not None: + OSDWindow.show(self, *a) + self.move(*self.compute_position()) + + def _build_and_show(self, image): + """Builds the window around the given background image and shows it.""" + self.realize() + self.background = SVGWidget(image, init_hilighted=True) + self.c.add(self.background) + self.add(self.c) + OSDWindow.show(self) self.move(*self.compute_position()) def on_event(self, daemon, what, data): @@ -199,8 +280,10 @@ class Box: SPACING = 2 MIN_WIDTH = 100 MIN_HEIGHT = 50 + MIN_SCALE = 0.4 # smallest font shrink before lines may overflow anyway - def __init__(self, anchor_x, anchor_y, align, name, min_width=MIN_WIDTH, min_height=MIN_HEIGHT, max_width=999999): + def __init__(self, anchor_x, anchor_y, align, name, min_width=MIN_WIDTH, min_height=MIN_HEIGHT, + max_width=999999, max_height=999999): self.name = name self.lines = [] self.anchor = anchor_x, anchor_y @@ -209,6 +292,7 @@ def __init__(self, anchor_x, anchor_y, align, name, min_width=MIN_WIDTH, min_hei self.x, self.y = 0, 0 self.min_width = min_width self.max_width = max_width + self.max_height = max_height self.min_height = min_height def to_string(self): @@ -237,7 +321,7 @@ def add(self, icon, context, action): action = action.strip() if isinstance(action, MenuAction): - if self.name == "bcs" and action.menu_id == "Default.menu": + if self.name in ("bcs", "system") and action.menu_id == "Default.menu": # Special case, this action is expected in every profile, # so there is no need to draw it here return LineCollection() @@ -277,6 +361,17 @@ def calculate(self, gen): self.width += 2 * self.PADDING + self.icount * (gen.line_height + self.SPACING) self.width = min(self.width, self.max_width) self.height = max(self.height, self.min_height) + # Auto-scale the font for this box so all its lines fit within max_height. + # place() draws every line regardless of box height, so without this a + # crowded box (e.g. a stick bound to a big radial/dpad, or mode-heavy face + # buttons) overflows downward off the box and the screen. + content = self.height - 2 * self.PADDING + avail = self.max_height - 2 * self.PADDING + if content > avail and content > 0: + self.scale = max(self.MIN_SCALE, avail / content) + self.height = self.max_height + else: + self.scale = 1.0 anchor_x, anchor_y = self.anchor if (self.align & Align.TOP) != 0: @@ -307,9 +402,12 @@ def place(self, gen, root): y=self.y, ) + scale = getattr(self, "scale", 1.0) + lh = gen.line_height * scale + text_style = gen.label_style(scale) y = self.y + self.PADDING for line in self.lines: - h = gen.line_height + h = lh x = self.x + self.PADDING for icon in line.icons: image = find_image(icon) @@ -327,12 +425,12 @@ def place(self, gen, root): x += h + self.SPACING x = self.x + self.PADDING + self.icount * (h + self.SPACING) y += h - txt = SVGEditor.add_element(root, "text", x=x, y=y, style=gen.label_template.attrib["style"]) - max_line_width = self.max_width - gen.line_height - self.PADDING - while line.text and line.get_size(gen)[0] > max_line_width: + txt = SVGEditor.add_element(root, "text", x=x, y=y, style=text_style) + max_line_width = self.max_width - lh - self.PADDING + while line.text and line.get_size(gen)[0] * scale > max_line_width: line.text = line.text[:-1] SVGEditor.set_text(txt, line.text) - y += self.SPACING + y += self.SPACING * scale def place_marker(self, gen, root): x1, y1 = self.x, self.y @@ -380,17 +478,97 @@ def place_marker(self, gen, root): ) +# --- per-controller binding-display layouts -------------------------------- +# Which controls go in which box is semantic, so it lives here rather than in +# the template SVG (which only supplies marker positions + the canvas). Keyed by +# the controller's gui "background" name; controllers without an entry fall back +# to the v1 layout (Generator._build_v1). Box positions are auto-placed from the +# Align flags; size caps are fractions of the canvas. Only bound controls draw a +# line and a box with no bound controls is hidden (Generator._build_layout), so +# every variant (grip-squeeze, stick/pad touch & press, ...) can be listed and +# simply stays invisible until the user binds it. +_B, _T, _P, _S = Action.AC_BUTTON, Action.AC_TRIGGER, Action.AC_PAD, Action.AC_STICK + + +def _btn(name): + return lambda p: p.buttons.get(SCButtons[name]) + + +def _pad(side): + return lambda p: p.pads.get(side) + + +def _trig(side): + return lambda p: p.triggers.get(side) + + +def _stick(p): + return p.stick + + +def _rstick(p): + return getattr(p, "rstick", None) + + +LAYOUTS = { + # Steam Controller v2 (2026) -- Steam Deck control set: two sticks, a D-pad, + # two trackpads, four system buttons, back paddles + grip-squeeze sensors. + # Six boxes: four corners + top/bottom centre, controller art in the middle. + "sc2": [ + dict(name="system", align=Align.TOP, ax=0, max_width_f=0.4, max_height_f=0.22, + controls=[("BACK", _B, _btn("BACK")), ("C", _B, _btn("C")), + ("START", _B, _btn("START")), ("DOTS", _B, _btn("DOTS"))]), + dict(name="lshoulder", align=Align.LEFT | Align.TOP, + min_width_f=0.18, max_width_f=0.27, max_height_f=0.42, + controls=[("LT", _T, _trig(LEFT)), ("LB", _B, _btn("LB")), + ("LGRIP", _B, _btn("LGRIP")), ("LGRIP2", _B, _btn("LGRIP2")), + ("LGRIPTOUCH", _B, _btn("LGRIPTOUCH"))]), + dict(name="rshoulder", align=Align.RIGHT | Align.TOP, + min_width_f=0.18, max_width_f=0.27, max_height_f=0.42, + controls=[("RT", _T, _trig(RIGHT)), ("RB", _B, _btn("RB")), + ("RGRIP", _B, _btn("RGRIP")), ("RGRIP2", _B, _btn("RGRIP2")), + ("RGRIPTOUCH", _B, _btn("RGRIPTOUCH"))]), + dict(name="lthumb", align=Align.LEFT | Align.BOTTOM, + min_width_f=0.18, max_width_f=0.27, max_height_f=0.42, + controls=[("STICK", _S, _stick), ("DPAD", _P, _pad(DPAD)), + ("LPAD", _P, _pad(LEFT))]), + dict(name="rthumb", align=Align.RIGHT | Align.BOTTOM, + min_width_f=0.18, max_width_f=0.27, max_height_f=0.42, + controls=[("RSTICK", _S, _rstick), ("RPAD", _P, _pad(RIGHT))]), + dict(name="face", align=Align.BOTTOM, ax=0, max_width_f=0.4, max_height_f=0.22, + controls=[("A", _B, _btn("A")), ("B", _B, _btn("B")), + ("X", _B, _btn("X")), ("Y", _B, _btn("Y"))]), + ], +} + + class Generator: PADDING = 10 - def __init__(self, editor, profile): + def __init__(self, editor, profile, layout_key=None): background = SVGEditor.get_element(editor, "background") self.label_template = SVGEditor.get_element(editor, "label_template") self.line_height = int(float(self.label_template.attrib.get("height") or 8)) self.char_width = int(float(self.label_template.attrib.get("width") or 8)) self.full_width = int(float(background.attrib.get("width") or 800)) self.full_height = int(float(background.attrib.get("height") or 800)) + self._label_style = self.label_template.attrib.get("style", "") + m = re.search(r"font-size:\s*([\d.]+)", self._label_style) + self.font_size = float(m.group(1)) if m else self.line_height * 1.45 + root = SVGEditor.get_element(editor, "root") + + layout = LAYOUTS.get(layout_key) + if layout is None: + self._build_v1(profile, root) + else: + self._build_layout(profile, root, layout) + editor.commit() + + def _build_v1(self, profile, root): + """The original 5-box layout (Steam Controller v1: one stick, no D-pad, + three system buttons). Used for v1 and any controller without a dedicated + entry in LAYOUTS.""" boxes = [] box_bcs = Box(0, self.PADDING, Align.TOP, "bcs") box_bcs.add("BACK", Action.AC_BUTTON, profile.buttons.get(SCButtons.BACK)) @@ -443,10 +621,6 @@ def __init__(self, editor, profile): box_stick.add("STICK", Action.AC_STICK, profile.stick) boxes.append(box_stick) - w = int(float(background.attrib.get("width") or 800)) - h = int(float(background.attrib.get("height") or 800)) - - root = SVGEditor.get_element(editor, "root") for b in boxes: b.calculate(self) @@ -465,7 +639,46 @@ def __init__(self, editor, profile): for b in boxes: b.place(self, root) - editor.commit() + def _build_layout(self, profile, root, layout): + """Builds boxes from a per-controller LAYOUTS spec. Box positions are + auto-placed from the Align flags; size caps come from canvas fractions. + Boxes whose controls are all unbound draw nothing and are dropped.""" + boxes = [] + for spec in layout: + box = Box( + spec.get("ax", self.PADDING), + spec.get("ay", self.PADDING), + spec["align"], + spec["name"], + min_width=spec.get("min_width_f", 0) * self.full_width or Box.MIN_WIDTH, + min_height=spec.get("min_height_f", 0) * self.full_height or Box.MIN_HEIGHT, + max_width=spec.get("max_width_f", 1.0) * self.full_width, + max_height=spec.get("max_height_f", 1.0) * self.full_height, + ) + for icon, context, getter in spec["controls"]: + box.add(icon, context, getter(profile)) + boxes.append(box) + + for b in boxes: + b.calculate(self) + # Hide boxes that ended up with no bound controls. + boxes = [b for b in boxes if b.lines] + + for b in boxes: + b.place_marker(self, root) + for b in boxes: + b.place(self, root) + + def label_style(self, scale): + """Label text style with font-size scaled by `scale` (used to shrink a + crowded box so its lines fit). Returns the template style unchanged at + scale 1.0.""" + if scale >= 0.999: + return self._label_style + fs = self.font_size * scale + if re.search(r"font-size:\s*[\d.]+px", self._label_style): + return re.sub(r"font-size:\s*[\d.]+px", "font-size:%.1fpx" % (fs,), self._label_style) + return "font-size:%.1fpx;%s" % (fs, self._label_style) def equal_width(self, *boxes): """Sets width of all passed boxes to width of widest box""" diff --git a/tools/binding-display-sc2-art.svg b/tools/binding-display-sc2-art.svg new file mode 100644 index 000000000..cf4caccbe --- /dev/null +++ b/tools/binding-display-sc2-art.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/gen_binding_display.py b/tools/gen_binding_display.py new file mode 100644 index 000000000..b3c33ae76 --- /dev/null +++ b/tools/gen_binding_display.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python3 +"""Generate the binding-display layout SVG for the v2 Steam Controller. + +The OSD "Display Current Bindings" window (scc/osd/binding_display.py) draws each +control's binding into boxes laid out around a controller picture, using a +per-controller template SVG (binding-display-.svg). This tool +assembles that template for the v2 controller. + +What it emits (images/binding-display-sc2.svg), all required by Generator: + - a 1280x720 canvas with `background` (sizes the layout), `label_template` + (label font/metrics) and `root` (boxes are drawn into it) elements; + - the restyled controller drawing, inlined verbatim from the source asset + tools/binding-display-sc2-art.svg (edit that in Inkscape to change the + look -- it carries its own placement transform); + - the six `markers_` groups (system/lshoulder/rshoulder/lthumb/rthumb/ + face -- the v2 box set in binding_display.py LAYOUTS["sc2"]), each with + circles placed at the matching AREA_* anchor centres of sc2.svg, mapped + into canvas coordinates. Each box draws a connector line to up to two. + +Markers come from the GUI image's (sc2.svg) AREA_* anchors -- they live in an +untransformed layer in final display coords, so their centres map into the +canvas via the ART_MAX_*_FRAC transform below. The art asset was placed to +register with that mapping; if you change ART_MAX_*_FRAC, re-place the art. + +Run from repo root: python3 tools/gen_binding_display.py +""" +import os +import xml.etree.ElementTree as ET + +SVG = "http://www.w3.org/2000/svg" +SRC = "images/controller-images/sc2.svg" # AREA anchors for markers +ART = "tools/binding-display-sc2-art.svg" # restyled controller drawing +OUT = "images/binding-display-sc2.svg" + +CANVAS_W, CANVAS_H = 1280, 720 + +# Defines the controller's footprint in the canvas, i.e. the sc2.svg-coords -> +# canvas transform used to place the AREA-anchor markers. The art asset +# (tools/binding-display-sc2-art.svg) was drawn/placed to register with this. +ART_MAX_W_FRAC = 0.38 +ART_MAX_H_FRAC = 0.70 + +# Generator box name -> AREA_* anchors its connector lines point at. A box draws +# at most two lines; missing anchors are skipped (so a box may get 1 or 2). These +# match the v2 (sc2) box set in scc/osd/binding_display.py LAYOUTS["sc2"]. +MARKERS = { + "system": ["BACK", "START"], + "lshoulder": ["LB", "LGRIPTOUCH"], + "rshoulder": ["RB", "RGRIPTOUCH"], + "lthumb": ["STICK", "LPAD"], + "rthumb": ["RSTICK", "RPAD"], + "face": ["Y", "A"], +} + +ET.register_namespace("", SVG) + + +def q(tag): + return "{%s}%s" % (SVG, tag) + + +def parse_viewbox(svg): + vb = svg.get("viewBox") + if vb: + p = [float(x) for x in vb.replace(",", " ").split()] + return p[2], p[3] + return float(svg.get("width")), float(svg.get("height")) + + +def read_area_centers(root): + """AREA_ rects sit in an untransformed layer in display coords, so + their centres are read directly.""" + centers = {} + for rect in root.iter(q("rect")): + rid = rect.get("id") or "" + if rid.startswith("AREA_"): + x, y = float(rect.get("x")), float(rect.get("y")) + w, h = float(rect.get("width")), float(rect.get("height")) + centers[rid[5:]] = (x + w / 2.0, y + h / 2.0) + return centers + + +def main(): + if not os.path.exists(SRC): + raise SystemExit("run from repo root: %s not found" % SRC) + src = ET.parse(SRC).getroot() + cw, ch = parse_viewbox(src) # controller art size (685x493) + centers = read_area_centers(src) + + # Scale + centre the art in the free middle band. + s = min(CANVAS_W * ART_MAX_W_FRAC / cw, CANVAS_H * ART_MAX_H_FRAC / ch) + ox = (CANVAS_W - cw * s) / 2.0 + oy = (CANVAS_H - ch * s) / 2.0 + + def to_canvas(pt): + return ox + s * pt[0], oy + s * pt[1] + + out = ET.Element(q("svg"), { + "width": str(CANVAS_W), "height": str(CANVAS_H), + "viewBox": "0 0 %d %d" % (CANVAS_W, CANVAS_H), "version": "1.1"}) + ET.SubElement(out, q("defs"), {"id": "defs1"}) + + # background: drives the Generator's layout (it reads width/height) and gives + # the OSD a dark backdrop so the labels read. + ET.SubElement(out, q("rect"), { + "id": "background", "x": "0", "y": "0", + "width": str(CANVAS_W), "height": str(CANVAS_H), + "style": "fill:#000000;fill-opacity:0.85"}) + + # controller art: the hand-restyled drawing, inlined verbatim from the source + # asset (kept separate so this generator reproduces it and the look is edited + # in Inkscape). It carries its own placement transform, made to register with + # the AREA-anchor marker mapping above. + if not os.path.exists(ART): + raise SystemExit("%s not found" % ART) + for child in list(ET.parse(ART).getroot()): + if child.tag.split("}")[-1] == "defs": + continue + out.append(child) + + # foreground: label_template + root (boxes drawn here) + the marker groups. + root = ET.SubElement(out, q("g"), {"id": "root", "style": "display:inline"}) + lt = ET.SubElement(root, q("text"), { + "id": "label_template", + "style": "font-size:22px;font-family:'Ubuntu Mono';fill:#ffffff", + "width": "11", "height": "15", "x": "-100", "y": "-100"}) + lt.text = "X" + + missing = [] + for name, anchors in MARKERS.items(): + g = ET.SubElement(root, q("g"), {"id": "markers_%s" % name}) + for a in anchors: + if a not in centers: + missing.append(a) + continue + cx, cy = to_canvas(centers[a]) + ET.SubElement(g, q("circle"), { + "cx": "%g" % cx, "cy": "%g" % cy, "r": "5", + "style": "fill:#000000;fill-opacity:0;stroke:#06a400;stroke-width:1"}) + + ET.ElementTree(out).write(OUT, encoding="unicode", xml_declaration=True) + print("wrote", OUT) + print(" art inlined from %s; marker mapping scale %.3f at (%.1f, %.1f)" + % (ART, s, ox, oy)) + if missing: + print(" WARNING: AREA anchors not found in %s: %s" % (SRC, ", ".join(missing))) + + +if __name__ == "__main__": + main() From 56fb35c6e58d808fc97f15a7b8b5c560798d6ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 19 Jun 2026 00:07:56 +0200 Subject: [PATCH 12/74] gui: "Edit Bindings" opens the OSD-keyboard bindings editor (sc-controller --osd) The OSD menu's "Edit Bindings" runs `sc-controller --osd`, which used the controller-driven "OSD mode" (osd_mode): it reused the full main window and drove it by injecting X11-style GDK events and matching windows by XID. That only works on the X11 backend, and even there it was fragile (a mispositioned, black- rendering hint overlay); on Wayland it just spawned a duplicate main window. --osd now opens only the standalone OSD-keyboard bindings editor instead - the same dialog as Settings > Menus & Keyboard > Advanced - on both X11 and Wayland. It is a plain GTK window with no backend dependency, so it behaves consistently everywhere: - no main window is shown (so it cannot pile up duplicate main windows) and no tray icon; - the OSK.* actions are registered first so the OSD-keyboard profile parses; - closing the editor quits the process; - an flock-based single-instance guard makes a repeat launch a no-op instead of stacking a second editor window. osd_mode is left in place but is now unreachable (osk_edit_mode replaces it); it is removed in the next commit. Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/scc/gui/app.py b/scc/gui/app.py index 026358d1d..c07682981 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -92,8 +92,9 @@ def __init__(self, gladepath: str = "/usr/share/scc", imagepath: str = "/usr/sha self.status = "unknown" self.context_menu_for = None self.daemon_changed_profile = False - self.osd_mode = False # In OSD mode, only active profile can be editted + self.osd_mode = False # legacy controller-driven OSD edit mode (retired; never enabled) self.osd_mode_mapper = None + self.osk_edit_mode = False # --osd: open only the OSD-keyboard bindings editor self.background = None self.outdated_version = None self.profile_switchers: list[ProfileSwitcher] = [] @@ -1416,13 +1417,17 @@ def do_startup(self, *a) -> None: Gtk.Application.do_startup(self, *a) self.load_profile_list() self.setup_widgets() - if self.app.config["gui"]["enable_status_icon"]: + # No tray icon for the transient OSD-keyboard bindings editor launch. + if self.app.config["gui"]["enable_status_icon"] and not self.osk_edit_mode: self.setup_statusicon() self.set_daemon_status("unknown", True) def do_local_options(self, trash, lo): set_logging_level(lo.contains("verbose"), lo.contains("debug")) - self.osd_mode = lo.contains("osd") + # --osd opens the standalone OSD-keyboard bindings editor (do_activate) - + # the same dialog as Settings > Menus & Keyboard > Advanced. Used on both + # X11 and Wayland for a consistent, reliable single-window experience. + self.osk_edit_mode = lo.contains("osd") return -1 def do_command_line(self, cl: ApplicationCommandLine) -> int: @@ -1449,12 +1454,49 @@ def i_told_you_to_quit(*a) -> Never: return 0 def do_activate(self, *a) -> None: + if self.osk_edit_mode: + # "Edit Bindings" (OSD menu): show only the OSD-keyboard bindings + # editor, never the main window, and quit when it is closed - so it + # can't pile up duplicate main windows. + if not getattr(self, "_osk_editor", None): + self.open_osk_editor() + return self.builder.get_object("window").show() if self.config["gui"]["minimize_on_start"] and self.statusicon and self.statusicon.get_property("active"): self.builder.get_object("window").hide() else: self.builder.get_object("window").show() + def open_osk_editor(self): + """Opens the standalone OSD-keyboard bindings editor (the same window + reachable from Settings > Menus & Keyboard > Advanced) as the only + window, quitting the app when it closes. Backs the OSD menu's + 'Edit Bindings' item.""" + import fcntl + + import scc.osd.osk_actions + from scc.actions import Action + from scc.gui.osk_binding_editor import OSKBindingEditor + # Single-instance: each "Edit Bindings" is its own process (the app is + # NON_UNIQUE), so without this a repeated launch would stack a second + # editor window. Hold an exclusive lock for our lifetime; if another + # launch already holds it, just quit instead of opening a duplicate. + try: + self._osk_lock = open(os.path.join(get_config_path(), ".osk-editor.lock"), "w") + fcntl.flock(self._osk_lock, fcntl.LOCK_EX | fcntl.LOCK_NB) + except OSError: + log.info("OSD-keyboard bindings editor already open; not opening another") + self.quit() + return + except Exception: + log.exception("OSK editor single-instance lock failed; opening anyway") + # The OSD-keyboard profile uses OSK.* actions; register them so the + # editor can parse it (GlobalSettings does the same before opening it). + Action.register_all(scc.osd.osk_actions, prefix="OSK") + self._osk_editor = OSKBindingEditor(self) + self._osk_editor.window.connect("destroy", lambda *a: self.quit()) + self._osk_editor.show(None) + def remove_dot_profile(self) -> None: """Checks if first profile in list begins with dot and if yes, removes it. This is done to undo automatic addition that is done when daemon reports @@ -1538,7 +1580,7 @@ def aso(long_name, short_name, description, arg=None, flags=GLib.OptionFlags.IN_ aso("verbose", b"v", "Be verbose") aso("debug", b"d", "Be more verbose (debug mode)") - aso("osd", b"o", "OSD mode (OSD-controllable editor for current profile)") + aso("osd", b"o", "Open the OSD-keyboard bindings editor") def save_profile_selection(self, path) -> None: """Saves name of profile into config file""" From d1c42c2e3f236d0b4a75f85ea28cffe3e21e9d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 19 Jun 2026 06:14:10 +0200 Subject: [PATCH 13/74] gui: remove the abandoned controller-driven OSD edit mode (osd_mode) This is the single, isolated removal of osd_mode, kept separate from v0.4 so the v0.4..v0.5 diff is the complete record of the feature should it ever be wanted back. What osd_mode was: launching `sc-controller --osd` opened the main window in a special mode you navigated with the controller itself - the pad drove focus and a floating hint overlay (OSDModeMappings) showed the button legend - so bindings could be edited from the couch without a keyboard or mouse. Why it is abandoned: - X11 only. It drives the GUI by synthesising X11-style GDK input events (OSDModeKeyboard/OSDModeMouse via Gtk.main_do_event) and matches windows by XID. Under a native Wayland GDK backend none of that works: focus cannot move (GTK_IS_WIDGET warnings) and there is no XID to match. - Even on X11 it is fragile: the hint overlay latches onto the wrong active window and renders black (it is an override-redirect window), and editing happens in the full main window rather than a focused dialog. - As of v0.4 "Edit Bindings" (`sc-controller --osd`) opens the standalone OSD-keyboard bindings editor instead, on both X11 and Wayland - a plain GTK dialog that is consistent and reliable - which made osd_mode unreachable dead code (osk_edit_mode replaced it). Removed: scc/gui/osd_mode.py (OSDModeMapper/Keyboard/Mouse/Mappings); App.osd_mode, App.osd_mode_mapper and all their conditionals; App.enable_osd_mode and OSD_MODE_PROF_NAME; the OsdmodeMappings window in glade/app.glade; the on_Dialog_key_press_event handler and its glade signal (action_editor); the osd_mode button-grab/name-entry guards (action_editor, ae/buttons); and the now-unused default profile .scc-osd.profile_editor.sccprofile. Co-Authored-By: Claude Opus 4.8 --- glade/action_editor.glade | 1 - glade/app.glade | 258 -------------------------------------- scc/gui/action_editor.py | 7 -- scc/gui/ae/buttons.py | 3 - scc/gui/app.py | 99 +-------------- scc/gui/osd_mode.py | 191 ---------------------------- 6 files changed, 5 insertions(+), 554 deletions(-) delete mode 100644 scc/gui/osd_mode.py diff --git a/glade/action_editor.glade b/glade/action_editor.glade index cf7025d6a..ecb228bed 100644 --- a/glade/action_editor.glade +++ b/glade/action_editor.glade @@ -161,7 +161,6 @@ True dialog - diff --git a/glade/app.glade b/glade/app.glade index 81ca3edfa..2d241af2a 100644 --- a/glade/app.glade +++ b/glade/app.glade @@ -2,264 +2,6 @@ - - False - 2 - False - True - True - False - False - False - False - - - True - False - 5 - 5 - 5 - 5 - - - 75 - True - False - - - True - False - gtk-missing-image - 3 - - - False - True - 5 - 0 - - - - - True - False - Exit - - - - - - - False - True - 1 - - - - - False - True - 5 - 0 - - - - - 75 - False - True - - - True - False - gtk-missing-image - 3 - - - False - True - 5 - 0 - - - - - True - False - Activate - - - - - - - False - True - 1 - - - - - False - True - 5 - 1 - - - - - 75 - True - False - - - True - False - gtk-missing-image - 3 - - - False - True - 5 - 0 - - - - - True - False - OK - - - - - - - False - True - 1 - - - - - False - True - 5 - 2 - - - - - 75 - False - True - - - True - False - gtk-missing-image - 3 - - - False - True - 5 - 0 - - - - - True - False - Close - - - - - - - False - True - 1 - - - - - False - True - 5 - 3 - - - - - 75 - True - False - - - True - False - gtk-missing-image - 3 - - - False - True - 5 - 0 - - - - - True - False - Save - - - - - - - False - True - 1 - - - - - False - True - 5 - 4 - - - - - True - False - - - True - True - 5 - - - - - True - False - - - True - True - 6 - - - - - diff --git a/scc/gui/action_editor.py b/scc/gui/action_editor.py index 54caf1543..e340e46ee 100644 --- a/scc/gui/action_editor.py +++ b/scc/gui/action_editor.py @@ -183,9 +183,6 @@ def setup_widgets(self): ), ) - if self.app.osd_mode: - self.builder.get_object("entName").set_sensitive(False) - def load_components(self): """Loads list of editor components""" # Import and load components @@ -217,10 +214,6 @@ def on_Dialog_destroy(self, *a): if self._selected_component is not None: self._selected_component.hidden() - def on_Dialog_key_press_event(self, window, event): - if self.app.osd_mode and event.keyval == 65471: - self.on_btOK_clicked() - def set_osd_enabled(self, value): """Sets value of OSD modifier checkbox, without firing any more events.""" self._recursing = True diff --git a/scc/gui/ae/buttons.py b/scc/gui/ae/buttons.py index d0dda7dfb..b32b0bd9d 100644 --- a/scc/gui/ae/buttons.py +++ b/scc/gui/ae/buttons.py @@ -50,9 +50,6 @@ def load(self): if not self.loaded: AEComponent.load(self) self.setup_image() - if self.app.osd_mode: - self.builder.get_object("btnGrabKey").set_sensitive(False) - self.builder.get_object("btnGrabAnother").set_sensitive(False) def area_action_selected(self, area, action): self.set_active_area(area) diff --git a/scc/gui/app.py b/scc/gui/app.py index c07682981..ade7f849f 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -58,7 +58,6 @@ class App(Gtk.Application, UserDataManager, BindingEditor): OBSERVE_COLOR = "#FF60A0FF" # ARGB CONFIG = "scc.config.json" RELEASE_URL = "https://github.com/C0rn3j/sc-controller/releases/tag/v%s" - OSD_MODE_PROF_NAME = ".scc-osd.profile_editor" def __init__(self, gladepath: str = "/usr/share/scc", imagepath: str = "/usr/share/scc/images"): Gtk.Application.__init__( @@ -92,8 +91,6 @@ def __init__(self, gladepath: str = "/usr/share/scc", imagepath: str = "/usr/sha self.status = "unknown" self.context_menu_for = None self.daemon_changed_profile = False - self.osd_mode = False # legacy controller-driven OSD edit mode (retired; never enabled) - self.osd_mode_mapper = None self.osk_edit_mode = False # --osd: open only the OSD-keyboard bindings editor self.background = None self.outdated_version = None @@ -162,14 +159,6 @@ def setup_widgets(self) -> None: self.main_area.put(self.lpad_test, 40, 40) self.main_area.put(self.rpad_test, 290, 90) self.main_area.put(self.stick_test, 150, 40) - self.main_area.put(self.rstick_test, 290, 40) - self.main_area.put(self.dpad_test, 40, 90) - self.main_area.put(self.cpad_test, 150, 90) - - # OSD mode (if used) - if self.osd_mode: - self.builder.get_object("btDaemon").set_sensitive(False) - self.window.set_title(_("Edit Profile")) # Headerbar headerbar(self.builder.get_object("hbWindow")) @@ -731,12 +720,6 @@ def on_switch_to_clicked(self, ps, *a) -> None: def on_profile_saved(self, giofile: Gio.File, send: bool = True) -> None: """Called when selected profile is saved to disk""" - if self.osd_mode: - # Special case, profile shouldn't be changed while in osd_mode - if not giofile.get_path().endswith(".mod"): - self.profile_switchers[0].set_profile_modified(False, self.current.is_template) - return - if giofile.get_path().endswith(".mod"): # Special case, this one is saved only to be sent to daemon # and user doesn't need to know about it @@ -873,7 +856,7 @@ def on_exiting_n_daemon_killed(self, *a): self.quit() def on_mnuExit_activate(self, *a): - if not self.osd_mode and self.app.config["gui"]["autokill_daemon"]: + if self.app.config["gui"]["autokill_daemon"]: log.debug("Terminating scc-daemon") for x in ("content", "mnuEmulationEnabled", "mnuEmulationEnabledTray"): w = self.builder.get_object(x) @@ -901,9 +884,7 @@ def on_daemon_alive(self, *a) -> None: if not self.release_notes_visible(): self.hide_error() self.just_started = False - if self.osd_mode: - self.enable_osd_mode() - elif self.profile_switchers[0].get_file() is not None and not self.just_started: + if self.profile_switchers[0].get_file() is not None and not self.just_started: self.dm.set_profile(self.current_file.get_path()) GLib.timeout_add_seconds(1, self.check) self.enable_test_mode() @@ -980,9 +961,6 @@ def add_switcher(self, margin_left=24, margin_right=24) -> ProfileSwitcher: sepSwitchers.set_visible(True) vbSwitchers.show_all() - if self.osd_mode: - ps.set_allow_switch(False) - if len(self.profile_switchers) > 0: ps.set_profile_list(self.profile_switchers[0].get_profile_list()) ps.set_switch_to_enabled(True) @@ -1006,7 +984,7 @@ def enable_test_mode(self, controller: ControllerManager | None = None) -> None: If sniffing is disabled in daemon configuration, 2nd call fails and logs error. """ - if self.dm.is_alive() and not self.osd_mode: + if self.dm.is_alive(): if self.test_mode_controller: self.test_mode_controller.unlock_all() if controller is None: @@ -1055,62 +1033,6 @@ def enable_test_mode(self, controller: ControllerManager | None = None) -> None: ) self.test_mode_controller = c - def enable_osd_mode(self): - # TODO: Support for multiple controllers here - self.osd_mode_controller = 0 - osd_mode_profile = Profile(GuiActionParser()) - osd_mode_profile.load(find_profile(App.OSD_MODE_PROF_NAME)) - try: - c = self.dm.get_controllers()[self.osd_mode_controller] - except IndexError: - log.error("osd_mode: Controller not connected") - self.quit() - return - - def on_lock_failed(*a): - log.error("osd_mode: Locking failed") - self.quit() - - def on_lock_success(*a): - log.debug("osd_mode: Locked everything") - from scc.gui.osd_mode import OSDModeMapper, OSDModeMappings - - self.osd_mode_mapper = OSDModeMapper(self, osd_mode_profile) - self.osd_mode_mapper.set_target_window(self.window.get_window()) - self.builder.get_object("btUndo").set_visible(False) - self.builder.get_object("btRedo").set_visible(False) - - m = OSDModeMappings(self, self.osd_mode_mapper, self.builder.get_object("OsdmodeMappings")) - m.set_controller(self.profile_switchers[0].get_controller()) - m.show() - - # Locks everything but pads. Pads are emulating mouse and this is - # better left in daemon - involving socket in mouse controls - # adds too much lags. - c.lock( - on_lock_success, - on_lock_failed, - "A", - "B", - "X", - "Y", - "START", - "BACK", - "LB", - "RB", - "C", - "STICK", - "LGRIP", - "RGRIP", - "LT", - "RT", - "STICKPRESS", - ) - - # Ask daemon to temporaly reconfigure pads for mouse emulation - c.replace(DaemonManager.nocallback, on_lock_failed, LEFT, osd_mode_profile.pads[LEFT]) - c.replace(DaemonManager.nocallback, on_lock_failed, RIGHT, osd_mode_profile.pads[RIGHT]) - def on_observe_failed(self, error): log.debug("Failed to enable test mode: %s", error) @@ -1129,8 +1051,7 @@ def on_daemon_version(self, daemon, version): # and we can check if there is anything new to inform user about elif self.app.config["gui"]["news"]["last_version"] != App.get_release(): if self.app.config["gui"]["news"]["enabled"]: - if not self.osd_mode: - self.check_release_notes() + self.check_release_notes() def on_daemon_error(self, daemon, error): log.debug("Daemon reported error '%s'", error) @@ -1163,16 +1084,11 @@ def on_daemon_error(self, daemon, error): return # If check() fails to find error reason, error message is displayed as it is - if self.osd_mode: - self.quit() - self.show_error(msg) self.set_daemon_status("error", True) def on_daemon_event_observer(self, daemon, c, what, data) -> None: - if self.osd_mode_mapper: - self.osd_mode_mapper.handle_event(daemon, what, data) - elif what in (LEFT, RIGHT, STICK, RSTICK, DPAD, CPAD): + if what in (LEFT, RIGHT, STICK, RSTICK, DPAD, CPAD): widget, area = { LEFT: (self.lpad_test, "LPADTEST"), RIGHT: (self.rpad_test, "RPADTEST"), @@ -1354,8 +1270,6 @@ def on_window_key_press_event(self, window, event) -> None: if (event.state & Gdk.ModifierType.CONTROL_MASK) != 0: if event.keyval == 115: self.on_save_clicked() - elif self.osd_mode and event.keyval == 65471: - self.on_save_clicked() def show_error(self, message, ribar=None): if self.ribar is None or self.ribar.get_label() is None: @@ -1390,9 +1304,6 @@ def on_daemon_dead(self, *a): self.set_daemon_status("unknown", True) return - if self.osd_mode: - self.quit() - for ps in self.profile_switchers: ps.set_controller(None) ps.on_daemon_dead() diff --git a/scc/gui/osd_mode.py b/scc/gui/osd_mode.py deleted file mode 100644 index 5f50e0385..000000000 --- a/scc/gui/osd_mode.py +++ /dev/null @@ -1,191 +0,0 @@ -"""SC Controller - OSD Mode Mapper - -Very special case of mapper used when main application is launched in "odd mode". -That means it's drawn in OSD layer, cannot be clicked and cannot react to -keyboard. This mapper emulates input events on it using GTK methods. - -Mouse movement (but not buttons) are passed to uinput as usuall. -""" - -import logging - -from gi.repository import Gdk, GLib, Gtk - -from scc.constants import SCButtons -from scc.gui.gdk_to_key import KEY_TO_GDK, KEY_TO_KEYCODE -from scc.osd.slave_mapper import SlaveMapper -from scc.uinput import Keys - -log = logging.getLogger("OSDModMapper") - - -class OSDModeMapper(SlaveMapper): - def __init__(self, app, profile): - SlaveMapper.__init__(self, profile, None, keyboard="osd", mouse="osd") - self.app = app - self.set_special_actions_handler(self) - self.target_window = None - - def on_sa_restart(self, *a): - """Restart / exit handler""" - self.app.quit() - - def set_target_window(self, w): - self.target_window = w - - def create_keyboard(self, name): - return OSDModeKeyboard(self) - - def create_mouse(self, name): - return OSDModeMouse(self) - - -class OSDModeKeyboard: - """Emulates uinput keyboard emulator""" - - def __init__(self, mapper): - self.mapper = mapper - self.display = Gdk.Display.get_default() - self.manager = self.display.get_device_manager() - self.device = [ - x for x in self.manager.list_devices(Gdk.DeviceType.MASTER) if x.get_source() == Gdk.InputSource.KEYBOARD - ][0] - - def pressEvent(self, keys): - for k in keys: - event = Gdk.Event.new(Gdk.EventType.KEY_PRESS) - event.time = Gtk.get_current_event_time() - event.hardware_keycode = KEY_TO_KEYCODE[k] - event.keyval = KEY_TO_GDK[k] - event.window = self.mapper.target_window - event.set_device(self.device) - Gtk.main_do_event(event) - - def releaseEvent(self, keys=[]): - for k in keys: - event = Gdk.Event.new(Gdk.EventType.KEY_RELEASE) - event.time = Gtk.get_current_event_time() - event.hardware_keycode = KEY_TO_KEYCODE[k] - event.keyval = KEY_TO_GDK[k] - event.window = self.mapper.target_window - event.set_device(self.device) - Gtk.main_do_event(event) - - -class OSDModeMouse: - """Emulates uinput keyboard emulator too""" - - def __init__(self, mapper): - self.mapper = mapper - self.display = Gdk.Display.get_default() - self.manager = self.display.get_device_manager() - self.device = [ - x for x in self.manager.list_devices(Gdk.DeviceType.MASTER) if x.get_source() == Gdk.InputSource.MOUSE - ][0] - - def synEvent(self, *a): - pass - - def keyEvent(self, key, val) -> None: - tp = Gdk.EventType.BUTTON_PRESS if val else Gdk.EventType.BUTTON_RELEASE - event = Gdk.Event.new(tp) - event.button = int(key) - Keys.BTN_LEFT + 1 - window, event.x, event.y = Gdk.Window.at_pointer() - screen, x, y, mask = Gdk.Display.get_default().get_pointer() - event.x_root, event.y_root = x, y - - gtk_window = None - for w in Gtk.Window.list_toplevels(): - if w.get_window(): - if window.get_toplevel().get_xid() == w.get_window().get_xid(): - gtk_window = w - break - if gtk_window: - if gtk_window.get_type_hint() == Gdk.WindowTypeHint.COMBO: - # Special case, clicking on combo does nothing, so - # pressing "space" is emulated instead. - if not val: - return - event = Gdk.Event.new(Gdk.EventType.KEY_PRESS) - event.time = Gtk.get_current_event_time() - event.hardware_keycode = 65 - event.keyval = Gdk.KEY_space - event.window = self.mapper.target_window - event.time = Gtk.get_current_event_time() - event.window = window - event.set_device(self.device) - Gtk.main_do_event(event) - - -class OSDModeMappings: - ICONS = { - "imgOsdmodeAct": SCButtons.A, - "imgOsdmodeClose": SCButtons.B, - "imgOsdmodeExit": SCButtons.C, - "imgOsdmodeSave": SCButtons.Y, - "imgOsdmodeOK": SCButtons.Y, - } - - MAIN_WINDOW_BUTTONS = {"vbOsdmodeExit", "vbOsdmodeSave"} - OTHER_WINDOW_BUTTONS = {"vbOsdmodeExit", "vbOsdmodeAct", "vbOsdmodeClose", "vbOsdmodeOK"} - - def __init__(self, app, mapper, window): - self.app = app - self.mapper = mapper - self.window = window - self.parent = app.window - self.first_window = None - GLib.timeout_add(10, self.move_around) - self.app.window.connect("focus-in-event", self.on_main_window_focus_in_event) - self.app.window.connect("focus-out-event", self.on_main_window_focus_out_event) - self.on_main_window_focus_in_event() - - def set_controller(self, c): - config = c.load_gui_config(self.app.imagepath or {}) - for name in OSDModeMappings.ICONS: - w = self.app.builder.get_object(name) - icon, trash = c.get_button_icon(config, OSDModeMappings.ICONS[name]) - w.set_from_file(icon) - - def on_main_window_focus_in_event(self, *a): - for x in self.OTHER_WINDOW_BUTTONS: - self.app.builder.get_object(x).set_visible(False) - for x in self.MAIN_WINDOW_BUTTONS: - self.app.builder.get_object(x).set_visible(True) - - def on_main_window_focus_out_event(self, *a): - for x in self.MAIN_WINDOW_BUTTONS: - self.app.builder.get_object(x).set_visible(False) - for x in self.OTHER_WINDOW_BUTTONS: - self.app.builder.get_object(x).set_visible(True) - - def get_target_position(self): - pos = self.first_window.get_position() - size = self.first_window.get_geometry() - my_size = self.window.get_window().get_geometry() - tx = pos.x + 0.5 * (size.width - my_size.width) - ty = pos.y + size.height + 100 - return tx, ty - - def show(self): - self.window.show() - self.window.get_window().set_override_redirect(True) - - def move_around(self, *a): - if self.first_window is None: - active = self.window.get_window().get_screen().get_active_window() - if active is None: - return None - self.first_window = active - - tx, ty = self.get_target_position() - self.window.get_window().move(tx, ty) - return True - - -def direction(x): - if x >= 1: - return 1 - if x <= -1: - return -1 - return 0 From ae899edf824ffae739168752441c78e4c54849ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 19 Jun 2026 17:39:40 +0200 Subject: [PATCH 14/74] gui: add "Act on release" (inverted button) for always-on sensors Adds InvertedButtonModifier (action-language COMMAND "inverted"): a held inversion that delivers the wrapped action's press on physical *release* and its release on physical press - so the binding is active while the button or sensor is NOT held. Meant for the Steam Controller's capacitive handle grips, which read "on" the whole time the controller is held. (Distinct from the existing pressed/released modifiers, which emit a momentary tap.) Exposed as an "Act on release" checkbox in the button binding pane, next to Toggle/Repeat, in the buttons action-editor component: apply_keys() and area_action_selected() wrap the action when ticked, set_action() detects and re-ticks it on load, and handles() looks through the wrapper - so it also round-trips with the Custom Action `inverted(...)` token. Label and tooltip are translatable. Co-Authored-By: Claude Opus 4.8 --- glade/ae/buttons.glade | 21 +++++++++++++++++++++ scc/gui/ae/buttons.py | 21 +++++++++++++++++++++ scc/modifiers.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/glade/ae/buttons.glade b/glade/ae/buttons.glade index d4b4f3a31..2a3f4746b 100644 --- a/glade/ae/buttons.glade +++ b/glade/ae/buttons.glade @@ -58,6 +58,27 @@ 1 + + + Act on release + 150 + True + True + False + start + end + 0 + True + Fire when the button or sensor is released instead of pressed. Useful for always-on sensors like the capacitive handle grips, which read "on" while the controller is held. + + + + False + True + end + 2 + + False diff --git a/scc/gui/ae/buttons.py b/scc/gui/ae/buttons.py index b32b0bd9d..14f333ea2 100644 --- a/scc/gui/ae/buttons.py +++ b/scc/gui/ae/buttons.py @@ -15,6 +15,7 @@ from scc.gui.key_grabber import KeyGrabber from scc.gui.parser import InvalidAction from scc.macros import Cycle, Macro, PressAction, ReleaseAction +from scc.modifiers import InvertedButtonModifier from scc.tools import _ from scc.uinput import Keys, Rels @@ -53,12 +54,19 @@ def load(self): def area_action_selected(self, area, action): self.set_active_area(area) + if self.builder.get_object("cbActOnRelease").get_active(): + action = InvertedButtonModifier(action) self.editor.set_action(action) def set_action(self, mode, action): cbToggle = self.builder.get_object("cbToggle") cbRepeat = self.builder.get_object("cbRepeat") + cbActOnRelease = self.builder.get_object("cbActOnRelease") if self.handles(mode, action): + # "Act on release" wraps the action in an InvertedButtonModifier + is_inverted = isinstance(action, InvertedButtonModifier) + if is_inverted: + action = action.action self.keys = set() is_togle, is_repeat = False, False if isinstance(action, MultiAction): @@ -77,6 +85,7 @@ def set_action(self, mode, action): is_togle = True cbToggle.set_active(is_togle) cbRepeat.set_active(is_repeat) + cbActOnRelease.set_active(is_inverted) area = action_to_area(action) if area is not None: self.set_active_area(area) @@ -87,6 +96,10 @@ def get_button_title(self): return _("Key or Button") def handles(self, mode, action): + # "Act on release" wraps the real action in an InvertedButtonModifier; + # look through it to the wrapped action. + if isinstance(action, InvertedButtonModifier): + return self.handles(mode, action.action) # Handles ButtonAction and MultiAction if all subactions are ButtonAction if isinstance(action, (ButtonAction, NoAction, InvalidAction)): return True @@ -124,8 +137,11 @@ def modifiers_first(key): def apply_keys(self, *a): """Common part of on_*key_grabbed""" + if not self.keys: + return cbToggle = self.builder.get_object("cbToggle") cbRepeat = self.builder.get_object("cbRepeat") + cbActOnRelease = self.builder.get_object("cbActOnRelease") keys = sorted(self.keys, key=ButtonsComponent.modifiers_first) action = ButtonAction(keys[0]) if len(keys) > 1: @@ -136,6 +152,8 @@ def apply_keys(self, *a): action.repeat = True elif cbToggle.get_active(): action = Cycle(PressAction(action), ReleaseAction(action)) + if cbActOnRelease.get_active(): + action = InvertedButtonModifier(action) self.editor.set_action(action) def on_btnGrabKey_clicked(self, *a): @@ -163,6 +181,9 @@ def on_cbRepeat_toggled(self, cbRepeat): cbToggle.set_active(False) self.apply_keys() + def on_cbActOnRelease_toggled(self, cb): + self.apply_keys() + def hide_toggle(self): """Hides 'set as toggle button' option""" cbToggle = self.builder.get_object("cbToggle") diff --git a/scc/modifiers.py b/scc/modifiers.py index 6ecf1aaf9..3a0c50784 100644 --- a/scc/modifiers.py +++ b/scc/modifiers.py @@ -340,6 +340,39 @@ def button_release(self, mapper): mapper.schedule(0.02, self._release) +class InvertedButtonModifier(Modifier): + """Acts on button release instead of press ("Act on release"). + + Swaps press and release, so the wrapped action is held while the physical + button is NOT pressed. Meant for always-on sensors such as the Steam + Controller's capacitive handle grips, which read "on" the whole time the + controller is held - inverting them lets the action fire when you let go. + Unlike PressedModifier/ReleasedModifier (which emit a momentary tap), this + is a true held inversion of the button state. + """ + COMMAND = "inverted" + + def describe(self, context): + if context in (Action.AC_STICK, Action.AC_PAD): + return _("(act on release)") + "\n" + self.action.describe(context) + return _("(act on release)") + " " + self.action.describe(context) + + def strip(self): + return self.action.strip() + + def compress(self): + self.action = self.action.compress() + return self + + def button_press(self, mapper): + # Physical press -> the wrapped action is released + self.action.button_release(mapper) + + def button_release(self, mapper): + # Physical release -> the wrapped action is pressed + self.action.button_press(mapper) + + class BallModifier(Modifier, WholeHapticAction): """Emulates ball-like movement with inertia and friction. From 60d3eef2ab0b44539a8650f8b3d48672bbe6201d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 19 Jun 2026 17:39:49 +0200 Subject: [PATCH 15/74] gui: fix Input Test Mode for the v2 controller Input Test Mode used the original (v1-era) observe list and a stick/pad cursor position that pinned the indicator to the top of the area: - Observe the v2 controls too: the "..." button (DOTS) and the capacitive handle-grip sensors (LGRIPTOUCH/RGRIPTOUCH). All are valid SCButtons that highlight by id (DOTS via the placed face glyph, the grips via their own elements), and they simply never fire on controllers without them. - Centre the stick/pad cursor on both axes. The rest position used `ay + 1.0` (the top of the area) instead of the area's vertical centre, so the left stick and both trackpad balls sat half a control too high until pushed. Now uses the area height for both centring and the Y offset. Right stick and d-pad still don't appear in test mode: the daemon's observe model (source_to_constant) has no positional source for RSTICK/DPAD yet. That is a separate, daemon-side follow-up. Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scc/gui/app.py b/scc/gui/app.py index ade7f849f..a4bb50baf 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -1104,13 +1104,17 @@ def on_daemon_event_observer(self, daemon, c, what, data) -> None: if not widget.is_visible(): widget.show() # Grab values - ax, ay, aw, trash = self.background.get_area_position(area) + ax, ay, aw, ah = self.background.get_area_position(area) cw = widget.get_allocation().width - # Compute center - x, y = ax + aw * 0.5 - cw * 0.5, ay + 1.0 - cw * 0.5 - # Add pad position + ch = widget.get_allocation().height + # Rest position = centre of the area on BOTH axes (the old code + # used 'ay + 1.0' for Y, pinning the cursor to the top of the area + # so it sat half a control too high until the stick/pad was pushed). + x = ax + aw * 0.5 - cw * 0.5 + y = ay + ah * 0.5 - ch * 0.5 + # Add pad/stick position x += data[0] * aw / STICK_PAD_MAX * 0.5 - y -= data[1] * aw / STICK_PAD_MAX * 0.5 + y -= data[1] * ah / STICK_PAD_MAX * 0.5 # Move circle self.main_area.move(widget, x, y) elif what in ("LT", "RT", "STICKPRESS"): From 1d2016e9b75632eb180352338338e59e1b938f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 19 Jun 2026 22:02:45 +0200 Subject: [PATCH 16/74] gui: show the right stick and d-pad in Input Test Mode Input Test Mode could not display the v2 right stick or d-pad: the daemon's observe model only recognised STICK/LEFT/RIGHT/CPAD as positional axis sources (plus SCButtons), so RSTICK and DPAD could not even be observed. - daemon: source_to_constant now also accepts "RSTICK" and "DPAD". The _apply machinery already routes them to profile.rstick / profile.pads[DPAD], and the mapper already evaluates both for controllers flagged HAS_RSTICK/HAS_DPAD, so observing them now reports position events like the other sticks/pads. - gui: observe RSTICK and DPAD in Input Test Mode, add right-stick and d-pad test cursors, and position them from the RSTICKTEST / DPADTEST areas. - image: add the AREA_DPADTEST region to controller-images/sc2.svg (RSTICKTEST already existed) and to tools/gen_sc2_image.py so a regen reproduces it. Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scc/gui/app.py b/scc/gui/app.py index a4bb50baf..f5c9d31dd 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -159,6 +159,8 @@ def setup_widgets(self) -> None: self.main_area.put(self.lpad_test, 40, 40) self.main_area.put(self.rpad_test, 290, 90) self.main_area.put(self.stick_test, 150, 40) + self.main_area.put(self.rstick_test, 290, 40) + self.main_area.put(self.dpad_test, 40, 90) # Headerbar headerbar(self.builder.get_object("hbWindow")) From efd40e1c8ff6f4f2b7a7e92c9a5c3f8862f5a6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 19 Jun 2026 22:50:18 +0200 Subject: [PATCH 17/74] daemon: remember each controller's profile across (re)connects Until now every controller loaded the global default profile (recent_profiles[0]) on connect; the per-controller config stored name/icon/LED/etc. but no profile, so with several controllers there was no way to keep a different profile per device. - config: add a "profile" key to CONTROLLER_DEFAULTS (None = global default); get_controller_config backfills it for existing configs. - daemon: add_controller now loads the controller's remembered profile if it has a valid one, else the global default - done explicitly after binding the mapper so a reused/pooled mapper never carries over another controller's profile. A deleted/missing remembered profile falls back to the default. - daemon: _remember_controller_profile persists the selection (by name) from the "Profile:" handler, but only for explicit user selections: the autoswitch daemon's contextual switches and transient .mod live-edits are skipped, and the config is written only when the value actually changes. Keyed by controller id, so the remembered profile follows the physical device with "Use Serial Numbers" enabled, or the connection slot otherwise. Single- controller behavior is unchanged (no remembered profile -> global default). Co-Authored-By: Claude Opus 4.8 --- scc/config.py | 4 ++++ scc/sccdaemon.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/scc/config.py b/scc/config.py index b651030ee..b8c12a928 100644 --- a/scc/config.py +++ b/scc/config.py @@ -126,6 +126,10 @@ class Config: "menu_control": "STICK", "menu_confirm": "A", "menu_cancel": "B", + # Remembered profile name, restored when this controller (re)connects. + # None means "use the global default". See SCCDaemon.add_controller and + # SCCDaemon._remember_controller_profile. + "profile": None, } def __init__(self) -> None: diff --git a/scc/sccdaemon.py b/scc/sccdaemon.py index 6c03ff4c4..ce9383393 100644 --- a/scc/sccdaemon.py +++ b/scc/sccdaemon.py @@ -33,7 +33,7 @@ from scc.poller import Poller from scc.profile import Profile from scc.scheduler import Scheduler -from scc.tools import clamp, find_binary, find_menu, find_profile, nameof, set_logging_level, shjoin, shsplit +from scc.tools import clamp, find_binary, find_menu, find_profile, get_profile_name, nameof, set_logging_level, shjoin, shsplit from scc.uinput import CannotCreateUInputException if TYPE_CHECKING: @@ -280,6 +280,31 @@ def _set_profile(self, mapper: Mapper, filename: str) -> None: else: self.send_profile_info(None, self._send_to_all, mapper=mapper) + def _remember_controller_profile(self, client, filename): + """Persists a controller's profile so it is restored on (re)connect. + + Only explicit, user-initiated selections are remembered: the autoswitch + daemon's contextual per-window switches and transient live-edit (.mod) + profiles are skipped. Stored by name under + config["controllers"][]["profile"]; with "Use Serial Numbers" on + that id is the physical device, otherwise it is the connection slot. + """ + if client is self.autoswitch_daemon: + # Autoswitcher changes are contextual, not the controller's choice + return + if filename.endswith(".mod"): + # Transient profile produced while live-editing in the GUI + return + c = client.mapper.get_controller() if client.mapper else None + if c is None: + return + name = get_profile_name(filename) + config = Config() + cc = config.get_controller_config(c.get_id()) + if cc.get("profile") != name: + cc["profile"] = name + config.save() + def _send_to_all(self, message_str: bytes) -> None: """Sends message to all connect clients. @@ -568,9 +593,27 @@ def add_controller(self, c: Controller) -> None: else: # New controller, but no mapper created mapper = self.init_mapper() - self.load_default_profile(mapper) mapper.set_controller(c) c.set_mapper(mapper) + + # Load this controller's remembered profile if it has a valid one, + # otherwise fall back to the global default. Done explicitly (rather + # than relying on the mapper's existing profile) so a reused/pooled + # mapper never carries over the profile of a previously-bound + # controller. With a single controller and no remembered profile this + # is exactly the old behavior (the global default is loaded). + remembered = Config().get_controller_config(c.get_id()).get("profile") + path = find_profile(remembered) if remembered else None + if path: + try: + mapper.profile.load(path).compress() + log.debug("Loaded remembered profile '%s' for %s", remembered, c.get_id()) + except Exception as e: + log.warning("Failed to load remembered profile '%s' for %s: %s", remembered, c.get_id(), e) + self.load_default_profile(mapper) + else: + self.load_default_profile(mapper) + if mapper == self.default_mapper: log.debug("Assigned default_mapper to %s", c) if mapper.profile.gyro: @@ -779,6 +822,7 @@ def _handle_message(self, client: Client, message: bytes) -> None: try: filename = message[8:].decode("utf-8").strip("\t ") self._set_profile(client.mapper, filename) + self._remember_controller_profile(client, filename) log.info("Loaded profile '%s'", filename) client.wfile.write(b"OK.\n") except Exception as e: From 64b8166b61c81584d4110f7dd4bbfcfa9eae3c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sat, 20 Jun 2026 19:57:45 +0200 Subject: [PATCH 18/74] gui: replace the per-controller profile bars with a controller selector With multiple controllers the window stacked one full profile bar per device (the same profile list repeated N times) plus a "switch-to" pen button. Replace that with a single controller selector above one profile picker: choose a controller to make it the active/edited one (with the same image transition the pen used) and its profile follows. This scales to any number of controllers as two dropdowns instead of N stacked bars. Also show friendly per-type names ("Steam Controller v2", "DualShock 4", ...) instead of the raw internal id ("sc1", "3:4"), numbering duplicates of the same type (#1/#2), with each controller's current profile as dim secondary text. Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 207 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 170 insertions(+), 37 deletions(-) diff --git a/scc/gui/app.py b/scc/gui/app.py index f5c9d31dd..b4eacde6b 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -12,7 +12,7 @@ import sys from urllib.parse import unquote -from gi.repository import Gdk, Gio, GLib, Gtk +from gi.repository import Gdk, GdkPixbuf, Gio, GLib, Gtk from scc.actions import NoAction from scc.config import Config @@ -34,6 +34,7 @@ from scc.tools import ( _, check_access, + find_controller_icon, find_gksudo, find_profile, get_profile_name, @@ -50,6 +51,25 @@ log = logging.getLogger("App") +# Human-friendly default names per controller type (controller.get_type()). +# Used when the user has not given the controller a custom name. Wrapped in +# _() at lookup time so they remain translatable. +CONTROLLER_TYPE_NAMES = { + "sc": "Steam Controller v1", + "scbt": "Steam Controller v1 (Bluetooth)", + "sc2": "Steam Controller v2", + "deck": "Steam Deck", + "ds4": "DualShock 4", + "ds4evdev": "DualShock 4", + "ds5": "DualSense", + "ds5evdev": "DualSense", + "ds5bt_hidraw": "DualSense", + "hid": "HID Controller", + "evdev": "Controller", + "rpad": "Remote Pad", + "fake": "Fake Controller", +} + class App(Gtk.Application, UserDataManager, BindingEditor): """Main application / window.""" @@ -125,6 +145,15 @@ def setup_widgets(self) -> None: ps.connect("new-clicked", self.on_new_clicked) ps.connect("save-clicked", self.on_save_clicked) + # Controller selector: shown above the profile switcher only when more + # than one controller is connected. Lets the user pick which controller + # the editor shows (replacing the old stack of one profile bar per + # controller + the per-bar "switch-to" pen button). Each row is the + # controller's icon + name, with its current profile as dim secondary + # text; selecting a row makes that controller the active/edited one. + self._selector_recursing = False + self.controller_selector = self._build_controller_selector() + # Drag&drop target self.builder.get_object("content").drag_dest_set( Gtk.DestDefaults.ALL, @@ -735,8 +764,9 @@ def on_profile_saved(self, giofile: Gio.File, send: bool = True) -> None: self.profile_switchers[0].set_profile_modified(False, self.current.is_template) if send and self.dm.is_alive() and not self.daemon_changed_profile: - for ps in self.profile_switchers: - controller = ps.get_controller() + # Re-send to every controller currently running this profile (not + # just the active one), so a saved profile reloads on all of them. + for controller in self.dm.get_controllers(): if controller: active = controller.get_profile() if active.endswith(".mod"): @@ -892,40 +922,29 @@ def on_daemon_alive(self, *a) -> None: self.enable_test_mode() def on_daemon_ccunt_changed(self, daemon, count: int) -> None: - if self.controller_count == 0: - # First controller connected - # - # 'event' signal should be connected only on first controller, - # so this block is executed only when number of connected - # controllers changes from 0 to 1 - if len(self.dm.get_controllers()) > 0: - c = self.dm.get_controllers()[0] - self.load_gui_config_for_controller(c, first=True) - if count > self.controller_count: - # Controller added - while len(self.profile_switchers) < count: - s = self.add_switcher() - elif count < self.controller_count: - # Controller removed - while len(self.profile_switchers) > max(1, count): - s = self.profile_switchers.pop() - s.set_controller(None) - self.remove_switcher(s) - - # Assign controllers to widgets - for i in range(count): - c = self.dm.get_controllers()[i] - self.profile_switchers[i].set_controller(c) - - if count == 0: - # Special case, no controllers are connected, but one widget has to stay on screen - self.profile_switchers[0].set_controller(None) - # First load, default controller decided by _ensure_config() in controller_image.py - if not self._controller_shown: - self.load_gui_config_for_controller(None, first=True) + # A single profile switcher always shows the *active* controller; any + # others are reachable through the controller selector above it (built + # in setup_widgets). So here we only keep the active controller in the + # switcher and rebuild the selector. + controllers = list(self.dm.get_controllers()) + ps0 = self.profile_switchers[0] + first_connect = self.controller_count == 0 and count >= 1 + + if count >= 1: + active = ps0.get_controller() + if active not in controllers: + # No active controller yet (first connect) or the active one was + # disconnected: fall back to the first connected controller and + # switch the editor image to it. + active = controllers[0] + ps0.set_controller(active) + self.load_gui_config_for_controller(active, first=first_connect) else: - self.enable_test_mode(self.profile_switchers[0].get_controller()) + # No controllers connected, but one switcher has to stay on screen + ps0.set_controller(None) + self.load_gui_config_for_controller(None, first=True) + self.rebuild_controller_selector() self.controller_count = count def new_profile(self, profile: Profile, name: str) -> None: @@ -981,6 +1000,113 @@ def remove_switcher(self, s): if len(vbSwitchers.get_children()) == 2: sepSwitchers.set_visible(False) + def _build_controller_selector(self): + """Creates the 'which controller' combo and packs it above the profile + switcher. Hidden until 2+ controllers are connected.""" + # model columns: controller object, icon pixbuf, name, current profile + model = Gtk.ListStore(object, GdkPixbuf.Pixbuf, str, str) + combo = Gtk.ComboBox.new_with_model(model) + rPix, rName, rProf = Gtk.CellRendererPixbuf(), Gtk.CellRendererText(), Gtk.CellRendererText() + rProf.set_property("foreground", "#888888") + combo.pack_start(rPix, False) + combo.pack_start(rName, True) + combo.pack_start(rProf, False) + combo.add_attribute(rPix, "pixbuf", 1) + combo.add_attribute(rName, "text", 2) + combo.add_attribute(rProf, "text", 3) + combo.set_margin_left(12) + combo.set_margin_right(12) + combo.set_margin_top(4) + combo.connect("changed", self.on_controller_selected) + combo.connect("notify::popup-shown", self._refresh_selector_profiles) + vbSwitchers = self.builder.get_object("vbSwitchers") + vbSwitchers.pack_start(combo, False, False, 0) + # Layout top-to-bottom: [ selector ][ separator ][ profile switcher ] + vbSwitchers.reorder_child(combo, 0) + vbSwitchers.reorder_child(self.builder.get_object("sepSwitchers"), 1) + combo.set_no_show_all(True) + combo.set_visible(False) + return combo + + def _load_controller_pixbuf(self, c): + """Loads the 24px icon for a controller, or None if unavailable.""" + try: + iconname = self.config.get_controller_config(c.get_id()).get("icon") + if iconname: + path = find_controller_icon(iconname) + if path and os.path.exists(path): + return GdkPixbuf.Pixbuf.new_from_file_at_size(path, 24, 24) + except Exception as e: + log.debug("No selector icon for %s: %s", c.get_id(), e) + return None + + def controller_display_name(self, c): + """Human-friendly controller name: the user's custom name if one was set + in controller settings, otherwise a per-type label (e.g. 'Steam + Controller v2') rather than the raw internal id (e.g. 'sc1' / '3:4').""" + name = self.config.get_controller_config(c.get_id())["name"] + if name and name != c.get_id(): + return name # user-customised + return _(CONTROLLER_TYPE_NAMES.get(c.get_type(), "Controller")) + + def rebuild_controller_selector(self): + """Refills the controller selector from the connected controllers and + shows it only when more than one is connected.""" + combo = self.controller_selector + controllers = list(self.dm.get_controllers()) + active = self.profile_switchers[0].get_controller() + # Friendly names, disambiguating duplicates of the same type with #N + # (e.g. two 'Steam Controller v1' become '... #1' and '... #2'). + names = [self.controller_display_name(c) for c in controllers] + dupes = {n for n in names if names.count(n) > 1} + seen = {} + labels = [] + for n in names: + if n in dupes: + seen[n] = seen.get(n, 0) + 1 + labels.append("%s #%d" % (n, seen[n])) + else: + labels.append(n) + self._selector_recursing = True + model = combo.get_model() + model.clear() + active_iter = None + for c, label in zip(controllers, labels): + prof = get_profile_name(c.get_profile() or "") or "" + it = model.append((c, self._load_controller_pixbuf(c), label, prof)) + if c is active: + active_iter = it + if active_iter is not None: + combo.set_active_iter(active_iter) + self._selector_recursing = False + multi = len(controllers) >= 2 + combo.set_visible(multi) + self.builder.get_object("sepSwitchers").set_visible(multi) + + def _refresh_selector_profiles(self, combo, *a): + """Refreshes each row's profile subtext when the dropdown is opened.""" + if not combo.get_property("popup-shown"): + return + for row in combo.get_model(): + row[3] = get_profile_name(row[0].get_profile() or "") or "" + + def on_controller_selected(self, combo): + """Makes the chosen controller the active (edited) one, with the same + image transition the old switch-to button used.""" + if self._selector_recursing: + return + it = combo.get_active_iter() + if it is None: + return + c = combo.get_model().get_value(it, 0) + ps0 = self.profile_switchers[0] + if c is None or c is ps0.get_controller(): + return + ps0.set_controller(c) + ps0.set_profile(c.get_profile()) + self.load_gui_config_for_controller(c, False) + self.enable_test_mode() + def enable_test_mode(self, controller: ControllerManager | None = None) -> None: """Disables and re-enables Input Test mode. @@ -1227,10 +1353,11 @@ def on_btRenameProfile_clicked(self, *a) -> None: controllers = list(self.dm.get_controllers()) for c in controllers: if get_profile_name(c.get_profile()) == old_name: - ps = self.profile_switchers[controllers.index(c)] - ps.set_profile(new_name, True) c.set_profile(new_name) + if c is self.profile_switchers[0].get_controller(): + self.profile_switchers[0].set_profile(new_name, True) self.load_profile_list() + self.rebuild_controller_selector() dlg.hide() def on_mnuProfileDelete_activate(self, *a) -> None: @@ -1302,6 +1429,7 @@ def on_daemon_reconfigured(self, *a) -> None: self.config.reload() for ps in self.profile_switchers: ps.set_controller(ps.get_controller()) + self.rebuild_controller_selector() def on_daemon_dead(self, *a): if self.just_started: @@ -1313,6 +1441,11 @@ def on_daemon_dead(self, *a): for ps in self.profile_switchers: ps.set_controller(None) ps.on_daemon_dead() + self._selector_recursing = True + self.controller_selector.get_model().clear() + self._selector_recursing = False + self.controller_selector.set_visible(False) + self.builder.get_object("sepSwitchers").set_visible(False) self.set_daemon_status("dead", False) def on_mnuEmulationEnabled_toggled(self, cb): From d65b236d102df03af82eb70fb2a6d8d32a910470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sat, 20 Jun 2026 19:57:45 +0200 Subject: [PATCH 19/74] fix(gui): make "Restart emulation" wait for the old daemon to exit The Settings restart button did dm.stop() then dm.start() on a fixed 1-second timer. stop() is asynchronous and the daemon's real shutdown -- releasing every claimed USB device -- can take longer than that, so the new daemon started against a still-dying one: a stale pidfile or still-claimed devices left controllers undetected (and a half-claimed device showing as off). Use the purpose-built dm.restart(), which runs the daemon's stop-and-wait-then-start handoff and so cannot race the shutdown. Co-Authored-By: Claude Opus 4.8 --- scc/gui/global_settings.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scc/gui/global_settings.py b/scc/gui/global_settings.py index 677da6f9d..f53876f3f 100644 --- a/scc/gui/global_settings.py +++ b/scc/gui/global_settings.py @@ -331,9 +331,13 @@ def on_cbShowOSD_toggled(self, cb): def on_btRestartEmulation_clicked(self, *a): rvRestartWarning = self.builder.get_object("rvRestartWarning") - self.app.dm.stop() rvRestartWarning.set_reveal_child(False) - GLib.timeout_add_seconds(1, self.app.dm.start) + # Use the daemon's built-in restart (stop-and-wait, *then* start) rather + # than a manual stop + fixed 1s delay + start. The old approach raced the + # daemon's own shutdown: with several USB devices the new daemon could + # start before the old one had died and released them, so it hit a stale + # pidfile / still-claimed devices and the controllers stayed undetected. + self.app.dm.restart() def on_restarting_checkbox_toggled(self, *a): if self._recursing: From b330a8197daad2eb29779c48b8003f4238616049 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Sun, 12 Jul 2026 17:43:28 +0200 Subject: [PATCH 20/74] fix(usb/sc_dongle): keep the v1 dongle alive when GET_SERIAL stalls With "Use Serial Numbers" on and two wireless v1 dongles connected, only one v1 appeared: the flaky v1 GET_SERIAL control request stalls (USBErrorPipe) during flush, and the generic USBDevice.flush() let that propagate to the mainloop, which closed the whole dongle and dropped its not-yet-added controller. Serials off was unaffected because controllers are added immediately, with no pending serial window to lose. - usb.py: flush() now recovers from a control-endpoint stall instead of propagating it. A stalled request is retried on later flushes (a control protocol stall clears on the next SETUP) up to REQUEST_MAX_ATTEMPTS, after which an optional on_giveup hook fires; a stalled config command is dropped. The device is no longer torn down by a transient control stall -- mirroring the resilience the sc2 puck driver already implements for itself. - sc_dongle.py: passes on_giveup so a v1 whose serial never reads is still added with a generated id, and guards on_serial_got so a blank/duplicate id cannot collapse two controllers into one (the GUI keys controllers by id). Verified on hardware: two Steam Controller v1s plus a v2 are now detected consistently with serials on, across daemon restarts (dialog and manual) and repeated on/off toggles of the setting. Co-Authored-By: Claude Opus 4.8 --- scc/drivers/sc_dongle.py | 17 +++++++++++- scc/drivers/usb.py | 58 +++++++++++++++++++++++++++++++--------- 2 files changed, 62 insertions(+), 13 deletions(-) diff --git a/scc/drivers/sc_dongle.py b/scc/drivers/sc_dongle.py index 7c4e0693e..5b6eb9e9e 100644 --- a/scc/drivers/sc_dongle.py +++ b/scc/drivers/sc_dongle.py @@ -300,8 +300,17 @@ def cb(rawserial) -> None: self._driver.make_request( self._ccidx, cb, struct.pack(">BBB61x", SCPacketType.GET_SERIAL, SCPacketLength.GET_SERIAL, 0x01), + on_giveup=self._on_serial_giveup, ) + def _on_serial_giveup(self): + """Called when the GET_SERIAL request kept stalling. Add the controller + with a generated id anyway, so it still appears (it just won't have a + stable serial-based identity).""" + log.warning("GET_SERIAL kept stalling for SC on endpoint %s; using a generated id", self._endpoint) + self.generate_serial() + self.on_serial_got() + def generate_serial(self) -> None: """Called only if ignore_serials is enabled""" if len(self._driver._available_serials) > 0: @@ -316,7 +325,13 @@ def on_serial_got(self) -> None: except UnicodeDecodeError: log.debug("Failed to decode wireless SC serial") self._serial = self._driver._available_serials.pop() - self._id = str(self._serial) + serial = str(self._serial).strip() + if not serial or serial in self._driver.daemon.get_active_ids(): + # A blank or already-used id would make two controllers collapse into + # one in the GUI (it keys controllers by id). Keep them distinct by + # falling back to a generated positional id. + serial = self._generate_id() + self._id = serial self._driver.daemon.add_controller(self) def apply_config(self, config: dict) -> None: diff --git a/scc/drivers/usb.py b/scc/drivers/usb.py index 12adfcfc6..ea0f72e65 100644 --- a/scc/drivers/usb.py +++ b/scc/drivers/usb.py @@ -27,6 +27,11 @@ log = logging.getLogger("USB") +# How many times to retry a stalling control request (notably the flaky Steam +# Controller v1 GET_SERIAL) on successive flushes before giving up, instead of +# letting the stall propagate and tear down the whole device. +REQUEST_MAX_ATTEMPTS = 20 + class SCUSBDevice: """Base class for all handled usb devices.""" @@ -97,10 +102,12 @@ def overwrite_control(self, index, data) -> None: break self.send_control(index, data) - def make_request(self, index, callback, data, size=64) -> None: + def make_request(self, index, callback, data, size=64, on_giveup=None) -> None: """Schedule a synchronous request that requires response. Request is done ASAP and provided callback is called with received data. + If the control transfer keeps stalling it is retried on later flushes, + and 'on_giveup' (if given) is called once the retries are exhausted. """ self._rmsg.append( ( @@ -114,26 +121,53 @@ def make_request(self, index, callback, data, size=64) -> None: index, size, callback, + on_giveup, + 0, # stall-retry attempts so far ), ) def flush(self) -> None: - """Flush all prepared control messages to the device.""" + """Flush all prepared control messages to the device. + + A control-endpoint stall (USBErrorPipe) is recovered from rather than + propagated: letting it reach the mainloop would tear down the whole + device and drop its controllers. Notably the Steam Controller v1 + GET_SERIAL request is flaky and can stall (more so with several dongles + connected at once); such a request is retried on a later flush. + """ while len(self._cmsg): msg = self._cmsg.pop() - self.handle.controlWrite(*msg) + try: + self.handle.controlWrite(*msg) + except usb1.USBErrorPipe: + # Config command stalled; drop it (it is re-sent on the next + # configure) instead of tearing the whole device down. + pass + requeue = [] while len(self._rmsg): - msg, index, size, callback = self._rmsg.pop() - self.handle.controlWrite(*msg) - data = self.handle.controlRead( - 0xA1, # request_type - 0x01, # request - 0x0300, # value - index, - size, - ) + msg, index, size, callback, on_giveup, attempts = self._rmsg.pop() + try: + self.handle.controlWrite(*msg) + data = self.handle.controlRead( + 0xA1, # request_type + 0x01, # request + 0x0300, # value + index, + size, + ) + except usb1.USBErrorPipe: + # Control protocol stall; it clears on the next SETUP, so retry on + # a later flush rather than letting it close the whole device. + if attempts + 1 < REQUEST_MAX_ATTEMPTS: + requeue.append((msg, index, size, callback, on_giveup, attempts + 1)) + else: + log.warning("Control request to %s kept stalling; giving up after %d tries", self, attempts + 1) + if on_giveup: + on_giveup() + continue callback(data) + self._rmsg.extend(requeue) def force_restart(self) -> None: """Restart device, close handle and try to re-grab it again. From a4ae647e388d1c0eac6858702a924da50803add0 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Wed, 15 Jul 2026 19:42:13 +0200 Subject: [PATCH 21/74] fix(osd): Add input locking to prevent stuck keys --- scc/osd/menu.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/scc/osd/menu.py b/scc/osd/menu.py index a551d57b2..35ed4d639 100644 --- a/scc/osd/menu.py +++ b/scc/osd/menu.py @@ -66,6 +66,14 @@ def __init__(self, cls="osd-menu", layer=None): self._menuid = None self._use_cursor = False self._eh_ids = [] + # Reveal-after-lock state: the menu is not made visible until inputs are + # locked, so a button press can't reach the normal mapping before the + # (asynchronous) lock lands. A fallback reveals anyway if the lock is + # slow, so the menu can never get stuck invisible. + self._inputs_locked = False + self._show_pending = False + self._reveal_timer = None + self._quit_done = False self._control_with = STICK self._control_with_dpad = False self._confirm_with = "A" @@ -401,9 +409,44 @@ def show(self, *a): if not self.select(0): self.next_item(1) self._fit_scroll() - OSDWindow.show(self, *a) + # Reveal only once inputs are locked, so a button press can never reach + # the normal mapping before the lock lands. That matters for more than a + # stray keystroke: if the press is handled by the old action (e.g. a key + # goes DOWN) and the release is then captured by the menu, the key never + # goes UP and gets stuck. So we must never show the menu while unlocked: + # if the lock does not land within the timeout, give up and CLOSE the + # menu rather than revealing it. + self._show_pending = True + if self._reveal_timer is None: + self._reveal_timer = GLib.timeout_add(2000, self._lock_timed_out) + self._reveal_if_locked() + + def _on_inputs_locked(self, *a): + """Called from the lock-success callback, once inputs are diverted to + this menu and it is safe to reveal it.""" + self._inputs_locked = True + self._reveal_if_locked() + + def _reveal_if_locked(self): + """Reveal the menu, but only once it is both requested and locked.""" + if not (self._show_pending and self._inputs_locked): + return + self._show_pending = False + if self._reveal_timer is not None: + GLib.source_remove(self._reveal_timer) + self._reveal_timer = None + OSDWindow.show(self) GLib.timeout_add(1, self._check_on_screen_position, True) + def _lock_timed_out(self, *a): + """The lock never landed; close the menu instead of revealing it while + unlocked (which could leak input or strand a key).""" + self._reveal_timer = None + if self._show_pending: + self._show_pending = False + self.quit(3) + return False + def on_daemon_connected(self, *a): if not self.config: self.config = Config() @@ -458,7 +501,7 @@ def use_controller(self, controller): def lock_inputs(self): def success(*a): - log.error("Sucessfully locked input") + self._on_inputs_locked() locks = [self._control_with, self._confirm_with, self._cancel_with] if self._control_with == "STICK": @@ -468,6 +511,19 @@ def success(*a): self.controller.lock(success, self.on_failed_to_lock, *locks) def quit(self, code=-2): + # A menu must unlock exactly once. quit() can be re-entered — most + # importantly by a *previous* menu's leftover timeout firing after this + # object should be gone — and unlock_all() is per-CLIENT: it clears every + # lock the OSD daemon holds, not just this menu's. Re-running it would + # strip the locks of whatever menu is open *now*, leaving it visible but + # dead (it stops responding and leaks input to the normal mapping). So + # make quit idempotent: a menu that already quit never unlocks again. + if self._quit_done: + return + self._quit_done = True + if self._reveal_timer is not None: + GLib.source_remove(self._reveal_timer) + self._reveal_timer = None if not self._is_submenu: if self.get_controller(): self.get_controller().unlock_all() From 0e70619d623ff245bd37db3bbf8633402f838ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 3 Jul 2026 15:34:08 +0200 Subject: [PATCH 22/74] fix(daemon): release a held action when locking so its key-up isn't lost --- scc/sccdaemon.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scc/sccdaemon.py b/scc/sccdaemon.py index ce9383393..c4f0daf80 100644 --- a/scc/sccdaemon.py +++ b/scc/sccdaemon.py @@ -1323,6 +1323,16 @@ class LockedAction(ReportingAction): def __init__(self, what, client: Client, original_action) -> None: ReportingAction.__init__(self, what, client) self.original_action = original_action + # If the button being locked is currently held, the original action's + # press already ran (a key it bound may be DOWN). Its release will now be + # captured by this lock instead of the original action, leaving the key + # stuck down (it has locked people's keyboards). Release the original + # action here so the matching key-UP is sent. + if what in SCButtons.__members__.values() and self.mapper and (self.mapper.buttons & what): + try: + original_action.button_release(self.mapper) + except Exception as e: + log.warning("Failed to release held action while locking %s: %s", what, e) original_action.cancel(self.mapper) self._store_lock() log.debug("%s locked by %s", nameof(self.what), self.client) From 966102bfcbdb54d4d43edb0fc3d61f7244dac6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 3 Jul 2026 15:36:37 +0200 Subject: [PATCH 23/74] fix(osd): keep generic face-button icons for the v2 quick menu --- scc/osd/quick_menu.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scc/osd/quick_menu.py b/scc/osd/quick_menu.py index 515aa79f5..87ba2a7c7 100644 --- a/scc/osd/quick_menu.py +++ b/scc/osd/quick_menu.py @@ -117,10 +117,16 @@ def success(*a): icon = self._icons[i] name = buttons[self.BUTTON_INDEXES[i]] filename, trash = find_icon("buttons/%s" % name) - icon.set_filename(filename) - icon.queue_draw() + # Some controllers (e.g. the v2) name their face buttons + # sc2_A/B/X/Y, which have no icon under buttons/. Only + # override when a real icon is found, otherwise keep the + # generic A/B/X/Y/LB/RB icon already set in generate_widget. + if filename: + icon.set_filename(filename) + icon.queue_draw() except IndexError: pass + self._on_inputs_locked() locks = [x for x in self.BUTTONS] + [self._cancel_with] self.controller.lock(success, self.on_failed_to_lock, *locks) From 297241dac0018cc65b628993d1223e51f27f4417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 3 Jul 2026 15:36:59 +0200 Subject: [PATCH 24/74] fix(osd): cancel the quick-menu auto-timeout on quit --- scc/osd/quick_menu.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scc/osd/quick_menu.py b/scc/osd/quick_menu.py index 87ba2a7c7..d5e4c6037 100644 --- a/scc/osd/quick_menu.py +++ b/scc/osd/quick_menu.py @@ -108,7 +108,6 @@ def _check_on_screen_position(self, quick=False): def lock_inputs(self): def success(*a): - log.error("Sucessfully locked input") config = self.controller.load_gui_config(os.path.join(get_share_path(), "images")) if config and config["gui"] and config["gui"]["buttons"]: buttons = config["gui"]["buttons"] @@ -247,6 +246,13 @@ def cancel_timer(self): GLib.source_remove(self._timer) self._timer = None + def quit(self, code=-2): + # Cancel the auto-timeout before quitting; otherwise it lingers and fires + # after this menu is gone, calling quit() again -> unlock_all(), which is + # per-client and would clear the *next* menu's locks. See Menu.quit. + self.cancel_timer() + Menu.quit(self, code) + def on_event(self, daemon, what, data): if self._submenu: return self._submenu.on_event(daemon, what, data) From 87fcb99bed3e17d33e50ad0154075d242db078d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 21 Jun 2026 14:03:43 +0200 Subject: [PATCH 25/74] fix(mapper): stop the v2 right stick crashing in set_button under a mode modifier A ModeModifier (mode/hold/doubleclick) on an analog stick or pad calls mapper.set_button(what, ...) where 'what' is a source string. set_button only translated LEFT/RIGHT to their touch bits, so RSTICK (and CPAD/DPAD) fell through to "self.buttons &= ~button" and raised "bad operand type for unary ~: 'str'". Because all of a frame's input handling shares one try/except, the crash aborted the rest of that frame -- so on the v2 (whose analog right stick the v1 lacked) it also blocked any menu controlled by a pad processed after the stick, making OSD menus appear to ignore input. set_button and set_was_pressed now translate RSTICK -> RSTICKTOUCH, STICK -> LSTICKTOUCH and CPAD -> CPADTOUCH (matching is_touched) and skip any other non-button source instead of crashing. Verified on hardware: Steam Controller v2 radial menu navigates and selects with no traceback. Co-Authored-By: Claude Opus 4.8 --- scc/mapper.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scc/mapper.py b/scc/mapper.py index c596b9e7d..7615342ec 100644 --- a/scc/mapper.py +++ b/scc/mapper.py @@ -340,6 +340,17 @@ def set_button(self, button, state): button = SCButtons.LPADTOUCH elif button == RIGHT: button = SCButtons.RPADTOUCH + elif button == RSTICK: + button = SCButtons.RSTICKTOUCH + elif button == STICK: + button = SCButtons.LSTICKTOUCH + elif button == CPAD: + button = SCButtons.CPADTOUCH + elif isinstance(button, str): + # Sources like DPAD/GYRO have no button bit to toggle; skip rather + # than crash on ~button. A ModeModifier on the (v2) right stick used + # to pass the RSTICK string here -> "bad operand type for unary ~". + return if state: self.buttons |= button @@ -356,6 +367,15 @@ def set_was_pressed(self, button, state): button = SCButtons.LPADTOUCH elif button == RIGHT: button = SCButtons.RPADTOUCH + elif button == RSTICK: + button = SCButtons.RSTICKTOUCH + elif button == STICK: + button = SCButtons.LSTICKTOUCH + elif button == CPAD: + button = SCButtons.CPADTOUCH + elif isinstance(button, str): + # See set_button: skip non-button sources instead of crashing. + return if state: self.old_buttons |= button From 6a6281b4e0b751592fb8e552edc342fad64b9168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 28 Jun 2026 02:18:22 +0200 Subject: [PATCH 26/74] =?UTF-8?q?fix(gui):=20Input=20Test=20mode=20?= =?UTF-8?q?=E2=80=94=20selected=20controller,=20viewBox=20cursor,=20re-arm?= =?UTF-8?q?=20on=20connect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - enable_test_mode observes the controller selected in the GUI (the one drawn on the big image) instead of always get_controllers()[0], so Input Test works with several controllers connected and on a non-first controller. Also observes the v2 lower paddles and right-stick click (LGRIP2, RGRIP2, RSTICKPRESS) plus RSTICK/DPAD positional sources. - on_daemon_event_observer ignores events from controllers other than the one being observed; skips a missing test area gracefully (e.g. an image without STICKTEST) instead of crashing with ValueError; and offsets the cursor by the SVG viewBox origin so a non-zero origin (sc2.svg's trigger headroom) no longer pushes every pad/stick cursor up and to the left. - Re-arm Input Test when a controller connects after the GUI has started. - svg_widget: add get_viewbox() to read the SVG viewBox. Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/scc/gui/app.py b/scc/gui/app.py index b4eacde6b..29cf47847 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -946,6 +946,12 @@ def on_daemon_ccunt_changed(self, daemon, count: int) -> None: self.rebuild_controller_selector() self.controller_count = count + if count >= 1: + # Re-arm Input Test on the (now) active controller. Without this, a + # controller connected *after* startup is never observed -- the + # enable at 'alive' ran while no controller was present -- so Input + # Test stays blank until the user toggles it off and on again. + self.enable_test_mode() def new_profile(self, profile: Profile, name: str) -> None: filename = os.path.join(get_profiles_path(), name + ".sccprofile") @@ -1216,6 +1222,11 @@ def on_daemon_error(self, daemon, error): self.set_daemon_status("error", True) def on_daemon_event_observer(self, daemon, c, what, data) -> None: + # Only react to the controller Input Test is observing. Other connected + # controllers also emit events; without this, their input would show on + # the selected controller's image. + if c is not self.test_mode_controller: + return if what in (LEFT, RIGHT, STICK, RSTICK, DPAD, CPAD): widget, area = { LEFT: (self.lpad_test, "LPADTEST"), @@ -1229,10 +1240,24 @@ def on_daemon_event_observer(self, daemon, c, what, data) -> None: if data[0] == data[1] == 0: widget.hide() return + # Grab values. The controller image may not define a test area for + # this input (e.g. deck.svg has no STICKTEST); skip silently rather + # than crashing the GUI and spamming the log with ValueError. + try: + ax, ay, aw, ah = self.background.get_area_position(area) + except ValueError: + widget.hide() + return + # Area coords are in SVG document space, but the cursor is a GTK + # overlay placed in image pixels. Shift by the viewBox origin so a + # non-zero origin (e.g. sc2.svg's "0 -45 ..." trigger headroom) + # doesn't push every cursor up/left. Origin is (0,0) for the other + # controllers, so they are unaffected. + vbx, vby, _vbw, _vbh = self.background.get_viewbox() + ax -= vbx + ay -= vby if not widget.is_visible(): widget.show() - # Grab values - ax, ay, aw, ah = self.background.get_area_position(area) cw = widget.get_allocation().width ch = widget.get_allocation().height # Rest position = centre of the area on BOTH axes (the old code From 41f3bdd944f62a487351590f1dd646f4890a9a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 28 Jun 2026 02:18:22 +0200 Subject: [PATCH 27/74] feat(controller-images): Input Test highlights and test-area fixes (SC v1/v2, Deck) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - sc.svg: give the pad/stick test areas real height (were h=1, so the cursor only moved horizontally). - sc2.svg: v2 Input Test layer — back-paddle highlights (LGRIP/LGRIP2/RGRIP/RGRIP2) with readable labels, stick-press highlights, trigger headroom. - deck.svg: back-button highlights L4/L5/R4/R5 -> LGRIP/LGRIP2/RGRIP/RGRIP2 (opacity:0 shapes revealed on press, with dark readable labels); fix the pad/stick cursor areas (LPADTEST/RPADTEST height, reposition RSTICKTEST onto the right stick, add the missing STICKTEST and DPADTEST); drop two dead opacity:0 ellipses left over on the sticks. Co-Authored-By: Claude Opus 4.8 --- images/controller-images/deck.svg | 743 +----------------------------- images/controller-images/sc.svg | 12 +- 2 files changed, 8 insertions(+), 747 deletions(-) diff --git a/images/controller-images/deck.svg b/images/controller-images/deck.svg index fdf7910e0..d357fe749 100644 --- a/images/controller-images/deck.svg +++ b/images/controller-images/deck.svg @@ -1,741 +1,2 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +image/svg+xmlL4L5R5R4 \ No newline at end of file diff --git a/images/controller-images/sc.svg b/images/controller-images/sc.svg index 94ee54345..df3c96002 100644 --- a/images/controller-images/sc.svg +++ b/images/controller-images/sc.svg @@ -432,9 +432,9 @@ style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#00b400;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" id="AREA_LPADTEST" width="115.90182" - height="1" + height="118" x="42" - y="105" + y="46.5" ry="0" /> From a1291ccd043e1c68eec808593b4f889a3265c3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 28 Jun 2026 03:36:58 +0200 Subject: [PATCH 28/74] fix(gui,images): correct Deck back-button mapping + stick-touch Input Test indicator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deck testing revealed two issues fixed here: - deck.svg: the L4/L5/R4/R5 highlights were flipped — pressing physical L4 lit the L5 shape. On the Deck the upper paddle reports *GRIP2 and the lower reports *GRIP (opposite of the assumed convention), so swap the shape ids upper<->lower. Visible labels and positions are unchanged. - sc2.svg, deck.svg: add a concentric LSTICKTOUCH/RSTICKTOUCH dot over each stick centre (opacity:0, revealed on touch) so Input Test shows capacitive stick-touch, matching the existing grip-touch highlights. - app.py: observe LSTICKTOUCH/RSTICKTOUCH so Input Test highlights them. Co-Authored-By: Claude Opus 4.8 --- images/controller-images/deck.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/controller-images/deck.svg b/images/controller-images/deck.svg index d357fe749..3228a00f9 100644 --- a/images/controller-images/deck.svg +++ b/images/controller-images/deck.svg @@ -1,2 +1,2 @@ -image/svg+xmlL4L5R5R4 \ No newline at end of file +image/svg+xmlL4L5R5R4 \ No newline at end of file From 51616b88b79c7c579e2dd2a7b48e523f8f85664d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 28 Jun 2026 03:44:15 +0200 Subject: [PATCH 29/74] fix(config): default "disable emulation on close" ON for Steam Deck MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gui.autokill_daemon defaulted to False, so closing the GUI left scc-daemon running and still emulating. On a Steam Deck — which has no built-in keyboard — that locks the user out of the device's own controls (only the touchscreen keeps working), even after the lingering daemon is killed. Detect Deck hardware via DMI product/board name (Jupiter = LCD, Galileo = OLED) and default autokill_daemon to True there. Desktop machines are unaffected, and an explicit user setting still wins. Co-Authored-By: Claude Opus 4.8 --- scc/config.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scc/config.py b/scc/config.py index b8c12a928..7b99ea6c0 100644 --- a/scc/config.py +++ b/scc/config.py @@ -14,6 +14,25 @@ log = logging.getLogger("Config") +def _is_steam_deck(): + """Return True when running on Steam Deck hardware (LCD reports DMI product + name 'Jupiter', OLED 'Galileo'). + + Used to flip the 'autokill_daemon' default on: the Deck has no built-in + keyboard, so a daemon left running after the GUI closes keeps emulating and + locks the user out of the device's own controls (only the touchscreen still + works). Desktop machines are unaffected. + """ + for path in ("/sys/class/dmi/id/product_name", "/sys/class/dmi/id/board_name"): + try: + with open(path) as f: + if f.read().strip() in ("Jupiter", "Galileo"): + return True + except OSError: + pass + return False + + class Config: DEFAULTS = { "autoswitch_osd": True, # True to show OSD message when profile is autoswitched @@ -47,7 +66,7 @@ class Config: "enable_status_icon": False, "minimize_to_status_icon": True, "minimize_on_start": False, - "autokill_daemon": False, + "autokill_daemon": _is_steam_deck(), # default ON on the Steam Deck (no built-in keyboard) "news": { # Controls "new in this version" message "enabled": True, # if disabled, no querying is done From e030eeac86845ae0afcc7f0c5bc50503e29e933c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 28 Jun 2026 15:30:43 +0200 Subject: [PATCH 30/74] feat(gui,images): per-controller button-image override + Deck back-button/pad icons The mapping-box icons resolve through find_button_image(), which was global, so the Deck reused the Steam Controller's long/short back-grip and round-pad art. - Add a per-controller override: find_button_image gains a controller_set arg and get_button_icon passes the controller's gui.background, so a controller can ship button-images//.svg that overrides the shared image, falling back to the shared set. SC v1/SC2 are unaffected (no override dirs). - images/button-images/deck/: Deck back-button (LGRIP/LGRIP2/RGRIP/RGRIP2) and trackpad (LPAD/RPAD) icons. Back-button shapes carry their physical L4/L5/ R4/R5 labels (note the swapped mapping: LGRIP = lower L5); pads are plain square trackpads. Co-Authored-By: Claude Opus 4.8 --- images/button-images/deck/LGRIP.svg | 53 ++++++++++++++++++++++++++++ images/button-images/deck/LGRIP2.svg | 53 ++++++++++++++++++++++++++++ images/button-images/deck/LPAD.svg | 48 +++++++++++++++++++++++++ images/button-images/deck/RGRIP.svg | 53 ++++++++++++++++++++++++++++ images/button-images/deck/RGRIP2.svg | 53 ++++++++++++++++++++++++++++ images/button-images/deck/RPAD.svg | 48 +++++++++++++++++++++++++ scc/gui/daemon_manager.py | 14 +++++++- scc/tools.py | 13 +++++-- 8 files changed, 331 insertions(+), 4 deletions(-) create mode 100644 images/button-images/deck/LGRIP.svg create mode 100644 images/button-images/deck/LGRIP2.svg create mode 100644 images/button-images/deck/LPAD.svg create mode 100644 images/button-images/deck/RGRIP.svg create mode 100644 images/button-images/deck/RGRIP2.svg create mode 100644 images/button-images/deck/RPAD.svg diff --git a/images/button-images/deck/LGRIP.svg b/images/button-images/deck/LGRIP.svg new file mode 100644 index 000000000..5c1a716d3 --- /dev/null +++ b/images/button-images/deck/LGRIP.svg @@ -0,0 +1,53 @@ + + + + + + + L5 + + diff --git a/images/button-images/deck/LGRIP2.svg b/images/button-images/deck/LGRIP2.svg new file mode 100644 index 000000000..fc8e7858b --- /dev/null +++ b/images/button-images/deck/LGRIP2.svg @@ -0,0 +1,53 @@ + + + + + + + L4 + + diff --git a/images/button-images/deck/LPAD.svg b/images/button-images/deck/LPAD.svg new file mode 100644 index 000000000..28df978f3 --- /dev/null +++ b/images/button-images/deck/LPAD.svg @@ -0,0 +1,48 @@ + + + + + + + + diff --git a/images/button-images/deck/RGRIP.svg b/images/button-images/deck/RGRIP.svg new file mode 100644 index 000000000..adcea6e9d --- /dev/null +++ b/images/button-images/deck/RGRIP.svg @@ -0,0 +1,53 @@ + + + + + + + R5 + + diff --git a/images/button-images/deck/RGRIP2.svg b/images/button-images/deck/RGRIP2.svg new file mode 100644 index 000000000..39a8fede2 --- /dev/null +++ b/images/button-images/deck/RGRIP2.svg @@ -0,0 +1,53 @@ + + + + + + + R4 + + diff --git a/images/button-images/deck/RPAD.svg b/images/button-images/deck/RPAD.svg new file mode 100644 index 000000000..3240c1649 --- /dev/null +++ b/images/button-images/deck/RPAD.svg @@ -0,0 +1,48 @@ + + + + + + + + diff --git a/scc/gui/daemon_manager.py b/scc/gui/daemon_manager.py index 039d47569..8549b02c4 100644 --- a/scc/gui/daemon_manager.py +++ b/scc/gui/daemon_manager.py @@ -416,8 +416,20 @@ def get_button_icon(config, button, prefer_bw=False): """For config returned by load_gui_config() and SCButton constant, returns icon filename assigned to that button in controller config or default if config is invalid or button unassigned. + + A controller whose gui.background names a button-images// subdir + (e.g. "deck") gets its own icons from there, falling back to the shared + set. This is how the Deck overrides the Steam Controller back-button and + trackpad art. """ - return find_button_image(ControllerManager.get_button_name(config, button), prefer_bw=prefer_bw) + controller_set = None + try: + controller_set = config["gui"]["background"] + except (KeyError, TypeError): + pass + return find_button_image( + ControllerManager.get_button_name(config, button), + prefer_bw=prefer_bw, controller_set=controller_set) @staticmethod def get_button_name(config, button): diff --git a/scc/tools.py b/scc/tools.py index 4bd4a100b..5f366d367 100644 --- a/scc/tools.py +++ b/scc/tools.py @@ -271,10 +271,17 @@ def find_icon( def find_button_image( - name: str | None, prefer_bw: bool = False, + name: str | None, prefer_bw: bool = False, controller_set: str | None = None, ) -> tuple[None, bool] | tuple[str, bool]: - """Similar to find_icon, but searches for button image""" - return find_icon(nameof(name), prefer_bw, paths=[get_button_images_path()], extensions=("svg",)) + """Similar to find_icon, but searches for a button image. + + controller_set (e.g. "deck") lets a controller override the shared images + with its own button-images//.svg, falling back to the + shared set when no override exists. + """ + base = get_button_images_path() + paths = (os.path.join(base, controller_set), base) if controller_set else (base,) + return find_icon(nameof(name), prefer_bw, paths=paths, extensions=("svg",)) def menu_is_default(name: str) -> bool: From 66b20d16972e5517dfdbc0726889465bca186560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 28 Jun 2026 16:14:39 +0200 Subject: [PATCH 31/74] fix(packaging,images): package per-controller icon dirs; Deck icons to images/deck/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The around-controller icons use a per-controller override, images// .svg (applied in app.py). It works in a source checkout, but setup.py never packaged the images// subdirs, so built AppImages dropped images/sc2/ — the new Steam Controller fell back to v1 back-button/pad/system icons — and would have dropped images/deck/ too. Hence "works via ./run.sh, broken in the AppImage". - setup.py: package every images//*.svg per-controller override dir (generic; currently sc2 + deck). This also restores the SC2's own icons in AppImages. - Move the Deck back-button/pad icons from button-images/deck/ to images/deck/, the directory the override actually reads. - Revert the find_button_image/get_button_icon controller_set override added in the previous commit — it targeted the wrong (button-images) mechanism; images// is the real one. Co-Authored-By: Claude Opus 4.8 --- images/{button-images => }/deck/LGRIP.svg | 0 images/{button-images => }/deck/LGRIP2.svg | 0 images/{button-images => }/deck/LPAD.svg | 0 images/{button-images => }/deck/RGRIP.svg | 0 images/{button-images => }/deck/RGRIP2.svg | 0 images/{button-images => }/deck/RPAD.svg | 0 scc/gui/daemon_manager.py | 14 +------------- scc/tools.py | 13 +++---------- setup.py | 7 +++++++ 9 files changed, 11 insertions(+), 23 deletions(-) rename images/{button-images => }/deck/LGRIP.svg (100%) rename images/{button-images => }/deck/LGRIP2.svg (100%) rename images/{button-images => }/deck/LPAD.svg (100%) rename images/{button-images => }/deck/RGRIP.svg (100%) rename images/{button-images => }/deck/RGRIP2.svg (100%) rename images/{button-images => }/deck/RPAD.svg (100%) diff --git a/images/button-images/deck/LGRIP.svg b/images/deck/LGRIP.svg similarity index 100% rename from images/button-images/deck/LGRIP.svg rename to images/deck/LGRIP.svg diff --git a/images/button-images/deck/LGRIP2.svg b/images/deck/LGRIP2.svg similarity index 100% rename from images/button-images/deck/LGRIP2.svg rename to images/deck/LGRIP2.svg diff --git a/images/button-images/deck/LPAD.svg b/images/deck/LPAD.svg similarity index 100% rename from images/button-images/deck/LPAD.svg rename to images/deck/LPAD.svg diff --git a/images/button-images/deck/RGRIP.svg b/images/deck/RGRIP.svg similarity index 100% rename from images/button-images/deck/RGRIP.svg rename to images/deck/RGRIP.svg diff --git a/images/button-images/deck/RGRIP2.svg b/images/deck/RGRIP2.svg similarity index 100% rename from images/button-images/deck/RGRIP2.svg rename to images/deck/RGRIP2.svg diff --git a/images/button-images/deck/RPAD.svg b/images/deck/RPAD.svg similarity index 100% rename from images/button-images/deck/RPAD.svg rename to images/deck/RPAD.svg diff --git a/scc/gui/daemon_manager.py b/scc/gui/daemon_manager.py index 8549b02c4..039d47569 100644 --- a/scc/gui/daemon_manager.py +++ b/scc/gui/daemon_manager.py @@ -416,20 +416,8 @@ def get_button_icon(config, button, prefer_bw=False): """For config returned by load_gui_config() and SCButton constant, returns icon filename assigned to that button in controller config or default if config is invalid or button unassigned. - - A controller whose gui.background names a button-images// subdir - (e.g. "deck") gets its own icons from there, falling back to the shared - set. This is how the Deck overrides the Steam Controller back-button and - trackpad art. """ - controller_set = None - try: - controller_set = config["gui"]["background"] - except (KeyError, TypeError): - pass - return find_button_image( - ControllerManager.get_button_name(config, button), - prefer_bw=prefer_bw, controller_set=controller_set) + return find_button_image(ControllerManager.get_button_name(config, button), prefer_bw=prefer_bw) @staticmethod def get_button_name(config, button): diff --git a/scc/tools.py b/scc/tools.py index 5f366d367..4bd4a100b 100644 --- a/scc/tools.py +++ b/scc/tools.py @@ -271,17 +271,10 @@ def find_icon( def find_button_image( - name: str | None, prefer_bw: bool = False, controller_set: str | None = None, + name: str | None, prefer_bw: bool = False, ) -> tuple[None, bool] | tuple[str, bool]: - """Similar to find_icon, but searches for a button image. - - controller_set (e.g. "deck") lets a controller override the shared images - with its own button-images//.svg, falling back to the - shared set when no override exists. - """ - base = get_button_images_path() - paths = (os.path.join(base, controller_set), base) if controller_set else (base,) - return find_icon(nameof(name), prefer_bw, paths=paths, extensions=("svg",)) + """Similar to find_icon, but searches for button image""" + return find_icon(nameof(name), prefer_bw, paths=[get_button_images_path()], extensions=("svg",)) def menu_is_default(name: str) -> bool: diff --git a/setup.py b/setup.py index 36c69a5f2..eb0e020d6 100755 --- a/setup.py +++ b/setup.py @@ -30,6 +30,13 @@ ] + [ # menu icons subfolders ("share/scc/images/menu-icons/" + x.split("/")[-1], [x + "/LICENSES"] + glob.glob(x + "/*.png")) for x in glob.glob("images/menu-icons/*") +] + [ # per-controller icon override dirs: images//*.svg (e.g. sc2, deck) + ("share/scc/images/" + d.split("/")[-1], glob.glob(d + "/*.svg")) + for d in (p.rstrip("/") for p in glob.glob("images/*/")) + if d.split("/")[-1] not in ( + "button-images", "controller-icons", "controller-images", + "24x24", "256x256", "menu-icons") + and glob.glob(d + "/*.svg") ] extensions = [ From 52da22864cc49acb0f1976fcb244d5537a7933a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 28 Jun 2026 17:38:09 +0200 Subject: [PATCH 32/74] feat(images): consistent around-controller icons for Deck & SC2 (from controller art) Make each button's mapping-box icon match how the button looks on the controller drawing, fit to the existing icon footprint so the layout is unchanged. - button-images/ELIPSE{,.bw}.svg: add a centred "STEAM" label (the Deck C-slot / Steam button image). - images/deck/{BACK,C,START,DOTS}.svg: Deck system-button icons (View/Steam/Menu/ QAM) from the stamped VIEW/ELIPSE/MENU/DOTS images, standardised to 49x32 (Steam was an odd 32x32 circle; QAM had no icon at all). - images/sc2/{LT,RT,LB,RB}.svg: new trigger/bumper icons lifted from sc2.svg. - images/sc2/{LGRIP,LGRIP2,RGRIP,RGRIP2}.svg: replace the early placeholder paddle art with the paddle shapes from sc2.svg. Co-Authored-By: Claude Opus 4.8 --- images/button-images/ELIPSE.bw.svg | 81 +++++------------------------ images/button-images/ELIPSE.svg | 82 +++++------------------------- images/deck/BACK.svg | 15 ++++++ images/deck/C.svg | 11 ++++ images/deck/DOTS.svg | 8 +++ images/deck/START.svg | 16 ++++++ images/sc2/LB.svg | 7 +++ images/sc2/LT.svg | 7 +++ images/sc2/RB.svg | 7 +++ images/sc2/RT.svg | 7 +++ 10 files changed, 102 insertions(+), 139 deletions(-) create mode 100644 images/deck/BACK.svg create mode 100644 images/deck/C.svg create mode 100644 images/deck/DOTS.svg create mode 100644 images/deck/START.svg create mode 100644 images/sc2/LB.svg create mode 100644 images/sc2/LT.svg create mode 100644 images/sc2/RB.svg create mode 100644 images/sc2/RT.svg diff --git a/images/button-images/ELIPSE.bw.svg b/images/button-images/ELIPSE.bw.svg index 7762731ab..8130cadb4 100644 --- a/images/button-images/ELIPSE.bw.svg +++ b/images/button-images/ELIPSE.bw.svg @@ -1,75 +1,18 @@ - - - - - - - + + + + + - + image/svg+xml - + - - - - + + + + STEAM - + \ No newline at end of file diff --git a/images/button-images/ELIPSE.svg b/images/button-images/ELIPSE.svg index b421c8dac..e29084217 100644 --- a/images/button-images/ELIPSE.svg +++ b/images/button-images/ELIPSE.svg @@ -1,76 +1,18 @@ - - - - - - - + + + + + - + image/svg+xml - + - - - - + + + + STEAM - + \ No newline at end of file diff --git a/images/deck/BACK.svg b/images/deck/BACK.svg new file mode 100644 index 000000000..3d3b206c4 --- /dev/null +++ b/images/deck/BACK.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/images/deck/C.svg b/images/deck/C.svg new file mode 100644 index 000000000..75c4a44dc --- /dev/null +++ b/images/deck/C.svg @@ -0,0 +1,11 @@ + + + + + + + STEAM + + + + diff --git a/images/deck/DOTS.svg b/images/deck/DOTS.svg new file mode 100644 index 000000000..45865c45b --- /dev/null +++ b/images/deck/DOTS.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/images/deck/START.svg b/images/deck/START.svg new file mode 100644 index 000000000..ac566553d --- /dev/null +++ b/images/deck/START.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/images/sc2/LB.svg b/images/sc2/LB.svg new file mode 100644 index 000000000..9a08c5c4a --- /dev/null +++ b/images/sc2/LB.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/images/sc2/LT.svg b/images/sc2/LT.svg new file mode 100644 index 000000000..1b7c95f87 --- /dev/null +++ b/images/sc2/LT.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/images/sc2/RB.svg b/images/sc2/RB.svg new file mode 100644 index 000000000..62e4ed1b6 --- /dev/null +++ b/images/sc2/RB.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/images/sc2/RT.svg b/images/sc2/RT.svg new file mode 100644 index 000000000..ba7f9eb54 --- /dev/null +++ b/images/sc2/RT.svg @@ -0,0 +1,7 @@ + + + + + + + From 2bdd84fa8bf8ee75ad6a6def209b64352e727a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 3 Jul 2026 15:39:06 +0200 Subject: [PATCH 33/74] fix(images): lighten the Deck Steam/QAM button infill --- images/button-images/DOTS.svg | 2 +- images/button-images/ELIPSE.svg | 4 ++-- images/deck/C.svg | 10 ++++------ images/deck/DOTS.svg | 8 +++----- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/images/button-images/DOTS.svg b/images/button-images/DOTS.svg index 1aa42bda3..e084c592e 100644 --- a/images/button-images/DOTS.svg +++ b/images/button-images/DOTS.svg @@ -51,7 +51,7 @@ inkscape:groupmode="layer" id="layer1"> - - + + STEAM \ No newline at end of file diff --git a/images/deck/C.svg b/images/deck/C.svg index 75c4a44dc..ff50726ff 100644 --- a/images/deck/C.svg +++ b/images/deck/C.svg @@ -1,11 +1,9 @@ - - - - + + + STEAM - - + diff --git a/images/deck/DOTS.svg b/images/deck/DOTS.svg index 45865c45b..da6038235 100644 --- a/images/deck/DOTS.svg +++ b/images/deck/DOTS.svg @@ -1,8 +1,6 @@ - - - - - + + + From a12f58aff0dc826329403fe6e135e131378b96f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 28 Jun 2026 21:22:54 +0200 Subject: [PATCH 34/74] fix(gui): SC v1 mislayout - gui: SC v1 (8 default axes + a C button) wrongly tripped the Deck UI layout, which moves the GYRO button over the Steam logo on sc.svg and shoves the Steam button to the right column. Gate the "deck" layout on "rstick_x" in axes (SC2/Deck have a right stick, SC v1 does not). - gui: add btRSTICK to the hide-when-unavailable set, so the right-stick mapping button no longer shows (greyed) on controllers without a right stick. Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scc/gui/app.py b/scc/gui/app.py index 29cf47847..75e6825fd 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -238,6 +238,7 @@ def apply_gui_config_buttons(self, config) -> None: btC = self.builder.get_object("btC") btLGRIPTOUCH = self.builder.get_object("btLGRIPTOUCH") btRGRIPTOUCH = self.builder.get_object("btRGRIPTOUCH") + btRSTICK = self.builder.get_object("btRSTICK") buttons = ControllerImage.get_names(config.get("buttons", {})) axes = ControllerImage.get_names(config.get("axes", {})) @@ -283,13 +284,13 @@ def apply_gui_config_buttons(self, config) -> None: # TODO: Maybe actual detection w.set_sensitive(gyros) - for w in (btC, btCPAD, btDPAD, btGYRO, btLGRIPTOUCH, btRGRIPTOUCH): + for w in (btC, btCPAD, btDPAD, btGYRO, btLGRIPTOUCH, btRGRIPTOUCH, btRSTICK): if w: w.set_visible(w.get_sensitive()) # Re-layout if needed expected_layout = "default" - if len(axes) >= 8 and btC.get_sensitive(): + if "rstick_x" in axes and btC.get_sensitive(): expected_layout = "deck" if expected_layout != self.current_ui_layout: From f4ae10d3680cc95a44e678d5ccb8fd21c6ea763a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 28 Jun 2026 21:26:53 +0200 Subject: [PATCH 35/74] =?UTF-8?q?fix(gui):=20Deck=20button=20layout=20?= =?UTF-8?q?=E2=80=94=20D-Pad=20to=20top,=20Steam=20to=20the=20left=20colum?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Deck layout put the Steam (C) button in the right column and the D-Pad at the bottom of the left column. Move the D-Pad to the top of the left column and Steam to its bottom, so the left column reads D-Pad, L4, L5, View, Steam — matching the Deck's physical arrangement. Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/scc/gui/app.py b/scc/gui/app.py index 75e6825fd..5782f6bc4 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -302,28 +302,24 @@ def apply_gui_config_buttons(self, config) -> None: def apply_ui_layout(self, layout) -> None: """Changes layout of ui elements to fit additional buttons needed for Deck""" if layout == "deck": - # Move 'C' button bellow LGRIP - btRGRIP = self.builder.get_object("btRGRIP") + btLGRIP = self.builder.get_object("btLGRIP") + # Put 'DPAD' at the top of the left column (above the back paddles), + # to mirror the Deck's physical layout: D-Pad, L4, L5, View, Steam. + btDPAD = self.builder.get_object("btDPAD") + btDPAD.get_parent().remove(btDPAD) + btLGRIP.get_parent().pack_start(btDPAD, False, True, 6) + btLGRIP.get_parent().reorder_child(btDPAD, 2) + # Move 'C' (Steam) to the bottom of the LEFT column (was the right) btC = self.builder.get_object("btC") btC.get_parent().remove(btC) btC.set_margin_right(0) - btRGRIP.get_parent().pack_start(btC, False, True, 0) - btRGRIP.get_parent().reorder_child(btC, 5) + btLGRIP.get_parent().pack_start(btC, False, True, 0) # Move 'GYRO' button to middle of image (where C was) btGYRO = self.builder.get_object("btGYRO") btGYRO.get_parent().remove(btGYRO) vbC = self.builder.get_object("vbC") vbC.pack_start(btGYRO, False, True, 0) btGYRO.set_margin_top(30) - # Resize buttons at bottom - # for w in ['btSTICK', 'btRSTICK', 'btLPAD', 'btRPAD']: - # w.set_size_request(150, -1) - # Move 'DPAD' bellow 'LGRIP' - btLGRIP = self.builder.get_object("btLGRIP") - btDPAD = self.builder.get_object("btDPAD") - btDPAD.get_parent().remove(btDPAD) - btLGRIP.get_parent().pack_start(btDPAD, False, True, 6) - btLGRIP.get_parent().reorder_child(btDPAD, 5) def setup_statusicon(self) -> None: if self.statusicon is None: From fa155995f84b4e29b166fcb28f48bbabd8fc0114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 28 Jun 2026 21:39:29 +0200 Subject: [PATCH 36/74] fix(gui,osd): SC2 hover offset + invisible OSD submenus - gui/svg_widget: apply the viewBox origin to the hover hit-test. On sc2.svg (viewBox "0 -45 ...") the mouse->area mapping ignored the -45 origin, so hovering a control highlighted an area shifted 45px up. (Same fix already applied to the Input Test cursor.) - osd/menu: a submenu reuses the parent menu's input lock (the parent forwards events), so it never requests its own lock and _on_inputs_locked() never fires. The reveal-when-locked gate added for the dead-menu fix therefore kept the submenu window permanently hidden, though it remained navigable via the forwarded input. Mark a submenu's inputs as already locked so it reveals. Fixes the invisible "All Profiles" and "Autoswitch Options" submenus. Co-Authored-By: Claude Opus 4.8 --- scc/gui/svg_widget.py | 4 ++-- scc/osd/menu.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scc/gui/svg_widget.py b/scc/gui/svg_widget.py index f85d4a0bc..fadd322c4 100644 --- a/scc/gui/svg_widget.py +++ b/scc/gui/svg_widget.py @@ -94,8 +94,8 @@ def on_mouse_click(self, trash, event): def on_mouse_moved(self, trash, event): """Not actual signal handler, just called from App.""" x_offset = (self.get_allocation().width - self.image_width) / 2 - x = event.x - x_offset - y = event.y + x = event.x - x_offset + vbx + y = event.y + vby for a in self.areas: # *TEST areas exist only to bound the Input Test cursor (looked up # by id via get_area_position), not as hover targets. Skip them so diff --git a/scc/osd/menu.py b/scc/osd/menu.py index 35ed4d639..f38f5958a 100644 --- a/scc/osd/menu.py +++ b/scc/osd/menu.py @@ -159,6 +159,14 @@ def use_daemon(self, d): if not self._is_submenu: self._connect_handlers() self.on_daemon_connected(self.daemon) + else: + # A submenu reuses the parent menu's input lock (the parent forwards + # events to it), so it never requests its own lock and + # _on_inputs_locked() is never called. Treat its inputs as already + # locked; otherwise the reveal-when-locked gate added for the + # dead-menu fix keeps the submenu window permanently hidden (it is + # navigable via forwarded input but never shown). + self._inputs_locked = True def use_config(self, c): """Allows reusing already existin Config instance in same process. From 6870ed0e9c55ccd1333a75149e88fddf87166959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 29 Jun 2026 05:54:20 +0200 Subject: [PATCH 37/74] fix(gui): Deck stick/dpad hover highlight deck.svg was missing the single AREA_STICK / AREA_RSTICK / AREA_DPAD hover areas that the editor looks up by control name (sc2.svg has them), and the AREA_RSTICK_1-6 it did have were misplaced over the LEFT stick. Add the three areas (copied from the matching *TEST rects so they sit exactly over each control) and drop the strays. Also skip *TEST areas in the hover hit-test (svg_widget.on_mouse_moved): they exist only to bound the Input Test cursor (resolved by id elsewhere) and were shadowing real control areas, so the stick/dpad never highlighted on the Deck. Co-Authored-By: Claude Opus 4.8 --- images/controller-images/deck.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/controller-images/deck.svg b/images/controller-images/deck.svg index 3228a00f9..9227f8eee 100644 --- a/images/controller-images/deck.svg +++ b/images/controller-images/deck.svg @@ -1,2 +1,2 @@ -image/svg+xmlL4L5R5R4 \ No newline at end of file +image/svg+xmlL4L5R5R4 \ No newline at end of file From f3b7224dd2c4908b2ddd19a9891841583f7b9692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 29 Jun 2026 06:35:13 +0200 Subject: [PATCH 38/74] feat(gui): show the Steam logo on the Steam Controller v1 C button The SC v1 fell back to GUI defaults (its drivers had no get_gui_config_file), so its Steam (C) button used the generic circle image while only the SC2 showed the logo. - SCController.get_gui_config_file() now returns sc-config.json (inherited by SCByCable / SCByBt), so the GUI loads it for the SC v1. - sc-config.json is now GUI-only (background + button slot images). Dropping its incomplete "buttons" dict keeps button sensitivity at the defaults (the default load goes through _ensure_config, which fills missing keys). The C slot now points at sc2_C, the Steam logo. - images/sc/C.svg added so the side mapping-box icon shows the logo too, via the per-controller images//.svg override. Co-Authored-By: Claude Opus 4.8 --- images/sc-config.json | 7 ++++--- images/sc/C.svg | 2 ++ scc/drivers/sc_dongle.py | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 images/sc/C.svg diff --git a/images/sc-config.json b/images/sc-config.json index ee0f62cd1..6368681cf 100644 --- a/images/sc-config.json +++ b/images/sc-config.json @@ -1,12 +1,13 @@ { - "_ " : "Currently, this file is used only when changing controller image", - "__" : "manually from context menu", + "_ ": "Loaded for the Steam Controller (v1) via SCController.get_gui_config_file", + "__": "and on manual image change. GUI section only: button/axis sets stay at", + "___": "their defaults; this just points the Steam (C) button at the logo image.", "gui": { "background": "sc", "buttons": [ "A", "B", "X", "Y", "BACK", - "C", "START", "LB", "RB", "LT", "RT", + "sc2_C", "START", "LB", "RB", "LT", "RT", "STICK", "LPAD", "RPAD", "LG", "RG" ] }, diff --git a/images/sc/C.svg b/images/sc/C.svg new file mode 100644 index 000000000..aff696047 --- /dev/null +++ b/images/sc/C.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/scc/drivers/sc_dongle.py b/scc/drivers/sc_dongle.py index 5b6eb9e9e..a02f2f797 100644 --- a/scc/drivers/sc_dongle.py +++ b/scc/drivers/sc_dongle.py @@ -204,6 +204,11 @@ def __init__(self, driver: Deck | Dongle | SCByBt | SCByCable | SC2Device, ccidx def get_type(self) -> str: return "sc" + def get_gui_config_file(self) -> str: + # Steam Controller (v1): GUI-only config that puts the Steam logo on the + # C button (image + side icon). Inherited by SCByCable / SCByBt. + return "sc-config.json" + def __repr__(self) -> str: return f"" From 3b3906ef1e6f0480f12b497beb0aeea874eebc52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 29 Jun 2026 06:57:01 +0200 Subject: [PATCH 39/74] fix(gui): size the SC v1 Steam logo to the generic C button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sc2_C.svg is sized for the SC2's larger AREA_C (~48.8 units); placed on the SC v1 at scale 1.0 it overflowed and overlapped the START button. Add button-images/sc_C.svg — the same Steam logo scaled to the generic C button's ~36.86 box (origin re-aligned to match) — and point sc-config.json at it. Co-Authored-By: Claude Opus 4.8 --- images/button-images/sc_C.svg | 2 ++ images/sc-config.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 images/button-images/sc_C.svg diff --git a/images/button-images/sc_C.svg b/images/button-images/sc_C.svg new file mode 100644 index 000000000..66a3b04ab --- /dev/null +++ b/images/button-images/sc_C.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/images/sc-config.json b/images/sc-config.json index 6368681cf..a6b060113 100644 --- a/images/sc-config.json +++ b/images/sc-config.json @@ -7,7 +7,7 @@ "background": "sc", "buttons": [ "A", "B", "X", "Y", "BACK", - "sc2_C", "START", "LB", "RB", "LT", "RT", + "sc_C", "START", "LB", "RB", "LT", "RT", "STICK", "LPAD", "RPAD", "LG", "RG" ] }, From ef294ef5858364e0691f33e6f516652223b28627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Thu, 2 Jul 2026 01:12:25 +0200 Subject: [PATCH 40/74] fix(gui): clear Input Test highlights when it is turned off Highlights are added/removed per observed press/release. Turning Input Test off (sniffing disabled) stops the events, so a control held at that moment (e.g. a grip sensor) never receives its release and stays highlighted. Clear the observe highlights in on_daemon_reconfigured when sniffing is off. Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scc/gui/app.py b/scc/gui/app.py index 5782f6bc4..c565b2dca 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -1449,6 +1449,12 @@ def hide_error(self, *a): def on_daemon_reconfigured(self, *a) -> None: log.debug("Reloading config...") self.config.reload() + # If Input Test was just turned off, drop any highlights left over from + # the last observed press (e.g. a held grip sensor): with sniffing off no + # release event arrives to clear them, so they'd stay stuck on the image. + if not self.config["enable_sniffing"] and self.hilights[App.OBSERVE_COLOR]: + self.hilights[App.OBSERVE_COLOR].clear() + self._update_background() for ps in self.profile_switchers: ps.set_controller(ps.get_controller()) self.rebuild_controller_selector() From 3bb4cd26f2896982e43d1c5ebfceb76f6f7e5fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Thu, 2 Jul 2026 10:12:52 +0200 Subject: [PATCH 41/74] fix(gui): Deck back-paddle order in side panel (L4/R4 above L5/R5) The Deck maps its lower paddles to LGRIP/RGRIP (labelled L5/R5) and the upper ones to LGRIP2/RGRIP2 (L4/R4) - the reverse of the SC2 (LGRIP=L4). Both share the "deck" UI layout and the .glade grip order (LGRIP above LGRIP2), so the Deck's side panel showed L5/R5 above L4/R4, upside-down vs the device. Reorder the paddle buttons per-controller (keyed on gui.background): on the Deck put L4/R4 above L5/R5; the SC2 and everything else keep the .glade order. Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scc/gui/app.py b/scc/gui/app.py index c565b2dca..951e4d99e 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -296,6 +296,23 @@ def apply_gui_config_buttons(self, config) -> None: if expected_layout != self.current_ui_layout: self.apply_ui_layout(expected_layout) + # The Steam Deck maps its lower back paddles to LGRIP/RGRIP (labelled + # L5/R5) and the upper ones to LGRIP2/RGRIP2 (L4/R4) - the reverse of the + # SC2. Left alone the side panel reads L5/R5 above L4/R4; reorder the + # paddle buttons so they match the device (L4/R4 above L5/R5). Every other + # controller (incl. the SC2, whose LGRIP=L4) keeps the .glade order. + if bg == "deck": + grip_pairs = (("btLGRIP2", "btLGRIP"), ("btRGRIP2", "btRGRIP")) + else: + grip_pairs = (("btLGRIP", "btLGRIP2"), ("btRGRIP", "btRGRIP2")) + for above, below in grip_pairs: + wa = self.builder.get_object(above) + wb = self.builder.get_object(below) + if wa and wb and wa.get_parent() is wb.get_parent(): + kids = wa.get_parent().get_children() + if kids.index(wa) > kids.index(wb): + wa.get_parent().reorder_child(wa, kids.index(wb)) + stckEditor.set_visible_child(grEditor) GLib.idle_add(self.on_c_size_allocate) From ceef075a675cd4f1001edeb7e47ebdb7c2af2fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 3 Jul 2026 15:14:24 +0200 Subject: [PATCH 42/74] build(images): add an svgo config and wire the asset generators to minify A GUI-safe svgo config (tools/svgo.config.js), a source-preserving variant for the generator-parsed art (tools/svgo.config.source.js) and a helper (tools/_svgo.py) that gen_sc2_image.py and gen_binding_display.py now call so regenerated SVGs stay optimized. The config disables the svgo passes that break the GUI's naive SVG parsing: it keeps element ids, the viewBox, hover areas, display:none layers, custom attributes, comma-separated transforms (SVGEditor.parse_transform is comma-only) and the glyph structure (_fill_button_images overwrites that group's transform). Co-Authored-By: Claude Opus 4.8 --- tools/gen_binding_display.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/gen_binding_display.py b/tools/gen_binding_display.py index b3c33ae76..b22ddabbf 100644 --- a/tools/gen_binding_display.py +++ b/tools/gen_binding_display.py @@ -25,8 +25,12 @@ Run from repo root: python3 tools/gen_binding_display.py """ import os +import sys import xml.etree.ElementTree as ET +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import _svgo # noqa: E402 + SVG = "http://www.w3.org/2000/svg" SRC = "images/controller-images/sc2.svg" # AREA anchors for markers ART = "tools/binding-display-sc2-art.svg" # restyled controller drawing @@ -55,11 +59,11 @@ ET.register_namespace("", SVG) -def q(tag): +def q(tag: str) -> str: return "{%s}%s" % (SVG, tag) -def parse_viewbox(svg): +def parse_viewbox(svg: ET.Element) -> tuple[float, float]: vb = svg.get("viewBox") if vb: p = [float(x) for x in vb.replace(",", " ").split()] @@ -67,7 +71,7 @@ def parse_viewbox(svg): return float(svg.get("width")), float(svg.get("height")) -def read_area_centers(root): +def read_area_centers(root: ET.Element) -> dict[str, tuple[float, float]]: """AREA_ rects sit in an untransformed layer in display coords, so their centres are read directly.""" centers = {} @@ -80,7 +84,7 @@ def read_area_centers(root): return centers -def main(): +def main() -> None: if not os.path.exists(SRC): raise SystemExit("run from repo root: %s not found" % SRC) src = ET.parse(SRC).getroot() @@ -92,7 +96,7 @@ def main(): ox = (CANVAS_W - cw * s) / 2.0 oy = (CANVAS_H - ch * s) / 2.0 - def to_canvas(pt): + def to_canvas(pt: tuple[float, float]) -> tuple[float, float]: return ox + s * pt[0], oy + s * pt[1] out = ET.Element(q("svg"), { @@ -139,6 +143,7 @@ def to_canvas(pt): "style": "fill:#000000;fill-opacity:0;stroke:#06a400;stroke-width:1"}) ET.ElementTree(out).write(OUT, encoding="unicode", xml_declaration=True) + _svgo.optimize(OUT) print("wrote", OUT) print(" art inlined from %s; marker mapping scale %.3f at (%.1f, %.1f)" % (ART, s, ox, oy)) From cccc3f912a4f314a79a2c2fd12f13072c99bb4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 3 Jul 2026 15:14:24 +0200 Subject: [PATCH 43/74] perf(images): svgo-optimize the SC1/SC2/Deck SVGs Runs the 50 shipped controller/button/icon SVGs and 7 source assets through svgo (tools/svgo.config.js): ~30% smaller with byte-identical AREA geometry and rendering. Every element id, the glyph group and every comma-separated transform is preserved. Co-Authored-By: Claude Opus 4.8 --- images/binding-display-sc2.svg | 39 +-- images/button-images/sc_C.svg | 3 +- images/controller-images/deck.svg | 3 +- images/controller-images/sc.svg | 554 +----------------------------- images/deck/BACK.svg | 16 +- images/deck/C.svg | 10 +- images/deck/DOTS.svg | 7 +- images/deck/LGRIP.svg | 54 +-- images/deck/LGRIP2.svg | 54 +-- images/deck/LPAD.svg | 49 +-- images/deck/RGRIP.svg | 54 +-- images/deck/RGRIP2.svg | 54 +-- images/deck/RPAD.svg | 49 +-- images/deck/START.svg | 17 +- images/sc/C.svg | 3 +- images/sc2/LB.svg | 8 +- images/sc2/LT.svg | 8 +- images/sc2/RB.svg | 8 +- images/sc2/RT.svg | 8 +- tools/binding-display-sc2-art.svg | 39 +-- 20 files changed, 20 insertions(+), 1017 deletions(-) diff --git a/images/binding-display-sc2.svg b/images/binding-display-sc2.svg index 2baf69256..63cbf55ce 100644 --- a/images/binding-display-sc2.svg +++ b/images/binding-display-sc2.svg @@ -1,38 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - X \ No newline at end of file +X \ No newline at end of file diff --git a/images/button-images/sc_C.svg b/images/button-images/sc_C.svg index 66a3b04ab..2253a099e 100644 --- a/images/button-images/sc_C.svg +++ b/images/button-images/sc_C.svg @@ -1,2 +1 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/images/controller-images/deck.svg b/images/controller-images/deck.svg index 9227f8eee..84fbe78be 100644 --- a/images/controller-images/deck.svg +++ b/images/controller-images/deck.svg @@ -1,2 +1 @@ - -image/svg+xmlL4L5R5R4 \ No newline at end of file +L4L5R5R4 \ No newline at end of file diff --git a/images/controller-images/sc.svg b/images/controller-images/sc.svg index df3c96002..0ed37dd55 100644 --- a/images/controller-images/sc.svg +++ b/images/controller-images/sc.svg @@ -1,553 +1 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/images/deck/BACK.svg b/images/deck/BACK.svg index 3d3b206c4..d818d4ce4 100644 --- a/images/deck/BACK.svg +++ b/images/deck/BACK.svg @@ -1,15 +1 @@ - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/images/deck/C.svg b/images/deck/C.svg index ff50726ff..0e06f2248 100644 --- a/images/deck/C.svg +++ b/images/deck/C.svg @@ -1,9 +1 @@ - - - - - - STEAM - - - +STEAM \ No newline at end of file diff --git a/images/deck/DOTS.svg b/images/deck/DOTS.svg index da6038235..fc0f4b4cb 100644 --- a/images/deck/DOTS.svg +++ b/images/deck/DOTS.svg @@ -1,6 +1 @@ - - - - - - + \ No newline at end of file diff --git a/images/deck/LGRIP.svg b/images/deck/LGRIP.svg index 5c1a716d3..cff736a50 100644 --- a/images/deck/LGRIP.svg +++ b/images/deck/LGRIP.svg @@ -1,53 +1 @@ - - - - - - - L5 - - +L5 \ No newline at end of file diff --git a/images/deck/LGRIP2.svg b/images/deck/LGRIP2.svg index fc8e7858b..119da8e4c 100644 --- a/images/deck/LGRIP2.svg +++ b/images/deck/LGRIP2.svg @@ -1,53 +1 @@ - - - - - - - L4 - - +L4 \ No newline at end of file diff --git a/images/deck/LPAD.svg b/images/deck/LPAD.svg index 28df978f3..5cc901816 100644 --- a/images/deck/LPAD.svg +++ b/images/deck/LPAD.svg @@ -1,48 +1 @@ - - - - - - - - + \ No newline at end of file diff --git a/images/deck/RGRIP.svg b/images/deck/RGRIP.svg index adcea6e9d..0849c27e8 100644 --- a/images/deck/RGRIP.svg +++ b/images/deck/RGRIP.svg @@ -1,53 +1 @@ - - - - - - - R5 - - +R5 \ No newline at end of file diff --git a/images/deck/RGRIP2.svg b/images/deck/RGRIP2.svg index 39a8fede2..8c93744eb 100644 --- a/images/deck/RGRIP2.svg +++ b/images/deck/RGRIP2.svg @@ -1,53 +1 @@ - - - - - - - R4 - - +R4 \ No newline at end of file diff --git a/images/deck/RPAD.svg b/images/deck/RPAD.svg index 3240c1649..5cc901816 100644 --- a/images/deck/RPAD.svg +++ b/images/deck/RPAD.svg @@ -1,48 +1 @@ - - - - - - - - + \ No newline at end of file diff --git a/images/deck/START.svg b/images/deck/START.svg index ac566553d..252773da4 100644 --- a/images/deck/START.svg +++ b/images/deck/START.svg @@ -1,16 +1 @@ - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/images/sc/C.svg b/images/sc/C.svg index aff696047..5bb1a60a9 100644 --- a/images/sc/C.svg +++ b/images/sc/C.svg @@ -1,2 +1 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/images/sc2/LB.svg b/images/sc2/LB.svg index 9a08c5c4a..db34ce7ee 100644 --- a/images/sc2/LB.svg +++ b/images/sc2/LB.svg @@ -1,7 +1 @@ - - - - - - - + \ No newline at end of file diff --git a/images/sc2/LT.svg b/images/sc2/LT.svg index 1b7c95f87..0c9322547 100644 --- a/images/sc2/LT.svg +++ b/images/sc2/LT.svg @@ -1,7 +1 @@ - - - - - - - + \ No newline at end of file diff --git a/images/sc2/RB.svg b/images/sc2/RB.svg index 62e4ed1b6..d9a7fa85d 100644 --- a/images/sc2/RB.svg +++ b/images/sc2/RB.svg @@ -1,7 +1 @@ - - - - - - - + \ No newline at end of file diff --git a/images/sc2/RT.svg b/images/sc2/RT.svg index ba7f9eb54..c18d7c04d 100644 --- a/images/sc2/RT.svg +++ b/images/sc2/RT.svg @@ -1,7 +1 @@ - - - - - - - + \ No newline at end of file diff --git a/tools/binding-display-sc2-art.svg b/tools/binding-display-sc2-art.svg index cf4caccbe..7d86bfcc3 100644 --- a/tools/binding-display-sc2-art.svg +++ b/tools/binding-display-sc2-art.svg @@ -1,38 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file From 5052c0746c7ebcd2c55c8ea636d3a2471716da25 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Sun, 2 Aug 2026 15:01:27 +0200 Subject: [PATCH 44/74] style(types): annotate the Steam Controller v2 / Deck changeset Type annotations for every function, class and parameter this branch introduced (driver, GUI, OSD, mapper, tools and tests), so ruff's flake8-annotations (ANN) rules pass on the added lines. No behaviour change. Co-Authored-By: Claude Opus 4.8 --- scc/config.py | 2 +- scc/drivers/sc_dongle.py | 2 +- scc/drivers/usb.py | 5 ++++- scc/gui/ae/buttons.py | 2 +- scc/gui/app.py | 14 +++++++------- scc/gui/modeshift_editor.py | 6 +++--- scc/lib/xwrappers.py | 2 +- scc/modifiers.py | 17 +++++++++++------ scc/osd/binding_display.py | 37 +++++++++++++++++++++---------------- scc/osd/grid_menu.py | 2 +- scc/osd/keyboard.py | 2 +- scc/osd/menu.py | 14 +++++++------- scc/osd/quick_menu.py | 2 +- scc/osd/radial_menu.py | 2 +- scc/sccdaemon.py | 2 +- 15 files changed, 62 insertions(+), 49 deletions(-) diff --git a/scc/config.py b/scc/config.py index 7b99ea6c0..38a1df86a 100644 --- a/scc/config.py +++ b/scc/config.py @@ -14,7 +14,7 @@ log = logging.getLogger("Config") -def _is_steam_deck(): +def _is_steam_deck() -> bool: """Return True when running on Steam Deck hardware (LCD reports DMI product name 'Jupiter', OLED 'Galileo'). diff --git a/scc/drivers/sc_dongle.py b/scc/drivers/sc_dongle.py index a02f2f797..4f9cd508f 100644 --- a/scc/drivers/sc_dongle.py +++ b/scc/drivers/sc_dongle.py @@ -308,7 +308,7 @@ def cb(rawserial) -> None: on_giveup=self._on_serial_giveup, ) - def _on_serial_giveup(self): + def _on_serial_giveup(self) -> None: """Called when the GET_SERIAL request kept stalling. Add the controller with a generated id anyway, so it still appears (it just won't have a stable serial-based identity).""" diff --git a/scc/drivers/usb.py b/scc/drivers/usb.py index ea0f72e65..a77000b6d 100644 --- a/scc/drivers/usb.py +++ b/scc/drivers/usb.py @@ -20,6 +20,8 @@ import usb1 if TYPE_CHECKING: + from collections.abc import Callable + from usb1 import USBContext, USBDevice, USBDeviceHandle, USBTransfer from scc.drivers.hiddrv import HIDDrvFakeDaemon @@ -102,7 +104,8 @@ def overwrite_control(self, index, data) -> None: break self.send_control(index, data) - def make_request(self, index, callback, data, size=64, on_giveup=None) -> None: + def make_request(self, index: int, callback: Callable[[bytes], None], data: bytes, + size: int = 64, on_giveup: Callable[[], None] | None = None) -> None: """Schedule a synchronous request that requires response. Request is done ASAP and provided callback is called with received data. diff --git a/scc/gui/ae/buttons.py b/scc/gui/ae/buttons.py index 14f333ea2..1e1b499c0 100644 --- a/scc/gui/ae/buttons.py +++ b/scc/gui/ae/buttons.py @@ -181,7 +181,7 @@ def on_cbRepeat_toggled(self, cbRepeat): cbToggle.set_active(False) self.apply_keys() - def on_cbActOnRelease_toggled(self, cb): + def on_cbActOnRelease_toggled(self, cb: Gtk.CheckButton) -> None: self.apply_keys() def hide_toggle(self): diff --git a/scc/gui/app.py b/scc/gui/app.py index 951e4d99e..81a15b3ea 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -1020,7 +1020,7 @@ def remove_switcher(self, s): if len(vbSwitchers.get_children()) == 2: sepSwitchers.set_visible(False) - def _build_controller_selector(self): + def _build_controller_selector(self) -> Gtk.ComboBox: """Creates the 'which controller' combo and packs it above the profile switcher. Hidden until 2+ controllers are connected.""" # model columns: controller object, icon pixbuf, name, current profile @@ -1048,7 +1048,7 @@ def _build_controller_selector(self): combo.set_visible(False) return combo - def _load_controller_pixbuf(self, c): + def _load_controller_pixbuf(self, c: ControllerManager) -> GdkPixbuf.Pixbuf | None: """Loads the 24px icon for a controller, or None if unavailable.""" try: iconname = self.config.get_controller_config(c.get_id()).get("icon") @@ -1060,7 +1060,7 @@ def _load_controller_pixbuf(self, c): log.debug("No selector icon for %s: %s", c.get_id(), e) return None - def controller_display_name(self, c): + def controller_display_name(self, c: ControllerManager) -> str: """Human-friendly controller name: the user's custom name if one was set in controller settings, otherwise a per-type label (e.g. 'Steam Controller v2') rather than the raw internal id (e.g. 'sc1' / '3:4').""" @@ -1069,7 +1069,7 @@ def controller_display_name(self, c): return name # user-customised return _(CONTROLLER_TYPE_NAMES.get(c.get_type(), "Controller")) - def rebuild_controller_selector(self): + def rebuild_controller_selector(self) -> None: """Refills the controller selector from the connected controllers and shows it only when more than one is connected.""" combo = self.controller_selector @@ -1103,14 +1103,14 @@ def rebuild_controller_selector(self): combo.set_visible(multi) self.builder.get_object("sepSwitchers").set_visible(multi) - def _refresh_selector_profiles(self, combo, *a): + def _refresh_selector_profiles(self, combo: Gtk.ComboBox, *a: object) -> None: """Refreshes each row's profile subtext when the dropdown is opened.""" if not combo.get_property("popup-shown"): return for row in combo.get_model(): row[3] = get_profile_name(row[0].get_profile() or "") or "" - def on_controller_selected(self, combo): + def on_controller_selected(self, combo: Gtk.ComboBox) -> None: """Makes the chosen controller the active (edited) one, with the same image transition the old switch-to button used.""" if self._selector_recursing: @@ -1562,7 +1562,7 @@ def do_activate(self, *a) -> None: else: self.builder.get_object("window").show() - def open_osk_editor(self): + def open_osk_editor(self) -> None: """Opens the standalone OSD-keyboard bindings editor (the same window reachable from Settings > Menus & Keyboard > Advanced) as the only window, quitting the app when it closes. Backs the OSD menu's diff --git a/scc/gui/modeshift_editor.py b/scc/gui/modeshift_editor.py index 1ba6bf205..69a175f48 100644 --- a/scc/gui/modeshift_editor.py +++ b/scc/gui/modeshift_editor.py @@ -277,9 +277,9 @@ def on_nomodclear_clicked(self, button, *a): actionButton = self.action_widgets[self.current_page][1] actionButton.set_label(self.nomods[self.current_page].describe(self.mode)) - def on_btTouch_clicked(self, *a): + def on_btTouch_clicked(self, *a: object) -> None: """'Touch' tab: edit the action bound to the stick-touch sensor.""" - def on_chosen(id, action): + def on_chosen(id: str, action: Action) -> None: self.touch_action = action self.builder.get_object("btTouch").set_label(action.describe(self.mode)) @@ -287,7 +287,7 @@ def on_chosen(id, action): ae.set_input(self.touch_id, self.touch_action, mode=Action.AC_BUTTON) ae.show(self.window) - def on_btClearTouch_clicked(self, *a): + def on_btClearTouch_clicked(self, *a: object) -> None: self.touch_action = NoAction() self.builder.get_object("btTouch").set_label(self.touch_action.describe(self.mode)) diff --git a/scc/lib/xwrappers.py b/scc/lib/xwrappers.py index fb559ef16..8511c44bf 100644 --- a/scc/lib/xwrappers.py +++ b/scc/lib/xwrappers.py @@ -59,7 +59,7 @@ def _load_lib(*names): _XErrorHandler = CFUNCTYPE(c_int, c_void_p, c_void_p) -def _ignore_x_error(display, error): +def _ignore_x_error(display: int, error: int) -> int: return 0 diff --git a/scc/modifiers.py b/scc/modifiers.py index 3a0c50784..1b3e66fe6 100644 --- a/scc/modifiers.py +++ b/scc/modifiers.py @@ -6,6 +6,8 @@ """ from __future__ import annotations +from __future__ import annotations + import inspect import itertools import logging @@ -13,7 +15,7 @@ from collections import OrderedDict, deque from math import atan2, copysign, cos, sin, sqrt from math import pi as PI -from typing import Self +from typing import TYPE_CHECKING, Self from scc.actions import ( Action, @@ -48,6 +50,9 @@ from scc.tools import clamp, nameof from scc.uinput import Axes, Rels +if TYPE_CHECKING: + from scc.mapper import Mapper + log = logging.getLogger("Modifiers") _ = lambda x: x @@ -352,23 +357,23 @@ class InvertedButtonModifier(Modifier): """ COMMAND = "inverted" - def describe(self, context): + def describe(self, context: int) -> str: if context in (Action.AC_STICK, Action.AC_PAD): return _("(act on release)") + "\n" + self.action.describe(context) return _("(act on release)") + " " + self.action.describe(context) - def strip(self): + def strip(self) -> Action: return self.action.strip() - def compress(self): + def compress(self) -> Action: self.action = self.action.compress() return self - def button_press(self, mapper): + def button_press(self, mapper: Mapper) -> None: # Physical press -> the wrapped action is released self.action.button_release(mapper) - def button_release(self, mapper): + def button_release(self, mapper: Mapper) -> None: # Physical release -> the wrapped action is pressed self.action.button_press(mapper) diff --git a/scc/osd/binding_display.py b/scc/osd/binding_display.py index e8d46a87b..c499200f8 100644 --- a/scc/osd/binding_display.py +++ b/scc/osd/binding_display.py @@ -5,21 +5,23 @@ Reuses styles from OSD Menu and OSD Dialog """ +from __future__ import annotations import base64 import logging import os import re import sys +from collections.abc import Callable from enum import IntEnum -from typing import Self +from typing import TYPE_CHECKING, Self from gi.repository import Gtk from scc.actions import Action, AxisAction, DPadAction, MouseAction, MultiAction, XYAction from scc.config import Config from scc.constants import DPAD, LEFT, RIGHT, SCButtons -from scc.gui.daemon_manager import DaemonManager +from scc.gui.daemon_manager import ControllerManager, DaemonManager from scc.gui.svg_widget import SVGEditor, SVGWidget from scc.modifiers import DoubleclickModifier, ModeModifier from scc.osd import OSDWindow @@ -30,6 +32,9 @@ from scc.tools import _, nameof from scc.uinput import Rels +if TYPE_CHECKING: + from xml.etree import ElementTree as ET + log = logging.getLogger("osd.binds") @@ -57,7 +62,7 @@ def __init__(self, config=None): def on_profile_changed(self, daemon: DaemonManager, filename: str): self._draw_profile(filename) - def _draw_profile(self, filename): + def _draw_profile(self, filename: str) -> None: """(Re)draws the binding boxes for the given profile onto the current background. No-op until the background image has been built, which happens in on_daemon_connected() once the connected controller (and @@ -149,7 +154,7 @@ def success(*a): locks = ["RB", "LB", self.args.cancel_with] c.lock(success, self.on_failed_to_lock, *locks) - def _resolve_image(self, controller): + def _resolve_image(self, controller: ControllerManager) -> str: """Picks the binding-display SVG for the connected controller. Order of preference: @@ -213,7 +218,7 @@ def show(self, *a): OSDWindow.show(self, *a) self.move(*self.compute_position()) - def _build_and_show(self, image): + def _build_and_show(self, image: str) -> None: """Builds the window around the given background image and shows it.""" self.realize() self.background = SVGWidget(image, init_hilighted=True) @@ -282,8 +287,8 @@ class Box: MIN_HEIGHT = 50 MIN_SCALE = 0.4 # smallest font shrink before lines may overflow anyway - def __init__(self, anchor_x, anchor_y, align, name, min_width=MIN_WIDTH, min_height=MIN_HEIGHT, - max_width=999999, max_height=999999): + def __init__(self, anchor_x: int, anchor_y: int, align: Align, name: str, min_width: int = MIN_WIDTH, + min_height: int = MIN_HEIGHT, max_width: int = 999999, max_height: int = 999999) -> None: self.name = name self.lines = [] self.anchor = anchor_x, anchor_y @@ -490,23 +495,23 @@ def place_marker(self, gen, root): _B, _T, _P, _S = Action.AC_BUTTON, Action.AC_TRIGGER, Action.AC_PAD, Action.AC_STICK -def _btn(name): +def _btn(name: str) -> Callable[[Profile], Action | None]: return lambda p: p.buttons.get(SCButtons[name]) -def _pad(side): +def _pad(side: str) -> Callable[[Profile], Action | None]: return lambda p: p.pads.get(side) -def _trig(side): +def _trig(side: str) -> Callable[[Profile], Action | None]: return lambda p: p.triggers.get(side) -def _stick(p): +def _stick(p: Profile) -> Action: return p.stick -def _rstick(p): +def _rstick(p: Profile) -> Action | None: return getattr(p, "rstick", None) @@ -545,7 +550,7 @@ def _rstick(p): class Generator: PADDING = 10 - def __init__(self, editor, profile, layout_key=None): + def __init__(self, editor: SVGEditor, profile: Profile, layout_key: str | None = None) -> None: background = SVGEditor.get_element(editor, "background") self.label_template = SVGEditor.get_element(editor, "label_template") self.line_height = int(float(self.label_template.attrib.get("height") or 8)) @@ -565,7 +570,7 @@ def __init__(self, editor, profile, layout_key=None): editor.commit() - def _build_v1(self, profile, root): + def _build_v1(self, profile: Profile, root: ET.Element) -> None: """The original 5-box layout (Steam Controller v1: one stick, no D-pad, three system buttons). Used for v1 and any controller without a dedicated entry in LAYOUTS.""" @@ -639,7 +644,7 @@ def _build_v1(self, profile, root): for b in boxes: b.place(self, root) - def _build_layout(self, profile, root, layout): + def _build_layout(self, profile: Profile, root: ET.Element, layout: list[dict]) -> None: """Builds boxes from a per-controller LAYOUTS spec. Box positions are auto-placed from the Align flags; size caps come from canvas fractions. Boxes whose controls are all unbound draw nothing and are dropped.""" @@ -669,7 +674,7 @@ def _build_layout(self, profile, root, layout): for b in boxes: b.place(self, root) - def label_style(self, scale): + def label_style(self, scale: float) -> str: """Label text style with font-size scaled by `scale` (used to shrink a crowded box so its lines fit). Returns the template style unchanged at scale 1.0.""" diff --git a/scc/osd/grid_menu.py b/scc/osd/grid_menu.py index 31aa73299..41e593cee 100644 --- a/scc/osd/grid_menu.py +++ b/scc/osd/grid_menu.py @@ -25,7 +25,7 @@ def __init__(self, cls="osd-menu"): Menu.__init__(self, cls) self.ipr = 1 # items per row - def scroll_wrap(self, parent): + def scroll_wrap(self, parent: Gtk.Widget) -> Gtk.Widget: return parent # grid menus manage their own fixed layout def create_parent(self): diff --git a/scc/osd/keyboard.py b/scc/osd/keyboard.py index e240e9b14..6ec47da88 100644 --- a/scc/osd/keyboard.py +++ b/scc/osd/keyboard.py @@ -367,7 +367,7 @@ def use_daemon(self, d: DaemonManager) -> None: self._cononect_handlers() self.on_daemon_connected(self.daemon) - def redraw_background(self, *a) -> None: + def redraw_background(self, *a: object) -> None: """Forces a repaint of the keyboard background image. Called by the OSD daemon after recolor()/update_labels() when the diff --git a/scc/osd/menu.py b/scc/osd/menu.py index f38f5958a..493bd29af 100644 --- a/scc/osd/menu.py +++ b/scc/osd/menu.py @@ -90,7 +90,7 @@ def create_parent(self): v.set_name("osd-menu") return v - def scroll_wrap(self, parent): + def scroll_wrap(self, parent: Gtk.Widget) -> Gtk.Widget: """Wrap the vertical item list in a scrolled viewport capped to the screen height, so very long menus (e.g. hundreds of profiles) don't run off-screen. Overridden to a no-op by grid/radial/horizontal menus.""" @@ -104,7 +104,7 @@ def scroll_wrap(self, parent): self._scrollwindow = sw return sw - def _max_menu_height(self): + def _max_menu_height(self) -> int: """Largest the menu may grow before scrolling (monitor height minus margin).""" try: display = Gdk.Display.get_default() @@ -113,7 +113,7 @@ def _max_menu_height(self): except Exception: return 720 - def _fit_scroll(self): + def _fit_scroll(self) -> None: """Size the scrolled viewport to the packed items, capped to the screen. The item box is empty when scroll_wrap() runs and a GtkFixed won't expand the viewport afterwards, so the size is set here once items are present.""" @@ -129,7 +129,7 @@ def _fit_scroll(self): else: sw.set_size_request(natw, nath) - def _ensure_visible(self, widget): + def _ensure_visible(self, widget: Gtk.Widget) -> None: """Scroll the viewport (if any) so the selected item stays on screen.""" sw = getattr(self, "_scrollwindow", None) if sw is None or widget is None: @@ -429,13 +429,13 @@ def show(self, *a): self._reveal_timer = GLib.timeout_add(2000, self._lock_timed_out) self._reveal_if_locked() - def _on_inputs_locked(self, *a): + def _on_inputs_locked(self, *a: object) -> None: """Called from the lock-success callback, once inputs are diverted to this menu and it is safe to reveal it.""" self._inputs_locked = True self._reveal_if_locked() - def _reveal_if_locked(self): + def _reveal_if_locked(self) -> None: """Reveal the menu, but only once it is both requested and locked.""" if not (self._show_pending and self._inputs_locked): return @@ -446,7 +446,7 @@ def _reveal_if_locked(self): OSDWindow.show(self) GLib.timeout_add(1, self._check_on_screen_position, True) - def _lock_timed_out(self, *a): + def _lock_timed_out(self, *a: object) -> None: """The lock never landed; close the menu instead of revealing it while unlocked (which could leak input or strand a key).""" self._reveal_timer = None diff --git a/scc/osd/quick_menu.py b/scc/osd/quick_menu.py index d5e4c6037..ac635bfab 100644 --- a/scc/osd/quick_menu.py +++ b/scc/osd/quick_menu.py @@ -246,7 +246,7 @@ def cancel_timer(self): GLib.source_remove(self._timer) self._timer = None - def quit(self, code=-2): + def quit(self, code: int = -2) -> None: # Cancel the auto-timeout before quitting; otherwise it lingers and fires # after this menu is gone, calling quit() again -> unlock_all(), which is # per-client and would clear the *next* menu's locks. See Menu.quit. diff --git a/scc/osd/radial_menu.py b/scc/osd/radial_menu.py index 0c841183f..6c11a723f 100644 --- a/scc/osd/radial_menu.py +++ b/scc/osd/radial_menu.py @@ -51,7 +51,7 @@ def __init__(self) -> None: self.set_app_paintable(True) self.connect("draw", self._on_draw_clip_circle) - def scroll_wrap(self, parent): + def scroll_wrap(self, parent: Gtk.Widget) -> Gtk.Widget: return parent # radial menu draws items on an SVG; no scroll viewport def create_parent(self) -> SVGWidget: diff --git a/scc/sccdaemon.py b/scc/sccdaemon.py index c4f0daf80..bb666696b 100644 --- a/scc/sccdaemon.py +++ b/scc/sccdaemon.py @@ -280,7 +280,7 @@ def _set_profile(self, mapper: Mapper, filename: str) -> None: else: self.send_profile_info(None, self._send_to_all, mapper=mapper) - def _remember_controller_profile(self, client, filename): + def _remember_controller_profile(self, client: "Client", filename: str) -> None: """Persists a controller's profile so it is restored on (re)connect. Only explicit, user-initiated selections are remembered: the autoswitch From 0d40e60da0e707432d7d8f3d1e97e25bb5739b5d Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Sun, 12 Jul 2026 17:30:23 +0200 Subject: [PATCH 45/74] fix(osd): Steam Deck OSD menu - helpers work in the AppImage, no Turn Off - "Run Program", "Display Current Bindings" and "Edit Bindings" launch scc-* / sc-controller helpers via shell(), which trusts PATH and the binary's shebang - both unreliable in the AppImage, so they failed silently. on_sa_shell now runs those helpers via find_python() + find_binary(), the same shebang-bypassing path the daemon uses for its own OSD helpers; arbitrary shell commands are unchanged. - "Turn Controller OFF" is hidden from the OSD menu for the Deck's built-in controls (they can't be powered off). The daemon passes the controller type via --controller-type; the menu drops turnoff items for type "deck". Since the OSD menu normally loads without an action parser (the daemon runs actions by id), the Deck menu now parses its actions so the filter can see them, and the filter is shared so QuickMenu drops the item too. Co-Authored-By: Claude Opus 4.8 --- scc/osd/__init__.py | 1 + scc/osd/menu.py | 30 +++++++++++++++++++++++++++--- scc/osd/quick_menu.py | 2 +- scc/sccdaemon.py | 14 ++++++++++++-- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/scc/osd/__init__.py b/scc/osd/__init__.py index 6f5f73725..b7babea56 100644 --- a/scc/osd/__init__.py +++ b/scc/osd/__init__.py @@ -158,6 +158,7 @@ def _add_arguments(self) -> None: Use negative value to specify as distance from bottom side (default: -20)""", ) self.argparser.add_argument("--controller", type=str, help="""id of controller to use""") + self.argparser.add_argument("--controller-type", type=str, help="""type of controller to use""") self.argparser.add_argument("-d", action="store_true", help="""display debug messages""") def choose_controller(self, daemonmanager: DaemonManager) -> ControllerManager: diff --git a/scc/osd/menu.py b/scc/osd/menu.py index 493bd29af..5b209d25f 100644 --- a/scc/osd/menu.py +++ b/scc/osd/menu.py @@ -16,6 +16,7 @@ from scc.lib import xwrappers as X from scc.menu_data import MenuData, Separator, Submenu from scc.osd import OSDWindow, StickController, menu_generators +from scc.parser import TalkingActionParser from scc.paths import get_share_path from scc.tools import _, circle_to_square, clamp, find_icon, find_menu from scc.x11 import autoswitcher @@ -240,10 +241,15 @@ def _get_on_screen_position(w): return a.x, a.y def parse_menu(self): + # Parse actions only when we may need to filter items by what they do + # (dropping "Turn Controller OFF" on the Steam Deck). Other controllers + # keep the lighter no-parse load: the daemon runs a menu action by id, so + # the OSD menu itself never needs the parsed action. + parser = TalkingActionParser() if getattr(self.args, "controller_type", None) == "deck" else None if self.args.from_profile: try: self._menuid = self.args.items[0] - self.items = MenuData.from_profile(self.args.from_profile, self._menuid) + self.items = MenuData.from_profile(self.args.from_profile, self._menuid, parser) except OSError: print("%s: error: profile file not found" % (sys.argv[0]), file=sys.stderr) return False @@ -253,7 +259,7 @@ def parse_menu(self): elif self.args.from_file: try: self._menuid = self.args.from_file - self.items = MenuData.from_file(self.args.from_file) + self.items = MenuData.from_file(self.args.from_file, parser) except: print("%s: error: failed to load menu file" % (sys.argv[0]), file=sys.stderr) return False @@ -266,6 +272,24 @@ def parse_menu(self): return False return True + def _drop_inapplicable_items(self, items): + """Removes generated menu items that don't apply to the connected + controller - currently "Turn Controller OFF" for the Steam Deck's + built-in controls, which can't be powered off. The live controller + isn't known when items are built (that happens before we connect to + the daemon), so the daemon passes its type via --controller-type. + """ + if getattr(self.args, "controller_type", None) != "deck": + return items + def is_turnoff(action): + # turnoff() directly, or wrapped e.g. as osd(turnoff()) - unwrap .action + while action is not None: + if getattr(action, "SA", "") == "turnoff": + return True + action = getattr(action, "action", None) + return False + return [i for i in items if not is_turnoff(getattr(i, "action", None))] + def parse_arguments(self, argv): if not OSDWindow.parse_arguments(self, argv): return False @@ -278,7 +302,7 @@ def parse_arguments(self, argv): self._size = self.args.size # Create buttons that are displayed on screen - items = self.items.generate(self) + items = self._drop_inapplicable_items(self.items.generate(self)) self.items = [] for item in items: item.widget = self.generate_widget(item) diff --git a/scc/osd/quick_menu.py b/scc/osd/quick_menu.py index ac635bfab..757a18239 100644 --- a/scc/osd/quick_menu.py +++ b/scc/osd/quick_menu.py @@ -144,7 +144,7 @@ def parse_arguments(self, argv): self._timeout = self.args.timeout # Create buttons that are displayed on screen - items = self.items.generate(self) + items = self._drop_inapplicable_items(self.items.generate(self)) self.items = [] self._button_index = 0 for item in items: diff --git a/scc/sccdaemon.py b/scc/sccdaemon.py index bb666696b..e4262ad3c 100644 --- a/scc/sccdaemon.py +++ b/scc/sccdaemon.py @@ -336,6 +336,15 @@ def on_sa_led(self, mapper: Mapper, action: LedAction) -> None: def on_sa_shell(self, mapper: Mapper, action: ShellCommandAction) -> Popen[bytes]: """Called when 'shell' action is used""" + cmd = shsplit(action.command) + # scc's own helpers (scc-osd-launcher, scc-osd-show-bindings, sc-controller + # ...) are Python entry points whose shebang and PATH can't be relied on in + # every environment - notably inside the AppImage, where a bare shell spawn + # silently fails (the same reason the daemon launches its other helpers via + # find_python() + find_binary()). Launch these the same way, bypassing the + # shebang; arbitrary user commands still go through the shell unchanged. + if cmd and (cmd[0].startswith("scc-") or cmd[0] == "sc-controller"): + return subprocess.Popen([find_python(), find_binary(cmd[0]), *cmd[1:]]) return subprocess.Popen(action.command, shell=True) def on_sa_gestures(self, mapper: Mapper, action: GesturesAction, x, y, what) -> None: @@ -419,8 +428,9 @@ def on_sa_keyboard(self, mapper: Mapper, action: KeyboardAction) -> None: def on_sa_menu(self, mapper: Mapper, action: MenuAction, *pars) -> None: """Called when 'menu' action is used""" p = [action.MENU_TYPE] - if mapper.get_controller(): - p += ["--controller", mapper.get_controller().get_id()] + c = mapper.get_controller() + if c: + p += ["--controller", c.get_id(), "--controller-type", c.get_type()] if "." in action.menu_id: path = find_menu(action.menu_id) if not path: From 399ee480b2e4d0101c88e41531a6371e9e5862df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sat, 4 Jul 2026 19:36:49 +0200 Subject: [PATCH 46/74] binding-display: auto-generate the template from controller art The OSD "Display Current Bindings" template was a hand-drawn per-controller asset (tools/binding-display-sc2-art.svg) that had to be maintained by hand and kept in sync with the controller drawing. Replace that with a generator that builds the template straight from the existing GUI controller drawing. tools/gen_binding_display.py is now controller-agnostic: driven by a CONTROLLERS table, for each entry it scales that controller's images/controller-images drawing into the OSD canvas, recolours it into the binding-display palette (green outlines over two greys on a dark backdrop so it recedes behind the binding boxes), strips the AREA_* hotspots and drops a marker ring at each control anchor. Adding a controller is now just a table entry plus a box layout. Also relocate the output out of the images/ root into an images/binding-display/ subdir (picked up by setup.py's images/*/ glob), so _resolve_image now looks for binding-display/.svg. Drop the hand-art asset, regenerate images/binding-display/sc2.svg, and document the art-generation tools under the README build section for future contributors. Co-Authored-By: Claude Opus 4.8 --- README.md | 29 +++++ images/binding-display-sc2.svg | 1 - images/binding-display/sc2.svg | 1 + scc/osd/binding_display.py | 6 +- tools/binding-display-sc2-art.svg | 1 - tools/gen_binding_display.py | 204 ++++++++++++++++++++---------- 6 files changed, 171 insertions(+), 71 deletions(-) delete mode 100644 images/binding-display-sc2.svg create mode 100644 images/binding-display/sc2.svg delete mode 100644 tools/binding-display-sc2-art.svg diff --git a/README.md b/README.md index f36dfb1f9..d0eedbe74 100644 --- a/README.md +++ b/README.md @@ -81,3 +81,32 @@ docker build -o build-output --build-arg BASE_CODENAME=noble . - Optionally checkout a branch or a tag, like `main`(default) or `v0.6.2` - Execute `./run.sh`, this automatically builds the project into a venv called `.venv`, activates it and runs sc-controller, which in turn runs scc-daemon if one does not run already - If you are debugging an issue, running `./run.sh daemon` first will launch the daemon in debug mode, allowing you to launch sc-controller in another terminal with `./run.sh` - note that sc-controller launched via `run.sh` always runs in debug mode too. + +### Regenerating controller artwork (for contributors) + +Some SVG assets under `images/` are **generated** from source drawings by scripts +in `tools/`, so edit the source and rerun the script rather than hand-editing the +committed output. All scripts run from the repository root and optimise their +output with [`svgo`](https://github.com/svg/svgo) when it is on `PATH` (optional; +without it the SVGs are just left un-minified). The `svgo` config +(`tools/svgo.config.js`) deliberately preserves the element ids, `` +geometry, `viewBox` and `display:none` layers that the GUI relies on. + +- **`tools/gen_sc2_image.py`** — builds the Steam Controller v2 GUI artwork + (`images/controller-images/sc2.svg`, the face-button glyphs and side-panel + icons) from the traced sources in `tools/` (`sc2-source.svg`, `sc2-assets/`). + +- **`tools/gen_binding_display.py`** — builds the per-controller *Display Current + Bindings* templates in `images/binding-display/.svg`. Instead of + a hand-drawn asset per controller, it derives each template straight from that + controller's GUI drawing (`images/controller-images/.svg`): it scales the + drawing into the OSD canvas, recolours it into the binding-display palette + (green outlines over two greys on a dark backdrop) and drops a marker ring at + each control's `AREA_*` anchor so the binding boxes can draw connector lines to + them. The OSD then picks the file up automatically via the controller's gui + `background` name (see `scc/osd/binding_display.py`, `_resolve_image`). + + To add a controller: give it an entry in the script's `CONTROLLERS` table (its + source drawing + which `AREA_*` anchors each binding box points at) and a + matching box layout in `LAYOUTS` in `scc/osd/binding_display.py`, then rerun the + script. Controllers that share a physical control set can share a layout. diff --git a/images/binding-display-sc2.svg b/images/binding-display-sc2.svg deleted file mode 100644 index 63cbf55ce..000000000 --- a/images/binding-display-sc2.svg +++ /dev/null @@ -1 +0,0 @@ -X \ No newline at end of file diff --git a/images/binding-display/sc2.svg b/images/binding-display/sc2.svg new file mode 100644 index 000000000..95d5b91e8 --- /dev/null +++ b/images/binding-display/sc2.svg @@ -0,0 +1 @@ +R4R5L5L4X \ No newline at end of file diff --git a/scc/osd/binding_display.py b/scc/osd/binding_display.py index c499200f8..c2aac6020 100644 --- a/scc/osd/binding_display.py +++ b/scc/osd/binding_display.py @@ -160,7 +160,7 @@ def _resolve_image(self, controller: ControllerManager) -> str: Order of preference: 1. an explicit image given on the command line 2. "binding_display" filename set in the controller's gui config - 3. convention: binding-display-.svg + 3. convention: binding-display/.svg (looked up in ~/.config/scc first, then the bundled images dir) 4. the generic binding-display.svg (user override, then bundled) The generic fallback keeps controllers without a dedicated layout @@ -190,7 +190,9 @@ def _resolve_image(self, controller: ControllerManager) -> str: background = gui.get("background") self._layout_key = background # selects the per-controller box layout if background: - fname = "binding-display-%s.svg" % (background,) + # per-controller templates live in the binding-display/ subdir, with + # an optional user override under ~/.config/scc/binding-display/. + fname = os.path.join("binding-display", "%s.svg" % (background,)) candidates.append(os.path.join(config_path, fname)) candidates.append(os.path.join(images_path, fname)) # 4. generic fallback (already user-override-then-bundled) diff --git a/tools/binding-display-sc2-art.svg b/tools/binding-display-sc2-art.svg deleted file mode 100644 index 7d86bfcc3..000000000 --- a/tools/binding-display-sc2-art.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tools/gen_binding_display.py b/tools/gen_binding_display.py index b22ddabbf..0a1a3e3ed 100644 --- a/tools/gen_binding_display.py +++ b/tools/gen_binding_display.py @@ -1,30 +1,35 @@ #!/usr/bin/env python3 -"""Generate the binding-display layout SVG for the v2 Steam Controller. +"""Generate the per-controller binding-display templates from controller art. The OSD "Display Current Bindings" window (scc/osd/binding_display.py) draws each control's binding into boxes laid out around a controller picture, using a -per-controller template SVG (binding-display-.svg). This tool -assembles that template for the v2 controller. - -What it emits (images/binding-display-sc2.svg), all required by Generator: - - a 1280x720 canvas with `background` (sizes the layout), `label_template` - (label font/metrics) and `root` (boxes are drawn into it) elements; - - the restyled controller drawing, inlined verbatim from the source asset - tools/binding-display-sc2-art.svg (edit that in Inkscape to change the - look -- it carries its own placement transform); +per-controller template SVG. This tool builds those templates -- one per entry +in CONTROLLERS -- straight from the existing controller drawings +(images/controller-images/.svg), so there is no hand-drawn per-controller +art to maintain: change a controller image and rerun this. + +For each controller it emits images/binding-display/.svg, containing all the +elements Generator needs: + - a 1280x720 canvas with `background` (sizes the layout + dark backdrop), + `label_template` (label font/metrics) and `root` (boxes are drawn into it); + - the controller drawing, scaled + centred into the canvas and recoloured into + the "Matrix" binding-display palette (green outlines + two greys) so it reads + as a subdued filled silhouette behind the bright binding boxes/labels; - the six `markers_` groups (system/lshoulder/rshoulder/lthumb/rthumb/ - face -- the v2 box set in binding_display.py LAYOUTS["sc2"]), each with - circles placed at the matching AREA_* anchor centres of sc2.svg, mapped - into canvas coordinates. Each box draws a connector line to up to two. + face -- the box set in binding_display.py LAYOUTS[]), each a ring at the + matching AREA_* anchor centre of the source drawing, mapped into canvas + coords. Each box draws a connector line to up to two of them. -Markers come from the GUI image's (sc2.svg) AREA_* anchors -- they live in an -untransformed layer in final display coords, so their centres map into the -canvas via the ART_MAX_*_FRAC transform below. The art asset was placed to -register with that mapping; if you change ART_MAX_*_FRAC, re-place the art. +The AREA_* anchors live in an untransformed layer of the source drawing in its +own coords; the same drawing->canvas transform places both the drawing and the +markers, so they always register regardless of the source viewBox (sc2.svg has a +non-zero origin). If you change ART_MAX_*_FRAC, both move together. Run from repo root: python3 tools/gen_binding_display.py """ +import copy import os +import re import sys import xml.etree.ElementTree as ET @@ -32,72 +37,129 @@ import _svgo # noqa: E402 SVG = "http://www.w3.org/2000/svg" -SRC = "images/controller-images/sc2.svg" # AREA anchors for markers -ART = "tools/binding-display-sc2-art.svg" # restyled controller drawing -OUT = "images/binding-display-sc2.svg" +ET.register_namespace("", SVG) CANVAS_W, CANVAS_H = 1280, 720 +OUT_DIR = "images/binding-display" -# Defines the controller's footprint in the canvas, i.e. the sc2.svg-coords -> -# canvas transform used to place the AREA-anchor markers. The art asset -# (tools/binding-display-sc2-art.svg) was drawn/placed to register with this. +# The controller drawing's footprint in the canvas (leaves the margins free for +# the binding boxes). Both the drawing and its AREA-anchor markers are placed +# through this, so they stay registered. ART_MAX_W_FRAC = 0.38 ART_MAX_H_FRAC = 0.70 -# Generator box name -> AREA_* anchors its connector lines point at. A box draws -# at most two lines; missing anchors are skipped (so a box may get 1 or 2). These -# match the v2 (sc2) box set in scc/osd/binding_display.py LAYOUTS["sc2"]. -MARKERS = { - "system": ["BACK", "START"], - "lshoulder": ["LB", "LGRIPTOUCH"], - "rshoulder": ["RB", "RGRIPTOUCH"], - "lthumb": ["STICK", "LPAD"], - "rthumb": ["RSTICK", "RPAD"], - "face": ["Y", "A"], +# "Matrix" binding-display palette: the GUI controller art is full-colour, but +# here it is flattened to green outlines over two greys on a dark backdrop, so it +# recedes behind the bright binding boxes and labels while staying readable. +GREEN = "#047100" # every outline/stroke -> this green +GRAY_LIGHT = "#3d3d3d" # lighter fills (luminance >= GRAY_SPLIT) +GRAY_DARK = "#262626" # darker fills, and the default for un-filled shapes +GRAY_SPLIT = 80 # fill luminance split between GRAY_LIGHT and GRAY_DARK +MARKER_GREEN = "#06a400" # marker rings + connector lines (matches Generator) + +# Per-controller source drawing + the AREA_* anchors each binding box points at. +# The box names match scc/osd/binding_display.py LAYOUTS[]. A box draws at +# most two connector lines; anchor names differ per controller image. +CONTROLLERS = { + "sc2": { + "src": "images/controller-images/sc2.svg", + "markers": { + "system": ["BACK", "START"], "lshoulder": ["LB", "LGRIPTOUCH"], + "rshoulder": ["RB", "RGRIPTOUCH"], "lthumb": ["STICK", "LPAD"], + "rthumb": ["RSTICK", "RPAD"], "face": ["Y", "A"], + }, + }, } -ET.register_namespace("", SVG) +_FILL = re.compile(r"fill:\s*#([0-9a-fA-F]{3,6})") +_STROKE = re.compile(r"stroke:\s*#([0-9a-fA-F]{3,6})") def q(tag: str) -> str: return "{%s}%s" % (SVG, tag) -def parse_viewbox(svg: ET.Element) -> tuple[float, float]: +def parse_viewbox(svg: ET.Element) -> tuple[float, float, float, float]: + """(x, y, w, h) of the source viewBox -- x/y may be non-zero (e.g. sc2.svg).""" vb = svg.get("viewBox") if vb: p = [float(x) for x in vb.replace(",", " ").split()] - return p[2], p[3] - return float(svg.get("width")), float(svg.get("height")) + return p[0], p[1], p[2], p[3] + return 0.0, 0.0, float(svg.get("width")), float(svg.get("height")) def read_area_centers(root: ET.Element) -> dict[str, tuple[float, float]]: - """AREA_ rects sit in an untransformed layer in display coords, so - their centres are read directly.""" + """AREA_ rects sit in an untransformed layer in the drawing's coords, + so their centres are read directly (and later mapped into the canvas).""" centers = {} for rect in root.iter(q("rect")): rid = rect.get("id") or "" if rid.startswith("AREA_"): - x, y = float(rect.get("x")), float(rect.get("y")) - w, h = float(rect.get("width")), float(rect.get("height")) + try: + x, y, w, h = (float(rect.get(k)) for k in ("x", "y", "width", "height")) + except (TypeError, ValueError): + continue centers[rid[5:]] = (x + w / 2.0, y + h / 2.0) return centers -def main() -> None: - if not os.path.exists(SRC): - raise SystemExit("run from repo root: %s not found" % SRC) - src = ET.parse(SRC).getroot() - cw, ch = parse_viewbox(src) # controller art size (685x493) +def _luminance(hexcolor: str) -> float: + h = hexcolor.lstrip("#") + if len(h) == 3: + h = "".join(c * 2 for c in h) + r, g, b = int(h[0:2], 16), int(h[2:4], 16), int(h[4:6], 16) + return 0.299 * r + 0.587 * g + 0.114 * b + + +def _gray(hexcolor: str) -> str: + """Map a source fill to one of the two binding-display greys by luminance, so + light body panels stay lighter than dark detailing.""" + return GRAY_LIGHT if _luminance(hexcolor) >= GRAY_SPLIT else GRAY_DARK + + +def recolor(el: ET.Element) -> None: + """Recolour a drawing subtree into the Matrix palette in place: every stroke + becomes GREEN, every explicit fill becomes one of the two greys. Shapes with + no fill inherit the drawing group's GRAY_DARK default (so they read instead + of falling back to SVG black); stroke-only outlines keep their fill:none.""" + style = el.get("style") + if style: + style = _FILL.sub(lambda m: "fill:" + _gray(m.group(1)), style) + style = _STROKE.sub(lambda _m: "stroke:" + GREEN, style) + el.set("style", style) + if (el.get("fill") or "").startswith("#"): + el.set("fill", _gray(el.get("fill"))) + if (el.get("stroke") or "").startswith("#"): + el.set("stroke", GREEN) + for child in el: + recolor(child) + + +def strip_areas(el: ET.Element) -> None: + """Remove AREA_* hotspot rects recursively -- they are invisible in the GUI + but recolour() would give them a grey fill and cover the drawing.""" + for child in list(el): + if (child.get("id") or "").startswith("AREA_"): + el.remove(child) + else: + strip_areas(child) + + +def build(key: str, spec: dict) -> None: + src_path = spec["src"] + if not os.path.exists(src_path): + raise SystemExit("run from repo root: %s not found" % src_path) + src = ET.parse(src_path).getroot() + vx, vy, cw, ch = parse_viewbox(src) centers = read_area_centers(src) - # Scale + centre the art in the free middle band. + # Scale + centre the drawing in the canvas. s = min(CANVAS_W * ART_MAX_W_FRAC / cw, CANVAS_H * ART_MAX_H_FRAC / ch) ox = (CANVAS_W - cw * s) / 2.0 oy = (CANVAS_H - ch * s) / 2.0 def to_canvas(pt: tuple[float, float]) -> tuple[float, float]: - return ox + s * pt[0], oy + s * pt[1] + return ox + s * (pt[0] - vx), oy + s * (pt[1] - vy) out = ET.Element(q("svg"), { "width": str(CANVAS_W), "height": str(CANVAS_H), @@ -111,16 +173,18 @@ def to_canvas(pt: tuple[float, float]) -> tuple[float, float]: "width": str(CANVAS_W), "height": str(CANVAS_H), "style": "fill:#000000;fill-opacity:0.85"}) - # controller art: the hand-restyled drawing, inlined verbatim from the source - # asset (kept separate so this generator reproduces it and the look is edited - # in Inkscape). It carries its own placement transform, made to register with - # the AREA-anchor marker mapping above. - if not os.path.exists(ART): - raise SystemExit("%s not found" % ART) - for child in list(ET.parse(ART).getroot()): - if child.tag.split("}")[-1] == "defs": + # The controller drawing, scaled into the canvas so it registers with the + # markers, then recoloured. The group's GRAY_DARK default catches shapes with + # no explicit fill (which would otherwise render SVG-black on the dark bg). + g = ET.SubElement(out, q("g"), { + "fill": GRAY_DARK, + "transform": "translate(%g,%g) scale(%g) translate(%g,%g)" % (ox, oy, s, -vx, -vy)}) + for child in list(src): + if child.get("id") == "layerAreas": continue - out.append(child) + g.append(copy.deepcopy(child)) + strip_areas(g) + recolor(g) # foreground: label_template + root (boxes drawn here) + the marker groups. root = ET.SubElement(out, q("g"), {"id": "root", "style": "display:inline"}) @@ -131,24 +195,30 @@ def to_canvas(pt: tuple[float, float]) -> tuple[float, float]: lt.text = "X" missing = [] - for name, anchors in MARKERS.items(): - g = ET.SubElement(root, q("g"), {"id": "markers_%s" % name}) + for name, anchors in spec["markers"].items(): + mg = ET.SubElement(root, q("g"), {"id": "markers_%s" % name}) for a in anchors: if a not in centers: missing.append(a) continue cx, cy = to_canvas(centers[a]) - ET.SubElement(g, q("circle"), { + ET.SubElement(mg, q("circle"), { "cx": "%g" % cx, "cy": "%g" % cy, "r": "5", - "style": "fill:#000000;fill-opacity:0;stroke:#06a400;stroke-width:1"}) + "style": "fill:none;stroke:%s;stroke-width:1" % MARKER_GREEN}) - ET.ElementTree(out).write(OUT, encoding="unicode", xml_declaration=True) - _svgo.optimize(OUT) - print("wrote", OUT) - print(" art inlined from %s; marker mapping scale %.3f at (%.1f, %.1f)" - % (ART, s, ox, oy)) + out_path = os.path.join(OUT_DIR, "%s.svg" % key) + ET.ElementTree(out).write(out_path, encoding="unicode", xml_declaration=True) + _svgo.optimize(out_path) + print("wrote %s (from %s, scale %.3f at %.1f,%.1f)" % (out_path, src_path, s, ox, oy)) if missing: - print(" WARNING: AREA anchors not found in %s: %s" % (SRC, ", ".join(missing))) + print(" WARNING: AREA anchors not found in %s: %s" % (src_path, ", ".join(missing))) + + +def main() -> None: + """Build every controller's binding-display template into OUT_DIR.""" + os.makedirs(OUT_DIR, exist_ok=True) + for key, spec in CONTROLLERS.items(): + build(key, spec) if __name__ == "__main__": From bd6f268c5d96a63c342314da3c6c3c2afee71f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sat, 4 Jul 2026 19:40:09 +0200 Subject: [PATCH 47/74] binding-display: add Steam Deck support The Deck had no Display Current Bindings template, so the OSD fell back to the generic layout and drew the wrong (Steam Controller v1) picture. Give it a real one: add a "deck" entry to gen_binding_display.py's CONTROLLERS table (the Deck's AREA naming differs -- segmented pads/bumpers, no grip-touch) and generate images/binding-display/deck.svg from the Deck GUI drawing. The Deck's built-in controller shares the v2's physical control set, so it reuses the v2 box layout (LAYOUTS["deck"] = LAYOUTS["sc2"]); controls the Deck lacks stay unbound and their boxes simply render nothing. Co-Authored-By: Claude Opus 4.8 --- images/binding-display/deck.svg | 1 + scc/osd/binding_display.py | 5 +++++ tools/gen_binding_display.py | 9 +++++++++ 3 files changed, 15 insertions(+) create mode 100644 images/binding-display/deck.svg diff --git a/images/binding-display/deck.svg b/images/binding-display/deck.svg new file mode 100644 index 000000000..440617688 --- /dev/null +++ b/images/binding-display/deck.svg @@ -0,0 +1 @@ +L4L5R5R4X \ No newline at end of file diff --git a/scc/osd/binding_display.py b/scc/osd/binding_display.py index c2aac6020..f6367d10c 100644 --- a/scc/osd/binding_display.py +++ b/scc/osd/binding_display.py @@ -548,6 +548,11 @@ def _rstick(p: Profile) -> Action | None: ], } +# The Steam Deck's built-in controller shares the v2's physical control set (same +# boxes, same controls), so it reuses the v2 layout. Controls the Deck lacks stay +# unbound and their boxes render nothing, so the shared list is safe. +LAYOUTS["deck"] = LAYOUTS["sc2"] + class Generator: PADDING = 10 diff --git a/tools/gen_binding_display.py b/tools/gen_binding_display.py index 0a1a3e3ed..8edf04d79 100644 --- a/tools/gen_binding_display.py +++ b/tools/gen_binding_display.py @@ -69,6 +69,15 @@ "rthumb": ["RSTICK", "RPAD"], "face": ["Y", "A"], }, }, + "deck": { + "src": "images/controller-images/deck.svg", + # Deck AREA naming differs (segmented pads/bumpers, no grip-touch). + "markers": { + "system": ["BACK", "START"], "lshoulder": ["LB_2", "LT_2"], + "rshoulder": ["RB_2", "RT_2"], "lthumb": ["STICK", "LPAD_1"], + "rthumb": ["RSTICK", "RPAD_1"], "face": ["Y", "A"], + }, + }, } _FILL = re.compile(r"fill:\s*#([0-9a-fA-F]{3,6})") From 3d93c28b76841ff2cc36e97b0db4a09340a95e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sat, 4 Jul 2026 20:55:59 +0200 Subject: [PATCH 48/74] sccdaemon: show/lock the invoking controller for Display Bindings The "Display Current Bindings" menu entry runs shell("scc-osd-show-bindings"), which was launched with no --controller. OSDWindow.choose_controller then falls back to the first connected controller, so with several controllers connected it showed the wrong controller's bindings -- and because the same controller is the one the OSD locks its cancel button on, the window couldn't be dismissed at all (the cancel press landed on a different controller). on_sa_shell now appends --controller for scc-osd-show-bindings, targeting the controller that actually invoked the action (mirroring on_sa_menu). Arbitrary user shell commands, and any command already passing --controller, are untouched. Co-Authored-By: Claude Opus 4.8 --- scc/sccdaemon.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scc/sccdaemon.py b/scc/sccdaemon.py index e4262ad3c..bb194665a 100644 --- a/scc/sccdaemon.py +++ b/scc/sccdaemon.py @@ -344,7 +344,17 @@ def on_sa_shell(self, mapper: Mapper, action: ShellCommandAction) -> Popen[bytes # find_python() + find_binary()). Launch these the same way, bypassing the # shebang; arbitrary user commands still go through the shell unchanged. if cmd and (cmd[0].startswith("scc-") or cmd[0] == "sc-controller"): - return subprocess.Popen([find_python(), find_binary(cmd[0]), *cmd[1:]]) + args = cmd[1:] + # scc-osd-show-bindings renders, and locks input on, one specific + # controller. Without --controller it falls back to the first + # connected controller (OSDWindow.choose_controller), so with several + # controllers it shows the wrong one's bindings AND its cancel button + # is locked on that other controller, so the window can't be + # dismissed. Target the controller that actually invoked the action. + c = mapper.get_controller() + if c and cmd[0] == "scc-osd-show-bindings" and "--controller" not in args: + args = ["--controller", c.get_id(), *args] + return subprocess.Popen([find_python(), find_binary(cmd[0]), *args]) return subprocess.Popen(action.command, shell=True) def on_sa_gestures(self, mapper: Mapper, action: GesturesAction, x, y, what) -> None: From 539f28e1769cb2049e0025b59862dd56ad572827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sat, 4 Jul 2026 20:59:21 +0200 Subject: [PATCH 49/74] osd/binding-display: fit the window to the screen (Steam Deck) The Display Bindings window was scaled to fit only the screen *width*, and did nothing at all when the active screen couldn't be determined -- as on the Steam Deck under gamescope, which reports no active window. There the 1280x720 image was shown at full size and overflowed the Deck's 1280x800 screen, pushing the edge-anchored binding boxes off-screen so their connector lines appeared to shoot outside the window. compute_position now caps the image to 80% of the screen in BOTH dimensions and falls back to the primary monitor when no active screen is reported, so it always fits with a margin. Co-Authored-By: Claude Opus 4.8 --- scc/osd/binding_display.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/scc/osd/binding_display.py b/scc/osd/binding_display.py index f6367d10c..a4ccd4949 100644 --- a/scc/osd/binding_display.py +++ b/scc/osd/binding_display.py @@ -91,19 +91,30 @@ def _add_arguments(self): ) def compute_position(self): - """Unlike other OSD windows, this one is scaled to 80% of screen size and centered in on active screen.""" - x, y = 10, 10 + """Fit the (per-controller) binding image to the active screen and centre + it. Unlike other OSD windows this one is nearly screen-sized, so it is + capped to 80% of the screen in BOTH dimensions and scaled down to fit.""" iw, ih = self.background.image_width, self.background.image_height geometry = self.get_active_screen_geometry() - if geometry: - width, height = iw, ih - if width > geometry.width * 0.8: - width = geometry.width * 0.8 - height = int(float(ih) / float(iw) * float(width)) - self.background.resize(width, height) - self.background.hilight({}) - x = geometry.x + ((geometry.width - width) / 2) - y = geometry.y + ((geometry.height - height) / 2) + if geometry is None: + # The Steam Deck (gamescope) reports no active window; fall back to the + # primary monitor so the image is still fitted instead of shown at full + # 1280x720, which overflows the Deck's 1280x800 screen. + screen = self.get_window().get_screen() + geometry = screen.get_monitor_geometry(screen.get_primary_monitor()) + if geometry is None: + return 10, 10 + # Cap to 80% of the screen in BOTH dimensions: width-only scaling left the + # window overflowing on screens barely larger than the image (the Deck's + # 1280x800 vs the 1280x720 image), and off-screen boxes made their + # connector lines appear to shoot outside the window. + scale = min(1.0, geometry.width * 0.8 / iw, geometry.height * 0.8 / ih) + width, height = int(iw * scale), int(ih * scale) + if scale < 1.0: + self.background.resize(width, height) + self.background.hilight({}) + x = geometry.x + (geometry.width - width) // 2 + y = geometry.y + (geometry.height - height) // 2 return x, y def parse_arguments(self, argv): From c99fa0b8ec3ff3c2d6dd8223d2485cf1e4786b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sat, 4 Jul 2026 20:59:43 +0200 Subject: [PATCH 50/74] osd/binding-display: shrink v1 labels to fit their boxes The per-controller (sc2/deck) layout caps each box's height, so Box.calculate() auto-scales the label font to keep a crowded box's lines inside the frame. The original v1 layout (_build_v1) never set max_height, so that auto-shrink never triggered and a busy box's labels spilled out of the frame and off the screen. Give the v1 boxes the same max_height caps so they shrink to fit like the sc2/ deck layout. Boxes that already fit keep scale 1.0, so uncrowded v1 displays are unchanged. Co-Authored-By: Claude Opus 4.8 --- scc/osd/binding_display.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scc/osd/binding_display.py b/scc/osd/binding_display.py index a4ccd4949..e761c06db 100644 --- a/scc/osd/binding_display.py +++ b/scc/osd/binding_display.py @@ -593,7 +593,7 @@ def _build_v1(self, profile: Profile, root: ET.Element) -> None: three system buttons). Used for v1 and any controller without a dedicated entry in LAYOUTS.""" boxes = [] - box_bcs = Box(0, self.PADDING, Align.TOP, "bcs") + box_bcs = Box(0, self.PADDING, Align.TOP, "bcs", max_height=self.full_height * 0.25) box_bcs.add("BACK", Action.AC_BUTTON, profile.buttons.get(SCButtons.BACK)) box_bcs.add("C", Action.AC_BUTTON, profile.buttons.get(SCButtons.C)) box_bcs.add("START", Action.AC_BUTTON, profile.buttons.get(SCButtons.START)) @@ -607,6 +607,7 @@ def _build_v1(self, profile: Profile, root: ET.Element) -> None: min_height=self.full_height * 0.5, min_width=self.full_width * 0.2, max_width=self.full_width * 0.275, + max_height=self.full_height * 0.85, ) box_left.add("LEFT", Action.AC_TRIGGER, profile.triggers.get(profile.LEFT)) box_left.add("LB", Action.AC_BUTTON, profile.buttons.get(SCButtons.LB)) @@ -622,6 +623,7 @@ def _build_v1(self, profile: Profile, root: ET.Element) -> None: min_height=self.full_height * 0.5, min_width=self.full_width * 0.2, max_width=self.full_width * 0.275, + max_height=self.full_height * 0.85, ) box_right.add("RIGHT", Action.AC_TRIGGER, profile.triggers.get(profile.RIGHT)) box_right.add("RB", Action.AC_BUTTON, profile.buttons.get(SCButtons.RB)) @@ -630,7 +632,8 @@ def _build_v1(self, profile: Profile, root: ET.Element) -> None: boxes.append(box_right) box_abxy = Box( - 4 * self.PADDING, self.PADDING, Align.RIGHT | Align.BOTTOM, "abxy", max_width=self.full_width * 0.45, + 4 * self.PADDING, self.PADDING, Align.RIGHT | Align.BOTTOM, "abxy", + max_width=self.full_width * 0.45, max_height=self.full_height * 0.25, ) box_abxy.add("A", Action.AC_BUTTON, profile.buttons.get(SCButtons.A)) box_abxy.add("B", Action.AC_BUTTON, profile.buttons.get(SCButtons.B)) @@ -639,7 +642,8 @@ def _build_v1(self, profile: Profile, root: ET.Element) -> None: boxes.append(box_abxy) box_stick = Box( - 4 * self.PADDING, self.PADDING, Align.LEFT | Align.BOTTOM, "stick", max_width=self.full_width * 0.45, + 4 * self.PADDING, self.PADDING, Align.LEFT | Align.BOTTOM, "stick", + max_width=self.full_width * 0.45, max_height=self.full_height * 0.25, ) box_stick.add("STICK", Action.AC_STICK, profile.stick) boxes.append(box_stick) From dd490b26b2c9e86e444004126352973369e37601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sat, 4 Jul 2026 21:26:15 +0200 Subject: [PATCH 51/74] binding-display: honor group transforms when placing markers (Deck) read_area_centers read each AREA_* rect's raw x/y, assuming the anchors live in the drawing's user space. That holds for sc2 (identity anchor layer) but not the Deck, whose anchors are nested in a separate layer under translated groups. Their raw coordinates land hundreds of units outside the 446x345 viewBox, so the Deck's shoulder (and pad) markers were placed below the canvas -- the binding boxes then drew their connector lines shooting off the bottom of the window. Accumulate the full ancestor transform chain (translate/scale/matrix/rotate, space- or comma-separated) down to each anchor, so a marker lands on its control regardless of how the source drawing nests it. sc2's identity layer is unchanged; the Deck's markers now sit on the sticks, pads, triggers and buttons. Co-Authored-By: Claude Opus 4.8 --- images/binding-display/deck.svg | 2 +- tools/gen_binding_display.py | 76 ++++++++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 11 deletions(-) diff --git a/images/binding-display/deck.svg b/images/binding-display/deck.svg index 440617688..27f17985a 100644 --- a/images/binding-display/deck.svg +++ b/images/binding-display/deck.svg @@ -1 +1 @@ -L4L5R5R4X \ No newline at end of file +L4L5R5R4X \ No newline at end of file diff --git a/tools/gen_binding_display.py b/tools/gen_binding_display.py index 8edf04d79..6473386fa 100644 --- a/tools/gen_binding_display.py +++ b/tools/gen_binding_display.py @@ -28,6 +28,7 @@ Run from repo root: python3 tools/gen_binding_display.py """ import copy +import math import os import re import sys @@ -97,18 +98,73 @@ def parse_viewbox(svg: ET.Element) -> tuple[float, float, float, float]: return 0.0, 0.0, float(svg.get("width")), float(svg.get("height")) +# --- affine transforms (a, b, c, d, e, f) mapping (x,y) -> (ax+cy+e, bx+dy+f) --- +IDENTITY = (1.0, 0.0, 0.0, 1.0, 0.0, 0.0) +_TRANSFORM = re.compile(r"(matrix|translate|scale|rotate)\s*\(([^)]*)\)") + + +def _compose(a: tuple, b: tuple) -> tuple: + """Return a after b (apply b first, then a) -- SVG's nested-transform order.""" + a1, b1, c1, d1, e1, f1 = a + a2, b2, c2, d2, e2, f2 = b + return (a1 * a2 + c1 * b2, b1 * a2 + d1 * b2, + a1 * c2 + c1 * d2, b1 * c2 + d1 * d2, + a1 * e2 + c1 * f2 + e1, b1 * e2 + d1 * f2 + f1) + + +def _parse_transform(s: str | None) -> tuple: + """Parse an SVG transform attribute into one composed affine matrix. Handles + space- OR comma-separated args and a list of transforms (leftmost outermost).""" + m = IDENTITY + if not s: + return m + for name, argstr in _TRANSFORM.findall(s): + v = [float(x) for x in re.split(r"[\s,]+", argstr.strip()) if x] + if name == "translate": + t = (1.0, 0.0, 0.0, 1.0, v[0], v[1] if len(v) > 1 else 0.0) + elif name == "scale": + t = (v[0], 0.0, 0.0, v[1] if len(v) > 1 else v[0], 0.0, 0.0) + elif name == "matrix": + t = tuple(v[:6]) + elif name == "rotate": + rad = math.radians(v[0]) + cos, sin = math.cos(rad), math.sin(rad) + t = (cos, sin, -sin, cos, 0.0, 0.0) + if len(v) >= 3: # rotate about (cx, cy) + t = _compose(_compose((1.0, 0.0, 0.0, 1.0, v[1], v[2]), t), + (1.0, 0.0, 0.0, 1.0, -v[1], -v[2])) + else: + t = IDENTITY + m = _compose(m, t) + return m + + def read_area_centers(root: ET.Element) -> dict[str, tuple[float, float]]: - """AREA_ rects sit in an untransformed layer in the drawing's coords, - so their centres are read directly (and later mapped into the canvas).""" + """Centre of each AREA_ rect in the drawing's user (viewBox) space. + + The rects may sit inside groups with their own transforms (the Deck nests + them under translated groups in a separate layer), so the full ancestor + transform chain is accumulated -- reading raw x/y put the Deck's shoulder + anchors hundreds of units outside the viewBox. sc2's anchors are in an + identity layer, so its result is unchanged.""" centers = {} - for rect in root.iter(q("rect")): - rid = rect.get("id") or "" - if rid.startswith("AREA_"): - try: - x, y, w, h = (float(rect.get(k)) for k in ("x", "y", "width", "height")) - except (TypeError, ValueError): - continue - centers[rid[5:]] = (x + w / 2.0, y + h / 2.0) + + def walk(el: ET.Element, acc: tuple) -> None: + acc = _compose(acc, _parse_transform(el.get("transform"))) + for child in el: + rid = child.get("id") or "" + if child.tag == q("rect") and rid.startswith("AREA_"): + try: + x, y, w, h = (float(child.get(k)) for k in ("x", "y", "width", "height")) + except (TypeError, ValueError): + continue + a, b, c, d, e, f = acc + cx, cy = x + w / 2.0, y + h / 2.0 + centers[rid[5:]] = (a * cx + c * cy + e, b * cx + d * cy + f) + else: + walk(child, acc) + + walk(root, IDENTITY) return centers From 0fc73ac4f017dbcf7eea6cdf5fdccd1e266f7644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 5 Jul 2026 00:10:53 +0200 Subject: [PATCH 52/74] binding-display: add ds4/ds5/x360 templates DualShock 4, DualSense and Xbox 360 fell back to the generic (Steam Controller v1) binding-display image. Give them their own, generated the same way as sc2/ deck: a CONTROLLERS entry (source drawing + per-box AREA anchors) plus a LAYOUTS entry. The three are physically alike and their drawings share the same anchor names, so they share one marker set (gen_binding_display.py _GAMEPAD_MARKERS) and one box layout (_GAMEPAD_LAYOUT). That layout reflects the gamepad control model, which differs from the Steam controllers: the right stick is the right pad (pads[RIGHT], not rstick) and the d-pad is the left pad (pads[LEFT]) -- verified against the bundled XBox default profile. Co-Authored-By: Claude Opus 4.8 --- images/binding-display/ds4.svg | 1 + images/binding-display/ds5.svg | 1 + images/binding-display/x360.svg | 1 + scc/osd/binding_display.py | 29 +++++++++++++++++++++++++++++ tools/gen_binding_display.py | 12 ++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 images/binding-display/ds4.svg create mode 100644 images/binding-display/ds5.svg create mode 100644 images/binding-display/x360.svg diff --git a/images/binding-display/ds4.svg b/images/binding-display/ds4.svg new file mode 100644 index 000000000..5184b84fa --- /dev/null +++ b/images/binding-display/ds4.svg @@ -0,0 +1 @@ +X \ No newline at end of file diff --git a/images/binding-display/ds5.svg b/images/binding-display/ds5.svg new file mode 100644 index 000000000..2501e08e2 --- /dev/null +++ b/images/binding-display/ds5.svg @@ -0,0 +1 @@ +X \ No newline at end of file diff --git a/images/binding-display/x360.svg b/images/binding-display/x360.svg new file mode 100644 index 000000000..96821e2dd --- /dev/null +++ b/images/binding-display/x360.svg @@ -0,0 +1 @@ +X \ No newline at end of file diff --git a/scc/osd/binding_display.py b/scc/osd/binding_display.py index e761c06db..37f1a89ff 100644 --- a/scc/osd/binding_display.py +++ b/scc/osd/binding_display.py @@ -564,6 +564,35 @@ def _rstick(p: Profile) -> Action | None: # unbound and their boxes render nothing, so the shared list is safe. LAYOUTS["deck"] = LAYOUTS["sc2"] +# Standard gamepads (DualShock 4, DualSense, Xbox 360). Their control model +# differs from the Steam controllers: the right stick is the right pad +# (pads[RIGHT], not rstick) and the d-pad is the left pad (pads[LEFT]); there are +# no trackpads or grip-touch. Same six-box frame. ds4/ds5/x360 are physically +# alike, so they share one layout. +_GAMEPAD_LAYOUT = [ + dict(name="system", align=Align.TOP, ax=0, max_width_f=0.4, max_height_f=0.22, + controls=[("BACK", _B, _btn("BACK")), ("C", _B, _btn("C")), + ("START", _B, _btn("START"))]), + dict(name="lshoulder", align=Align.LEFT | Align.TOP, + min_width_f=0.18, max_width_f=0.27, max_height_f=0.42, + controls=[("LT", _T, _trig(LEFT)), ("LB", _B, _btn("LB")), + ("LGRIP", _B, _btn("LGRIP"))]), + dict(name="rshoulder", align=Align.RIGHT | Align.TOP, + min_width_f=0.18, max_width_f=0.27, max_height_f=0.42, + controls=[("RT", _T, _trig(RIGHT)), ("RB", _B, _btn("RB")), + ("RGRIP", _B, _btn("RGRIP"))]), + dict(name="lthumb", align=Align.LEFT | Align.BOTTOM, + min_width_f=0.18, max_width_f=0.27, max_height_f=0.42, + controls=[("STICK", _S, _stick), ("DPAD", _P, _pad(LEFT))]), + dict(name="rthumb", align=Align.RIGHT | Align.BOTTOM, + min_width_f=0.18, max_width_f=0.27, max_height_f=0.42, + controls=[("RSTICK", _P, _pad(RIGHT))]), + dict(name="face", align=Align.BOTTOM, ax=0, max_width_f=0.4, max_height_f=0.22, + controls=[("A", _B, _btn("A")), ("B", _B, _btn("B")), + ("X", _B, _btn("X")), ("Y", _B, _btn("Y"))]), +] +LAYOUTS["ds4"] = LAYOUTS["ds5"] = LAYOUTS["x360"] = _GAMEPAD_LAYOUT + class Generator: PADDING = 10 diff --git a/tools/gen_binding_display.py b/tools/gen_binding_display.py index 6473386fa..3ebffe9d5 100644 --- a/tools/gen_binding_display.py +++ b/tools/gen_binding_display.py @@ -58,6 +58,15 @@ GRAY_SPLIT = 80 # fill luminance split between GRAY_LIGHT and GRAY_DARK MARKER_GREEN = "#06a400" # marker rings + connector lines (matches Generator) +# Standard gamepads (ds4, ds5, x360) share one anchor set: left stick + d-pad +# (LPAD) on the left, right stick (RPAD) on the right, the ABXY face cluster, and +# the top bumpers/triggers. Their drawings use the same AREA_* names. +_GAMEPAD_MARKERS = { + "system": ["BACK", "START"], "lshoulder": ["LB_1", "LT_1"], + "rshoulder": ["RB_4", "RT_1"], "lthumb": ["STICK_1", "LPAD_1"], + "rthumb": ["RPAD_1"], "face": ["Y", "A"], +} + # Per-controller source drawing + the AREA_* anchors each binding box points at. # The box names match scc/osd/binding_display.py LAYOUTS[]. A box draws at # most two connector lines; anchor names differ per controller image. @@ -79,6 +88,9 @@ "rthumb": ["RSTICK", "RPAD_1"], "face": ["Y", "A"], }, }, + "ds4": {"src": "images/controller-images/ds4.svg", "markers": _GAMEPAD_MARKERS}, + "ds5": {"src": "images/controller-images/ds5.svg", "markers": _GAMEPAD_MARKERS}, + "x360": {"src": "images/controller-images/x360.svg", "markers": _GAMEPAD_MARKERS}, } _FILL = re.compile(r"fill:\s*#([0-9a-fA-F]{3,6})") From efa2a50dcf5e4ac5d27706649647daec82a306fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 5 Jul 2026 00:18:02 +0200 Subject: [PATCH 53/74] input-test: square the degenerate stick/pad test-areas Input Test moves a test-cursor inside each control's invisible AREA_*TEST rect, scaling the motion by the rect's width and height. Several controller images ship those rects flattened to ~0-1px tall (ds4/ds5/x360/remotepad, and the unwired ps1/psx/snes), so the cursor could only move horizontally -- the left stick showed no vertical motion, and the pads barely moved. Square each degenerate rect (height = width, keep its centre, which already sits on the control). These are hotspot rects, not visible art, so the drawing is untouched. sc/sc2/deck already have proper squares and are left alone. Co-Authored-By: Claude Opus 4.8 --- images/controller-images/ds4.svg | 12 ++++++------ images/controller-images/ds5.svg | 12 ++++++------ images/controller-images/ps1.svg | 8 ++++---- images/controller-images/psx.svg | 12 ++++++------ images/controller-images/remotepad.svg | 12 ++++++------ images/controller-images/snes.svg | 8 ++++---- images/controller-images/x360.svg | 12 ++++++------ 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/images/controller-images/ds4.svg b/images/controller-images/ds4.svg index 02d6fedcf..17cfa8680 100644 --- a/images/controller-images/ds4.svg +++ b/images/controller-images/ds4.svg @@ -330,9 +330,9 @@ style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#00000a;fill-opacity:0.04313725;fill-rule:evenodd;stroke:#00b400;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" id="AREA_LPADTEST" width="90.008965" - height="1" + height="90.008965" x="46" - y="105" + y="60.495517" ry="0" /> @@ -344,9 +344,9 @@ style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#00000a;fill-opacity:0.04313725;fill-rule:evenodd;stroke:#00b400;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" id="AREA_RSTICKTEST" width="63.352852" - height="0.25254059" + height="63.352852" x="46.561966" - y="79.079262" + y="47.529106" ry="0" /> @@ -317,9 +317,9 @@ ry="0" /> diff --git a/images/controller-images/x360.svg b/images/controller-images/x360.svg index 3ff1d0609..07cecb931 100644 --- a/images/controller-images/x360.svg +++ b/images/controller-images/x360.svg @@ -427,9 +427,9 @@ ry="0" /> @@ -451,17 +451,17 @@ ry="0" /> From 6dd57ef49fb396ae4c37eb6b156c32a1cf4120d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 5 Jul 2026 00:18:11 +0200 Subject: [PATCH 54/74] input-test: track and highlight the DS4/DS5 touchpad The Input Test observe list never included the touchpad. Add a cpad test-cursor and observe CPAD -- mapped to the touchpad's AREA_CPAD rect (a real rectangle, so no *TEST square is needed) -- so the cursor tracks the finger; the daemon emits CPAD positionally only while touched, so it hides on release like the other pads. Also observe CPADPRESS so a touchpad click brightens the CPADPRESS element. Harmless on controllers without a touchpad (neither source ever fires). Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scc/gui/app.py b/scc/gui/app.py index 81a15b3ea..c427b7a45 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -190,6 +190,7 @@ def setup_widgets(self) -> None: self.main_area.put(self.stick_test, 150, 40) self.main_area.put(self.rstick_test, 290, 40) self.main_area.put(self.dpad_test, 40, 90) + self.main_area.put(self.cpad_test, 150, 90) # Headerbar headerbar(self.builder.get_object("hbWindow")) From 822fa7efce36969842bb03db13f42a04e295386d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 5 Jul 2026 01:15:34 +0200 Subject: [PATCH 55/74] mapper: guard rstick/dpad state access for gamepads on the HID decoder DS4/DS5 set HAS_RSTICK and HAS_DPAD, but store the right stick as the right pad and the d-pad as a hatswitch, so their generic HID state (HIDControllerInput) has no rstick_* / dpad_* fields. The mapper read them unconditionally, so every input event raised AttributeError -- caught, but only after aborting the rest of input processing. That silently killed the right stick, triggers and touchpad on the DS4 (everything after the sticks block), while buttons and the left stick, handled earlier, still worked. Guard both accesses with hasattr(state, ...). Controllers with a real rstick/dpad in their state (Steam Controller 2, Deck) are unaffected; gamepads on the generic HID decoder skip the fields they don't have and process the rest normally. Co-Authored-By: Claude Opus 4.8 --- scc/mapper.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scc/mapper.py b/scc/mapper.py index 7615342ec..0e4632981 100644 --- a/scc/mapper.py +++ b/scc/mapper.py @@ -443,7 +443,14 @@ def input(self, controller: Controller, old_state, state) -> None: elif not self.buttons & SCButtons.LPADTOUCH: if FE_STICK in fe or self.old_state.lpad_x != state.lpad_x or self.old_state.lpad_y != state.lpad_y: self.profile.stick.whole(self, state.lpad_x, state.lpad_y, STICK) - if self.controller.flags & ControllerFlags.HAS_RSTICK: + # HAS_RSTICK controllers store the right stick either as a real rstick + # (Steam Controller 2 / Deck) or, for gamepads on the generic HID decoder + # (DS4/DS5), as the right pad (pads[RIGHT]). The latter's state struct + # (HIDControllerInput) has no rstick_* fields, so guard the access: + # without it every event raised AttributeError here, which aborted the + # rest of input processing (right pad, triggers, touchpad) -- the reason + # those controls were dead on the DS4. + if self.controller.flags & ControllerFlags.HAS_RSTICK and hasattr(state, "rstick_x"): if ( FE_STICK in fe or self.old_state.rstick_x != state.rstick_x From b8fadc6d2ec78b9e8c179c6b181bb8e7e2a4bac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 5 Jul 2026 23:20:16 +0200 Subject: [PATCH 56/74] modifiers: neutralize a released absolute-gyro action in ModeModifier When a mode-shift (e.g. a gyro-enable button) deselects a gyro action, ModeModifier zeroed it by calling gyro(0, 0, 0, ...). That neutralizes a relative GyroAction (its output is pitch/yaw/roll * speed), but a GyroAbsAction ignores those and reads q1-q4, so it kept emitting its last orientation and the output axis stayed stuck -- a held gamepad axis is continuous output, i.e. runaway. Reset each GyroAbsAction (re-taking its reference) before the zeroing call so it emits neutral, walking MultiAction children so mixed relative+absolute bindings are covered. Co-Authored-By: Claude Opus 4.8 --- scc/modifiers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scc/modifiers.py b/scc/modifiers.py index 1b3e66fe6..5f24d1be6 100644 --- a/scc/modifiers.py +++ b/scc/modifiers.py @@ -1037,6 +1037,16 @@ def gyro(self, mapper, pitch, yaw, roll, *q): sel = self.select(mapper) if sel is not self.old_action: if self.old_action: + # Neutralize the outgoing gyro action so its output axis doesn't stay + # stuck when the enable button is released. Relative GyroAction zeroes + # on (0,0,0), but GyroAbsAction ignores pitch/yaw/roll (it tracks + # q1-q4), so it would emit its last orientation and leave the axis + # deflected. Reset each GyroAbsAction's reference first (the only gyro + # action with reset()) so the neutralizing call below emits 0. Covers + # MultiAction (mixed relative+absolute) via its .actions children. + for a in getattr(self.old_action, "actions", None) or (self.old_action,): + if hasattr(a, "reset"): + a.reset() self.old_action.gyro(mapper, 0, 0, 0, *q) self.old_action = sel return sel.gyro(mapper, pitch, yaw, roll, *q) From 130de92c143c78e7c513b7e7b1d20dacdd6801ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 5 Jul 2026 23:21:01 +0200 Subject: [PATCH 57/74] gui: fix gyro Per-Axis mouse-axis labels + add a Clear button The gyro Per-Axis editor forced every axis through AxisAction, so a mouse axis (REL_*) mislabeled as "LStick" and the "Select Axis" chooser highlighted the stick for it. Root cause: Axes and Rels are IntEnums with colliding values (ABS_X == REL_X), so value-based checks misfire; use isinstance in the label and in the chooser's display_action. Also stop hide_mouse() from greying out the mouse arrows (a GyroAbsAction validly maps to REL_X/REL_Y), and add a Clear button to the axis chooser so an axis can be unset. (The mouse axis still serializes/round-trips as a stick axis -- the same collision in the save/load path -- so gamepad axes remain the reliable gyro target; that fix is tracked in TODO.) Co-Authored-By: Claude Opus 4.8 --- glade/simple_chooser.glade | 9 ++++++++- scc/gui/ae/gyro.py | 27 ++++++++++++++++++++++----- scc/gui/simple_chooser.py | 9 +++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/glade/simple_chooser.glade b/glade/simple_chooser.glade index bce863de3..98f4d2696 100644 --- a/glade/simple_chooser.glade +++ b/glade/simple_chooser.glade @@ -17,7 +17,14 @@ False True - + + Clear + True + True + True + Unset this axis + + diff --git a/scc/gui/ae/gyro.py b/scc/gui/ae/gyro.py index 78c4e46fd..82a5de253 100644 --- a/scc/gui/ae/gyro.py +++ b/scc/gui/ae/gyro.py @@ -5,8 +5,9 @@ import itertools import logging -from scc.actions import Action, AxisAction, GyroAbsAction, GyroAction, MultiAction, NoAction, RangeOP +from scc.actions import Action, AxisAction, GyroAbsAction, GyroAction, MouseAction, MultiAction, NoAction, RangeOP from scc.constants import STICK, SCButtons +from scc.uinput import Rels from scc.gui.ae import AEComponent, describe_action from scc.gui.ae.gyro_action import TRIGGERS, fill_buttons, is_gyro_enable from scc.gui.simple_chooser import SimpleChooser @@ -88,14 +89,24 @@ def on_select_axis(self, source, *a): i = self.buttons.index(source) def cb(action): - self.axes[i] = action.parameters[0] + self.axes[i] = None if isinstance(action, NoAction) else action.parameters[0] self.update() self.send() b = SimpleChooser(self.app, "axis", cb) b.set_title(_("Select Axis")) - b.hide_mouse() - b.display_action(Action.AC_STICK, AxisAction(self.axes[i])) + b.show_clear() + # Mouse is a valid target here: an axis marked "Absolute" becomes a + # GyroAbsAction, which maps orientation to REL_X/REL_Y (mapper.mouse_move). + # (Relative GyroAction ignores mouse -- use the dedicated Mouse gyro editor + # for that.) hide_mouse() wrongly blocked it, greying out the mouse arrows. + # + # Show the current axis with the matching action class, or the chooser + # highlights the stick for a mouse axis (Axes/Rels value collision) and + # re-confirming would silently retarget the binding to the stick. + axis = self.axes[i] + current = MouseAction(axis) if isinstance(axis, Rels) else AxisAction(axis) + b.display_action(Action.AC_STICK, current) b.show(self.editor.window) def on_abs_changed(self, source, *a): @@ -143,7 +154,13 @@ def on_sclSoftLevel_format_value(self, scale, value): def update(self, *a): for i in range(3): - self.labels[i].set_label(describe_action(Action.AC_STICK, AxisAction, self.axes[i])) + # A mouse axis (REL_*) must be described as a MouseAction; forcing it + # through AxisAction mislabels "Mouse X/Y" as "LStick X/Y". Use an + # isinstance check, not "in Rels.values()" -- Axes and Rels are IntEnums + # with overlapping values, so ABS_X == REL_X and membership misfires. + axis = self.axes[i] + cls = MouseAction if isinstance(axis, Rels) else AxisAction + self.labels[i].set_label(describe_action(Action.AC_STICK, cls, axis)) def send(self, *a): if self._recursing: diff --git a/scc/gui/simple_chooser.py b/scc/gui/simple_chooser.py index 074ceebd0..ae33f868b 100644 --- a/scc/gui/simple_chooser.py +++ b/scc/gui/simple_chooser.py @@ -8,6 +8,7 @@ import importlib import logging +from scc.actions import NoAction from scc.gui.ae import AEComponent from scc.gui.dwsnc import headerbar from scc.gui.editor import Editor @@ -61,3 +62,11 @@ def hide_axes(self): def hide_mouse(self): """Prevents user from selecting mouse-related stuff""" self.component.hide_mouse() + + def show_clear(self): + """Reveals a 'Clear' button. The caller's callback must accept a NoAction + (i.e. handle the unset case).""" + self.builder.get_object("btClear").set_visible(True) + + def on_btClear_clicked(self, *a): + self.set_action(NoAction()) From 8bbc72ce329e665970db9b2edf3864afa2cfd846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Tue, 7 Jul 2026 00:40:35 +0200 Subject: [PATCH 58/74] fix(gyro,gui): make gyro->mouse fully work (routing, labels, direction, highlight) Absolute gyro could target Mouse X/Y, but a family of Axes/Rels IntEnum collisions -- plus Rels.REL_X having integer value 0 (falsy) -- broke it: - GyroAbsAction.gyro routed REL_X/REL_Y into the gamepad branch, because `axis in Axes.__members__.values()` is True for them (REL_X == ABS_X == 0, REL_Y == ABS_Y == 1), so gyro->mouse moved the stick, not the cursor. Use isinstance(axis, Axes) so the mouse branches run. Same fix in GyroAction.gyro. - MouseAction.__init__ did `self._mouse_axis = axis or None`, collapsing REL_X (value 0, falsy) to None -- describing it as "Mouse" (not "Mouse X") and moving both axes. Assign directly. - GyroAction.describe used `if x:` (skipping REL_X) and a colliding `in Rels.__members__.values()` that returned a bare "Mouse". Rewrite it per-axis, `is not None`, isinstance-aware -> "Mouse X" / "Mouse Y". - Mouse Y was inverted: negate REL_Y (screen Y grows downward) so tilting up moves the cursor up. X needed no flip. - action_to_area never highlighted a configured Mouse X/Y/Wheel in the axis chooser: the whole-axis mouse entries carried a redundant trailing "1" (2-param, and a duplicate of MOUSE_RIGHT), so the matcher skipped them against the bare 1-param MouseAction the editors store. Make MOUSE_X/Y/WHEEL/HWHEEL bare, mirroring the bare stick entries (ABS_X etc.). Verified on DS4 hardware: gyro-absolute -> Mouse X/Y moves the cursor with the correct direction, labels read "Mouse X"/"Mouse Y", the axis dialog highlights them, and stick axes / relative mode are unaffected. Co-Authored-By: Claude Opus 4.8 --- scc/actions.py | 39 +++++++++++++++++++++++++++------------ scc/gui/area_to_action.py | 13 +++++++++---- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/scc/actions.py b/scc/actions.py index c81e9886e..f1f7fb70f 100644 --- a/scc/actions.py +++ b/scc/actions.py @@ -797,7 +797,10 @@ class MouseAction(WholeHapticAction, Action): def __init__(self, axis=None, speed=None): Action.__init__(self, *strip_none(axis, speed)) WholeHapticAction.__init__(self) - self._mouse_axis = axis or None + # NOT `axis or None`: Rels.REL_X has integer value 0, which is falsy, so + # `or None` would collapse REL_X to None -- describing it as "Mouse" (not + # "Mouse X") and moving both axes instead of just X. + self._mouse_axis = axis if axis is not None else None self._old_pos = None if speed: self.speed = (speed, speed) @@ -1175,8 +1178,11 @@ def get_speed(self): def gyro(self, mapper: Mapper, *pyr): for i in (0, 1, 2): axis = self.axes[i] - # 'gyro' cannot map to mouse, but 'mouse' does that. - if axis in Axes.__members__.values() or type(axis) is int: + # 'gyro' cannot map to mouse, but 'mouse' does that. isinstance, not + # `in Axes.__members__.values()`: Rels and Axes are IntEnums with + # overlapping values (REL_X == ABS_X == 0), so the membership test + # would misroute a mouse axis here as a gamepad axis. + if isinstance(axis, Axes) or type(axis) is int: mapper.gamepad.axisEvent(axis, AxisAction.clamp_axis(axis, pyr[i] * self.speed[i] * -10)) mapper.syn_list.add(mapper.gamepad) @@ -1184,15 +1190,18 @@ def describe(self, context): if self.name: return self.name rv = [] - - if self.axes[0] in Rels.__members__.values(): - return _("Mouse") - for x in self.axes: - if x: + # `is not None`, not truthiness: Rels.REL_X / Axes.ABS_X have value 0 + # (falsy) yet are valid axes. isinstance keeps mouse (Rels) apart from + # stick (Axes) -- their integer values collide (REL_X == ABS_X == 0). + if x is None: + continue + if isinstance(x, Rels): + s = MouseAction(x).describe(context) + else: s, trash, trash = AxisAction.get_axis_description(x) - if s not in rv: - rv.append(s) + if s not in rv: + rv.append(s) return "\n".join(rv) @@ -1253,7 +1262,11 @@ def gyro(self, mapper: Mapper, pitch, yaw, roll, q1, q2, q3, q4): pyr[i] = int(clamp(STICK_PAD_MIN, pyr[i], STICK_PAD_MAX)) for i in self.GYROAXES: axis = self.axes[i] - if axis in Axes.__members__.values() or type(axis) == int: + # isinstance, not `in Axes.__members__.values()`: REL_X == ABS_X == 0 + # and REL_Y == ABS_Y == 1 by IntEnum value, so the membership test + # swallowed the mouse axes into this gamepad branch (the elifs below + # never ran) -- gyro->mouse moved the stick instead of the cursor. + if isinstance(axis, Axes) or type(axis) == int: val = AxisAction.clamp_axis(axis, pyr[i] * self.speed[i]) if self._deadzone_fn: val, trash = self._deadzone_fn(val, 0, STICK_PAD_MAX) @@ -1263,7 +1276,9 @@ def gyro(self, mapper: Mapper, pitch, yaw, roll, q1, q2, q3, q4): elif axis == Rels.REL_X: mapper.mouse_move(AxisAction.clamp_axis(axis, pyr[i] * GyroAbsAction.MOUSE_FACTOR * self.speed[i]), 0) elif axis == Rels.REL_Y: - mapper.mouse_move(0, AxisAction.clamp_axis(axis, pyr[i] * GyroAbsAction.MOUSE_FACTOR * self.speed[i])) + # Screen Y grows downward, so negate: tilting/looking up moves the + # cursor up. (REL_X needs no flip -- verified on hardware.) + mapper.mouse_move(0, -AxisAction.clamp_axis(axis, pyr[i] * GyroAbsAction.MOUSE_FACTOR * self.speed[i])) class ResetGyroAction(Action): diff --git a/scc/gui/area_to_action.py b/scc/gui/area_to_action.py index 870bd8aa7..2987043df 100644 --- a/scc/gui/area_to_action.py +++ b/scc/gui/area_to_action.py @@ -80,10 +80,15 @@ Rels.REL_Y, 1, ), - "MOUSE_X": (MouseAction, Rels.REL_X, 1), - "MOUSE_Y": (MouseAction, Rels.REL_Y, 1), - "MOUSE_WHEEL": (MouseAction, Rels.REL_WHEEL, 1), - "MOUSE_HWHEEL": (MouseAction, Rels.REL_HWHEEL, 1), + # Full-axis (whole) mouse entries are bare, mirroring the bare stick entries + # (ABS_X etc.) -- the whole X axis is MouseAction(REL_X), no direction. The + # trailing "1" made these 2-param, so action_to_area could never match the + # 1-param MouseAction the editors store (gyro Mouse X/Y went un-highlighted), + # and it duplicated the directional MOUSE_LEFT/RIGHT/UP/DOWN entries anyway. + "MOUSE_X": (MouseAction, Rels.REL_X), + "MOUSE_Y": (MouseAction, Rels.REL_Y), + "MOUSE_WHEEL": (MouseAction, Rels.REL_WHEEL), + "MOUSE_HWHEEL": (MouseAction, Rels.REL_HWHEEL), # Mouse buttons "MOUSE1": (ButtonAction, Keys.BTN_LEFT), "MOUSE2": (ButtonAction, Keys.BTN_MIDDLE), From bcb56a2ab694b6879d51fd09638c6f07ee410dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Thu, 9 Jul 2026 18:24:56 +0200 Subject: [PATCH 59/74] fix(actions): decode euler gyros in TiltAction (rest false-fires, axis map) TiltAction.gyro decoded q1-q4 as a quaternion unconditionally; it never got the EUREL_GYROS branch GyroAbsAction has. On euler controllers (DS4) q1-q3 hold euler angles in 2**15/PI fixed point with q4 always 0, so quat2euler computed atan2 of near-zero noise products -- arbitrary full-range angles that constantly crossed the +-0.75 rad threshold and fired tilt actions (continuous yaw output) with the pad at rest on the table. Read q1-q3 directly as euler when the controller has EUREL_GYROS, mapped to the slot wiring: slots are (front down/up, TILTED left/right, ROTATED left/right) = (pitch, roll, yaw), so yaw/roll are swapped into that order, and pitch/yaw are negated to match the slot firing directions. All six motions plus rest-silence verified on DS4 hardware. The quaternion path for other controllers is unchanged. Co-Authored-By: Claude Opus 4.8 --- scc/actions.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scc/actions.py b/scc/actions.py index f1f7fb70f..feaa39933 100644 --- a/scc/actions.py +++ b/scc/actions.py @@ -1364,7 +1364,19 @@ def get_compatible_modifiers(self): def gyro(self, mapper: Mapper, *pyr): q1, q2, q3, q4 = pyr[-4:] - pyr = quat2euler(q1 / 32767.0, q2 / 32767.0, q3 / 32767.0, q4 / 32767.0) + if mapper.get_controller().flags & ControllerFlags.EUREL_GYROS: + # q1-q3 already hold euler angles in 2**15/PI fixed point (q4 unused). + # Feeding them into quat2euler as if they were a quaternion computes + # atan2 of near-zero noise products -> arbitrary full-range angles that + # constantly cross MIN and fire tilt actions with the pad at rest. + # + # Slot order below is (front down/up, TILTED left/right, ROTATED + # left/right) = (pitch, roll, yaw), so swap yaw/roll into that order; + # pitch and yaw are negated to match the slot firing directions against + # the DS4 integration conventions (all three axes hw-verified). + pyr = (-q1 / 10430.37, q3 / 10430.37, -q2 / 10430.37) + else: + pyr = quat2euler(q1 / 32767.0, q2 / 32767.0, q3 / 32767.0, q4 / 32767.0) for j in (0, 1, 2): i = j * 2 if self.actions[i]: From 88f3fff290e6cec4d25cbe42e0f906a9419e7d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 10 Jul 2026 04:13:12 +0200 Subject: [PATCH 60/74] gyro: intuitive mouse semantics -- Absolute = laser pointer, relative = lean-to-turn The gyro->mouse mapping had the semantics backwards and half-dead: with "Absolute" checked, the held angle was fed to mouse_move every frame, making cursor VELOCITY proportional to tilt (a joystick semantic on a delta device: 90 deg scrolled faster than 45 and never stopped); with it unchecked, mouse axes did nothing at all (GyroAction skipped Rels by design). New semantics, matched against Steam's gyro-mouse: - Absolute checked (GyroAbsAction): laser pointer. The angular rate is the move delta, exactly like MouseAction.gyro (the dedicated Mouse gyro editor); the rate integrates to the rotation angle, so the cursor tracks the controller's absolute orientation and stops when the rotation stops. Per-gyro-axis signs (pitch +, yaw -, roll -) hw-verified on the DS4. - Unchecked (GyroAction): lean-to-turn. Cursor velocity is proportional to the held tilt angle (saturating at +-90 deg): lean and it keeps moving, return to level and it stops. Uses the fused absolute angle (EUREL or quat2euler), so "level = stop" is anchored to gravity for pitch/roll. Useful where holding a leaned position should keep turning. Stick axes are unchanged in both modes (absolute = deflection follows the held angle; relative = deflection follows the rate). The now-unused GyroAbsAction.MOUSE_FACTOR velocity constant moves to GyroAction, and the gyro editor comment is updated. All verified on DS4 hardware. Co-Authored-By: Claude Opus 4.8 --- scc/actions.py | 45 ++++++++++++++++++++++++++++++++++++--------- scc/gui/ae/gyro.py | 9 +++++---- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/scc/actions.py b/scc/actions.py index feaa39933..1c3d709d0 100644 --- a/scc/actions.py +++ b/scc/actions.py @@ -1160,6 +1160,11 @@ class GyroAction(Action): """Uses *relative* gyroscope position as input for emulated axes""" COMMAND = "gyro" + # Mouse-path tuning, shared with GyroAbsAction. RATE_SIGN is per gyro axis + # (pitch, yaw, roll), hw-verified on the DS4. MOUSE_FACTOR scales the + # lean-to-turn cursor velocity into a sane default range. + MOUSE_RATE_SIGN = (1.0, -1.0, -1.0) + MOUSE_FACTOR = 0.01 def __init__(self, axis1, axis2=None, axis3=None): Action.__init__(self, axis1, *strip_none(axis2, axis3)) @@ -1176,15 +1181,34 @@ def get_speed(self): return self.speed def gyro(self, mapper: Mapper, *pyr): + angles = None for i in (0, 1, 2): axis = self.axes[i] - # 'gyro' cannot map to mouse, but 'mouse' does that. isinstance, not - # `in Axes.__members__.values()`: Rels and Axes are IntEnums with - # overlapping values (REL_X == ABS_X == 0), so the membership test - # would misroute a mouse axis here as a gamepad axis. + # isinstance, not `in Axes.__members__.values()`: Rels and Axes are + # IntEnums with overlapping values (REL_X == ABS_X == 0), so the + # membership test would misroute a mouse axis here as a gamepad axis. if isinstance(axis, Axes) or type(axis) is int: mapper.gamepad.axisEvent(axis, AxisAction.clamp_axis(axis, pyr[i] * self.speed[i] * -10)) mapper.syn_list.add(mapper.gamepad) + # Relative mouse = lean-to-turn: cursor VELOCITY is proportional to + # the held tilt angle -- lean and the cursor keeps moving, return to + # level and it stops. (For laser-pointer tracking, where the cursor + # follows the rotation and stops with it, check Absolute.) + elif axis in (Rels.REL_X, Rels.REL_Y) and len(pyr) >= 7: + if angles is None: + q1, q2, q3, q4 = pyr[3:7] + if mapper.get_controller().flags & ControllerFlags.EUREL_GYROS: + angles = (q1 / 10430.37, q2 / 10430.37, q3 / 10430.37) # 2**15 / PI + else: + angles = quat2euler(q1 / 32767.0, q2 / 32767.0, q3 / 32767.0, q4 / 32767.0) + # saturate at +-90 deg, then scale to a sane default velocity + v = clamp(STICK_PAD_MIN, angles[i] * (2**15) * 2 / PI, STICK_PAD_MAX) + v = v * GyroAction.MOUSE_FACTOR * self.speed[i] + if axis == Rels.REL_X: + mapper.mouse_move(v, 0) + else: + # screen Y grows downward (sign hw-verified on the DS4) + mapper.mouse_move(0, -v) def describe(self, context): if self.name: @@ -1209,7 +1233,6 @@ class GyroAbsAction(HapticEnabledAction, GyroAction): """Uses *absolute* gyroscope position as input for emulated axes""" COMMAND = "gyroabs" - MOUSE_FACTOR = 0.01 # Just random number to put default sensitivity into sane range def __init__(self, *blah): GyroAction.__init__(self, *blah) @@ -1234,6 +1257,7 @@ def get_previewable(self) -> bool: GYROAXES = (0, 1, 2) def gyro(self, mapper: Mapper, pitch, yaw, roll, q1, q2, q3, q4): + rates = (pitch, yaw, roll) # raw angular rates, used for the mouse axes if mapper.get_controller().flags & ControllerFlags.EUREL_GYROS: pyr = [q1 / 10430.37, q2 / 10430.37, q3 / 10430.37] # 2**15 / PI else: @@ -1273,12 +1297,15 @@ def gyro(self, mapper: Mapper, pitch, yaw, roll, q1, q2, q3, q4): val = int(val) mapper.gamepad.axisEvent(axis, val) mapper.syn_list.add(mapper.gamepad) + # Absolute mouse = laser pointer: the angular RATE is the move delta + # (like MouseAction.gyro); the rate integrates to the rotation angle, + # so the cursor tracks the controller's absolute orientation and stops + # when the rotation stops (Steam's gyro-mouse behavior). For + # angle-proportional cursor velocity (lean-to-turn), uncheck Absolute. elif axis == Rels.REL_X: - mapper.mouse_move(AxisAction.clamp_axis(axis, pyr[i] * GyroAbsAction.MOUSE_FACTOR * self.speed[i]), 0) + mapper.mouse_move(rates[i] * GyroAction.MOUSE_RATE_SIGN[i] * self.speed[i], 0) elif axis == Rels.REL_Y: - # Screen Y grows downward, so negate: tilting/looking up moves the - # cursor up. (REL_X needs no flip -- verified on hardware.) - mapper.mouse_move(0, -AxisAction.clamp_axis(axis, pyr[i] * GyroAbsAction.MOUSE_FACTOR * self.speed[i])) + mapper.mouse_move(0, rates[i] * GyroAction.MOUSE_RATE_SIGN[i] * self.speed[i]) class ResetGyroAction(Action): diff --git a/scc/gui/ae/gyro.py b/scc/gui/ae/gyro.py index 82a5de253..768903b84 100644 --- a/scc/gui/ae/gyro.py +++ b/scc/gui/ae/gyro.py @@ -96,10 +96,11 @@ def cb(action): b = SimpleChooser(self.app, "axis", cb) b.set_title(_("Select Axis")) b.show_clear() - # Mouse is a valid target here: an axis marked "Absolute" becomes a - # GyroAbsAction, which maps orientation to REL_X/REL_Y (mapper.mouse_move). - # (Relative GyroAction ignores mouse -- use the dedicated Mouse gyro editor - # for that.) hide_mouse() wrongly blocked it, greying out the mouse arrows. + # Mouse is a valid target here in both modes: Absolute checked gives + # laser-pointer tracking (cursor follows the rotation, Steam-style, + # rate-based); unchecked gives lean-to-turn (cursor velocity follows the + # held tilt angle). hide_mouse() wrongly blocked it, greying out the + # mouse arrows. # # Show the current axis with the matching action class, or the chooser # highlights the stick for a mouse axis (Axes/Rels value collision) and From 2f904eca4955908ce457d1bb46503977ac01b333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sat, 11 Jul 2026 09:07:42 +0200 Subject: [PATCH 61/74] tests,docs: cover the 'inverted' modifier (3 long-failing meta-tests) The InvertedButtonModifier ("act on release") shipped without a docs anchor in docs/actions.md or test_inverted methods, so the suite's completeness meta-tests (test_every_action_has_docs and both TestModifiers.test_tests) have been failing since the feature landed. Nobody noticed because the AppImage build's test step silently never ran (see the next commit). Add the actions.md entry and parser + profile round-trip tests. The full suite is green, unfiltered: 160 passed. Co-Authored-By: Claude Opus 4.8 --- docs/actions.md | 8 ++++++++ tests/test_parser/test_modifiers.py | 7 +++++++ tests/test_profile/test_modifiers.py | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/docs/actions.md b/docs/actions.md index fa49425e8..5b3b8dfa8 100755 --- a/docs/actions.md +++ b/docs/actions.md @@ -325,6 +325,14 @@ A button whenever physical button is pressed. #### released(action) Creates action that occurs for brief moment when button is released. +#### inverted(action) +Acts on release: swaps press and release, so the wrapped action is held while +the physical button is NOT pressed and released while it is. Meant for +always-on sensors such as the capacitive handle grips, which read "on" the +whole time the controller is held - inverting them fires the action when you +let go. Unlike `pressed`/`released`, which emit a momentary tap, this is a +true held inversion of the button state. + #### pressed(action) Creates action that occurs for brief moment when finger touches pad. diff --git a/tests/test_parser/test_modifiers.py b/tests/test_parser/test_modifiers.py index 303ba8029..133902910 100644 --- a/tests/test_parser/test_modifiers.py +++ b/tests/test_parser/test_modifiers.py @@ -37,6 +37,13 @@ def test_released(self): a = _parse_compressed("pressed(axis(KEY_A))") assert isinstance(a, PressedModifier) + def test_inverted(self): + """Tests if InvertedButtonModifier is parsed + """ + a = _parse_compressed("inverted(button(KEY_A))") + assert isinstance(a, InvertedButtonModifier) + assert isinstance(a.action, ButtonAction) + def test_touched(self): """Tests if TouchedModifier is parsed""" a = _parse_compressed("touched(button(KEY_A))") diff --git a/tests/test_profile/test_modifiers.py b/tests/test_profile/test_modifiers.py index 81fa99383..f2195074b 100644 --- a/tests/test_profile/test_modifiers.py +++ b/tests/test_profile/test_modifiers.py @@ -53,6 +53,13 @@ def test_released(self): assert isinstance(a, ReleasedModifier) assert _is_axis_with_value(a.action) + def test_inverted(self): + """Tests if InvertedButtonModifier is parsed correctly from json. + """ + a = parser.from_json_data({"action": "inverted(axis(ABS_X))"}) + assert isinstance(a, InvertedButtonModifier) + assert _is_axis_with_value(a.action) + def test_touched(self): """Tests if TouchedModifier is parsed correctly from json.""" a = parser.from_json_data({"action": "touched(button(KEY_A))"}) From 60d8d16d2e93cf47253ab08ee42f1331e8c188fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 12 Jul 2026 03:12:01 +0200 Subject: [PATCH 62/74] fix(gyro): align "Mouse (Desktop)" signs with the calibrated rate table MouseAction.gyro (the "Joystick or Mouse" tab's Mouse (Desktop) output) still hardcoded its pre-calibration negation of all three rates, which inverted pitch (screen Y) once the DS4/SC2 drivers were normalized to the shared rate convention -- while its yaw/roll negation happened to match. Use GyroAction.MOUSE_RATE_SIGN (hw-verified on DS4 + SC2) as the single source of truth. Verified on SC2 hardware: pitch up now moves the cursor up. Note for the Steam Controller v1 (whose driver predates the normalization): if its rates run opposite, the correction belongs in sc_dongle.py -- drivers normalize to the one convention. Queued in the v1 regression pass. Co-Authored-By: Claude Opus 4.8 --- scc/actions.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scc/actions.py b/scc/actions.py index 1c3d709d0..15b9addeb 100644 --- a/scc/actions.py +++ b/scc/actions.py @@ -912,10 +912,16 @@ def whole(self, mapper: Mapper, x, y, what): self._old_pos = None def gyro(self, mapper: Mapper, pitch, yaw, roll, *a): + # Use the same per-gyro-axis rate signs as the Per-Axis mouse paths + # (GyroAction.MOUSE_RATE_SIGN, hw-verified on DS4 + SC2). The old + # hardcoded negation of ALL axes predates the drivers' rate-convention + # normalization; with normalized rates it inverted pitch (screen Y), + # while its yaw/roll negation happened to match the sign table. + sp, sy, sr = GyroAction.MOUSE_RATE_SIGN if self._mouse_axis == YAW: - mapper.mouse_move(yaw * -self.speed[0], pitch * -self.speed[1]) + mapper.mouse_move(yaw * sy * self.speed[0], pitch * sp * self.speed[1]) else: - mapper.mouse_move(roll * -self.speed[0], pitch * -self.speed[1]) + mapper.mouse_move(roll * sr * self.speed[0], pitch * sp * self.speed[1]) def trigger(self, mapper: Mapper, position, old_position): delta = position - old_position From 592ba3d12317337186e60f9ee803163c6d97d974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 12 Jul 2026 03:12:44 +0200 Subject: [PATCH 63/74] gui: per-controller grip/paddle button lists (gyro enablers, chords, labels) The button lists were static and Steam-Controller-v1-shaped, which broke down on the SC2 (reported by a user): - The gyro-enable dropdowns offered no way to gate the gyro on the SC2's capacitive handles -- the natural "aim while gripping" enabler. "Left/Right Grip" there is the rear upper paddle, which users read as the handle sensor. Add "Left/Right Grip Touched" (LGRIPTOUCH/RGRIPTOUCH) and the lower paddles (LGRIP2/RGRIP2) to both gyro editors' enabler lists. - On paddle controllers (sc2, deck) the four rear paddles are physically labeled L4/L5/R4/R5; calling them "Left Grip (2)" is confusing there, while the v1's squeeze grips must KEEP the grip naming. New button_label() helper renames just the paddles per controller type, applied to the gyro enabler lists, the modeshift/chord editor and the action editor header. - The reverse problem: the v1 (and anything else without them) must not see "Grip Touched" / "Grip 2" / stick-touch entries at all. New button_available() filters list entries against the controller's gui config "buttons" capability list -- restricted to an OPTIONAL_BUTTONS set whose presence that list records reliably, so configless controllers (e.g. DS4) never lose valid entries. Labels are display-only: profiles still store LGRIP/RGRIP2/... internally, so saved profiles and cross-controller reuse are unaffected. Verified on SC2 (L4/R4/L5/R5 + Touched entries, all functional as enablers) and v1 (classic grip naming, no phantom entries) hardware. Co-Authored-By: Claude Opus 4.8 --- scc/gui/ae/__init__.py | 57 +++++++++++++++++++++++++++++++++++++ scc/gui/ae/first_page.py | 11 +++++-- scc/gui/ae/gyro.py | 2 +- scc/gui/ae/gyro_action.py | 19 +++++++++++-- scc/gui/modeshift_editor.py | 10 +++++++ 5 files changed, 93 insertions(+), 6 deletions(-) diff --git a/scc/gui/ae/__init__.py b/scc/gui/ae/__init__.py index 70c3e54d6..2c545adb9 100644 --- a/scc/gui/ae/__init__.py +++ b/scc/gui/ae/__init__.py @@ -10,11 +10,68 @@ from gi.repository import Gdk, GLib, Gtk from scc.actions import Action, NoAction, XYAction +from scc.constants import SCButtons from scc.gui.editor import ComboSetter from scc.tools import _, ensure_size log = logging.getLogger("AE") +# Rear-paddle display names. On controllers whose four rear paddles are +# physically labeled L4/L5/R4/R5 (Steam Controller 2, Steam Deck) the generic +# "Left Grip (2)" naming is confusing -- especially on the SC2, where "grip" +# reads as the capacitive handle sensor instead. The Steam Controller v1's +# LGRIP/RGRIP are its squeeze grips and keep the "Left/Right Grip" naming. +PADDLE_TYPES = ("sc2", "deck") +PADDLE_NAMES = { + SCButtons.LGRIP: "L4", + SCButtons.RGRIP: "R4", + SCButtons.LGRIP2: "L5", + SCButtons.RGRIP2: "R5", +} + + +def button_label(app, button, default): + """Per-controller display name for a button: the rear paddles are + L4/L5/R4/R5 on paddle controllers (sc2/deck), the default (grip) name + elsewhere. `app` may be None (falls back to the default label).""" + ctype = None + try: + c = app.profile_switchers[0].get_controller() if app else None + ctype = c.get_type() if c else None + except Exception: + pass + if ctype in PADDLE_TYPES and button in PADDLE_NAMES: + return PADDLE_NAMES[button] + return default + + +# Buttons that only SOME controllers have and whose presence is reliably +# recorded in the controller's gui config "buttons" capability list (sc2 and +# deck ship configs; everything else falls back to DEFAULT_BUTTONS, which +# correctly lacks these). Only these are ever filtered out of button lists -- +# filtering arbitrary buttons against the capability list would wrongly hide +# valid entries on configless controllers (e.g. the DS4's stick presses). +OPTIONAL_BUTTONS = { + SCButtons.LGRIP2, SCButtons.RGRIP2, + SCButtons.LGRIPTOUCH, SCButtons.RGRIPTOUCH, + SCButtons.LSTICKTOUCH, SCButtons.RSTICKTOUCH, +} + + +def button_available(app, button) -> bool: + """True unless `button` is an optional extra (OPTIONAL_BUTTONS) that the + currently displayed controller's capability list does not include.""" + if button not in OPTIONAL_BUTTONS: + return True + try: + available = app.background.get_config()["buttons"] if app else None + except Exception: + available = None + if not available: + return True + from scc.tools import nameof + return nameof(button) in available + class AEComponent(ComboSetter): GLADE = None diff --git a/scc/gui/ae/first_page.py b/scc/gui/ae/first_page.py index 562b83090..7203c6115 100644 --- a/scc/gui/ae/first_page.py +++ b/scc/gui/ae/first_page.py @@ -6,7 +6,8 @@ import logging from scc.actions import Action -from scc.gui.ae import AEComponent +from scc.constants import SCButtons +from scc.gui.ae import AEComponent, button_label from scc.tools import _, nameof log = logging.getLogger("AE.1st") @@ -96,6 +97,8 @@ def load(self): "RPAD": _("Right Pad"), "LGRIP": _("Left Grip"), "RGRIP": _("Right Grip"), + "LGRIP2": _("Left Grip 2"), + "RGRIP2": _("Right Grip 2"), "LB": _("Left Bumper"), "RB": _("Right Bumper"), "LEFT": _("Left Trigger"), @@ -104,8 +107,12 @@ def load(self): "RSTICK": _("Right Stick"), } + name = nameof(self.editor.get_id()) + what = long_names.get(name, name.title()) + # Per-controller paddle naming (L4/L5/R4/R5 on sc2/deck) + what = button_label(self.app, getattr(SCButtons, name, None), what) markup = markup % { - "what": long_names.get(nameof(self.editor.get_id()), nameof(self.editor.get_id()).title()), + "what": what, } self.builder.get_object("lblMarkup").set_markup(markup.strip(" \r\n\t")) return True diff --git a/scc/gui/ae/gyro.py b/scc/gui/ae/gyro.py index 768903b84..6c4ab9794 100644 --- a/scc/gui/ae/gyro.py +++ b/scc/gui/ae/gyro.py @@ -37,7 +37,7 @@ def load(self): cbGyroButton = self.builder.get_object("cbGyroButton") self._recursing = True cbGyroButton = self.builder.get_object("cbGyroButton") - fill_buttons(cbGyroButton) + fill_buttons(cbGyroButton, self.app) self._recursing = False self.buttons = [self.builder.get_object(x) for x in ("btPitch", "btYaw", "btRoll")] self.cbs = [self.builder.get_object(x) for x in ("cbPitchAbs", "cbYawAbs", "cbRollAbs")] diff --git a/scc/gui/ae/gyro_action.py b/scc/gui/ae/gyro_action.py index 7b6775cd1..d2b09023d 100644 --- a/scc/gui/ae/gyro_action.py +++ b/scc/gui/ae/gyro_action.py @@ -6,7 +6,7 @@ from scc.actions import Action, GyroAbsAction, GyroAction, MouseAbsAction, MouseAction, MultiAction, NoAction, RangeOP from scc.constants import ROLL, STICK, YAW, SCButtons -from scc.gui.ae import AEComponent +from scc.gui.ae import AEComponent, button_available, button_label from scc.gui.parser import GuiActionParser from scc.modifiers import ModeModifier, SensitivityModifier from scc.special_actions import CemuHookAction @@ -38,8 +38,17 @@ class GyroActionComponent(AEComponent): (SCButtons.LPAD, _("Left Pad Pressed")), (SCButtons.RPAD, _("Right Pad Pressed")), (None, None), + # The rear paddles. Labels are per-controller (see button_label): + # L4/R4/L5/R5 on sc2/deck, Left/Right Grip (2) elsewhere. (SCButtons.LGRIP, _("Left Grip")), (SCButtons.RGRIP, _("Right Grip")), + (SCButtons.LGRIP2, _("Left Grip 2")), + (SCButtons.RGRIP2, _("Right Grip 2")), + # Capacitive handle sensors (Steam Controller 2). On the SC2 the + # entries above are the rear paddles; the handle TOUCH sensors are + # separate buttons -- and the natural "gyro while gripping" enabler. + (SCButtons.LGRIPTOUCH, _("Left Grip Touched")), + (SCButtons.RGRIPTOUCH, _("Right Grip Touched")), (STICK, _("Stick Tilted")), (None, None), (SCButtons.A, _("A")), @@ -66,7 +75,7 @@ def load(self) -> None: AEComponent.load(self) self._recursing = True cbGyroButton = self.builder.get_object("cbGyroButton") - fill_buttons(cbGyroButton) + fill_buttons(cbGyroButton, self.app) self._recursing = False def set_action(self, mode: int, action) -> None: @@ -312,9 +321,13 @@ def is_gyro_enable(modemod) -> bool: return False -def fill_buttons(cb): +def fill_buttons(cb, app=None): cb.set_row_separator_func(lambda model, iter: model.get_value(iter, 1) is None) model = cb.get_model() for button, text in GyroActionComponent.BUTTONS: + if button is not None: + if not button_available(app, button): + continue # e.g. grip-touch / GRIP2 on controllers without them + text = button_label(app, button, text) model.append((None if button is None else nameof(button), text)) cb.set_active(0) diff --git a/scc/gui/modeshift_editor.py b/scc/gui/modeshift_editor.py index 69a175f48..886b970d5 100644 --- a/scc/gui/modeshift_editor.py +++ b/scc/gui/modeshift_editor.py @@ -10,6 +10,7 @@ from scc.actions import Action, NoAction, RangeOP from scc.constants import HapticPos, SCButtons +from scc.gui.ae import button_available, button_label from scc.gui.controller_widget import PADS, STICKS from scc.gui.dwsnc import headerbar from scc.gui.editor import Editor @@ -102,6 +103,11 @@ def _fill_button_chooser(self, *a): if any([x[0] == item for x in self.actions[self.current_page]]): # Skip already added buttons continue + if isinstance(item, SCButtons): + if not button_available(self.app, item): + continue # optional button this controller doesn't have + # Per-controller paddle naming (L4/L5/R4/R5 on sc2/deck) + text = button_label(self.app, item, text) if type(item) is str: # Special case for soft pull items button = getattr(SCButtons, item.split(" ")[-1]) @@ -207,6 +213,10 @@ def on_clearb_clicked(self, trash, index, button): model.clear() # Fill it again for button, text in self.BUTTONS: + if isinstance(button, SCButtons): + if not button_available(self.app, button): + continue # optional button this controller doesn't have + text = button_label(self.app, button, text) model.append((None if button is None else nameof(button), text)) if button is not None: if nameof(button) == active: From 508a560c77df5906c2b2100d2637ea14ae261414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 12 Jul 2026 03:12:44 +0200 Subject: [PATCH 64/74] fix(gyro): make the Recenter Gyro special action actually recenter Reported: resetgyro (Special Action "recenter gyro sensor") did nothing. Two real causes and one by-design case: - Lean-to-turn (relative gyro -> mouse) had NO neutral reference at all: it read the driver's fused absolute angle directly, so its zero was gravity level for pitch/roll and an arbitrary power-on orientation for yaw -- unrecenterable and making yaw-lean unusable. GyroAction now captures a neutral pose on the first event after (re)activation and measures the lean against it (anglediff), with reset() re-capturing. The ModeModifier deactivation hook already calls reset(), so a gated lean re-references on every activation, Steam-style. - mapper.reset_gyros only reset GyroAbsAction; broaden to GyroAction (the parent class), covering absolute (ir) and relative (lean neutral) alike, through ModeModifier wrapping. - The laser-pointer mouse (absolute -> mouse) is rate-based and has no center by nature; recentering rightly leaves it alone (now documented). Verified on hardware: recenter-while-leaned stops the lean cursor and moves the neutral; an absolute stick recenters its deflection at the current pose. Co-Authored-By: Claude Opus 4.8 --- scc/actions.py | 18 +++++++++++++++++- scc/mapper.py | 8 ++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/scc/actions.py b/scc/actions.py index 15b9addeb..50fbf0573 100644 --- a/scc/actions.py +++ b/scc/actions.py @@ -1176,6 +1176,15 @@ def __init__(self, axis1, axis2=None, axis3=None): Action.__init__(self, axis1, *strip_none(axis2, axis3)) self.axes = [axis1, axis2, axis3] self.speed = (1.0, 1.0, 1.0) + # lean-to-turn neutral reference (per gyro axis, radians); captured on + # the first gyro event after (re)activation or a Recenter Gyro action. + self._lean_ref = [None, None, None] + + def reset(self): + """Re-captures the lean-to-turn neutral pose on the next gyro event. + Called by mapper.reset_gyros (the Recenter Gyro special action) and by + ModeModifier when a gated gyro deactivates.""" + self._lean_ref = [None, None, None] def get_compatible_modifiers(self): return Action.MOD_SENSITIVITY | Action.MOD_SENS_Z @@ -1207,8 +1216,15 @@ def gyro(self, mapper: Mapper, *pyr): angles = (q1 / 10430.37, q2 / 10430.37, q3 / 10430.37) # 2**15 / PI else: angles = quat2euler(q1 / 32767.0, q2 / 32767.0, q3 / 32767.0, q4 / 32767.0) + # The lean is measured against the neutral reference captured on + # the first event after (re)activation or Recenter Gyro -- NOT + # against the driver's absolute zero, whose yaw is an arbitrary + # power-on orientation (and would make yaw-lean unusable). + if self._lean_ref[i] is None: + self._lean_ref[i] = angles[i] + lean = anglediff(self._lean_ref[i], angles[i]) # saturate at +-90 deg, then scale to a sane default velocity - v = clamp(STICK_PAD_MIN, angles[i] * (2**15) * 2 / PI, STICK_PAD_MAX) + v = clamp(STICK_PAD_MIN, lean * (2**15) * 2 / PI, STICK_PAD_MAX) v = v * GyroAction.MOUSE_FACTOR * self.speed[i] if axis == Rels.REL_X: mapper.mouse_move(v, 0) diff --git a/scc/mapper.py b/scc/mapper.py index 0e4632981..a0c5b25a4 100644 --- a/scc/mapper.py +++ b/scc/mapper.py @@ -6,7 +6,7 @@ import traceback from typing import TYPE_CHECKING -from scc.actions import ButtonAction, GyroAbsAction +from scc.actions import ButtonAction, GyroAction from scc.aliases import ALL_AXES, ALL_BUTTONS from scc.config import Config from scc.constants import ( @@ -399,8 +399,12 @@ def cancel_all(self): a.cancel(self) def reset_gyros(self): + # GyroAction covers GyroAbsAction (subclass): absolute actions re-capture + # their orientation reference (ir), relative ones their lean-to-turn + # neutral pose. Rate-based outputs (laser-pointer mouse, relative stick) + # have no reference by nature, so recentering rightly leaves them alone. for a in self.profile.get_all_actions(): - if isinstance(a, GyroAbsAction): + if isinstance(a, GyroAction): a.reset() def input(self, controller: Controller, old_state, state) -> None: From c6e1f361b5d334fb9e811f47ea6e2c39e4132b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Fri, 19 Jun 2026 22:50:18 +0200 Subject: [PATCH 65/74] docs: add a "Using multiple controllers" section to the README Covers the one-window / one-bar-per-controller model, per-controller remembered profiles, safe disconnect, and the "Use Serial Numbers to Identify Controllers" setting (connection-order vs per-device identity). Screenshots may follow. Co-Authored-By: Claude Opus 4.8 --- README.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d0eedbe74..624ddfae7 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ User-mode driver, mapper and GTK3 based GUI for Steam Controller, DS4 and many o ## Features - Allows to setup, configure and use the Steam Controller without ever launching Steam -- Connect multiple controllers at the same time +- Connect multiple controllers at the same time, each with its own remembered profile - Supports profiles switchable in GUI or with controller button - Stick, Pads and Gyroscope input - Steam Controller 2 (2026) support, including its capacitive stick-touch and grip sensors — bind actions to them directly, or use them as conditions in mode-shift combinations @@ -24,6 +24,41 @@ User-mode driver, mapper and GTK3 based GUI for Steam Controller, DS4 and many o Based on [Standalone Steam Controller Driver](https://github.com/ynsta/steamcontroller) by [Ynsta](https://github.com/ynsta). +## Using multiple controllers + +SC Controller can drive several controllers at once — Steam Controllers (v1 and +v2), a DualShock 4 and others can all be connected together. + +- **One window, one bar per controller.** Just connect them: each controller + gets its own profile selector stacked in the main window, there is no separate + window per device. The controller that connected *first* is the primary one — + it is the one drawn on the big controller image and the default target when a + command (a menu, the OSD) does not name a specific controller. +- **Each controller keeps its own profile.** Picking a profile from a + controller's own bar applies only to that controller. The choice is remembered + and restored automatically the next time that controller connects, so you do + not have to re-pick it every session. +- **Disconnecting is safe.** Turning one controller off (or letting it go idle) + leaves the window and the other controllers untouched; when it comes back it + returns to its remembered profile. + +### Telling controllers apart + +How a controller is identified — and therefore which remembered profile and +per-controller settings it gets — is governed by **Use Serial Numbers to +Identify Controllers** in *Settings*: + +- **Off (default):** controllers are identified by connection order (first + connected, second connected, …). This is simplest for a fixed setup, but if + you change which controller powers on first they will swap profiles. +- **On:** each controller is identified by its own hardware serial number, so + its profile and settings follow the physical device no matter what order + things connect in. + +Turn this **on** when you regularly use more than one controller — especially +two of the same model, such as two Steam Controllers — and want each to reliably +keep its own profile. + ## Like what I'm doing? You can check out the ways to donate on [my website](https://rys.rs/donate), or just go straight to my [Ko-Fi](https://ko-fi.com/martinrys). From 0467d219eef2340689b2dd3af65973dd4f8d37c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 21 Jun 2026 14:46:34 +0200 Subject: [PATCH 66/74] docs(README): document the controller selector and add a multi-controller screenshot The "Using multiple controllers" section still described the old layout (one stacked profile bar per controller). Rewrote it for the current design: a controller-selector bar that lists every connected controller (by type, numbered for duplicates) with its current profile, plus a separate bar that sets the selected controller's profile. Added a screenshot of three controllers (two v1s and a v2) connected at once. Co-Authored-By: Claude Opus 4.8 --- README.md | 27 ++++++++++++++++++--------- docs/multiple-controllers.jpg | Bin 0 -> 74459 bytes 2 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 docs/multiple-controllers.jpg diff --git a/README.md b/README.md index 624ddfae7..35c046f99 100644 --- a/README.md +++ b/README.md @@ -29,19 +29,28 @@ Based on [Standalone Steam Controller Driver](https://github.com/ynsta/steamcont SC Controller can drive several controllers at once — Steam Controllers (v1 and v2), a DualShock 4 and others can all be connected together. -- **One window, one bar per controller.** Just connect them: each controller - gets its own profile selector stacked in the main window, there is no separate - window per device. The controller that connected *first* is the primary one — - it is the one drawn on the big controller image and the default target when a - command (a menu, the OSD) does not name a specific controller. -- **Each controller keeps its own profile.** Picking a profile from a - controller's own bar applies only to that controller. The choice is remembered - and restored automatically the next time that controller connects, so you do - not have to re-pick it every session. +- **One window, two bars: pick the controller, then its profile.** Just connect + them: a controller-selector bar lists every connected controller (by type, + numbered when you have more than one of the same model) together with its + current profile; choosing one shows it on the big controller image, and a + second bar sets that controller's profile. There is no separate window per + device. The controller that connected *first* is the primary one — it is the + one drawn by default and the target when a command (a menu, the OSD) does not + name a specific controller. +- **Each controller keeps its own profile.** Selecting a controller and setting + a profile applies only to that controller. The choice is remembered and + restored automatically the next time that controller connects, so you do not + have to re-pick it every session. - **Disconnecting is safe.** Turning one controller off (or letting it go idle) leaves the window and the other controllers untouched; when it comes back it returns to its remembered profile. +![SC Controller with three controllers connected](docs/multiple-controllers.jpg?raw=true) + +*Two Steam Controller v1s and a Steam Controller v2 connected at once: the +selector at the top lists each controller — numbered when there are duplicates — +alongside its current profile.* + ### Telling controllers apart How a controller is identified — and therefore which remembered profile and diff --git a/docs/multiple-controllers.jpg b/docs/multiple-controllers.jpg new file mode 100644 index 0000000000000000000000000000000000000000..788ebfa1c3473447004f395f3291546d25262dee GIT binary patch literal 74459 zcmeFZ1ymi$wlLgSaCZ+LG)l@>Z&cZt7_M-s$J*wIoFfd^8kjdq>Lm01qB5dfERE*1Bd}I z(9n<@1X%EfLx6*Wg@r?chrfe>f`o#CjD(DgiiU-OiiU}XjEsSYfr*WSi;Ihbj!%Gx zLx6>Yivv*t1p}6Wg+qjcL&QNvM#cGW!*vUQi2$7hQvw5p2|!~)!C*pNw*e#o6aWLZ z7Hsb?09yzRbq5{+q z1|djbO&E`pAXQ|Cm7(Pw(=C15z$nOw=$6ZL6xuy6|3BxM6Hj?LMb^$YTZwmKJdebbC!O{CM|IqJKg_8e8c<@hUkz;r!&|KBKSnO7Y@dlv4I;V}U{x9sh&0 zK)0@jmy5+@9$NcfrUVrFFBRkn@F?2S$WFg1Rp#0*+l-%nP;dGZn=55eHC-q$h(h6 zaogMbm#_!abDa&j(*M5czjNWvMyyQdPD?-5?{;f0dj>#%@;?kc^PhDaTTD9jeZlm* zy;PGJh@SfX2dNA2R5n6{- z;@4)>9lQjv5+g{c%v1Z8#DwW`s2}|ltda<@&VxC`+vu3cB4c}UeS(6mV&&lWSG@nd zLb#DCtmY(uk|hDdVrL-n(bm5g|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kB1%;vjoKcA~r*M4dX0WjjKDd11oL(^gWcJyGTZFx$ zX6{xJl|v1JMI9uPiKq70G~szbC57r|l`RaEw^P@4&Qt-)x=hTUsJZ%O?MU>VhNl=Y zy!CevP_uUbN>+p4(EBCZY_`_RGFh%&MfK<7d{Y6-fnkUt;qzB`V7#Pcf|c*dj>ja5@86<|5wR;v)0OMN2eSrP6$Ae&ZN)USjKB;vD zAHX_Gci;X)n{0b^&q9G|w1$GS?-RXeY_4jwhhpeHfCxH3mLUZB!R|;FNd;>JA~zu* zds&{0W%VRg{gifzwLf%4@?k&-n9F^a4gU>yT{Kv_O4v042XeU!Cr|_w!)-F$hjADo zJ>$*^mZD#^1zDVg5zJ7&3>@tyjc{2Y)lfRIzZRnRBADu4S(|`qsXdz3lwH2Wv&Onn zkrqIRW#w+$^aGb648Qu?G3(aclDbqANon%-hb?;2m~IHZgQOVCcW2q^D5w0|2rt@$ zkEy3^Pt~9tHh6%+qE$tw9H&+Eb1sh2mD<~zhpx;z7u|s~7Fkj(x*1j@DXuhtC6;xx z@8Aj888QOD*vkQMXtSMTnIoR`&D>aS7^uOG_-8Tc@g4L4GvW4XpE@u*`tvp zpAMXt)|M!~Z*9kPY%KSbl)70_po}nYEasnY2W1dTc`-ld2*l*So)y}o)Z<`yr zdBycp-|qMHfoI;5)|OhEb8R~smYAdOBt3PaO=^s!>>oC>ds0|+FASp z$#1^z^IUUVxL)?d>#-em=Ra=res=z*i|5*|%Ojpgzjl@%k&GJKQNtO&xaafz{{lu5 B?dJdh literal 0 HcmV?d00001 From 46f08f0690149ff1f122314e6837e22b050a114b Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Sun, 12 Jul 2026 17:51:02 +0200 Subject: [PATCH 67/74] docs(appimage): document AppImage udev steps Co-Authored-By: Claude Opus 4.8 --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 35c046f99..e040cafeb 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,23 @@ Linux: - **Void Linux:** Packaged as [sc-controller](https://github.com/void-linux/void-packages/blob/master/srcpkgs/sc-controller/template) - Run `xbps-install -S sc-controller` in a terminal, points to archived Ryochan7's fork at the time of writing - **Others:** You can attempt to use one of the AppImages (try all, AppImages built on older distributions tend to work better), or a package meant for your parent distribution if applicable. Flatpak is planned. +### AppImage: install the udev rules + +The AppImage is self-contained but **cannot install the udev rules** it needs (those live in a system directory). Without them your user can't access the controller and SC Controller can't create the virtual gamepad (`/dev/uinput`), so a detected controller appears to "do nothing". Distro packages install these rules for you; **AppImage users must do it once, by hand:** + +1. Download `69-sc-controller.rules` from the [latest release](https://github.com/Patola/sc-controller-cc/releases/latest). +2. Copy it into place — this needs `sudo`: + ```sh + sudo cp 69-sc-controller.rules /etc/udev/rules.d/69-sc-controller.rules + ``` +3. Reload and re-apply the rules: + ```sh + sudo udevadm control --reload-rules && sudo udevadm trigger + ``` +4. Unplug and replug the controller (or its wireless dongle) — or reboot. + +Only the AppImage needs this; the Arch and other distro packages already ship these rules. **The Steam Deck doesn't need it either** — SteamOS already ships udev rules for Steam devices, so the AppImage works out of the box there. + Windows: - It should be possible to get it running as per the [wiki](https://github.com/C0rn3j/sc-controller/wiki/Running-SC-Controller-on-Windows), but this is untested and might be broken, report a bug if so From f39c4394d70c49bf7ee920ed1dca01591dbfd57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 15 Jun 2026 05:45:16 +0200 Subject: [PATCH 68/74] docs(TODO.md): Add changes Grip sensing reads "on" most of the time while holding the controller, so note a future option to invert it -- fire when the grip is released -- as a general "inverted button" condition usable for any always-on sensor. Co-Authored-By: Claude Opus 4.8 TODO: capture v2 GUI plan (stick "Touch" tab, grip on main, v2 artwork) Record the agreed interface decisions: stick-touch belongs in a new "Touch" tab of the stick/pad editor (not the main image); grip-touch stays exposed on the main controller image (no parent control to nest under); and the dedicated v2 controller artwork with AREA_* anchors + matching config is still to come. Co-Authored-By: Claude Opus 4.8 docs(todo): mark "Act on release" done; scope per-controller profile memory - Move "Act on release" (inverted button) to the Done list. - Scope a future feature: remember each controller's profile across (re)connects (persist by controller id from the daemon's "Profile:" handler, excluding autoswitch and temp profiles; load it in add_controller). Co-Authored-By: Claude Opus 4.8 docs(TODO): note per-controller icons and the serials-on multi-v1 limitation - Custom 24px icons per controller type (only sc/sc2 are bespoke today). - Steam Controller v1 with "Use Serial Numbers" on and multiple wireless dongles: only one v1 shows because one dongle throws a USBErrorPipe during flush and the daemon closes it. The serial read itself succeeds; the fix is to recover from the transient stall instead of tearing the dongle down. Workaround: use serials off. Co-Authored-By: Claude Opus 4.8 docs(TODO): scope continuous "HD rumble" (v2 haptics) as a future entry Records the baseline (single-pulse 0x8F / 0x82 clicks), the gap (the v2's continuous-rumble report is not yet identified), the capture-and-port approach (read SDL / hid-steam, check SDL3 v2 support first, else usbmon capture, replicate, map FF -> LRA) and the reference implementations. Co-Authored-By: Claude Opus 4.8 docs(todo): record Deck OSD menu fixes Deck OSD is missing "Display Current Bindings", "Run Program" and "Edit Bindings"; make the first two work there, and drop "Turn Controller OFF" on the Deck (its built-in controller can't be powered off). Co-Authored-By: Claude Opus 4.8 docs(todo): refine Deck OSD-menu item, add Deck tray-icon note The OSD entries aren't dropped - they ship disabled in the menu settings and do nothing when enabled/selected. Also note the Deck status (tray) icon doesn't appear even when enabled (works on desktop now that libdbusmenu is bundled). Co-Authored-By: Claude Opus 4.8 docs(todo): defer AppImage desktop app-id rebrand to org.patola.sc-controller-cc Co-Authored-By: Claude Opus 4.8 docs(todo): note the remaining deprecated new_from_stock icon calls macro_editor.py and modeshift_editor.py still use the deprecated Gtk.Image.new_from_stock() API for their up/down/delete/clear buttons. They render (stock->icon fallback) but should move to new_from_icon_name with freedesktop names, mirroring the profile_switcher.py save/edit fix. Co-Authored-By: Claude Opus 4.8 docs(todo): drop items that are now implemented or superseded - per-controller profile memory: implemented (persisted + restored by controller id); moved to the Done list - action-editor "Touch" tab: superseded - the capacitive stick-touch is bound via the controller image instead - LT/RT/GYRO side-panel icon note: status-only (the shared defaults look fine); the v2 side-panel icons are already recorded under Done Co-Authored-By: Claude Opus 4.8 docs(todo): note remaining DualShock 4 / DualSense issues Record the DS4/DS5 rough edges left after the HID driver was made functional: asymmetric stick highlighting, generic (non-DualShock) input icons, missing rumble and lightbar, and the unverified DS5 / unscaled DS5HidRawController touchpad. Co-Authored-By: Claude Opus 4.8 docs(todo): note DS4 gyro + Bluetooth rumble/lightbar follow-ups The DS4 gyro/IMU is decoded but never confirmed to work (USB or Bluetooth), and the new DS4HidRawController is input-only -- rumble and lightbar over Bluetooth need output reports with the BT CRC32 wrapper, like the DS5 driver. Co-Authored-By: Claude Opus 4.8 docs(todo): DS4 gyro absolute works (drift + mouse-serialization follow-ups) Co-Authored-By: Claude Opus 4.8 docs(todo): evaluate selectable output device (Xbox / DS4-DS5 / none) Code-verified feasibility notes: the emulated pad's X360 identity is pure config (config["output"]), a keyboard+mouse-only mode already exists as the undocumented SCC_NOGAMEPAD env var, and DS4/DS5 output splits into a cheap evdev identity preset (glyphs, no gyro) vs a real /dev/uhid emulation (kernel hid-playstation binds -> native in-game gyro). Co-Authored-By: Claude Opus 4.8 --- TODO.md | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/TODO.md b/TODO.md index 7d5070afd..2882e92b1 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,135 @@ List of (possibly) planned features in no particular order: +- Selectable output device: virtual Xbox (today's default), virtual DS4/DS5, + or NO virtual controller at all. The current "Xbox 360 pad" is just a + generic uinput device wearing an X360 identity defined entirely in + config["output"] (scc/config.py: vendor/product/name/buttons/axes), so the + architecture already treats identity as data. Three tiers of work: + - no-controller mode (keyboard+mouse only) ALREADY EXISTS as the + undocumented SCC_NOGAMEPAD env var (scc/mapper.py create_gamepad); + promote it to a config key + GUI toggle (trivial), or per-profile + (moderate: create/destroy the uinput gamepad on profile switch). + Essential for games that refuse mouse/keyboard input while any + controller is detected; + - evdev-level DS4/DS5 identity presets (Sony VID/PID + the button/axis + layout SDL's gamecontrollerdb expects on the classic path): preset + table + GUI dropdown; gives PlayStation glyphs in most games, but no + gyro/touchpad/lightbar (those ride on hidraw, which uinput cannot + fake; SDL HIDAPI just falls back to evdev); + - faithful DS4/DS5 emulation via /dev/uhid: present a real HID device so + the kernel's hid-playstation binds and exposes motion/touchpad nodes + -> native in-game gyro from ANY supported controller. Big: a uhid + backend beside uinput, authentic report descriptors/streams, a udev + rule for /dev/uhid. Prior art exists (fake-DS4-over-uhid projects). + +- DualShock 4 / DualSense (ds4/ds5) polish. The HID driver is now functional + (mapper rstick/dpad guards, touchpad coordinate scaling + click highlight), but + rough edges remain: + - the two analog sticks are asymmetric in Input Test -- the left and right + stick brighten / behave differently from each other; + - the input icons drawn around the controller are the generic ones, not the + DualShock face symbols (cross / circle / square / triangle); + - the DS4 gyro works as relative and absolute (host-side euler integration in + _step_orientation, verified on hardware) but the absolute path is gyro-only, + so it DRIFTS and gimbals on large combined rotations. The clean next step is + accelerometer drift-correction: fuse gyro + accel (complementary filter) to + pin pitch/roll to the gravity vector -- the raw accel is still in q1-q3 right + after decode, before _step_orientation overwrites them (yaw has no absolute + reference without a magnetometer, so it drifts inherently); + - gyro -> MOUSE routes to the stick instead: an Axes/Rels IntEnum value + collision (ABS_X == REL_X) makes a mouse axis serialize/round-trip as a stick + axis. The gyro editor labels + chooser display are fixed, but the save/reload + path still needs a proper Axes-vs-Rels disambiguation; use gamepad axes for + gyro meanwhile; + - no rumble: neither DS4Controller nor DS4HidRawController drives the pad (the + DS5 driver does) -- port the DS5/kernel output report; over Bluetooth the + DS4HidRawController is input-only, so rumble + lightbar there need output + reports with the BT CRC32 wrapper (mirror DS5HidRawController); + - the lightbar LED is not driven (no DS4-specific set_led); + - DS5 is UNVERIFIED (no DualSense hardware here): its HID touchpad scaling was + added by analogy to the DS4 (DualSense pad assumed 1920x1080) and not tested; + the DS5HidRawController touchpad is still unscaled and stores cpad as unsigned + c_uint16, which can't hold the signed scaled range -- it needs a field type + change as well as scaling. - Multiple on-screen menus (and possibly keyboards) when using multiple controllers - Injecting emulated xbox controller into wine +- mnuImage right-click "change background" menu has no `sc2` entry (the v2 + image is selected automatically via sc2.config.json `gui.background`, but + it can't be picked manually from that menu yet). +- Custom small (24px) controller icons per supported controller. Today only the + Steam Controller v1 (sc-*) and v2 (sc2-*) have bespoke top-down glyphs; every + other type (deck, ds4, ds5, evdev, hid, scbt, fake) reuses the same generic + silhouette, just recolored. Draw a distinct glyph per type so each controller + is recognisable at a glance. The v2 glyph could also be refined further (its + trackpads are necessarily small at 24px). +- Steam Controller v1 GET_SERIAL reliability (nicety). The flaky v1 serial read + is now handled gracefully - usb.py retries a stalled control request instead of + tearing the dongle down, and sc_dongle falls back to a generated id if it never + reads - so multiple v1s with "Use Serial Numbers" on are detected reliably. + Remaining nicety: investigate *why* GET_SERIAL stalls, so a v1 always ends up + with its real serial (today a persistent stall yields a positional id instead). +- Continuous "HD rumble" for the Steam Controller v2 (and v1/Deck). The SC pads + are LRA voice-coil actuators, not ERM spin-motors. We already drive single + pulses (v1: FEEDBACK report 0x8F; v2: interrupt-OUT report 0x82, effect 0x01 = + one click) which suit pad/scroll detents but NOT sustained, amplitude/ + frequency-modulated game rumble. Gap: the v2's continuous-rumble report is + unknown (see sc2.py feedback(): "sustained game rumble may need another report, + not yet found"); the v2 uses its own report scheme (interrupt-OUT 0x82), + distinct from the Deck's feature-report commands, so it needs confirming for + the v2 specifically. Approach (do NOT brute-force the HID space by trial and + error - a wrong report just does nothing and gives no signal): + 1. Read the canonical implementations: SDL's hidapi Steam driver + (SDL_hidapi_steam.c / SDL_hidapi_steamdeck.c - ID_TRIGGER_RUMBLE_CMD plus + the left/right gain "magic numbers") and the Linux kernel + drivers/hid/hid-steam.c (FF play_effect, derived from SDL's Deck code). + 2. Check first whether SDL3 already rumbles the v2 by its VID/PID - if so, + its source *is* the v2 report format and no capture is needed. + 3. Otherwise capture ground truth: run Steam Input on the v2, trigger rumble + (Steam's controller rumble test, or a rumbling game) and capture the USB + OUTPUT reports with usbmon + Wireshark; decode the continuous-rumble + report Steam actually sends. + 4. Replicate it in sc2.py feedback() and diff the emitted bytes against the + capture to confirm. + 5. Map the emulated gamepad's FF_RUMBLE strong/weak magnitudes to the LRA's + amplitude/frequency/gain and tune for feel (LRA != ERM, so a curve is + needed). + Plumbing already exists (emulated gamepad FF -> controller.feedback()); the + missing piece is the v2 continuous-rumble report itself. Refs: SDL hidapi steam + driver, kernel hid-steam.c, and Alice Mikhaylenko's "Steam Deck, HID, and + libmanette adventures" writeup. +- Deck OSD menu fixes. (a) "Display Current Bindings..." and "Run Program..." + ship disabled in the menu settings; once enabled they appear in the OSD, but + selecting them does nothing - their shell() actions (scc-osd-show-bindings, + scc-osd-launcher) don't actually run/work on the Deck. Make them functional. + (b) Remove "Turn Controller OFF" from the Deck's OSD menu - the Deck's + built-in controller can't be powered off (today it shows and does nothing). + Entries defined in scc/gui/global_settings.py (~L45-58, e.g. + "Turn Controller OFF" -> osd(turnoff())); menu data in + default_menus/Default.menu. +- Generalize the OSD "Turn Controller OFF" hiding. It's currently hidden only + for the Deck's built-in controls (controller type == "deck", checked in + scc/osd/menu.py against the --controller-type the daemon passes). Replace that + hardcoded type check with a per-controller capability (a ControllerFlags bit or + a controller.can_turnoff()) so any controller that can't be powered off + remotely hides the entry, not just the Deck. +- Deck tray/status icon not visible. On the Steam Deck the status (tray) icon + doesn't appear even with the option enabled - works on desktop now that + libdbusmenu is bundled, so this is a Deck/gamescope SNI-tray-host issue to + investigate. +- Rebrand the AppImage desktop app-id. app_info.id in AppImageBuilder.yml / + AppImageBuilder.debian.yml is still org.c0rn3j.sc-controller (upstream), so the + installed .desktop carries the upstream id, and the after_bundle step symlinks + it as org.c0rn3j.sc-controller.desktop. Switch both to org.patola.sc-controller-cc + once the fork is stable and we have committed/PR'd to upstream. +- Replace the last deprecated GTK stock-icon calls. macro_editor.py (the + up/down/delete buttons) and modeshift_editor.py (the clear button) still call + `Gtk.Image.new_from_stock("gtk-go-up" / "gtk-go-down" / "gtk-delete", ...)`. + They render today (GTK maps the stock id to an icon internally) but the stock + API is deprecated; move them to `Gtk.Image.new_from_icon_name` with freedesktop + names (go-up / go-down / edit-delete, or the -symbolic variants - all present in + Adwaita/Breeze). Same class as the profile_switcher.py save/edit buttons, which + were actively blank because `new_from_icon_name` was handed the stock ids + "gtk-save"/"gtk-edit" (now document-save / document-edit). Hard stuff: - Injecting emulated xbox controller into PlayOnLinux @@ -10,7 +138,22 @@ Very hard stuff: - Visual feedback in binding editor ( [what this guy says](https://www.reddit.com/r/linux_gaming/comments/5pcdmr/sc_controller_use_steam_controller_without_steam/dcqpvf4/) ) **Done** stuff: +- "Act on release" (inverted button): a general InvertedButtonModifier plus a + checkbox in the button action editor (next to Toggle/Repeat) that fires a + binding on *release* instead of press - for always-on sensors like the + capacitive grips. Round-trips with the Custom Action `inverted(...)` token. +- Dedicated v2 controller artwork: traced SVG (tools/sc2-source.svg) wired by + tools/gen_sc2_image.py into controller-images/sc2.svg + v2 face-overlay + glyphs (button-images/sc2_*.svg, lifted from the drawn symbols so the face + buttons are blank in the art -> no duplication, monochrome ABXY, round Steam, + single dots) + v2 side-panel icons (images/sc2/*.svg, per-controller override + added in app.apply_gui_config_buttons). Control-name ids on sticks/pads/dpad/ + bumpers + grip-touch shapes so everything highlights on hover; darker body + (#b8b8b8). sc2.config.json points at it all. Replaces the borrowed Deck image. - Multicontroller support +- Per-controller profile memory: each controller's profile is remembered by id + (config["controllers"][id]["profile"]) and restored on (re)connect - follows + the physical device with "Use Serial Numbers" on, per-slot otherwise. - Configurable gamepad type (e.g. 4 axes and 16 buttons) - Steam Profile import - Radial Menu for the Joystick/Trackpad From a4eb28f5f828042c732c53f371edad7db20c27ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 26 Jul 2026 23:59:41 +0200 Subject: [PATCH 69/74] gui: name the Bluetooth hidraw DualShock 4 in the controller list CONTROLLER_TYPE_NAMES was missing the "ds4bt_hidraw" type (the DS4's Bluetooth hidraw driver), so a DS4 connected over Bluetooth showed as the generic "Controller" in the multi-controller list. USB ("ds4") and evdev ("ds4evdev") already mapped to "DualShock 4"; add the third. Co-Authored-By: Claude Opus 4.8 --- scc/gui/app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scc/gui/app.py b/scc/gui/app.py index c427b7a45..8fa90e852 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -61,6 +61,7 @@ "deck": "Steam Deck", "ds4": "DualShock 4", "ds4evdev": "DualShock 4", + "ds4bt_hidraw": "DualShock 4", "ds5": "DualSense", "ds5evdev": "DualSense", "ds5bt_hidraw": "DualSense", From 0418e2076fab65c9487eb3b8fecf189482ede4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 26 Jul 2026 23:59:41 +0200 Subject: [PATCH 70/74] sc1: convert the hardware quaternion to EUREL euler angles (one gyro path) The Steam Controller v1 was the last controller feeding its quaternion straight to quat2euler, whose axis convention does not match the calibrated EUREL one -- so the relative-mouse (lean-to-turn) path moved wrong (pitch inverted, roll/yaw drifting left), while absolute happened to work. Held-pose captures show the v1 quaternion (q1=w q2=x q3=y q4=z, norm 32767, identity at rest, steady when still) uses the IDENTICAL axis convention as the SC2: x = pitch (nose-up +), y = roll (roll-right +), z = yaw (yaw-left +). Reuse the SC2's verified quat->euler mapping in the driver, hand the mapper DS4-convention EUREL angles in q1-q3, and set EUREL_GYROS on SCController: every controller now shares the single hardware-verified gyro code path (absolute, relative, tilt, lean-to-turn, laser mouse). Also add the same SCC_GYRO_CALIB=1 calibration instrument the DS4/SC2 have, which produced the measurement. All five gyro suite tests verified on v1 hardware. Co-Authored-By: Claude Opus 4.8 --- scc/drivers/sc_dongle.py | 75 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/scc/drivers/sc_dongle.py b/scc/drivers/sc_dongle.py index 4f9cd508f..c12a55954 100644 --- a/scc/drivers/sc_dongle.py +++ b/scc/drivers/sc_dongle.py @@ -7,16 +7,19 @@ from __future__ import annotations import logging +import os import struct +import time from enum import IntEnum -from math import cos, sin +from math import asin, atan2, cos, sin, sqrt from math import pi as PI from typing import TYPE_CHECKING, NamedTuple from scc.config import Config -from scc.constants import STICK_PAD_MAX, STICK_PAD_MIN, SCButtons +from scc.constants import STICK_PAD_MAX, STICK_PAD_MIN, ControllerFlags, SCButtons from scc.controller import Controller from scc.drivers.usb import SCUSBDevice, register_hotplug_device +from scc.tools import quat2euler if TYPE_CHECKING: from usb1 import USBDevice, USBDeviceHandle @@ -27,6 +30,27 @@ from scc.drivers.steamdeck import Deck from scc.sccdaemon import SCCDaemon +_EUREL_SCALE = 32768.0 / PI # radians -> the 2**15/PI fixed point EUREL_GYROS wants + + +def _quat_to_eurel(q1: int, q2: int, q3: int, q4: int) -> tuple[int, int, int]: + """Convert the SC1 hardware quaternion (q1=w q2=x q3=y q4=z, unit * 32767) + to DS4/SC2-convention EUREL euler angles (pitch, yaw, roll) in 2**15/PI fixed + point. Measured from held poses: the SC1 and SC2 use the identical quaternion + convention -- x=pitch (nose-up +), y=roll (roll-right +), z=yaw (yaw-left +) -- + so this is byte-for-byte the sc2.parse_input mapping. Feeding these to the + mapper (with EUREL_GYROS set) puts SC1 on the same single gyro code path as + the DS4/SC2, where all the axis/sign conventions are hardware-verified.""" + w, x, y, z = q1 / 32767.0, q2 / 32767.0, q3 / 32767.0, q4 / 32767.0 + pitch = atan2(2.0 * (w * x + y * z), 1.0 - 2.0 * (x * x + y * y)) + roll = asin(max(-1.0, min(1.0, 2.0 * (w * y - z * x)))) + yaw = atan2(2.0 * (w * z + x * y), 1.0 - 2.0 * (y * y + z * z)) + return ( + int(-pitch * _EUREL_SCALE), + int(-yaw * _EUREL_SCALE), + int(roll * _EUREL_SCALE), + ) + class ControllerInput(NamedTuple): """Based on INPUT_FORMAT except anything starting with "ukn_""" @@ -92,7 +116,39 @@ class ControllerInput(NamedTuple): log = logging.getLogger("SCDongle") - +_CALIB = bool(os.environ.get("SCC_GYRO_CALIB")) +if _CALIB: + # The daemon leaves the root logger at WARNING; opt this logger into INFO so + # the IMU-calibration dump is visible. + log.setLevel(logging.INFO) +_calib_last_t = 0.0 + + +def _log_imu_calib(idata) -> None: + """Throttled IMU dump for Steam Controller v1 gyro calibration (gate: env + SCC_GYRO_CALIB=1). Logs the accel gravity vector, the raw hardware + quaternion, what quat2euler currently makes of it, and the raw rates -- so + held poses reveal the quaternion's real axis/sign convention vs the + EUREL convention the DS4/SC2 use.""" + global _calib_last_t + now = time.time() + if now - _calib_last_t < 0.25: + return + _calib_last_t = now + ax, ay, az = idata.accel_x, idata.accel_y, idata.accel_z + mag = sqrt(ax * ax + ay * ay + az * az) or 1.0 + q = (idata.q1 / 32767.0, idata.q2 / 32767.0, idata.q3 / 32767.0, idata.q4 / 32767.0) + qnorm = sqrt(sum(c * c for c in q)) * 32767.0 + e = quat2euler(*q) + deg = 180.0 / PI + log.info( + "IMU-CALIB accel unit=(% .2f % .2f % .2f) |a|=%6.0f | quat=(% 6d % 6d % 6d % 6d) |q|=%6.0f | " + "quat2euler deg=(% 6.1f % 6.1f % 6.1f) | rates(gpitch,groll,gyaw)=(% 5d % 5d % 5d)", + ax / mag, ay / mag, az / mag, mag, + idata.q1, idata.q2, idata.q3, idata.q4, qnorm, + e[0] * deg, e[1] * deg, e[2] * deg, + idata.gpitch, idata.groll, idata.gyaw, + ) class Dongle(SCUSBDevice): MAX_ENDPOINTS = 4 @@ -186,6 +242,10 @@ class SCConfigType(IntEnum): class SCController(Controller): + # The SC1 quaternion is converted to euler host-side (input()) and handed to + # the mapper in q1-q3 as EUREL angles, so SC1 shares the DS4/SC2 gyro path. + flags = ControllerFlags.EUREL_GYROS + def __init__(self, driver: Deck | Dongle | SCByBt | SCByCable | SC2Device, ccidx: int, endpoint: int) -> None: Controller.__init__(self) self._driver: Deck | Dongle | SCByBt | SCByCable | SC2Device = driver @@ -269,6 +329,15 @@ def input(self, idata: ControllerInput) -> None: idata.q4, ) + if _CALIB: + _log_imu_calib(idata) # logs the RAW quaternion, before conversion + # Convert the hardware quaternion (q1-q4) to EUREL euler angles in + # q1-q3 (q4 unused) so the mapper's gyro paths -- absolute, tilt, + # lean-to-turn -- match the DS4/SC2 exactly. Only when the gyro is + # streaming (a nonzero quaternion); disabled, q1-q4 are 0. + if idata.q1 or idata.q2 or idata.q3 or idata.q4: + p, y, r = _quat_to_eurel(idata.q1, idata.q2, idata.q3, idata.q4) + idata = idata._replace(q1=p, q2=y, q3=r, q4=0) self.mapper.input(self, old_state, idata) def _generate_id(self) -> str: From e49b45789d13de85b6c7a3329329be13fc6ea575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Sun, 26 Jul 2026 23:59:41 +0200 Subject: [PATCH 71/74] fix(gyro): re-center absolute gyro at every activation, not at release With a gated absolute gyro, the reference was effectively captured at the RELEASE pose: ModeModifier's deactivation fix reset the reference and then called the neutralizing gyro(0,0,0,*q), whose first-event capture stamped it right back at wherever the controller was on release. Rotating while disengaged then carried a stale offset into the next engage (stick starts deflected), while cycling the enable button appeared to "move the origin". Found on the SC1 but general: the bug lived in the shared modifier/action layer and affected every controller. Rules now, deterministic and Steam-like: - the reference is captured at each ENGAGE (ModeModifier resets again after the neutralizing call, so it cannot poison the next activation); - the very first activation behaves like every other one (GyroAbsAction.ir starts all-None / capture-at-first-event, instead of pitch/yaw pinned to the driver zero); - a legitimate 0.0 reference sticks (explicit None test instead of the falsy `or` capture). Also benefits lean-to-turn, which shared the release-pose poisoning. Verified on SC1 hardware: engage anywhere reads centered, tilt deflects, release zeroes, rotating while off never carries over. Co-Authored-By: Claude Opus 4.8 --- scc/actions.py | 11 +++++++++-- scc/modifiers.py | 13 ++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/scc/actions.py b/scc/actions.py index 50fbf0573..aa7c4c22e 100644 --- a/scc/actions.py +++ b/scc/actions.py @@ -1259,7 +1259,11 @@ class GyroAbsAction(HapticEnabledAction, GyroAction): def __init__(self, *blah): GyroAction.__init__(self, *blah) HapticEnabledAction.__init__(self) - self.ir = [0, 0, None, 0] # Initial rotation, last has to be determined + # Orientation reference: None = capture at the next gyro event. All + # axes capture-at-first-event, so the very first activation centers at + # the current pose exactly like every later one (re-centered by + # reset() on deactivation / Recenter Gyro). + self.ir = [None, None, None, None] self._was_oor = False self._deadzone_fn = None @@ -1285,7 +1289,10 @@ def gyro(self, mapper: Mapper, pitch, yaw, roll, q1, q2, q3, q4): else: pyr = list(quat2euler(q1 / 32767.0, q2 / 32767.0, q3 / 32767.0, q4 / 32767.0)) for i in self.GYROAXES: - self.ir[i] = self.ir[i] or pyr[i] + # explicit None test, not `or`: a legitimate 0.0 reference is falsy + # and would re-capture on every event + if self.ir[i] is None: + self.ir[i] = pyr[i] pyr[i] = anglediff(self.ir[i], pyr[i]) * (2**15) * self.speed[2] * 2 / PI if self.haptic: oor = False # oor - Out Of Range diff --git a/scc/modifiers.py b/scc/modifiers.py index 5f24d1be6..ccf7e985a 100644 --- a/scc/modifiers.py +++ b/scc/modifiers.py @@ -1041,13 +1041,20 @@ def gyro(self, mapper, pitch, yaw, roll, *q): # stuck when the enable button is released. Relative GyroAction zeroes # on (0,0,0), but GyroAbsAction ignores pitch/yaw/roll (it tracks # q1-q4), so it would emit its last orientation and leave the axis - # deflected. Reset each GyroAbsAction's reference first (the only gyro - # action with reset()) so the neutralizing call below emits 0. Covers - # MultiAction (mixed relative+absolute) via its .actions children. + # deflected. Reset the reference first so the neutralizing call below + # emits 0. Covers MultiAction (mixed relative+absolute) via .actions. for a in getattr(self.old_action, "actions", None) or (self.old_action,): if hasattr(a, "reset"): a.reset() self.old_action.gyro(mapper, 0, 0, 0, *q) + # That neutralizing call just re-captured the reference at the + # RELEASE pose (reset -> first-event capture). Reset once more so + # the next activation captures ITS OWN pose: the gyro re-centers + # on every engage (Steam-like), instead of carrying a stale + # offset accumulated while deactivated. + for a in getattr(self.old_action, "actions", None) or (self.old_action,): + if hasattr(a, "reset"): + a.reset() self.old_action = sel return sel.gyro(mapper, pitch, yaw, roll, *q) From 9afb7dbd63fa6619a3ad430bc2543d887c6e2e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 3 Aug 2026 01:33:20 +0200 Subject: [PATCH 72/74] fix(gyro): scale gyro output to the target axis' own range A gyro bound to a trigger was unusable. Both GyroAction and GyroAbsAction compute their value in the stick range (STICK_PAD_MIN..STICK_PAD_MAX) and handed it straight to AxisAction.clamp_axis, which for ABS_Z / ABS_RZ merely clamps into the trigger's unipolar 0..255. Two symptoms fell out of that: - saturation: in absolute mode 0.7 degrees of rotation pinned the trigger at 255, so it read as a button rather than an axis. Relative mode was roughly 64x over. - a dead half: every negative value clamped to 0, so rotating one way did nothing at all -- reported as "no input", although it is the same bug as the sensitivity, just seen from the other direction. Route both through a new GyroAction.emit_axis(), which rescales onto the axis' own range. The neutral pose now rests at "released" (which is what a trigger has to do) and full pull needs the same 90 degrees that fully deflects a stick; the opposite rotation is available with a negative sensitivity or the 'inverted' modifier. Sticks are untouched -- the rescale applies to AxisAction.Z only. Also moves GyroAbsAction's deadzone call ahead of the rescale, so the deadzone keeps working in stick range where its bounds are expressed. tests/test_gyro.py is new: first runtime coverage for the gyro actions, using a fake mapper (the real one needs a daemon, a controller and uinput). --- scc/actions.py | 32 +++++++++++---- tests/test_gyro.py | 100 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 7 deletions(-) create mode 100644 tests/test_gyro.py diff --git a/scc/actions.py b/scc/actions.py index aa7c4c22e..c5b210200 100644 --- a/scc/actions.py +++ b/scc/actions.py @@ -1189,6 +1189,26 @@ def reset(self): def get_compatible_modifiers(self): return Action.MOD_SENSITIVITY | Action.MOD_SENS_Z + @staticmethod + def emit_axis(mapper: Mapper, axis, value): + """Sends a stick-range gyro value (STICK_PAD_MIN..STICK_PAD_MAX) to a + gamepad axis, rescaled to that axis' own range. + + Triggers need the rescale: they are unipolar (TRIGGER_MIN..TRIGGER_MAX + == 0..255), so merely clamping a stick-range value into them -- what + this used to do -- discarded the whole negative half and saturated the + positive half within about 0.7 deg of rotation. A gyro-driven trigger + behaved like a button. Mapping the positive half across the full + trigger travel keeps the neutral pose at "released" (which is what a + trigger has to rest at) and full pull at the same rotation that would + fully deflect a stick; bind the opposite rotation with a negative + sensitivity or the 'inverted' modifier. + """ + if axis in AxisAction.Z: + value = value * TRIGGER_MAX / STICK_PAD_MAX + mapper.gamepad.axisEvent(axis, AxisAction.clamp_axis(axis, value)) + mapper.syn_list.add(mapper.gamepad) + def set_speed(self, x: float, y: float, z: float): self.speed = (x, y, z) @@ -1203,8 +1223,7 @@ def gyro(self, mapper: Mapper, *pyr): # IntEnums with overlapping values (REL_X == ABS_X == 0), so the # membership test would misroute a mouse axis here as a gamepad axis. if isinstance(axis, Axes) or type(axis) is int: - mapper.gamepad.axisEvent(axis, AxisAction.clamp_axis(axis, pyr[i] * self.speed[i] * -10)) - mapper.syn_list.add(mapper.gamepad) + GyroAction.emit_axis(mapper, axis, pyr[i] * self.speed[i] * -10) # Relative mouse = lean-to-turn: cursor VELOCITY is proportional to # the held tilt angle -- lean and the cursor keeps moving, return to # level and it stops. (For laser-pointer tracking, where the cursor @@ -1320,12 +1339,11 @@ def gyro(self, mapper: Mapper, pitch, yaw, roll, q1, q2, q3, q4): # swallowed the mouse axes into this gamepad branch (the elifs below # never ran) -- gyro->mouse moved the stick instead of the cursor. if isinstance(axis, Axes) or type(axis) == int: - val = AxisAction.clamp_axis(axis, pyr[i] * self.speed[i]) + val = pyr[i] * self.speed[i] if self._deadzone_fn: - val, trash = self._deadzone_fn(val, 0, STICK_PAD_MAX) - val = int(val) - mapper.gamepad.axisEvent(axis, val) - mapper.syn_list.add(mapper.gamepad) + # deadzone works in stick range, before the axis rescale + val, trash = self._deadzone_fn(clamp(STICK_PAD_MIN, val, STICK_PAD_MAX), 0, STICK_PAD_MAX) + GyroAction.emit_axis(mapper, axis, val) # Absolute mouse = laser pointer: the angular RATE is the move delta # (like MouseAction.gyro); the rate integrates to the rotation angle, # so the cursor tracks the controller's absolute orientation and stops diff --git a/tests/test_gyro.py b/tests/test_gyro.py new file mode 100644 index 000000000..29c1a5ea8 --- /dev/null +++ b/tests/test_gyro.py @@ -0,0 +1,100 @@ +"""Runtime behaviour of the gyro actions. + +Driven through a fake mapper: the real one needs a daemon, a controller and +uinput devices. +""" +import math + +from scc.actions import GyroAbsAction, GyroAction +from scc.constants import STICK_PAD_MAX, TRIGGER_MAX, ControllerFlags +from scc.uinput import Axes + +# driver-side euler encoding: 2**15 / PI fixed point, see ControllerFlags.EUREL_GYROS +EUREL = 32768.0 / math.pi + + +class FakeGamepad: + def __init__(self): + self.events = {} + + def axisEvent(self, axis, value): + self.events.setdefault(axis, []).append(value) + + +class FakeController: + flags = ControllerFlags.EUREL_GYROS + + +class FakeState: + rtrig = 0 + + +class FakeMapper: + def __init__(self): + self.gamepad = FakeGamepad() + self.syn_list = set() + self.mouse_moves = [] + self.state = FakeState() + self._controller = FakeController() + + def get_controller(self): + return self._controller + + def mouse_move(self, dx, dy): + self.mouse_moves.append((dx, dy)) + + def send_feedback(self, *a): + pass + + +def sweep(action, mapper, to_degrees, steps=20): + """Rotates all three gyro axes from neutral to 'to_degrees'.""" + prev = None + for n in range(steps + 1): + a = math.radians(to_degrees * n / steps) + rates = (0, 0, 0) if prev is None else tuple([(a - prev) * 3000.0] * 3) + prev = a + q = int(a * EUREL) + action.gyro(mapper, rates[0], rates[1], rates[2], q, q, q, 0) + + +def peak(mapper, axis): + vals = mapper.gamepad.events[axis] + return max(vals, key=abs) + + +class TestGyroAxisRange: + """A gyro bound to a trigger must use the trigger's own 0..255 range. + + Feeding it a stick-range value and clamping (what it used to do) threw + away the negative half and saturated within a fraction of a degree, so + the trigger behaved like a button. + """ + + def test_absolute_trigger_is_proportional(self): + m = FakeMapper() + sweep(GyroAbsAction(Axes.ABS_Z), m, 20) + # 20 of the 90 deg that deflect a stick fully -> ~22% of trigger travel + assert 0.15 * TRIGGER_MAX < peak(m, Axes.ABS_Z) < 0.30 * TRIGGER_MAX + + def test_absolute_trigger_reaches_full_pull(self): + m = FakeMapper() + sweep(GyroAbsAction(Axes.ABS_Z), m, 90) + assert peak(m, Axes.ABS_Z) == TRIGGER_MAX + + def test_absolute_trigger_rests_released(self): + """A trigger has to sit at 0 when the controller is not rotated.""" + m = FakeMapper() + sweep(GyroAbsAction(Axes.ABS_Z), m, 0) + assert set(m.gamepad.events[Axes.ABS_Z]) == {0} + + def test_relative_trigger_is_not_digital(self): + m = FakeMapper() + sweep(GyroAction(Axes.ABS_Z), m, -20) + assert 0 < peak(m, Axes.ABS_Z) < TRIGGER_MAX + + def test_stick_range_is_unchanged(self): + """The rescale must apply to triggers only.""" + m = FakeMapper() + sweep(GyroAbsAction(Axes.ABS_X), m, 90) + assert peak(m, Axes.ABS_X) == STICK_PAD_MAX From fbc21988f49536cbc1ded96a8ed741a846feb22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 3 Aug 2026 01:34:14 +0200 Subject: [PATCH 73/74] fix(modeshift): give analog range conditions hysteresis RangeOP compared the axis against its threshold with a bare float compare, so an analog axis parked near that threshold flipped the condition several times a second. Every flip runs ModeModifier's switch path, which releases held buttons and calls reset() on the outgoing action. For gyro bindings that is fatal rather than merely jittery. reset() drops the captured neutral reference -- GyroAbsAction.ir, GyroAction._lean_ref -- so the measured deflection never accumulates beyond a single frame's worth and the binding looks completely dead. A user reported exactly this on `mode(RT >= 0.7, ...)`, and the shape of the report is the fingerprint: absolute-gyro-to-stick and relative-gyro-to-mouse were dead while relative-gyro-to-stick and absolute-gyro-to-mouse worked. Those are precisely the two paths that carry a reference versus the two that read instantaneous angular rate and hold no state. Measured with the gate flipping every third frame: absolute gyro to stick fell from 7280 to 364, gyro to mouse from 72 px to 3.6 px. Once the condition holds, the value now has to travel HYSTERESIS (5% of the axis range) back past the threshold before it stops holding. Applied to all six operators, with the band widening in whichever direction satisfies the operator. --- scc/actions.py | 61 ++++++++++++++++++++++++---------------- tests/test_gyro.py | 70 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 102 insertions(+), 29 deletions(-) diff --git a/scc/actions.py b/scc/actions.py index c5b210200..144d24baf 100644 --- a/scc/actions.py +++ b/scc/actions.py @@ -15,6 +15,7 @@ from scc.mapper import Mapper import inspect import logging +import operator import sys from enum import IntEnum from math import atan2, copysign, cos, sin, sqrt @@ -387,11 +388,21 @@ class RangeOP: OPS = ("<", ">", "<=", ">=") + # An analog axis parked near a modeshift threshold jitters across it, and + # every crossing runs ModeModifier's switch path -- which releases held + # buttons and recenters gyro references. With a hair-trigger comparison a + # trigger held at "70%" could re-center an absolute gyro several times a + # second, leaving it permanently at its neutral output. Once the condition + # holds, the value has to travel this far (as a fraction of the axis range) + # back past the threshold before it stops holding. + HYSTERESIS = 0.05 + def __init__(self, what, op, value): """Raises ValueError if 'what' or 'op' is not supported value""" self.what = what self.op = op self.value = value + self.held = False self.min = float(TRIGGER_MIN) self.max = float(TRIGGER_MAX) @@ -441,41 +452,43 @@ def __init__(self, what, op, value): def cmp_or(self, mapper: Mapper): return any([x(mapper) for x in self.children]) - def cmp_gt(self, mapper: Mapper): + def _cmp(self, mapper: Mapper, op, state, rising: bool) -> bool: + """Compares 'state' against the threshold with HYSTERESIS applied, and + latches the result. 'rising' says which side of the threshold satisfies + the operator, so the band always widens in the holding direction. + """ + margin = -RangeOP.HYSTERESIS if self.held else RangeOP.HYSTERESIS + self.held = op(state, self.value + (margin if rising else -margin)) + return self.held + + def _state(self, mapper: Mapper): if mapper.state is None: - return False - state = float(getattr(mapper.state, self.axis_name)) / self.max - return state > self.value + return None + return float(getattr(mapper.state, self.axis_name)) / self.max + + def cmp_gt(self, mapper: Mapper): + state = self._state(mapper) + return False if state is None else self._cmp(mapper, operator.gt, state, True) def cmp_lt(self, mapper: Mapper): - if mapper.state is None: - return False - state = float(getattr(mapper.state, self.axis_name)) / self.max - return state < self.value + state = self._state(mapper) + return False if state is None else self._cmp(mapper, operator.lt, state, False) def cmp_ge(self, mapper: Mapper): - if mapper.state is None: - return False - state = float(getattr(mapper.state, self.axis_name)) / self.max - return state >= self.value + state = self._state(mapper) + return False if state is None else self._cmp(mapper, operator.ge, state, True) def cmp_le(self, mapper: Mapper): - if mapper.state is None: - return False - state = float(getattr(mapper.state, self.axis_name)) / self.max - return state <= self.value + state = self._state(mapper) + return False if state is None else self._cmp(mapper, operator.le, state, False) def cmp_labs(self, mapper: Mapper): - if mapper.state is None: - return False - state = float(getattr(mapper.state, self.axis_name)) / self.max - return abs(state) < self.value + state = self._state(mapper) + return False if state is None else self._cmp(mapper, operator.lt, abs(state), False) def cmp_gabs(self, mapper: Mapper): - if mapper.state is None: - return False - state = float(getattr(mapper.state, self.axis_name)) / self.max - return abs(state) > self.value + state = self._state(mapper) + return False if state is None else self._cmp(mapper, operator.gt, abs(state), True) def __call__(self, mapper: Mapper): return self.op_method(mapper) diff --git a/tests/test_gyro.py b/tests/test_gyro.py index 29c1a5ea8..29cae7b4d 100644 --- a/tests/test_gyro.py +++ b/tests/test_gyro.py @@ -1,12 +1,13 @@ -"""Runtime behaviour of the gyro actions. +"""Runtime behaviour of the gyro actions and of the analog modeshift gate. -Driven through a fake mapper: the real one needs a daemon, a controller and -uinput devices. +Both are driven through a fake mapper: the real one needs a daemon, a +controller and uinput devices. """ import math -from scc.actions import GyroAbsAction, GyroAction -from scc.constants import STICK_PAD_MAX, TRIGGER_MAX, ControllerFlags +from scc.actions import GyroAbsAction, GyroAction, RangeOP +from scc.constants import STICK_PAD_MAX, TRIGGER_MAX, ControllerFlags, SCButtons +from scc.parser import ActionParser from scc.uinput import Axes # driver-side euler encoding: 2**15 / PI fixed point, see ControllerFlags.EUREL_GYROS @@ -98,3 +99,62 @@ def test_stick_range_is_unchanged(self): m = FakeMapper() sweep(GyroAbsAction(Axes.ABS_X), m, 90) assert peak(m, Axes.ABS_X) == STICK_PAD_MAX + + +class TestRangeOPHysteresis: + """`mode(RT >= 0.7, ...)` must not flip while the trigger is parked near + the threshold: every flip runs ModeModifier's switch path, which recenters + gyro references and releases held buttons. + """ + + def test_holds_through_jitter(self): + m = FakeMapper() + op = RangeOP(SCButtons.RT, ">=", 0.7) + m.state.rtrig = int(0.9 * TRIGGER_MAX) + assert op(m) + # dip just under the raw threshold, still inside the hysteresis band + m.state.rtrig = int((0.7 - RangeOP.HYSTERESIS / 2) * TRIGGER_MAX) + assert op(m) + + def test_still_releases(self): + m = FakeMapper() + op = RangeOP(SCButtons.RT, ">=", 0.7) + m.state.rtrig = int(0.9 * TRIGGER_MAX) + assert op(m) + m.state.rtrig = int((0.7 - 2 * RangeOP.HYSTERESIS) * TRIGGER_MAX) + assert not op(m) + + def test_needs_the_full_threshold_to_engage(self): + """Approaching from below, the band tightens rather than loosens.""" + m = FakeMapper() + op = RangeOP(SCButtons.RT, ">=", 0.7) + m.state.rtrig = int((0.7 + RangeOP.HYSTERESIS / 2) * TRIGGER_MAX) + assert not op(m) + m.state.rtrig = int((0.7 + 2 * RangeOP.HYSTERESIS) * TRIGGER_MAX) + assert op(m) + + def test_less_than_direction(self): + m = FakeMapper() + op = RangeOP(SCButtons.RT, "<", 0.3) + m.state.rtrig = 0 + assert op(m) + m.state.rtrig = int((0.3 + RangeOP.HYSTERESIS / 2) * TRIGGER_MAX) + assert op(m) + m.state.rtrig = int((0.3 + 2 * RangeOP.HYSTERESIS) * TRIGGER_MAX) + assert not op(m) + + def test_gated_absolute_gyro_survives_jitter(self): + """End to end: the reported symptom was an absolute gyro producing + nothing at all when gated behind a trigger held at 70%. + """ + action = ActionParser().restart("mode(RT >= 0.7, gyroabs(Axes.ABS_X), None)").parse().compress() + m = FakeMapper() + prev = None + for n in range(21): + m.state.rtrig = TRIGGER_MAX if n % 3 else int(0.69 * TRIGGER_MAX) + a = math.radians(20.0 * n / 20) + rate = 0 if prev is None else (a - prev) * 3000.0 + prev = a + q = int(a * EUREL) + action.gyro(m, rate, rate, rate, q, q, q, 0) + assert peak(m, Axes.ABS_X) > 0.15 * STICK_PAD_MAX From b4bff7ef0ec61c2d1805a66ed44810511df6eab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20=27Patola=27=20Sampaio?= Date: Mon, 3 Aug 2026 01:34:58 +0200 Subject: [PATCH 74/74] fix(gyro): apply per-axis sensitivity once, before clamping GyroAbsAction scaled all three gyro axes by self.speed[2] -- the Z sensitivity -- and then, down in the output loop, scaled the gamepad-axis branch by self.speed[i] as well. Sensitivity was therefore applied twice and one of the two was read from the wrong axis: a setting of 2.0 came out as 4.0 (measured: baseline peak 3640, sens 2.0 peak 14560). Use speed[i], once, and do it before the clamp rather than after. Applying it after meant sensitivity could not move the point at which the axis pegs: the value was already clamped to STICK_PAD_MAX at 90 degrees of rotation, so a higher sensitivity just scaled a saturated reading and got re-clamped. It now behaves as the setting reads -- sens 3.0 pegs the axis at 30 degrees. Scaling before the clamp also fixes the out-of-range haptic, which sits between the two multiplications and was testing a pre-sensitivity value: at sens > 1 the axis could sit pegged without ever firing the feedback pulse. Note for release notes: a sensitivity tuned by feel against the old squaring needs its number squared to match (a working 2.0 becomes 4.0). --- scc/actions.py | 12 ++++++++++-- tests/test_gyro.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/scc/actions.py b/scc/actions.py index 144d24baf..ab5023cb5 100644 --- a/scc/actions.py +++ b/scc/actions.py @@ -1325,7 +1325,15 @@ def gyro(self, mapper: Mapper, pitch, yaw, roll, q1, q2, q3, q4): # and would re-capture on every event if self.ir[i] is None: self.ir[i] = pyr[i] - pyr[i] = anglediff(self.ir[i], pyr[i]) * (2**15) * self.speed[2] * 2 / PI + # speed[i], not speed[2]: sensitivity is per gyro axis, and the Z + # one used to be applied to all three -- and then applied a SECOND + # time, per-axis, down in the output loop, so a sensitivity of 2 + # came out as 4. Scaling here rather than there also means the + # clamp and the out-of-range haptic below see the value that is + # actually emitted: sensitivity now moves the rotation needed for + # full deflection, instead of merely scaling an already saturated + # reading. + pyr[i] = anglediff(self.ir[i], pyr[i]) * (2**15) * self.speed[i] * 2 / PI if self.haptic: oor = False # oor - Out Of Range for i in self.GYROAXES: @@ -1352,7 +1360,7 @@ def gyro(self, mapper: Mapper, pitch, yaw, roll, q1, q2, q3, q4): # swallowed the mouse axes into this gamepad branch (the elifs below # never ran) -- gyro->mouse moved the stick instead of the cursor. if isinstance(axis, Axes) or type(axis) == int: - val = pyr[i] * self.speed[i] + val = pyr[i] if self._deadzone_fn: # deadzone works in stick range, before the axis rescale val, trash = self._deadzone_fn(clamp(STICK_PAD_MIN, val, STICK_PAD_MAX), 0, STICK_PAD_MAX) diff --git a/tests/test_gyro.py b/tests/test_gyro.py index 29cae7b4d..8a2c5b3dd 100644 --- a/tests/test_gyro.py +++ b/tests/test_gyro.py @@ -101,6 +101,39 @@ def test_stick_range_is_unchanged(self): assert peak(m, Axes.ABS_X) == STICK_PAD_MAX +class TestGyroSensitivity: + """Per-axis sensitivity used to be read from index 2 for every axis and + then applied a second time per-axis, squaring it. + """ + + def test_applied_once(self): + plain, scaled = FakeMapper(), FakeMapper() + a = GyroAbsAction(Axes.ABS_X) + sweep(a, plain, 10) + b = GyroAbsAction(Axes.ABS_X) + b.set_speed(2.0, 2.0, 2.0) + sweep(b, scaled, 10) + assert peak(scaled, Axes.ABS_X) == 2 * peak(plain, Axes.ABS_X) + + def test_is_per_axis(self): + """Sensitivity of gyro axis 0 must not be taken from axis 2.""" + m = FakeMapper() + a = GyroAbsAction(Axes.ABS_X, Axes.ABS_Y, Axes.ABS_RX) + a.set_speed(1.0, 1.0, 3.0) + sweep(a, m, 10) + assert peak(m, Axes.ABS_RX) == 3 * peak(m, Axes.ABS_X) + + def test_moves_the_full_deflection_point(self): + """Sensitivity has to change the rotation needed to peg the axis, not + just scale a value that already saturated at 90 deg. + """ + m = FakeMapper() + a = GyroAbsAction(Axes.ABS_X) + a.set_speed(3.0, 3.0, 3.0) + sweep(a, m, 35) # 3x35 deg is past the 90 deg full-deflection point + assert peak(m, Axes.ABS_X) == STICK_PAD_MAX + + class TestRangeOPHysteresis: """`mode(RT >= 0.7, ...)` must not flip while the trigger is parked near the threshold: every flip runs ModeModifier's switch path, which recenters