relay.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. // relay.h — host→controller relay seam.
  2. //
  3. // The personality hands Steam's actuator/config writes (haptics 0x80-0x86,
  4. // settings 0x87, power-off 0x9F, and feature-id-1 passthrough) to relay_enqueue.
  5. // Where they go depends on what is bound to the slot:
  6. // - Phase 2: a generic BLE/Classic pad → mapped to the pad's rumble output.
  7. // - Phase 4: a Steam Controller 2 → GATT-written verbatim to the Valve report
  8. // characteristic (transparent forwarding).
  9. // In Phase 1 there is nothing bound, so this is a no-op.
  10. //
  11. // SPDX-License-Identifier: AGPL-3.0-or-later
  12. #ifndef PICOPUCK_RELAY_H
  13. #define PICOPUCK_RELAY_H
  14. #include <stdint.h>
  15. #include <stdint.h>
  16. // Diagnostics (read by the WebUSB panel): total relays and the last report id.
  17. extern volatile uint16_t g_relay_count;
  18. extern volatile uint8_t g_relay_last_id;
  19. // Build the SC2 0x80 rumble report from 16-bit motor magnitudes and relay it to
  20. // the controller bound to `slot` (OpenPuck's hapticSteamRumble). Emulated modes
  21. // call this from their host output-report handlers.
  22. void puck_rumble(int slot, uint16_t lo, uint16_t hi);
  23. // Forward the HID report [report_id][body...] to the controller bound to `slot`
  24. // (SC2: written verbatim to the Valve report characteristic; generic pad: 0x80
  25. // rumble mapped to the pad's output). No length byte is re-inserted — pass the
  26. // exact bytes that should land on the controller after the report-id.
  27. void relay_enqueue(int slot, uint8_t report_id, const uint8_t *body, uint16_t len);
  28. #endif // PICOPUCK_RELAY_H