ctrl_bonds.h 1.2 KB

12345678910111213141516171819202122232425262728
  1. // ctrl_bonds.h -- the emulated controller's bonds to pucks.
  2. //
  3. // A real Steam Controller bonds to up to two pucks under the Zephyr settings keys `esb/bond` (slot 0)
  4. // and `esb/bond_2` (slot 1). We mirror that: two slots, each holding the 24-byte bond record
  5. // rec = [proteus_uuid 4 LE][ibex_uuid 4 LE][puck_serial 16]
  6. // -- the SAME 24-byte shape Steam writes to the puck via 0xA2, except the trailing serial is the
  7. // PUCK's (the peer), not the controller's. The 8-byte uuid key is identical on both sides and is what
  8. // matches the puck's E1 host frame at reconnect. Persists to LittleFS `/ctrlbond.bin`.
  9. #pragma once
  10. #include <stdint.h>
  11. #define NBOND 2
  12. struct CtrlBond {
  13. uint8_t rec[24]; // [proteus_uuid 4][ibex_uuid 4][puck_serial 16]
  14. bool used;
  15. // feature-report reply staging (filled in ISR, read on GET)
  16. uint8_t resp[63];
  17. uint16_t resp_len;
  18. };
  19. extern CtrlBond g_bond[NBOND];
  20. extern volatile bool g_bondDirty; // bonds changed -> flush to flash from loop()
  21. bool ctrlRecEmpty(const uint8_t *r);
  22. void loadCtrlBonds();
  23. void saveCtrlBonds();
  24. // Find a bond slot matching a puck E1 host frame's [proteus_uuid 4][ibex_uuid 4]; -1 if none.
  25. int ctrlBondMatch(const uint8_t *proteus_uuid, const uint8_t *ibex_uuid);