123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #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
|