1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #ifndef KEYS_H
- #define KEYS_H
- #include <iostream>
- #include <array>
- #include "common/utils/Types.h"
- #include "GameClient.h"
- class Keys
- {
- public:
- class Key
- {
- public:
- friend class Keys;
- bool isDown() const;
- bool isReleased() const;
- u32 getDownTime() const;
-
- private:
- Key() = default;
- 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[4];
-
- public:
- Keys();
- const Key& left;
- const Key& right;
- const Key& up;
- const Key& down;
-
- 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& m);
- #endif
|