Controller.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "GLFW/glfw3.h"
  2. #include "client/input/Controller.h"
  3. #include "client/rendering/Engine.h"
  4. Window::Controls::ButtonId Controller::left = 0;
  5. Window::Controls::ButtonId Controller::right = 0;
  6. Window::Controls::ButtonId Controller::up = 0;
  7. Window::Controls::ButtonId Controller::down = 0;
  8. Window::Controls::ButtonId Controller::jump = 0;
  9. Window::Controls::ButtonId Controller::sneak = 0;
  10. Window::Controls::ButtonId Controller::camLeft = 0;
  11. Window::Controls::ButtonId Controller::camRight = 0;
  12. Window::Controls::ButtonId Controller::camUp = 0;
  13. Window::Controls::ButtonId Controller::camDown = 0;
  14. Window::Controls::ButtonId Controller::leftClick = 0;
  15. Window::Controls::ButtonId Controller::rightClick = 0;
  16. void Controller::init() {
  17. left = Window::Controls::add("Left");
  18. Window::Controls::bindKey(left, GLFW_KEY_A);
  19. right = Window::Controls::add("Right");
  20. Window::Controls::bindKey(right, GLFW_KEY_D);
  21. up = Window::Controls::add("Up");
  22. Window::Controls::bindKey(up, GLFW_KEY_W);
  23. down = Window::Controls::add("Down");
  24. Window::Controls::bindKey(down, GLFW_KEY_S);
  25. jump = Window::Controls::add("Jump");
  26. Window::Controls::bindKey(jump, GLFW_KEY_SPACE);
  27. sneak = Window::Controls::add("Sneak");
  28. Window::Controls::bindKey(sneak, GLFW_KEY_LEFT_SHIFT);
  29. camLeft = Window::Controls::add("Camera Left");
  30. Window::Controls::bindKey(camLeft, GLFW_KEY_LEFT);
  31. camRight = Window::Controls::add("Camera Right");
  32. Window::Controls::bindKey(camRight, GLFW_KEY_RIGHT);
  33. camUp = Window::Controls::add("Camera Up");
  34. Window::Controls::bindKey(camUp, GLFW_KEY_UP);
  35. camDown = Window::Controls::add("Camera Down");
  36. Window::Controls::bindKey(camDown, GLFW_KEY_DOWN);
  37. leftClick = Window::Controls::add("Left Click");
  38. Window::Controls::bindMouse(leftClick, GLFW_MOUSE_BUTTON_LEFT);
  39. rightClick = Window::Controls::add("Right Click");
  40. Window::Controls::bindMouse(leftClick, GLFW_MOUSE_BUTTON_RIGHT);
  41. }
  42. bool Controller::wasReleased(Window::Controls::ButtonId id) {
  43. return Window::Controls::wasReleased(id);
  44. }
  45. bool Controller::isDown(Window::Controls::ButtonId id) {
  46. return Window::Controls::isDown(id);
  47. }