-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCylon.h
370 lines (322 loc) · 10.7 KB
/
Cylon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
//Cylon.h
//Gives definition for cylonStruct and its supporting structures for use with Saul and other Final Five services.
//"By your command," - Cylon Centurion
//josh@mindaptiv.com
#pragma once
//includes
#include <string>
#include <list>
#include <stdint.h>
//definitions
#define cylon_username__max_Utf8_k 128
#define cylon_deviceName__max_Utf8_k 192
//Type mappings for reference
/*
UBYTE -> unsigned byte -> uint8_t
WORD -> unsigned short -> uint16_t
DWORD -> unsigned int -> uint32_t
unsigned long -> uint32_t
long unsigned int -> uint64_t
BYTE -> signed byte -> int8_t
SHORT -> short integer -> int16_t
long -> signed integer -> int32_t
long long -> signed long long -> int64_t
void* -> uintptr_t
bool -> uint32_t
float32 -> float
*/
//Constants
//Days
static const int SUNDAY = 0;
static const int MONDAY = 1;
static const int TUESDAY = 2;
static const int WEDNESDAY = 3;
static const int THURSDAY = 4;
static const int FRIDAY = 5;
static const int SATURDAY = 6;
//Months
static const int JANUARY = 1;
static const int FEBRUARY = 2;
static const int MARCH = 3;
static const int APRIL = 4;
static const int MAY = 5;
static const int JUNE = 6;
static const int JULY = 7;
static const int AUGUST = 8;
static const int SEPTEMBER = 9;
static const int OCTOBER = 10;
static const int DECEMBER = 12;
static const int NOVEMBER = 11;
//DST
static const int STANDARD_TIME = 0;
static const int DAYLIGHT_TIME = 1;
//controllerStruct buttons
static const int A_BUTTON = 0x1000;
static const int B_BUTTON = 0x2000;
static const int X_BUTTON = 0x4000;
static const int Y_BUTTON = 0x8000;
static const int UP_DPAD = 0x0001;
static const int DOWN_DPAD = 0x0002;
static const int LEFT_DPAD = 0x0004;
static const int RIGHT_DPAD = 0x0008;
static const int START_BUTTON = 0x0010;
static const int SELECT_BUTTON = 0x0020;
static const int LEFT_THUMB = 0x0040;
static const int RIGHT_THUMB = 0x0080;
static const int LEFT_SHOULDER = 0x0100;
static const int RIGHT_SHOULDER = 0x0200;
static const int HOME_BUTTON = 0x0400;
//deviceStruct Types
static const int ERROR_TYPE = 0;
static const int GENERIC_TYPE = 1;
static const int AUDIO_CAPTURE_TYPE = 2;
static const int AUDIO_RENDER_TYPE = 3;
static const int STORAGE_TYPE = 4;
static const int VIDEO_CAPTURE_TYPE = 5;
static const int IMAGE_SCANNER_TYPE = 6;
static const int LOCATION_AWARE_TYPE = 7;
static const int DISPLAY_TYPE = 8;
static const int MOUSE_TYPE = 9;
static const int KEYBOARD_TYPE = 10;
static const int CONTROLLER_TYPE = 11;
static const int TOUCHSCREEN_TYPE = 12;
static const int TOUCH_PAD_TYPE = 13;
static const int TRACKBALL_TYPE = 14;
static const int STYLUS_TYPE = 15;
static const int POSITION_TYPE = 16;
static const int HID_TYPE = 17;
static const int RUMBLE_TYPE = 18;
static const int SENSOR_TYPE = 19;
static const int BLUETOOTH_RADIO_TYPE = 20;
static const int PHYSICAL_TYPE = 21;
static const int PRINTER_TYPE = 22;
static const int HUB_TYPE = 23;
static const int COMMUNICATIONS_DATA_TYPE = 24;
static const int SMART_CARD_TYPE = 25;
static const int CONTENT_SECURITY_TYPE = 26;
static const int PERSONAL_HEALTHCARE_TYPE = 27;
static const int BILLBOARD_TYPE = 28;
static const int WIRELESS_PHONE_TYPE = 29;
static const int MIDI_TYPE = 30;
//deviceStruct location
static const int UNKNOWN_PANEL_LOCATION = 0;
static const int FRONT_PANEL = 1;
static const int BACK_PANEL = 2;
static const int TOP_PANEL = 3;
static const int BOTTOM_PANEL = 4;
static const int LEFT_PANEL = 5;
static const int RIGHT_PANEL = 6;
//displayStruct rotations
static const int NO_ROTATION = 0;
static const int LANDSCAPE = 1;
static const int PORTRAIT = 2;
static const int FLIPPED_LANDSCAPE = 4;
static const int FLIPPED_PORTRAIT = 8;
//midi constants
static const int MIDI_VIRTUAL = 0;
static const int MIDI_USB = 1;
static const int MIDI_BLUETOOTH = 2;
static const int MIDI_IN = 0;
static const int MIDI_OUT = 1;
//error codes
static const int CONTROLLERS_LIST_ID_SYNCH_ERROR = 1; //failed to correctly synchronize data between the controllers and detectedDevices lists
static const int INVALID_CONTROLLER_ID = 2; //failed to correctly get the ID of a controller device
//support structure for cylonStruct for holding the properties of a given device in a single struct
struct deviceStruct
{
//NOTE: Values of 0 are errors for non-bools
uint32_t panelLocation; //devices panel location on the physical computer
uint32_t inLid; //if the device is located in the lid of the computer
uint32_t inDock; //if the device is in the docking station of the computer
uint32_t isDefault; //if device is the default for its function
uint32_t isEnabled; //if the device is enabled
uint32_t orientation; //orientation of the device
uint32_t vendorID; //vendor ID
std::string name;
std::string id_string; //id in string format
uint32_t id_int; //id in integer format
uint32_t usb_bus; //usb bus, where available
uint32_t udev_deviceNumber; //usb device #, where available
//type
uint32_t deviceType;
uint32_t displayIndex; //device's index in the displayDevices list if type is 8
uint32_t controllerIndex; //device's index in the pointerDevices list if type is 9
uint32_t storageIndex;
uint32_t sensorsIndex;
uint32_t midiIndex; //device's index in the midiDevices list if type is 30
};
//END deviceStruct
//for handling DisplayInformation class objects' metadata
struct displayStruct
{
struct deviceStruct superDevice; //parent deviceStruct object
uint32_t deviceIndex;
uint32_t rotationPreference;
uint32_t currentRotation;
uint32_t nativeRotation;
uint32_t isStereoscopicEnabled;
uint32_t horizontalResolution;
uint32_t verticalResolution;
uint32_t upperLeftX;
uint32_t upperLeftY;
float refreshRate;
float resolutionScale;
float logicalDPI;
float rawDPIX;
float rawDPIY;
void* driverData;
unsigned char* colorData;
unsigned int colorLength;
};
//end displayStruct
//struct for a gamepad device
struct controllerStruct
{
struct deviceStruct superDevice;
uint32_t deviceIndex;
uint32_t userIndex; //player number 0-3
uint32_t id; //id number of controller (if applicable on platform, otherwise == userIndex)
//xinput state
uint32_t packetNumber; //for detecting changes
uint32_t buttons; //bit mask for what buttons are pressed
float leftTrigger;
float rightTrigger;
float thumbLeftY;
float thumbLeftX;
float thumbRightX;
float thumbRightY;
};
//end controller struct
//for handling device-specific metadata for a mouse in a WinRT context
struct mouseStruct
{
struct deviceStruct superDevice; //parent deviceStruct object
uint32_t deviceIndex;
//properties of available mice
uint32_t anyLeftRightSwapped;
uint32_t anyVerticalWheelPresent;
uint32_t anyHorizontalWheelPresent;
uint32_t maxNumberOfButons; //most buttons available for all given mice attached (i.e. if 3 and 5 button mice are attached, return value should be 5)
};
//END mouseStruct
//for handling device-specific metadata for a sensor in an Android context
struct sensorStruct
{
struct deviceStruct superDevice; //parent deviceStruct object
uint32_t deviceIndex;
//data from Android 16+
uint32_t minDelay;
uint32_t type; //based on Android Sensor class type mappings
uint32_t version;
std::string name;
std::string vendor;
float power;
float resolution;
float maxRange;
//data from Android 19+
uint32_t fifoMaxEventCount;
uint32_t fifoReservedEventCount;
//data from Android 20+
std::string stringType;
//data from Android 21+
uint32_t maxDelay;
uint32_t reportingMode; //based on Android Sensor class type mappings
uint32_t isWakeUpSensor;
};
//struct for representing a path used for storage (device, mounted network drive, etc.)
struct storageStruct
{
struct deviceStruct superDevice; //parent deviceStruct object
uint32_t deviceIndex;
//Path to access the storage device in the file system
std::string path;
//Space
uint64_t bytesAvails;
uint64_t totalBytes;
//Emulated Storage?
uint32_t isEmulated;
};
//struct for representing a MIDI port
struct midiPortStruct
{
std::string name;
uint32_t number;
uint32_t type; //IN = 0, OUT = 1
};
//struct for representing a MIDI device
struct midiStruct
{
struct deviceStruct superDevice; //parent deviceStruct object
uint32_t deviceIndex;
uint32_t id;
uint32_t type; //virtual = 0, usb = 1, bluetooth = 2
//Ports
uint32_t outCount;
uint32_t inCount;
std::list<struct midiPortStruct> ports;
//String names and numbers
std::string vendorName;
std::string deviceName;
std::string productName;
std::string versionNumber;
std::string serialNumber;
};
//struct definition for storing user and system data from a WinRT based machine for later use
struct cylonStruct
{
//time
uint32_t milliseconds;
uint32_t seconds;
uint32_t minutes;
uint32_t hours;
//date
uint32_t day; //day of the week, 0-6
uint32_t date; //1-31
uint32_t month; //1-12
uint32_t year; //1601 until the cows come home
//timezone
uint32_t dst; //0 is standard time, 1 is daylight time, otherwise is invalid
int32_t timeZone; //expressed in minutes +/- UTC
std::string timeZoneName;
//names
std::string deviceName;
std::string username;
//processor
std::string architecture; //0=error, 1=x64, 2=ARM, 3=Itanium, 4=x86
uint16_t processorLevel; //architecture-dependent processor level
uint32_t pageSize; //size of page in bytes
uint32_t allocationGranularity; //granularity for starting address where virtual memory can be allocated (assuming in bits?)
uintptr_t minAppAddress; //lowest point in memory an application can access
uintptr_t maxAppAddress; //highest point in memory an app can access
float hertz; //speed of processor (or default lowest possible speed for current OS)
uint64_t processorCount; //number of processors
//memory
uint64_t memoryBytes; //system memory measured in bytes
uint32_t osArchitecture; //operating system architecture, 16, 32, 64, 128, etc.
uint32_t lowMemory;
uint64_t threshold;
uint64_t bytesAvails;
//account picture
std::string pictureType;
std::string picturePath;
uintptr_t pictureLocation;
//devices
uint32_t installedDeviceCount;
uint32_t detectedDeviceCount;
uint32_t portableStorageCount;
uint32_t videoCount;
uint32_t micCount;
uint32_t speakerCount;
uint32_t locationCount;
uint32_t scannerCount;
std::list<struct deviceStruct> detectedDevices;
std::list<struct displayStruct> displayDevices;
std::list<struct controllerStruct> controllers;
std::list<struct sensorStruct> sensors;
std::list<struct storageStruct> storages;
std::list<struct midiStruct> midiDevices;
struct mouseStruct mice;
//error
int32_t error;
};
//END cylonStruct