123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #ifndef CONTROLLER_H
- #define CONTROLLER_H
- #include "utils/Array.h"
- enum Button {
- A, B, X, Y, L, R, SELECT, START, LEFT, RIGHT, UP, DOWN
- };
- struct Controller final {
- Controller();
- void tick();
- uint getButtonAmount() const;
- const char* getName(uint button) const;
- uint getDownTime(uint button) const;
- bool isDown(uint button) const;
- bool wasReleased(uint button) const;
- private:
- bool findController();
- void reset();
- void increment(uint button, const u8* mapping, uint index);
- void increment(uint button, bool notReleased);
- struct ButtonState final {
- ButtonState();
- uint downTime;
- bool justReleased;
- };
-
- Array<ButtonState, 12> buttons;
- uint activeController;
- };
- #endif
- /*#ifndef KEYS_H
- #define KEYS_H
- #include <iostream>
- #include <array>
- #include "common/utils/Types.h"
- class Keys final {
- public:
- class Key final {
- public:
- friend class Keys;
- bool isDown() const;
- bool isReleased() const;
- u32 getDownTime() const;
- private:
- Key();
- Key(const Key&) = delete;
- Key(Key&&) = delete;
- Key& operator=(const Key&) = delete;
- Key& operator=(Key&&) = delete;
- int glfwKey;
- bool down;
- bool shouldRelease;
- u32 downTime;
- };
- private:
- Key keys[15];
- public:
- Keys();
- const Key& left;
- const Key& right;
- const Key& up;
- const Key& down;
- const Key& jump;
- const Key& sneak;
- const Key& camLeft;
- const Key& camRight;
- const Key& camUp;
- const Key& camDown;
- const Key& test;
- const Key& test2;
- const Key& test3;
- const Key& test4;
- const Key& test5;
- void release(int key);
- void press(int key);
- void tick();
- private:
- Keys(const Keys&) = delete;
- Keys& operator=(const Keys&) = delete;
- Keys(Key&&) = delete;
- Keys& operator=(Keys&&) = delete;
- };
- std::ostream& operator<<(std::ostream& os, const Keys::Key& k);
- #endif*/
|