Controller.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132
  1. #include "input/Controller.h"
  2. Controller::Controller(Buttons& bs) : list(bs.get()), a(bs.add(GLFW_KEY_A, "A")), b(bs.add(GLFW_KEY_S, "B")),
  3. x(bs.add(GLFW_KEY_X, "X")), y(bs.add(GLFW_KEY_Z, "Y")), l(bs.add(GLFW_KEY_Q, "L")), r(bs.add(GLFW_KEY_W, "R")),
  4. start(bs.add(GLFW_KEY_E, "Start")), select(bs.add(GLFW_KEY_D, "Select")), left(bs.add(GLFW_KEY_LEFT, "Left")),
  5. right(bs.add(GLFW_KEY_RIGHT, "Right")), up(bs.add(GLFW_KEY_UP, "Up")), down(bs.add(GLFW_KEY_DOWN, "Down")) {
  6. bs.mapGamepadButton(a, GLFW_GAMEPAD_BUTTON_A);
  7. bs.mapGamepadButton(b, GLFW_GAMEPAD_BUTTON_B);
  8. bs.mapGamepadButton(x, GLFW_GAMEPAD_BUTTON_X);
  9. bs.mapGamepadButton(y, GLFW_GAMEPAD_BUTTON_Y);
  10. bs.mapGamepadButton(l, GLFW_GAMEPAD_BUTTON_LEFT_BUMPER);
  11. bs.mapGamepadButton(r, GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER);
  12. bs.mapGamepadButton(select, GLFW_GAMEPAD_BUTTON_BACK);
  13. bs.mapGamepadButton(start, GLFW_GAMEPAD_BUTTON_START);
  14. bs.mapGamepadButton(select, GLFW_GAMEPAD_BUTTON_LEFT_THUMB);
  15. bs.mapGamepadButton(start, GLFW_GAMEPAD_BUTTON_RIGHT_THUMB);
  16. bs.mapGamepadButton(up, GLFW_GAMEPAD_BUTTON_DPAD_UP);
  17. bs.mapGamepadButton(right, GLFW_GAMEPAD_BUTTON_DPAD_RIGHT);
  18. bs.mapGamepadButton(down, GLFW_GAMEPAD_BUTTON_DPAD_DOWN);
  19. bs.mapGamepadButton(left, GLFW_GAMEPAD_BUTTON_DPAD_LEFT);
  20. bs.mapGamepadAxis(left, -0.5f, GLFW_GAMEPAD_AXIS_LEFT_X);
  21. bs.mapGamepadAxis(right, 0.5f, GLFW_GAMEPAD_AXIS_LEFT_X);
  22. bs.mapGamepadAxis(left, -0.5f, GLFW_GAMEPAD_AXIS_RIGHT_X);
  23. bs.mapGamepadAxis(right, 0.5f, GLFW_GAMEPAD_AXIS_RIGHT_X);
  24. bs.mapGamepadAxis(up, -0.5f, GLFW_GAMEPAD_AXIS_LEFT_Y);
  25. bs.mapGamepadAxis(down, 0.5f, GLFW_GAMEPAD_AXIS_LEFT_Y);
  26. bs.mapGamepadAxis(up, -0.5f, GLFW_GAMEPAD_AXIS_RIGHT_Y);
  27. bs.mapGamepadAxis(down, 0.5f, GLFW_GAMEPAD_AXIS_RIGHT_Y);
  28. bs.mapGamepadAxis(l, 0.1f, GLFW_GAMEPAD_AXIS_LEFT_TRIGGER);
  29. bs.mapGamepadAxis(r, 0.1f, GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER);
  30. }