controllers.cpp 993 B

12345678910111213141516171819202122232425262728
  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. #include "mode_xboxone.h"
  10. IController* g_active = nullptr;
  11. // Map a USB-presentation mode to its singleton controller. Steam and Lizard share the puck controller (the
  12. // lizard-vs-forward decision is made per-report inside it). This is the one place that knows the mode->class
  13. // mapping; everything else dispatches through g_active.
  14. IController* controllerFor(uint8_t mode){
  15. switch(mode){
  16. case MODE_STEAM: return &g_steamPuck;
  17. case MODE_LIZARD: return &g_steamPuck;
  18. case MODE_XBOX: return &g_xboxCtl;
  19. case MODE_SW_HORI: return &g_switchHori;
  20. case MODE_SW_PRO: return &g_switchPro;
  21. case MODE_PS5: return &g_ps5Ctl;
  22. case MODE_HIDGYRO: return &g_hidGyroCtl;
  23. case MODE_XBOXONE: return &g_xboxOneCtl;
  24. default: return &g_steamPuck;
  25. }
  26. }