SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
Inputable.h
1#ifndef Inputable_H
2#define Inputable_H
3
4#include "AzulCore.h"
5#include "KeyboardEventManager.h"
6#include "../EventType.h"
8
13
22class Inputable
23{
24protected:
25 Inputable() = default;
26 Inputable(const Inputable&) = delete;
27 Inputable& operator=(const Inputable&) = delete;
28 virtual ~Inputable();
29
35 void SubmitKeyRegistration(AZUL_KEY k, EventType e);
36
42 void SubmitKeyDeregistration(AZUL_KEY k, EventType e);
43
49 void SubmitMouseKeyRegistration(AZUL_MOUSE m, EventType e);
50
56 void SubmitMouseKeyDeregistration(AZUL_MOUSE m, EventType e);
57
58private:
59 friend class InputableAttorney;
60
65 {
67 RegistrationState RegStateCurr = RegistrationState::CURRENTLY_DEREGISTERED;
68 KeyRegistrationCommand* pKeyRegistrationCommand = nullptr;
69 KeyDeregistrationCommand* pKeyDeregistrationCommand = nullptr;
70 };
71
76 {
78 RegistrationState RegStateCurr = RegistrationState::CURRENTLY_DEREGISTERED;
79 MouseKeyRegistrationCommand* pKeyRegistrationCommand = nullptr;
80 MouseKeyDeregistrationCommand* pKeyDeregistrationCommand = nullptr;
81 };
82
87 {
88 AZUL_KEY key;
89 EventType eventType;
90
96 bool operator<(const KeyEventPair& other) const
97 {
98 return std::tie(key, eventType) < std::tie(other.key, other.eventType);
99 };
100 };
101
106 {
107 AZUL_MOUSE key;
108 EventType eventType;
109
115 bool operator<(const MouseKeyEventPair& other) const
116 {
117 return std::tie(key, eventType) < std::tie(other.key, other.eventType);
118 };
119 };
120
124 using KeyMap = std::map<KeyEventPair, RegistrationData*>;
125
129 using MouseKeyMap = std::map<MouseKeyEventPair, MouseRegistrationData*>;
130
134 using KeyMapIt = KeyMap::iterator;
135
139 using MouseKeyMapIt = MouseKeyMap::iterator;
140
145
150
155 virtual void KeyInactive(AZUL_KEY k) { k; };
156
161 virtual void KeyPress(AZUL_KEY k) { k; };
162
167 virtual void KeyHeld(AZUL_KEY k) { k; };
168
173 virtual void KeyRelease(AZUL_KEY k) { k; };
174
179 virtual void MouseInactive(AZUL_MOUSE m) { m; };
180
185 virtual void MousePress(AZUL_MOUSE m) { m; };
186
191 virtual void MouseHeld(AZUL_MOUSE m) { m; };
192
197 virtual void MouseRelease(AZUL_MOUSE m) { m; };
198
204 void KeyRegistration(AZUL_KEY k, EventType e);
205
211 void KeyDeregistration(AZUL_KEY k, EventType e);
212
218 void MouseKeyRegistration(AZUL_MOUSE m, EventType e);
219
225 void MouseKeyDeregistration(AZUL_MOUSE m, EventType e);
226};
227
228#endif
Defines the event types for input handling.
EventType
Enum class representing the types of input events.
Definition EventType.h:19
Defines the registration states for GameObjects.
RegistrationState
Enum class representing the registration states of GameObjects.
Definition RegistrationState.h:19
void MouseKeyDeregistration(AZUL_MOUSE m, EventType e)
Deregisters the mouse key for the GameObject.
Definition Inputable.cpp:127
MouseKeyMap::iterator MouseKeyMapIt
Type alias for the mouse key map iterator.
Definition Inputable.h:139
std::map< KeyEventPair, RegistrationData * > KeyMap
Type alias for the key map.
Definition Inputable.h:124
void KeyRegistration(AZUL_KEY k, EventType e)
Registers the key for the GameObject.
Definition Inputable.cpp:97
KeyMap::iterator KeyMapIt
Type alias for the key map iterator.
Definition Inputable.h:134
void MouseKeyRegistration(AZUL_MOUSE m, EventType e)
Registers the mouse key for the GameObject.
Definition Inputable.cpp:117
virtual void MousePress(AZUL_MOUSE m)
Virtual method to be implemented by derived classes for mouse press functionality.
Definition Inputable.h:185
KeyMap keyMap
The key map of the GameObject.
Definition Inputable.h:144
virtual void KeyPress(AZUL_KEY k)
Virtual method to be implemented by derived classes for key press functionality.
Definition Inputable.h:161
void KeyDeregistration(AZUL_KEY k, EventType e)
Deregisters the key for the GameObject.
Definition Inputable.cpp:107
virtual void KeyInactive(AZUL_KEY k)
Virtual method to be implemented by derived classes for key inactive functionality.
Definition Inputable.h:155
void SubmitMouseKeyDeregistration(AZUL_MOUSE m, EventType e)
Submits the mouse key deregistration for the GameObject.
Definition Inputable.cpp:87
void SubmitMouseKeyRegistration(AZUL_MOUSE m, EventType e)
Submits the mouse key registration for the GameObject.
Definition Inputable.cpp:64
virtual void KeyRelease(AZUL_KEY k)
Virtual method to be implemented by derived classes for key release functionality.
Definition Inputable.h:173
virtual void KeyHeld(AZUL_KEY k)
Virtual method to be implemented by derived classes for key held functionality.
Definition Inputable.h:167
void SubmitKeyRegistration(AZUL_KEY k, EventType e)
Submits the key registration for the GameObject.
Definition Inputable.cpp:31
virtual void MouseHeld(AZUL_MOUSE m)
Virtual method to be implemented by derived classes for mouse held functionality.
Definition Inputable.h:191
MouseKeyMap mouseKeyMap
The mouse key map of the GameObject.
Definition Inputable.h:149
void SubmitKeyDeregistration(AZUL_KEY k, EventType e)
Submits the key deregistration for the GameObject.
Definition Inputable.cpp:54
virtual void MouseInactive(AZUL_MOUSE m)
Virtual method to be implemented by derived classes for mouse inactive functionality.
Definition Inputable.h:179
virtual void MouseRelease(AZUL_MOUSE m)
Virtual method to be implemented by derived classes for mouse release functionality.
Definition Inputable.h:197
std::map< MouseKeyEventPair, MouseRegistrationData * > MouseKeyMap
Type alias for the mouse key map.
Definition Inputable.h:129
Command to handle the deregistration of a key event for an Inputable object.
Definition KeyDeregistrationCommand.h:18
Command to handle the registration of a key event for an Inputable object.
Definition KeyRegistrationCommand.h:18
MapMouseKeyManager::iterator StorageMapMouseRef
Type alias for the storage map mouse iterator.
Definition KeyboardEventManager.h:92
MapKeyManager::iterator StorageMapRef
Type alias for the storage map iterator.
Definition KeyboardEventManager.h:87
Command to handle the deregistration of a key event for an Inputable object.
Definition MouseKeyDeregistrationCommand.h:18
Command to handle the registration of a key event for an Inputable object.
Definition MouseKeyRegistrationCommand.h:18
Structure to hold key event pairs.
Definition Inputable.h:87
bool operator<(const KeyEventPair &other) const
Comparison operator for key event pairs.
Definition Inputable.h:96
Structure to hold mouse key event pairs.
Definition Inputable.h:106
bool operator<(const MouseKeyEventPair &other) const
Comparison operator for mouse key event pairs.
Definition Inputable.h:115
Structure to hold registration data for mouse keys.
Definition Inputable.h:76
Structure to hold registration data for keys.
Definition Inputable.h:65