39 #ifndef __CU_INPUT_H__
40 #define __CU_INPUT_H__
42 #include "../base/CUBase.h"
43 #include "../util/CUTimestamp.h"
44 #include <unordered_map>
45 #include <unordered_set>
50 #define UINT32_MAX (0xffffffff)
89 std::unordered_map<std::type_index, InputDevice*>
_devices;
92 std::unordered_map<Uint32,std::unordered_set<std::type_index>>
_subscribers;
94 #pragma mark Constructor
105 #pragma mark Application Access
167 bool update(SDL_Event event);
172 #pragma mark Internal Helpers
208 #pragma mark Service Access
219 template <
typename T>
221 if (!_singleton) {
return nullptr; }
222 std::type_index indx = std::type_index(
typeid(
T));
223 auto it = _singleton->
_devices.find(indx);
224 if (it != _singleton->
_devices.end()) {
225 return static_cast<T*
>(it->second);
240 template <
typename T>
242 if (!_singleton) {
return false; }
243 std::type_index indx = std::type_index(
typeid(
T));
244 auto it = _singleton->
_devices.find(indx);
246 if (it != _singleton->
_devices.end()) {
251 if (alloc->init() && _singleton->
registerDevice(indx,dynamic_cast<InputDevice*>(alloc))) {
270 template <
typename T>
272 if (!_singleton) {
return false; }
273 std::type_index indx = std::type_index(
typeid(
T));
274 auto it = _singleton->
_devices.find(indx);
276 if (it != _singleton->
_devices.end()) {
348 virtual bool init() {
return true; }
388 virtual void queryEvents(std::vector<Uint32>& eventset) = 0;
Definition: CUTimestamp.h:61
Definition: CUApplication.h:83
Definition: CUAnimationNode.h:52