controllers.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "controllers.h"
  2. #include "config.h"
  3. #include "puck_hid.h"
  4. #include "mode_xinput.h"
  5. #include "mode_switch_hori.h"
  6. #include "mode_switch_pro.h"
  7. #include "mode_ps5.h"
  8. #include "mode_hidgyro.h"
  9. IController *g_active = nullptr;
  10. // Map a USB-presentation mode to its singleton controller. Steam and Lizard share the puck controller (the
  11. // lizard-vs-forward decision is made per-report inside it). This is the one place that knows the mode->class
  12. // mapping; everything else dispatches through g_active.
  13. IController *controllerFor(uint8_t mode)
  14. {
  15. switch (mode) {
  16. case MODE_STEAM:
  17. return &g_steamPuck;
  18. case MODE_LIZARD:
  19. return &g_steamPuck;
  20. case MODE_XBOX:
  21. return &g_xboxCtl;
  22. case MODE_SW_HORI:
  23. return &g_switchHori;
  24. case MODE_SW_PRO:
  25. return &g_switchPro;
  26. case MODE_PS5:
  27. return &g_ps5Ctl;
  28. case MODE_HIDGYRO:
  29. return &g_hidGyroCtl;
  30. case MODE_PS5_GAME:
  31. // same DualSense controller; setup() drops wake/WebUSB for clean enum
  32. return &g_ps5Ctl;
  33. case MODE_DS4_GAME:
  34. // same DS4 controller; setup() drops wake/WebUSB for clean enum
  35. return &g_hidGyroCtl;
  36. default:
  37. return &g_steamPuck;
  38. }
  39. }