Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/Input/Input.hpp
1163 views
1
#ifndef INPUT_H
2
#define INPUT_H
3
4
namespace RSDK
5
{
6
7
#define PLAYER_COUNT (4)
8
#define INPUTDEVICE_COUNT (0x10)
9
10
#define INPUT_DEADZONE (0.3)
11
12
enum InputIDs {
13
INPUT_UNASSIGNED = -2,
14
INPUT_AUTOASSIGN = -1,
15
INPUT_NONE = 0,
16
};
17
18
enum InputSlotIDs {
19
CONT_ANY,
20
CONT_P1,
21
CONT_P2,
22
CONT_P3,
23
CONT_P4,
24
};
25
26
enum InputDeviceTypes {
27
DEVICE_TYPE_NONE,
28
DEVICE_TYPE_KEYBOARD,
29
DEVICE_TYPE_CONTROLLER,
30
DEVICE_TYPE_UNKNOWN,
31
DEVICE_TYPE_STEAMOVERLAY,
32
};
33
34
enum InputDeviceIDs {
35
DEVICE_KEYBOARD,
36
DEVICE_XBOX,
37
DEVICE_PS4,
38
DEVICE_SATURN,
39
DEVICE_SWITCH_HANDHELD,
40
DEVICE_SWITCH_JOY_GRIP,
41
DEVICE_SWITCH_JOY_L,
42
DEVICE_SWITCH_JOY_R,
43
DEVICE_SWITCH_PRO,
44
};
45
46
enum InputDeviceAPIs {
47
DEVICE_API_NONE,
48
DEVICE_API_KEYBOARD,
49
DEVICE_API_XINPUT,
50
DEVICE_API_RAWINPUT,
51
DEVICE_API_STEAM,
52
53
// CUSTOM APIs
54
#if RETRO_INPUTDEVICE_SDL2
55
DEVICE_API_SDL2, // custom-made for SDL2 API, afaik it's not in original RSDKv5 (since it could be in a mac-version, but I do not have that so...)
56
#endif
57
#if RETRO_INPUTDEVICE_GLFW
58
DEVICE_API_GLFW, // custom-made for OGL, won't be in ANY real RSDKv5 version ever, it's just cool
59
#endif
60
#if RETRO_INPUTDEVICE_PDBOAT
61
DEVICE_API_PDBOAT // custom-made for android (paddleboat API)
62
#endif
63
};
64
65
enum ControllerKeys {
66
KEY_UP,
67
KEY_DOWN,
68
KEY_LEFT,
69
KEY_RIGHT,
70
KEY_A,
71
KEY_B,
72
KEY_C,
73
KEY_X,
74
KEY_Y,
75
KEY_Z,
76
KEY_START,
77
KEY_SELECT,
78
KEY_MAX,
79
};
80
81
enum KeyMasks {
82
KEYMASK_UP = 1 << 0,
83
KEYMASK_DOWN = 1 << 1,
84
KEYMASK_LEFT = 1 << 2,
85
KEYMASK_RIGHT = 1 << 3,
86
KEYMASK_START = 1 << 4,
87
KEYMASK_SELECT = 1 << 5,
88
KEYMASK_STICKL = 1 << 6,
89
KEYMASK_STICKR = 1 << 7,
90
KEYMASK_BUMPERL = 1 << 8,
91
KEYMASK_BUMPERR = 1 << 9,
92
KEYMASK_C = 1 << 10,
93
KEYMASK_Z = 1 << 11,
94
KEYMASK_A = 1 << 12,
95
KEYMASK_B = 1 << 13,
96
KEYMASK_X = 1 << 14,
97
KEYMASK_Y = 1 << 15,
98
KEYMASK_TRIGGERL = 1 << 16,
99
KEYMASK_TRIGGERR = 1 << 17,
100
};
101
102
enum WinMappings {
103
KEYMAP_AUTO_MAPPING = -1,
104
KEYMAP_NO_MAPPING = 0,
105
106
#ifndef VK_LBUTTON
107
VK_LBUTTON = 0x01,
108
VK_RBUTTON = 0x02,
109
VK_CANCEL = 0x03,
110
VK_MBUTTON = 0x04,
111
VK_XBUTTON1 = 0x05,
112
VK_XBUTTON2 = 0x06,
113
VK_BACK = 0x08,
114
VK_TAB = 0x09,
115
VK_CLEAR = 0x0C,
116
VK_RETURN = 0x0D,
117
VK_SHIFT = 0x10,
118
VK_CONTROL = 0x11,
119
VK_MENU = 0x12,
120
VK_PAUSE = 0x13,
121
VK_CAPITAL = 0x14,
122
VK_KANA = 0x15,
123
VK_HANGEUL = 0x15,
124
VK_HANGUL = 0x15,
125
VK_JUNJA = 0x17,
126
VK_FINAL = 0x18,
127
VK_HANJA = 0x19,
128
VK_KANJI = 0x19,
129
VK_ESCAPE = 0x1B,
130
VK_CONVERT = 0x1C,
131
VK_NONCONVERT = 0x1D,
132
VK_ACCEPT = 0x1E,
133
VK_MODECHANGE = 0x1F,
134
VK_SPACE = 0x20,
135
VK_PRIOR = 0x21,
136
VK_NEXT = 0x22,
137
VK_END = 0x23,
138
VK_HOME = 0x24,
139
VK_LEFT = 0x25,
140
VK_UP = 0x26,
141
VK_RIGHT = 0x27,
142
VK_DOWN = 0x28,
143
VK_SELECT = 0x29,
144
VK_PRINT = 0x2A,
145
VK_EXECUTE = 0x2B,
146
VK_SNAPSHOT = 0x2C,
147
VK_INSERT = 0x2D,
148
VK_DELETE = 0x2E,
149
VK_HELP = 0x2F,
150
#endif
151
VK_0 = 0x30,
152
VK_1 = 0x31,
153
VK_2 = 0x32,
154
VK_3 = 0x33,
155
VK_4 = 0x34,
156
VK_5 = 0x35,
157
VK_6 = 0x36,
158
VK_7 = 0x37,
159
VK_8 = 0x38,
160
VK_9 = 0x39,
161
VK_A = 0x41,
162
VK_B = 0x42,
163
VK_C = 0x43,
164
VK_D = 0x44,
165
VK_E = 0x45,
166
VK_F = 0x46,
167
VK_G = 0x47,
168
VK_H = 0x48,
169
VK_I = 0x49,
170
VK_J = 0x4A,
171
VK_K = 0x4B,
172
VK_L = 0x4C,
173
VK_M = 0x4D,
174
VK_N = 0x4E,
175
VK_O = 0x4F,
176
VK_P = 0x50,
177
VK_Q = 0x51,
178
VK_R = 0x52,
179
VK_S = 0x53,
180
VK_T = 0x54,
181
VK_U = 0x55,
182
VK_V = 0x56,
183
VK_W = 0x57,
184
VK_X = 0x58,
185
VK_Y = 0x59,
186
VK_Z = 0x5A,
187
#ifndef VK_LBUTTON
188
VK_LWIN = 0x5B,
189
VK_RWIN = 0x5C,
190
VK_APPS = 0x5D,
191
VK_SLEEP = 0x5F,
192
VK_NUMPAD0 = 0x60,
193
VK_NUMPAD1 = 0x61,
194
VK_NUMPAD2 = 0x62,
195
VK_NUMPAD3 = 0x63,
196
VK_NUMPAD4 = 0x64,
197
VK_NUMPAD5 = 0x65,
198
VK_NUMPAD6 = 0x66,
199
VK_NUMPAD7 = 0x67,
200
VK_NUMPAD8 = 0x68,
201
VK_NUMPAD9 = 0x69,
202
VK_MULTIPLY = 0x6A,
203
VK_ADD = 0x6B,
204
VK_SEPARATOR = 0x6C,
205
VK_SUBTRACT = 0x6D,
206
VK_DECIMAL = 0x6E,
207
VK_DIVIDE = 0x6F,
208
VK_F1 = 0x70,
209
VK_F2 = 0x71,
210
VK_F3 = 0x72,
211
VK_F4 = 0x73,
212
VK_F5 = 0x74,
213
VK_F6 = 0x75,
214
VK_F7 = 0x76,
215
VK_F8 = 0x77,
216
VK_F9 = 0x78,
217
VK_F10 = 0x79,
218
VK_F11 = 0x7A,
219
VK_F12 = 0x7B,
220
VK_F13 = 0x7C,
221
VK_F14 = 0x7D,
222
VK_F15 = 0x7E,
223
VK_F16 = 0x7F,
224
VK_F17 = 0x80,
225
VK_F18 = 0x81,
226
VK_F19 = 0x82,
227
VK_F20 = 0x83,
228
VK_F21 = 0x84,
229
VK_F22 = 0x85,
230
VK_F23 = 0x86,
231
VK_F24 = 0x87,
232
#endif
233
#ifndef VK_NAVIGATION_VIEW
234
VK_NAVIGATION_VIEW = 0x88,
235
VK_NAVIGATION_MENU = 0x89,
236
VK_NAVIGATION_UP = 0x8A,
237
VK_NAVIGATION_DOWN = 0x8B,
238
VK_NAVIGATION_LEFT = 0x8C,
239
VK_NAVIGATION_RIGHT = 0x8D,
240
VK_NAVIGATION_ACCEPT = 0x8E,
241
VK_NAVIGATION_CANCEL = 0x8F,
242
#endif
243
#ifndef VK_LBUTTON
244
VK_NUMLOCK = 0x90,
245
VK_SCROLL = 0x91,
246
VK_OEM_NEC_EQUAL = 0x92,
247
VK_OEM_FJ_JISHO = 0x92,
248
VK_OEM_FJ_MASSHOU = 0x93,
249
VK_OEM_FJ_TOUROKU = 0x94,
250
VK_OEM_FJ_LOYA = 0x95,
251
VK_OEM_FJ_ROYA = 0x96,
252
VK_LSHIFT = 0xA0,
253
VK_RSHIFT = 0xA1,
254
VK_LCONTROL = 0xA2,
255
VK_RCONTROL = 0xA3,
256
VK_LMENU = 0xA4,
257
VK_RMENU = 0xA5,
258
VK_BROWSER_BACK = 0xA6,
259
VK_BROWSER_FORWARD = 0xA7,
260
VK_BROWSER_REFRESH = 0xA8,
261
VK_BROWSER_STOP = 0xA9,
262
VK_BROWSER_SEARCH = 0xAA,
263
VK_BROWSER_FAVORITES = 0xAB,
264
VK_BROWSER_HOME = 0xAC,
265
VK_VOLUME_MUTE = 0xAD,
266
VK_VOLUME_DOWN = 0xAE,
267
VK_VOLUME_UP = 0xAF,
268
VK_MEDIA_NEXT_TRACK = 0xB0,
269
VK_MEDIA_PREV_TRACK = 0xB1,
270
VK_MEDIA_STOP = 0xB2,
271
VK_MEDIA_PLAY_PAUSE = 0xB3,
272
VK_LAUNCH_MAIL = 0xB4,
273
VK_LAUNCH_MEDIA_SELECT = 0xB5,
274
VK_LAUNCH_APP1 = 0xB6,
275
VK_LAUNCH_APP2 = 0xB7,
276
VK_OEM_1 = 0xBA,
277
VK_OEM_PLUS = 0xBB,
278
VK_OEM_COMMA = 0xBC,
279
VK_OEM_MINUS = 0xBD,
280
VK_OEM_PERIOD = 0xBE,
281
VK_OEM_2 = 0xBF,
282
VK_OEM_3 = 0xC0,
283
#endif
284
#ifndef VK_GAMEPAD_A
285
VK_GAMEPAD_A = 0xC3,
286
VK_GAMEPAD_B = 0xC4,
287
VK_GAMEPAD_X = 0xC5,
288
VK_GAMEPAD_Y = 0xC6,
289
VK_GAMEPAD_RIGHT_SHOULDER = 0xC7,
290
VK_GAMEPAD_LEFT_SHOULDER = 0xC8,
291
VK_GAMEPAD_LEFT_TRIGGER = 0xC9,
292
VK_GAMEPAD_RIGHT_TRIGGER = 0xCA,
293
VK_GAMEPAD_DPAD_UP = 0xCB,
294
VK_GAMEPAD_DPAD_DOWN = 0xCC,
295
VK_GAMEPAD_DPAD_LEFT = 0xCD,
296
VK_GAMEPAD_DPAD_RIGHT = 0xCE,
297
VK_GAMEPAD_MENU = 0xCF,
298
VK_GAMEPAD_VIEW = 0xD0,
299
VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON = 0xD1,
300
VK_GAMEPAD_RIGHT_THUMBSTICK_BUTTON = 0xD2,
301
VK_GAMEPAD_LEFT_THUMBSTICK_UP = 0xD3,
302
VK_GAMEPAD_LEFT_THUMBSTICK_DOWN = 0xD4,
303
VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT = 0xD5,
304
VK_GAMEPAD_LEFT_THUMBSTICK_LEFT = 0xD6,
305
VK_GAMEPAD_RIGHT_THUMBSTICK_UP = 0xD7,
306
VK_GAMEPAD_RIGHT_THUMBSTICK_DOWN = 0xD8,
307
VK_GAMEPAD_RIGHT_THUMBSTICK_RIGHT = 0xD9,
308
VK_GAMEPAD_RIGHT_THUMBSTICK_LEFT = 0xDA,
309
#endif
310
#ifndef VK_LBUTTON
311
VK_OEM_4 = 0xDB,
312
VK_OEM_5 = 0xDC,
313
VK_OEM_6 = 0xDD,
314
VK_OEM_7 = 0xDE,
315
VK_OEM_8 = 0xDF,
316
VK_OEM_AX = 0xE1,
317
VK_OEM_102 = 0xE2,
318
VK_ICO_HELP = 0xE3,
319
VK_ICO_00 = 0xE4,
320
VK_PROCESSKEY = 0xE5,
321
VK_ICO_CLEAR = 0xE6,
322
VK_PACKET = 0xE7,
323
VK_OEM_RESET = 0xE9,
324
VK_OEM_JUMP = 0xEA,
325
VK_OEM_PA1 = 0xEB,
326
VK_OEM_PA2 = 0xEC,
327
VK_OEM_PA3 = 0xED,
328
VK_OEM_WSCTRL = 0xEE,
329
VK_OEM_CUSEL = 0xEF,
330
VK_OEM_ATTN = 0xF0,
331
VK_OEM_FINISH = 0xF1,
332
VK_OEM_COPY = 0xF2,
333
VK_OEM_AUTO = 0xF3,
334
VK_OEM_ENLW = 0xF4,
335
VK_OEM_BACKTAB = 0xF5,
336
VK_ATTN = 0xF6,
337
VK_CRSEL = 0xF7,
338
VK_EXSEL = 0xF8,
339
VK_EREOF = 0xF9,
340
VK_PLAY = 0xFA,
341
VK_ZOOM = 0xFB,
342
VK_NONAME = 0xFC,
343
VK_PA1 = 0xFD,
344
VK_OEM_CLEAR = 0xFE,
345
#endif
346
};
347
348
struct GamePadButtonMap {
349
int32 maskVal;
350
int16 mappingType;
351
int16 offset;
352
};
353
354
struct GamePadMappings {
355
char name[0x40];
356
GamePadButtonMap buttons[24];
357
int32 vendorID;
358
int32 productID;
359
int32 type;
360
};
361
362
struct InputDevice {
363
virtual void UpdateInput() {}
364
virtual void ProcessInput(int32 controllerID) {}
365
virtual void CloseDevice() {}
366
virtual int32 Unknown1(int32 unknown1, int32 unknown2) { return 0; }
367
virtual int32 Unknown2(int32 unknown1, int32 unknown2) { return 0; }
368
369
virtual ~InputDevice() = default;
370
371
int32 gamepadType;
372
uint32 id;
373
uint8 active;
374
uint8 isAssigned;
375
uint8 unused;
376
uint8 disabled;
377
uint8 anyPress;
378
int32 inactiveTimer[2];
379
};
380
381
struct InputState {
382
bool32 down;
383
bool32 press;
384
int32 keyMap;
385
};
386
387
struct ControllerState {
388
InputState keyUp;
389
InputState keyDown;
390
InputState keyLeft;
391
InputState keyRight;
392
InputState keyA;
393
InputState keyB;
394
InputState keyC;
395
InputState keyX;
396
InputState keyY;
397
InputState keyZ;
398
InputState keyStart;
399
InputState keySelect;
400
401
// Rev01 hasn't split these into different structs yet
402
#if !RETRO_REV02
403
InputState keyBumperL;
404
InputState keyBumperR;
405
InputState keyTriggerL;
406
InputState keyTriggerR;
407
InputState keyStickL;
408
InputState keyStickR;
409
#endif
410
};
411
412
struct AnalogState {
413
InputState keyUp;
414
InputState keyDown;
415
InputState keyLeft;
416
InputState keyRight;
417
#if RETRO_REV02
418
InputState keyStick;
419
float deadzone;
420
float hDelta;
421
float vDelta;
422
#else
423
float deadzone;
424
float triggerDeltaL;
425
float triggerDeltaR;
426
float hDeltaL;
427
float vDeltaL;
428
float hDeltaR;
429
float vDeltaR;
430
#endif
431
};
432
433
#if RETRO_REV02
434
struct TriggerState {
435
InputState keyBumper;
436
InputState keyTrigger;
437
float bumperDelta;
438
float triggerDelta;
439
};
440
#endif
441
442
struct TouchInfo {
443
float x[0x10];
444
float y[0x10];
445
bool32 down[0x10];
446
uint8 count;
447
#if !RETRO_REV02
448
bool32 pauseHold;
449
bool32 pausePress;
450
bool32 unknown1;
451
bool32 anyKeyHold;
452
bool32 anyKeyPress;
453
bool32 unknown2;
454
#endif
455
};
456
457
extern InputDevice *inputDeviceList[INPUTDEVICE_COUNT];
458
extern int32 inputDeviceCount;
459
460
extern int32 inputSlots[PLAYER_COUNT];
461
extern InputDevice *inputSlotDevices[PLAYER_COUNT];
462
463
extern ControllerState controller[PLAYER_COUNT + 1];
464
extern AnalogState stickL[PLAYER_COUNT + 1];
465
#if RETRO_REV02
466
extern AnalogState stickR[PLAYER_COUNT + 1];
467
extern TriggerState triggerL[PLAYER_COUNT + 1];
468
extern TriggerState triggerR[PLAYER_COUNT + 1];
469
#endif
470
extern TouchInfo touchInfo;
471
472
extern GamePadMappings *gamePadMappings;
473
extern int32 gamePadCount;
474
475
#if RETRO_INPUTDEVICE_KEYBOARD
476
#include "Keyboard/KBInputDevice.hpp"
477
#endif
478
479
#if RETRO_INPUTDEVICE_XINPUT
480
#include "XInput/XInputDevice.hpp"
481
#endif
482
483
#if RETRO_INPUTDEVICE_RAWINPUT
484
#include "RawInput/RawInputDevice.hpp"
485
#endif
486
487
#if RETRO_INPUTDEVICE_STEAM
488
#include "Steam/SteamInputDevice.hpp"
489
#endif
490
491
#if RETRO_INPUTDEVICE_NX
492
#include "NX/NXInputDevice.hpp"
493
#endif
494
495
#if RETRO_INPUTDEVICE_SDL2
496
#include "SDL2/SDL2InputDevice.hpp"
497
#endif
498
499
#if RETRO_INPUTDEVICE_GLFW
500
#include "GLFW/GLFWInputDevice.hpp"
501
#endif
502
503
#if RETRO_INPUTDEVICE_PDBOAT
504
#include "Paddleboat/PDBInputDevice.hpp"
505
#endif
506
507
// Initializes the input devices & the backend APIs powering em
508
void InitInputDevices();
509
// clears the input states, used by ProcessInput()
510
void ClearInput();
511
// Processes the state of the input devices & parses that as data that RSDK can use
512
void ProcessInput();
513
// used to process various events on input devices, switch uses it to controller connects/disconnects/changes
514
void ProcessInputDevices();
515
// Releases the input devices & closes the backend APIs powering em
516
void ReleaseInputDevices();
517
518
void RemoveInputDevice(InputDevice *targetDevice);
519
520
inline InputDevice *InputDeviceFromID(uint32 deviceID)
521
{
522
for (int32 i = 0; i < inputDeviceCount; ++i) {
523
if (inputDeviceList[i] && inputDeviceList[i]->id == deviceID)
524
return inputDeviceList[i];
525
}
526
527
return NULL;
528
}
529
inline int32 GetAvaliableInputDevice()
530
{
531
for (int32 i = 0; i < inputDeviceCount; ++i) {
532
if (inputDeviceList[i] && inputDeviceList[i]->active && !inputDeviceList[i]->disabled && !inputDeviceList[i]->isAssigned
533
&& inputDeviceList[i]->anyPress) {
534
return inputDeviceList[i]->id;
535
}
536
}
537
538
return INPUT_AUTOASSIGN;
539
}
540
541
inline uint32 GetInputDeviceID(uint8 inputSlot)
542
{
543
uint8 slotID = inputSlot - 1;
544
if (slotID < PLAYER_COUNT)
545
return inputSlots[slotID];
546
547
return INPUT_NONE;
548
}
549
550
#if RETRO_REV02
551
inline uint32 GetFilteredInputDeviceID(bool32 confirmOnly, bool32 unassignedOnly, uint32 maxInactiveTimer)
552
{
553
uint32 mostRecentTime = -1;
554
int32 mostRecentValidID = 0;
555
int32 mostRecentID = 0;
556
uint32 maxTime = maxInactiveTimer ? maxInactiveTimer : -1;
557
558
if (inputDeviceCount) {
559
for (int32 i = 0; i < inputDeviceCount; ++i) {
560
if (inputDeviceList[i] && inputDeviceList[i]->active && !inputDeviceList[i]->disabled
561
&& (!inputDeviceList[i]->isAssigned || !unassignedOnly)) {
562
if (inputDeviceList[i]->inactiveTimer[confirmOnly] < mostRecentTime) {
563
mostRecentTime = inputDeviceList[i]->inactiveTimer[confirmOnly];
564
if (inputDeviceList[i]->inactiveTimer[confirmOnly] <= maxTime)
565
mostRecentValidID = inputDeviceList[i]->id;
566
mostRecentID = inputDeviceList[i]->id;
567
}
568
}
569
}
570
571
if (mostRecentValidID)
572
return mostRecentValidID;
573
}
574
575
if (mostRecentID)
576
return mostRecentID;
577
578
for (int32 i = 0; i < inputDeviceCount; ++i) {
579
if (inputDeviceList[i] && inputDeviceList[i]->active && !inputDeviceList[i]->disabled
580
&& (!inputDeviceList[i]->isAssigned || !unassignedOnly)) {
581
return inputDeviceList[i]->id;
582
}
583
}
584
585
return mostRecentID;
586
}
587
#else
588
inline int32 GetFilteredInputDeviceID(uint32 deviceID)
589
{
590
bool32 confirmOnly = false;
591
bool32 unassignedOnly = false;
592
593
uint32 mostRecentTime = -1;
594
int32 mostRecentValidID = 0;
595
int32 mostRecentID = 0;
596
uint32 maxTime = -1;
597
598
if (inputDeviceCount) {
599
for (int32 i = 0; i < inputDeviceCount; ++i) {
600
if (inputDeviceList[i] && inputDeviceList[i]->active && !inputDeviceList[i]->disabled
601
&& (!inputDeviceList[i]->isAssigned || !unassignedOnly)) {
602
603
if (deviceID && inputDeviceList[i]->id == deviceID)
604
continue;
605
606
if (inputDeviceList[i]->inactiveTimer[confirmOnly] < mostRecentTime) {
607
mostRecentTime = inputDeviceList[i]->inactiveTimer[confirmOnly];
608
if (inputDeviceList[i]->inactiveTimer[confirmOnly] <= maxTime)
609
mostRecentValidID = inputDeviceList[i]->id;
610
mostRecentID = inputDeviceList[i]->id;
611
}
612
}
613
}
614
615
if (mostRecentValidID)
616
return mostRecentValidID;
617
}
618
619
if (mostRecentID)
620
return mostRecentID;
621
622
for (int32 i = 0; i < inputDeviceCount; ++i) {
623
if (inputDeviceList[i] && inputDeviceList[i]->active && !inputDeviceList[i]->disabled
624
&& (!inputDeviceList[i]->isAssigned || !unassignedOnly)) {
625
return inputDeviceList[i]->id;
626
}
627
}
628
629
return mostRecentID;
630
}
631
#endif
632
633
int32 GetInputDeviceType(uint32 deviceID);
634
635
inline bool32 IsInputDeviceAssigned(uint32 deviceID)
636
{
637
for (int32 i = 0; i < inputDeviceCount; ++i) {
638
if (inputDeviceList[i] && inputDeviceList[i]->id == deviceID) {
639
return inputDeviceList[i]->isAssigned;
640
}
641
}
642
643
return false;
644
}
645
646
inline int32 GetInputDeviceUnknown(uint32 deviceID)
647
{
648
for (int32 i = 0; i < inputDeviceCount; ++i) {
649
if (inputDeviceList[i] && inputDeviceList[i]->id == deviceID) {
650
return 0xFFFF; // ???
651
}
652
}
653
654
return 0xFFFF;
655
}
656
657
inline int32 InputDeviceUnknown1(uint32 deviceID, int32 unknown1, int32 unknown2)
658
{
659
for (int32 i = 0; i < inputDeviceCount; ++i) {
660
if (inputDeviceList[i] && inputDeviceList[i]->id == deviceID) {
661
return inputDeviceList[i]->Unknown1(unknown1, unknown2);
662
}
663
}
664
665
return 0;
666
}
667
668
inline int32 InputDeviceUnknown2(uint32 deviceID, int32 unknown1, int32 unknown2)
669
{
670
for (int32 i = 0; i < inputDeviceCount; ++i) {
671
if (inputDeviceList[i] && inputDeviceList[i]->id == deviceID) {
672
return inputDeviceList[i]->Unknown2(unknown1, unknown2);
673
}
674
}
675
676
return 0;
677
}
678
679
inline int32 GetInputSlotUnknown(uint8 inputSlot) { return 0xFFFF; }
680
681
inline int32 InputSlotUnknown1(uint8 inputSlot, int32 unknown1, int32 unknown2)
682
{
683
uint8 slotID = inputSlot - 1;
684
685
if (slotID < PLAYER_COUNT && inputSlots[slotID])
686
return inputSlotDevices[slotID]->Unknown1(unknown1, unknown2);
687
688
return 0;
689
}
690
691
inline int32 InputSlotUnknown2(uint8 inputSlot, int32 unknown1, int32 unknown2)
692
{
693
uint8 slotID = inputSlot - 1;
694
695
if (slotID < PLAYER_COUNT && inputSlots[slotID])
696
return inputSlotDevices[slotID]->Unknown2(unknown1, unknown2);
697
698
return 0;
699
}
700
701
inline void AssignInputSlotToDevice(uint8 inputSlot, uint32 deviceID)
702
{
703
uint8 slotID = inputSlot - 1;
704
705
if (slotID < PLAYER_COUNT) {
706
if (deviceID && deviceID != INPUT_AUTOASSIGN) {
707
if (deviceID == INPUT_UNASSIGNED) {
708
inputSlots[slotID] = INPUT_UNASSIGNED;
709
}
710
else {
711
for (int32 i = 0; i < inputDeviceCount; ++i) {
712
if (inputDeviceList[i] && inputDeviceList[i]->id == deviceID) {
713
inputDeviceList[i]->isAssigned = true;
714
inputSlots[slotID] = deviceID;
715
inputSlotDevices[slotID] = inputDeviceList[i];
716
break;
717
}
718
}
719
}
720
}
721
else {
722
InputDevice *device = InputDeviceFromID(inputSlots[slotID]);
723
if (device)
724
device->isAssigned = false;
725
inputSlots[slotID] = deviceID;
726
}
727
}
728
}
729
730
#if RETRO_REV02
731
inline bool32 IsInputSlotAssigned(uint8 inputSlot)
732
{
733
uint8 slotID = inputSlot - 1;
734
735
if (slotID < PLAYER_COUNT)
736
return inputSlots[slotID] != INPUT_NONE;
737
738
return false;
739
}
740
#else
741
inline bool32 InputIDIsDisconnected(uint8 inputSlot)
742
{
743
uint8 slotID = inputSlot - 1;
744
745
if (slotID < PLAYER_COUNT)
746
return inputSlots[slotID] == INPUT_NONE;
747
748
return false;
749
}
750
#endif
751
752
inline void ResetInputSlotAssignments()
753
{
754
for (int32 i = 0; i < PLAYER_COUNT; ++i) {
755
inputSlots[i] = INPUT_NONE;
756
inputSlotDevices[i] = NULL;
757
}
758
759
for (int32 i = 0; i < inputDeviceCount; ++i) {
760
if (inputDeviceList[i])
761
inputDeviceList[i]->isAssigned = false;
762
}
763
}
764
765
inline void SetInputLEDColor()
766
{
767
// empty
768
}
769
770
#if !RETRO_REV02
771
inline void GetUnknownInputValue(int32 inputSlot, int32 type, int32 *value)
772
{
773
uint8 slotID = inputSlot - 1;
774
775
if (value && type < PLAYER_COUNT && inputSlotDevices[slotID]) {
776
switch (type) {
777
default:
778
break;
779
// case 0: *value = inputSlotDevices[slotID].unknown1; break;
780
// case 1: *value = inputSlotDevices[slotID].unknown2; break;
781
}
782
}
783
}
784
#endif
785
786
} // namespace RSDK
787
788
#endif // !INPUT_H
789