12345678910111213141516171819202122232425262728293031323334 |
- #include "client/input/Controller.h"
- Controller::Controller(Buttons& b)
- : buttons(b), list(b.get()), left(b.add(GLFW_KEY_A, "Left")),
- right(b.add(GLFW_KEY_D, "Right")), up(b.add(GLFW_KEY_W, "X")),
- down(b.add(GLFW_KEY_S, "Y")), jump(b.add(GLFW_KEY_SPACE, "L")),
- sneak(b.add(GLFW_KEY_LEFT_SHIFT, "R")),
- camLeft(b.add(GLFW_KEY_LEFT, "Start")),
- camRight(b.add(GLFW_KEY_RIGHT, "Select")),
- camUp(b.add(GLFW_KEY_UP, "Left")), camDown(b.add(GLFW_KEY_DOWN, "Right")),
- mouseList(b.getMouse()),
- leftClick(b.addMouse(GLFW_MOUSE_BUTTON_LEFT, "Left Click")),
- rightClick(b.addMouse(GLFW_MOUSE_BUTTON_RIGHT, "Right Click")) {
- b.mapGamepadAxis(left, -0.5f, GLFW_GAMEPAD_AXIS_LEFT_X);
- b.mapGamepadAxis(right, 0.5f, GLFW_GAMEPAD_AXIS_LEFT_X);
- b.mapGamepadAxis(up, -0.5f, GLFW_GAMEPAD_AXIS_LEFT_Y);
- b.mapGamepadAxis(down, 0.5f, GLFW_GAMEPAD_AXIS_LEFT_Y);
- b.mapGamepadAxis(camUp, -0.5f, GLFW_GAMEPAD_AXIS_RIGHT_Y);
- b.mapGamepadAxis(camDown, 0.5f, GLFW_GAMEPAD_AXIS_RIGHT_Y);
- b.mapGamepadAxis(camLeft, -0.5f, GLFW_GAMEPAD_AXIS_RIGHT_X);
- b.mapGamepadAxis(camRight, 0.5f, GLFW_GAMEPAD_AXIS_RIGHT_X);
- }
- Vector2 Controller::getMouse() const {
- return Vector2(static_cast<float>(buttons.getMouseX()),
- static_cast<float>(buttons.getMouseY()));
- }
- Vector2 Controller::getMouseChange() const {
- return Vector2(
- static_cast<float>(buttons.getMouseX() - buttons.getLastMouseX()),
- static_cast<float>(buttons.getMouseY() - buttons.getLastMouseY()));
- }
|