123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #ifndef BUTTONS_H
- #define BUTTONS_H
- #include "input/Button.h"
- #include "utils/Array.h"
- #include "utils/ArrayList.h"
- #include "rendering/Window.h"
- typedef ArrayList<Button, 32> ButtonList;
- class Buttons final {
- typedef Array<bool, 32> DownArray;
- const Window& window;
- Button dummy;
- int activeController;
- ButtonList buttons;
- struct Axis {
- float less;
- float greater;
- int lessIndex;
- int greaterIndex;
- Axis();
- };
- Array<int, 1 + GLFW_GAMEPAD_BUTTON_LAST> gamepadToButton;
- Array<Axis, 1 + GLFW_GAMEPAD_AXIS_LAST> gamepadAxisToButton;
- public:
- Buttons(const Window& window);
- Button& add(int key, 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;
- private:
- bool searchForGamepad();
- void checkGamepad(DownArray& down);
- int searchButton(const Button& button) const;
- };
- #endif
|