Gainput  v1.0.0
gainput.h
1 
8 #ifndef GAINPUT_H_
9 #define GAINPUT_H_
10 
11 #if defined(__ANDROID__) || defined(ANDROID)
12  #define GAINPUT_PLATFORM_ANDROID
13  #define GAINPUT_LIBEXPORT
14 #elif defined(__linux) || defined(__linux__) || defined(linux) || defined(LINUX)
15  #define GAINPUT_PLATFORM_LINUX
16  #define GAINPUT_LIBEXPORT
17 #elif defined(_WIN32) || defined(__WIN32__) || defined(_MSC_VER)
18  #define GAINPUT_PLATFORM_WIN
19  #if defined(GAINPUT_LIB_DYNAMIC)
20  #define GAINPUT_LIBEXPORT __declspec(dllexport)
21  #elif defined(GAINPUT_LIB_DYNAMIC_USE)
22  #define GAINPUT_LIBEXPORT __declspec(dllimport)
23  #else
24  #define GAINPUT_LIBEXPORT
25  #endif
26 #elif defined(__APPLE__)
27  #define GAINPUT_LIBEXPORT
28  #include <TargetConditionals.h>
29  #if TARGET_OS_TV
30  #define GAINPUT_PLATFORM_TVOS
31  #elif TARGET_OS_IPHONE
32  #define GAINPUT_PLATFORM_IOS
33  #elif TARGET_OS_MAC
34  #define GAINPUT_PLATFORM_MAC
35  #else
36  #error Gainput: Unknown/unsupported Apple platform!
37  #endif
38 #else
39  #error Gainput: Unknown/unsupported platform!
40 #endif
41 
42 
43 //#define GAINPUT_DEBUG
44 //#define GAINPUT_DEV
45 #define GAINPUT_ENABLE_ALL_GESTURES
46 #define GAINPUT_ENABLE_RECORDER
47 #define GAINPUT_TEXT_INPUT_QUEUE_LENGTH 32
48 
49 #ifdef GAINPUT_ENABLE_CONCURRENCY
50 #define MOODYCAMEL_EXCEPTIONS_DISABLED
51 #include "concurrentqueue.h"
52 #define GAINPUT_CONC_QUEUE(TYPE) moodycamel::ConcurrentQueue<TYPE>
53 #define GAINPUT_CONC_CONSTRUCT(queue) queue()
54 #define GAINPUT_CONC_ENQUEUE(queue, obj) queue.enqueue(obj)
55 #define GAINPUT_CONC_DEQUEUE(queue, obj) queue.try_dequeue(obj)
56 #else
57 #define GAINPUT_CONC_QUEUE(TYPE) gainput::Array<TYPE>
58 #define GAINPUT_CONC_CONSTRUCT(queue) queue(allocator)
59 #define GAINPUT_CONC_ENQUEUE(queue, obj) queue.push_back(obj)
60 #define GAINPUT_CONC_DEQUEUE(queue, obj) (!queue.empty() ? (obj = queue[queue.size()-1], queue.pop_back(), true) : false)
61 #endif
62 
63 #include <cassert>
64 #include <cstring>
65 #include <new>
66 
67 #define GAINPUT_ASSERT assert
68 #define GAINPUT_UNUSED(x) (void)(x)
69 
70 #if defined(GAINPUT_PLATFORM_LINUX)
71 
72 #include <cstdlib>
73 #include <stdint.h>
74 
75 union _XEvent;
76 typedef _XEvent XEvent;
77 
78 #elif defined(GAINPUT_PLATFORM_WIN)
79 
80 #include <cstdlib>
81 
82 typedef struct tagMSG MSG;
83 
84 namespace gainput
85 {
86  typedef unsigned __int8 uint8_t;
87  typedef __int8 int8_t;
88  typedef unsigned __int32 uint32_t;
89  typedef unsigned __int64 uint64_t;
90 }
91 
92 #elif defined(GAINPUT_PLATFORM_ANDROID)
93 
94 #include <stdint.h>
95 #include <stdlib.h>
96 struct AInputEvent;
97 
98 #endif
99 
100 
101 
103 namespace gainput
104 {
105 
107 typedef unsigned int DeviceId;
109 typedef unsigned int DeviceButtonId;
110 
113 {
115  DeviceId deviceId;
117  DeviceButtonId buttonId;
118 };
119 
121 typedef unsigned int UserButtonId;
123 typedef unsigned int ListenerId;
125 typedef unsigned int ModifierId;
126 
128 static const DeviceId InvalidDeviceId = -1;
130 static const DeviceButtonId InvalidDeviceButtonId = -1;
132 static const UserButtonId InvalidUserButtonId = -1;
133 
135 const char* GetLibName();
137 uint32_t GetLibVersion();
139 const char* GetLibVersionString();
140 
141 class InputDeltaState;
142 class InputListener;
143 class InputManager;
144 class DebugRenderer;
145 class DeviceStateModifier;
146 
147 template <class T> T Abs(T a) { return a < T() ? -a : a; }
148 
150 
164 void DevSetHttp(bool enable);
165 }
166 
167 #define GAINPUT_VER_MAJOR_SHIFT 16
168 #define GAINPUT_VER_GET_MAJOR(ver) (ver >> GAINPUT_VER_MAJOR_SHIFT)
169 #define GAINPUT_VER_GET_MINOR(ver) (ver & (uint32_t(-1) >> GAINPUT_VER_MAJOR_SHIFT))
170 
171 
172 #include <gainput/GainputAllocator.h>
173 #include <gainput/GainputContainers.h>
174 #include <gainput/GainputInputState.h>
175 #include <gainput/GainputInputDevice.h>
176 #include <gainput/GainputInputListener.h>
177 #include <gainput/GainputInputManager.h>
178 #include <gainput/GainputInputMap.h>
179 
180 #include <gainput/GainputInputDeviceMouse.h>
181 #include <gainput/GainputInputDeviceKeyboard.h>
182 #include <gainput/GainputInputDevicePad.h>
183 #include <gainput/GainputInputDeviceTouch.h>
184 #include <gainput/GainputInputDeviceBuiltIn.h>
185 
186 #include <gainput/gestures/GainputGestures.h>
187 
188 #include <gainput/recorder/GainputInputRecording.h>
189 #include <gainput/recorder/GainputInputPlayer.h>
190 #include <gainput/recorder/GainputInputRecorder.h>
191 
192 #endif
193 
DeviceId deviceId
ID of the input device.
Definition: gainput.h:115
Interface for debug rendering of input device states.
Definition: GainputDebugRenderer.h:15
void DevSetHttp(bool enable)
Switches the library&#39;s internal development server to HTTP mode.
Interface for modifiers that change device input states after they have been updated.
Definition: GainputInputManager.h:315
Manages all input devices and some other helpful stuff.
Definition: GainputInputManager.h:24
unsigned int UserButtonId
ID of a user-defined, mapped button.
Definition: gainput.h:121
Listener interface that allows to receive notifications when device button states change...
Definition: GainputInputListener.h:9
Stores a list of input state changes.
Definition: GainputInputDeltaState.h:9
Describes a device button on a specific device.
Definition: gainput.h:112
const char * GetLibVersionString()
Returns the version number of the library as a printable string.
Definition: gainput.cpp:377
unsigned int DeviceId
ID of an input device.
Definition: gainput.h:107
unsigned int ListenerId
ID of an input listener.
Definition: gainput.h:123
uint32_t GetLibVersion()
Returns the version number of the library.
Definition: gainput.cpp:371
unsigned int ModifierId
ID of a device state modifier.
Definition: gainput.h:125
DeviceButtonId buttonId
ID of the button on the given input device.
Definition: gainput.h:117
const char * GetLibName()
Returns the name of the library, should be "Gainput".
Definition: gainput.cpp:365
unsigned int DeviceButtonId
ID of a specific button unique to an input device.
Definition: gainput.h:109
Contains all Gainput related classes, types, and functions.
Definition: gainput.h:103