deck_input.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // deck_input.h -- the USB-CDC link to the Steam Deck forwarder app.
  2. //
  3. // The Deck app (deck/) streams the Deck's grabbed controls as INPUT frames; we decode them into g_in
  4. // (report45.cpp then encodes the RF report 0x45). We stream STATUS frames back so the app's UI can show
  5. // which bonded pucks are live. One framed binary protocol both ways; the reader resynchronizes on a
  6. // 2-byte sync word so a serial monitor's stray text is harmless. The wire format is mirrored exactly in
  7. // deck/frame.py.
  8. //
  9. // frame = [0xA5][0x5A][type][len][payload(len)][sum8(type,len,payload...)]
  10. //
  11. // Deck -> nRF: 0x01 INPUT (34B fields), 0x02 CONTROL ([sub][..]: sub 0x01=set-forwarding[0/1]),
  12. // 0x03 REQUEST_STATUS (no payload)
  13. // nRF -> Deck: 0x10 STATUS, 0x1F TEXT(debug)
  14. #pragma once
  15. #include <stdint.h>
  16. #define DECK_SYNC0 0xA5
  17. #define DECK_SYNC1 0x5A
  18. #define DECK_T_INPUT 0x01
  19. #define DECK_T_CONTROL 0x02
  20. #define DECK_T_REQ_STATUS 0x03
  21. #define DECK_T_STATUS 0x10
  22. #define DECK_T_TEXT 0x1F
  23. // Pump the CDC RX state machine: parse any complete frames, fill g_in, update forwarding state.
  24. void deckInputPoll();
  25. // Emit a STATUS frame (bond list + link state) to the Deck. Rate-limited internally; call each loop.
  26. void deckStatusTask();
  27. // Send a debug text line as a 0x1F frame (skipped by the app unless it shows debug).
  28. void deckText(const char *s);
  29. // Is the app currently forwarding (user tapped a puck)? When false, ctrl_link sends a neutral report.
  30. bool deckForwarding();
  31. // millis() of the last INPUT frame; ctrl_link sends neutral if input goes stale while forwarding.
  32. unsigned long deckLastInputMs();