Controller.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "input/Controller.h"
  2. Button Controller::a{GLFW_KEY_A, "A"};
  3. Button Controller::b{GLFW_KEY_S, "B"};
  4. Button Controller::x{GLFW_KEY_X, "X"};
  5. Button Controller::y{GLFW_KEY_Z, "Y"};
  6. Button Controller::l{GLFW_KEY_Q, "L"};
  7. Button Controller::r{GLFW_KEY_W, "R"};
  8. Button Controller::start{GLFW_KEY_E, "Start"};
  9. Button Controller::select{GLFW_KEY_D, "Select"};
  10. Button Controller::left{GLFW_KEY_LEFT, "Left"};
  11. Button Controller::right{GLFW_KEY_RIGHT, "Right"};
  12. Button Controller::up{GLFW_KEY_UP, "Up"};
  13. Button Controller::down{GLFW_KEY_DOWN, "Down"};
  14. void Controller::init(Buttons& bs) {
  15. bs.add(a);
  16. bs.add(b);
  17. bs.add(x);
  18. bs.add(y);
  19. bs.add(l);
  20. bs.add(r);
  21. bs.add(start);
  22. bs.add(select);
  23. bs.add(left);
  24. bs.add(right);
  25. bs.add(up);
  26. bs.add(down);
  27. bs.mapGamepadButton(a, GLFW_GAMEPAD_BUTTON_A);
  28. bs.mapGamepadButton(b, GLFW_GAMEPAD_BUTTON_B);
  29. bs.mapGamepadButton(x, GLFW_GAMEPAD_BUTTON_X);
  30. bs.mapGamepadButton(y, GLFW_GAMEPAD_BUTTON_Y);
  31. bs.mapGamepadButton(l, GLFW_GAMEPAD_BUTTON_LEFT_BUMPER);
  32. bs.mapGamepadButton(r, GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER);
  33. bs.mapGamepadButton(select, GLFW_GAMEPAD_BUTTON_BACK);
  34. bs.mapGamepadButton(start, GLFW_GAMEPAD_BUTTON_START);
  35. bs.mapGamepadButton(select, GLFW_GAMEPAD_BUTTON_LEFT_THUMB);
  36. bs.mapGamepadButton(start, GLFW_GAMEPAD_BUTTON_RIGHT_THUMB);
  37. bs.mapGamepadButton(up, GLFW_GAMEPAD_BUTTON_DPAD_UP);
  38. bs.mapGamepadButton(right, GLFW_GAMEPAD_BUTTON_DPAD_RIGHT);
  39. bs.mapGamepadButton(down, GLFW_GAMEPAD_BUTTON_DPAD_DOWN);
  40. bs.mapGamepadButton(left, GLFW_GAMEPAD_BUTTON_DPAD_LEFT);
  41. bs.mapGamepadAxis(left, -0.5f, GLFW_GAMEPAD_AXIS_LEFT_X);
  42. bs.mapGamepadAxis(right, 0.5f, GLFW_GAMEPAD_AXIS_LEFT_X);
  43. bs.mapGamepadAxis(left, -0.5f, GLFW_GAMEPAD_AXIS_RIGHT_X);
  44. bs.mapGamepadAxis(right, 0.5f, GLFW_GAMEPAD_AXIS_RIGHT_X);
  45. bs.mapGamepadAxis(up, -0.5f, GLFW_GAMEPAD_AXIS_LEFT_Y);
  46. bs.mapGamepadAxis(down, 0.5f, GLFW_GAMEPAD_AXIS_LEFT_Y);
  47. bs.mapGamepadAxis(up, -0.5f, GLFW_GAMEPAD_AXIS_RIGHT_Y);
  48. bs.mapGamepadAxis(down, 0.5f, GLFW_GAMEPAD_AXIS_RIGHT_Y);
  49. bs.mapGamepadAxis(l, 0.1f, GLFW_GAMEPAD_AXIS_LEFT_TRIGGER);
  50. bs.mapGamepadAxis(r, 0.1f, GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER);
  51. }