1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #ifndef BUTTONS_H
- #define BUTTONS_H
- #include <GL/glew.h>
- #include <GLFW/glfw3.h>
- #include "input/Button.h"
- #include "utils/Array.h"
- #include "utils/ArrayList.h"
- #include "utils/HashMap.h"
- class Buttons final {
- friend class Window;
- HashMap<int, Button*> buttons;
- HashMap<int, Button*> mouseButtons;
- double lastMouseX;
- double lastMouseY;
- double mouseX;
- double mouseY;
- int activeController;
- struct Axis {
- float less;
- float greater;
- Button* lessButton;
- Button* greaterButton;
- Axis();
- };
- Array<Axis, 1 + GLFW_GAMEPAD_AXIS_LAST> gamepadAxisToButton;
- Array<Button*, 1 + GLFW_GAMEPAD_BUTTON_LAST> gamepadToButton;
- public:
- Buttons();
- void add(Button& button);
- void addMouse(Button& button);
- void mapGamepadButton(Button& button, int mapping);
- void mapGamepadAxis(Button& button, float value, int index);
- void tick();
- double getLastMouseX() const;
- double getLastMouseY() const;
- double getMouseX() const;
- double getMouseY() const;
- private:
- void onButton(HashMap<int, Button*>& map, int key, int action);
- void onKey(int key, int scancode, int action, int mods);
- void onMouse(int button, int action, int mods);
- void onMouseMove(double x, double y);
- bool searchForGamepad();
- void checkGamepad();
- };
- #endif
|