Controls.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "GLFW/glfw3.h"
  2. #include "client/Controls.h"
  3. Window::Controls::ButtonId Controls::left = 0;
  4. Window::Controls::ButtonId Controls::right = 0;
  5. Window::Controls::ButtonId Controls::up = 0;
  6. Window::Controls::ButtonId Controls::down = 0;
  7. Window::Controls::ButtonId Controls::jump = 0;
  8. Window::Controls::ButtonId Controls::sneak = 0;
  9. Window::Controls::ButtonId Controls::escape = 0;
  10. Window::Controls::ButtonId Controls::chat = 0;
  11. Window::Controls::ButtonId Controls::enter = 0;
  12. Window::Controls::ButtonId Controls::primaryClick = 0;
  13. Window::Controls::ButtonId Controls::secondaryClick = 0;
  14. void Controls::init() {
  15. left = Window::Controls::add("Left");
  16. Window::Controls::bindKey(left, GLFW_KEY_A);
  17. right = Window::Controls::add("Right");
  18. Window::Controls::bindKey(right, GLFW_KEY_D);
  19. up = Window::Controls::add("Up");
  20. Window::Controls::bindKey(up, GLFW_KEY_W);
  21. down = Window::Controls::add("Down");
  22. Window::Controls::bindKey(down, GLFW_KEY_S);
  23. jump = Window::Controls::add("Jump");
  24. Window::Controls::bindKey(jump, GLFW_KEY_SPACE);
  25. sneak = Window::Controls::add("Sneak");
  26. Window::Controls::bindKey(sneak, GLFW_KEY_LEFT_SHIFT);
  27. escape = Window::Controls::add("Escape");
  28. Window::Controls::bindKey(escape, GLFW_KEY_ESCAPE);
  29. chat = Window::Controls::add("Chat");
  30. Window::Controls::bindKey(chat, GLFW_KEY_T);
  31. enter = Window::Controls::add("Enter");
  32. Window::Controls::bindKey(enter, GLFW_KEY_ENTER);
  33. primaryClick = Window::Controls::add("Primary Click");
  34. Window::Controls::bindMouse(primaryClick, GLFW_MOUSE_BUTTON_LEFT);
  35. secondaryClick = Window::Controls::add("Secondary Click");
  36. Window::Controls::bindMouse(secondaryClick, GLFW_MOUSE_BUTTON_RIGHT);
  37. }
  38. bool Controls::wasReleased(Window::Controls::ButtonId id) {
  39. return Window::Controls::wasReleased(id);
  40. }
  41. bool Controls::isDown(Window::Controls::ButtonId id) {
  42. return Window::Controls::isDown(id);
  43. }