Controller.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include "input/Controller.h"
  2. void Controller::tick() {
  3. }
  4. /*#include <GLFW/glfw3.h>
  5. #include "client/input/Keys.h"
  6. Keys::Key::Key() : down(false), shouldRelease(false), downTime(0) {
  7. }
  8. bool Keys::Key::isDown() const {
  9. return down;
  10. }
  11. bool Keys::Key::isReleased() const {
  12. return shouldRelease;
  13. }
  14. u32 Keys::Key::getDownTime() const {
  15. return downTime;
  16. }
  17. std::ostream& operator<<(std::ostream& os, const Keys::Key& k) {
  18. os << "Key(down: " << k.isDown() << ", release: " << k.isReleased() <<
  19. ", time: " << k.getDownTime() << ")";
  20. return os;
  21. }
  22. Keys::Keys() : left(keys[0]), right(keys[1]), up(keys[2]), down(keys[3]), jump(keys[4]), sneak(keys[5]),
  23. camLeft(keys[6]), camRight(keys[7]), camUp(keys[8]), camDown(keys[9]), test(keys[10]), test2(keys[11]), test3(keys[12]),
  24. test4(keys[13]), test5(keys[14]) {
  25. keys[0].glfwKey = GLFW_KEY_A;
  26. keys[1].glfwKey = GLFW_KEY_D;
  27. keys[2].glfwKey = GLFW_KEY_W;
  28. keys[3].glfwKey = GLFW_KEY_S;
  29. keys[4].glfwKey = GLFW_KEY_SPACE;
  30. keys[5].glfwKey = GLFW_KEY_LEFT_SHIFT;
  31. keys[6].glfwKey = GLFW_KEY_LEFT;
  32. keys[7].glfwKey = GLFW_KEY_RIGHT;
  33. keys[8].glfwKey = GLFW_KEY_UP;
  34. keys[9].glfwKey = GLFW_KEY_DOWN;
  35. keys[10].glfwKey = GLFW_KEY_T;
  36. keys[11].glfwKey = GLFW_KEY_Y;
  37. keys[12].glfwKey = GLFW_KEY_U;
  38. keys[13].glfwKey = GLFW_KEY_I;
  39. keys[14].glfwKey = GLFW_KEY_R;
  40. }
  41. void Keys::release(int key) {
  42. for(Key& k : keys) {
  43. if(k.glfwKey == key) {
  44. k.shouldRelease = true;
  45. }
  46. }
  47. }
  48. void Keys::press(int key) {
  49. for(Key& k : keys) {
  50. if(k.glfwKey == key) {
  51. k.down = true;
  52. k.shouldRelease = false;
  53. }
  54. }
  55. }
  56. void Keys::tick() {
  57. for(Key& k : keys) {
  58. k.downTime += k.down;
  59. k.down = k.down && !k.shouldRelease;
  60. k.downTime *= !k.shouldRelease;
  61. k.shouldRelease = false;
  62. }
  63. }*/