[PR #84] [CLOSED] Switch Pro mode: attach one HID mouse per connected controller, driven by the right trackpad #190

Closed
opened 2026-10-22 05:07:21 +00:00 by roman · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/safijari/openpuck/pull/84
Author: @Copilot
Created: 6/24/2026
Status: ❌ Closed

Base: main ← Head: copilot/attach-hid-mouse-for-switch-pro-mode


📝 Commits (2)

  • bab9563 Add per-slot HID mouse to Switch Pro mode for right trackpad
  • 7fa1b3b Clarify maxSlots divisor comment and mouse sensitivity comment

📊 Changes

12 files changed (+197 additions, -60 deletions)

View changed files

📝 AGENTS.md (+1 -1)
📝 OpenPuck/OpenPuck.ino (+11 -8)
📝 OpenPuck/config.cpp (+4 -3)
📝 OpenPuck/config.h (+4 -2)
📝 OpenPuck/mode_switch_pro.cpp (+105 -8)
📝 OpenPuck/mode_xinput.cpp (+2 -1)
📝 OpenPuck/radio.cpp (+7 -5)
📝 OpenPuck/rf_link.cpp (+4 -2)
📝 OpenPuck/rf_link.h (+8 -4)
📝 OpenPuck/serial_console.cpp (+7 -4)
📝 OpenPuck/webusb_config.cpp (+4 -2)
📝 puck_sniffer/puck_sniffer.ino (+40 -20)

📄 Description

Switch Pro mode previously exposed only the Pro Controller HID per slot. This adds a paired relative-mouse HID per connected controller, with the right trackpad feeding it via the same glide/friction algorithm used by lizard and Xbox modes.

Core changes (mode_switch_pro.cpp)

  • SW_MOUSE_HID_DESC — standard TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(1)) descriptor; g_swMouse[NSLOT] array of Adafruit_USBD_HID instances with matching per-slot glide state (vx/vy, prx/pry, sub-pixel carry, last-buttons).
  • maxSlots() — CFG_TUD_HID - 1 → (CFG_TUD_HID - 1) / 2; each slot now consumes 2 HID instances (Pro Controller + mouse).
  • beginPool() — registers mouse pool after the Pro Controller pool to keep TinyUSB instance indices stable: wake=0, pro[0..N-1], mouse[0..N-1].
  • mountSlots(k) — mounts all Pro Controllers first (preserves existing interface numbering), then mice; resets glide state on re-enumeration to clear stale velocity / stuck buttons.
  • task() — independent per-slot mouse loop runs regardless of Pro Controller handshake state so the mouse is live on PC before a Switch completes the 0x30 report-mode exchange. Right-pad click (TB_RPADC) → primary button; sensitivity via existing g_mDiv/g_mFric tunables.

HID budget

CFG_TUD_HID Slots Pro + Mouse HIDs Wake IN eps (+ WebUSB)
5 2 2 + 2 1 6 ✓
9 4 4 + 4 1 10 ⚠ over nRF52840 limit

CFG_TUD_HID=5 is the recommended value; it fits within the nRF52840's 7 IN-endpoint ceiling.

Build (OpenPuck.ino, AGENTS.md)

Minimum CFG_TUD_HID raised 4 → 5; build example updated accordingly.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/safijari/openpuck/pull/84 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 6/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `copilot/attach-hid-mouse-for-switch-pro-mode` --- ### 📝 Commits (2) - [`bab9563`](https://github.com/safijari/openpuck/commit/bab95634debfd47956f9d98a27d2a530f03c07a5) Add per-slot HID mouse to Switch Pro mode for right trackpad - [`7fa1b3b`](https://github.com/safijari/openpuck/commit/7fa1b3b66d0e2bb0cfba3b75ecc2233dcea8cfcc) Clarify maxSlots divisor comment and mouse sensitivity comment ### 📊 Changes **12 files changed** (+197 additions, -60 deletions) <details> <summary>View changed files</summary> 📝 `AGENTS.md` (+1 -1) 📝 `OpenPuck/OpenPuck.ino` (+11 -8) 📝 `OpenPuck/config.cpp` (+4 -3) 📝 `OpenPuck/config.h` (+4 -2) 📝 `OpenPuck/mode_switch_pro.cpp` (+105 -8) 📝 `OpenPuck/mode_xinput.cpp` (+2 -1) 📝 `OpenPuck/radio.cpp` (+7 -5) 📝 `OpenPuck/rf_link.cpp` (+4 -2) 📝 `OpenPuck/rf_link.h` (+8 -4) 📝 `OpenPuck/serial_console.cpp` (+7 -4) 📝 `OpenPuck/webusb_config.cpp` (+4 -2) 📝 `puck_sniffer/puck_sniffer.ino` (+40 -20) </details> ### 📄 Description Switch Pro mode previously exposed only the Pro Controller HID per slot. This adds a paired relative-mouse HID per connected controller, with the right trackpad feeding it via the same glide/friction algorithm used by lizard and Xbox modes. ## Core changes (`mode_switch_pro.cpp`) - **`SW_MOUSE_HID_DESC`** — standard `TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(1))` descriptor; `g_swMouse[NSLOT]` array of `Adafruit_USBD_HID` instances with matching per-slot glide state (`vx/vy`, `prx/pry`, sub-pixel carry, last-buttons). - **`maxSlots()`** — `CFG_TUD_HID - 1` → `(CFG_TUD_HID - 1) / 2`; each slot now consumes 2 HID instances (Pro Controller + mouse). - **`beginPool()`** — registers mouse pool after the Pro Controller pool to keep TinyUSB instance indices stable: `wake=0`, `pro[0..N-1]`, `mouse[0..N-1]`. - **`mountSlots(k)`** — mounts all Pro Controllers first (preserves existing interface numbering), then mice; resets glide state on re-enumeration to clear stale velocity / stuck buttons. - **`task()`** — independent per-slot mouse loop runs regardless of Pro Controller handshake state so the mouse is live on PC before a Switch completes the `0x30` report-mode exchange. Right-pad click (`TB_RPADC`) → primary button; sensitivity via existing `g_mDiv`/`g_mFric` tunables. ## HID budget | `CFG_TUD_HID` | Slots | Pro + Mouse HIDs | Wake | IN eps (+ WebUSB) | |---|---|---|---|---| | 5 | 2 | 2 + 2 | 1 | 6 ✓ | | 9 | 4 | 4 + 4 | 1 | 10 ⚠ over nRF52840 limit | `CFG_TUD_HID=5` is the recommended value; it fits within the nRF52840's 7 IN-endpoint ceiling. ## Build (`OpenPuck.ino`, `AGENTS.md`) Minimum `CFG_TUD_HID` raised 4 → 5; build example updated accordingly. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
roman 2026-10-22 05:07:21 +00:00
Sign in to join this conversation.
No labels
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
safijari/openpuck#190
No description provided.