12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #ifndef BUTTONS_H
- #define BUTTONS_H
- #include "input/Button.h"
- #include "rendering/Window.h"
- #include "utils/Array.h"
- #include "utils/ArrayList.h"
- typedef ArrayList<Button, 32> ButtonList;
- typedef ArrayList<Button, 1 + GLFW_MOUSE_BUTTON_LAST> MouseList;
- class Buttons final {
- typedef Array<bool, 32> DownArray;
- const Window& window;
- Button dummy;
- int activeController;
- ButtonList buttons;
- MouseList mouseButtons;
- double lastMouseX;
- double lastMouseY;
- double mouseX;
- double mouseY;
- struct Axis {
- float less;
- float greater;
- int lessIndex;
- int greaterIndex;
- Axis();
- };
- Array<Axis, 1 + GLFW_GAMEPAD_AXIS_LAST> gamepadAxisToButton;
- Array<int, 1 + GLFW_GAMEPAD_BUTTON_LAST> gamepadToButton;
- public:
- Buttons(const Window& window);
- Button& add(int key, const char* name);
- Button& addMouse(int mouse, const char* name);
- void mapGamepadButton(const Button& button, int mapping);
- void mapGamepadAxis(const Button& button, float value, int index);
- void tick();
- const ButtonList& get() const;
- const MouseList& getMouse() const;
- double getLastMouseX() const;
- double getLastMouseY() const;
- double getMouseX() const;
- double getMouseY() const;
- private:
- bool searchForGamepad();
- void checkGamepad(DownArray& down);
- int searchButton(const Button& button) const;
- };
- #endif
|