Skip to content

Latest commit

 

History

History
635 lines (525 loc) · 18 KB

SDL_windowsjoystick.c

File metadata and controls

635 lines (525 loc) · 18 KB
 
1
2
/*
Simple DirectMedia Layer
Jan 17, 2020
Jan 17, 2020
3
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
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
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_JOYSTICK_DINPUT || SDL_JOYSTICK_XINPUT
/* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
* A. Formiga's WINMM driver.
*
* Hats and sliders are completely untested; the app I'm writing this for mostly
* doesn't use them and I don't own any joysticks with them.
*
* We don't bother to use event notification here. It doesn't seem to work
* with polled devices, and it's fine to call IDirectInputDevice8_GetDeviceData and
* let it return 0 events. */
#include "SDL_error.h"
#include "SDL_assert.h"
#include "SDL_events.h"
#include "SDL_timer.h"
#include "SDL_mutex.h"
#include "SDL_joystick.h"
#include "../SDL_sysjoystick.h"
Apr 12, 2016
Apr 12, 2016
42
#include "../../thread/SDL_systhread.h"
43
44
45
46
47
48
49
50
51
#include "../../core/windows/SDL_windows.h"
#if !defined(__WINRT__)
#include <dbt.h>
#endif
#define INITGUID /* Only set here, if set twice will cause mingw32 to break. */
#include "SDL_windowsjoystick_c.h"
#include "SDL_dinputjoystick_c.h"
#include "SDL_xinputjoystick_c.h"
Nov 27, 2020
Nov 27, 2020
52
#include "SDL_rawinputjoystick_c.h"
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
#include "../../haptic/windows/SDL_dinputhaptic_c.h" /* For haptic hot plugging */
#include "../../haptic/windows/SDL_xinputhaptic_c.h" /* For haptic hot plugging */
#ifndef DEVICE_NOTIFY_WINDOW_HANDLE
#define DEVICE_NOTIFY_WINDOW_HANDLE 0x00000000
#endif
/* local variables */
static SDL_bool s_bDeviceAdded = SDL_FALSE;
static SDL_bool s_bDeviceRemoved = SDL_FALSE;
static SDL_cond *s_condJoystickThread = NULL;
static SDL_mutex *s_mutexJoyStickEnum = NULL;
static SDL_Thread *s_threadJoystick = NULL;
static SDL_bool s_bJoystickThreadQuit = SDL_FALSE;
JoyStick_DeviceData *SYS_Joystick; /* array to hold joystick ID values */
static SDL_bool s_bWindowsDeviceChanged = SDL_FALSE;
#ifdef __WINRT__
typedef struct
{
int unused;
} SDL_DeviceNotificationData;
static void
SDL_CleanupDeviceNotification(SDL_DeviceNotificationData *data)
{
}
static int
SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data)
{
return 0;
}
Sep 8, 2017
Sep 8, 2017
92
93
static SDL_bool
SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_mutex *mutex)
Sep 8, 2017
Sep 8, 2017
95
return SDL_FALSE;
96
97
98
99
100
101
102
103
104
105
106
107
}
#else /* !__WINRT__ */
typedef struct
{
HRESULT coinitialized;
WNDCLASSEX wincl;
HWND messageWindow;
HDEVNOTIFY hNotify;
} SDL_DeviceNotificationData;
Sep 8, 2017
Sep 8, 2017
108
109
#define IDT_SDL_DEVICE_CHANGE_TIMER_1 1200
#define IDT_SDL_DEVICE_CHANGE_TIMER_2 1201
110
111
112
/* windowproc for our joystick detect thread message only window, to detect any USB device addition/removal */
static LRESULT CALLBACK
Nov 27, 2020
Nov 27, 2020
113
SDL_PrivateJoystickDetectProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Nov 27, 2020
Nov 27, 2020
115
switch (msg) {
116
117
118
119
120
case WM_DEVICECHANGE:
switch (wParam) {
case DBT_DEVICEARRIVAL:
case DBT_DEVICEREMOVECOMPLETE:
if (((DEV_BROADCAST_HDR*)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
Sep 8, 2017
Sep 8, 2017
121
122
123
/* notify 300ms and 2 seconds later to ensure all APIs have updated status */
SetTimer(hwnd, IDT_SDL_DEVICE_CHANGE_TIMER_1, 300, NULL);
SetTimer(hwnd, IDT_SDL_DEVICE_CHANGE_TIMER_2, 2000, NULL);
124
125
126
127
}
break;
}
return 0;
Sep 8, 2017
Sep 8, 2017
128
129
130
131
case WM_TIMER:
KillTimer(hwnd, wParam);
s_bWindowsDeviceChanged = SDL_TRUE;
return 0;
Nov 27, 2020
Nov 27, 2020
134
135
136
137
138
#if SDL_JOYSTICK_RAWINPUT
return CallWindowProc(RAWINPUT_WindowProc, hwnd, msg, wParam, lParam);
#else
return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
#endif
139
140
141
142
143
}
static void
SDL_CleanupDeviceNotification(SDL_DeviceNotificationData *data)
{
Nov 27, 2020
Nov 27, 2020
144
145
146
147
#if SDL_JOYSTICK_RAWINPUT
RAWINPUT_UnregisterNotifications();
#endif
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
if (data->hNotify)
UnregisterDeviceNotification(data->hNotify);
if (data->messageWindow)
DestroyWindow(data->messageWindow);
UnregisterClass(data->wincl.lpszClassName, data->wincl.hInstance);
if (data->coinitialized == S_OK) {
WIN_CoUninitialize();
}
}
static int
SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data)
{
DEV_BROADCAST_DEVICEINTERFACE dbh;
GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2L, 0xF16F, 0x11CF, { 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } };
SDL_zerop(data);
data->coinitialized = WIN_CoInitialize();
data->wincl.hInstance = GetModuleHandle(NULL);
data->wincl.lpszClassName = L"Message";
data->wincl.lpfnWndProc = SDL_PrivateJoystickDetectProc; /* This function is called by windows */
data->wincl.cbSize = sizeof (WNDCLASSEX);
if (!RegisterClassEx(&data->wincl)) {
WIN_SetError("Failed to create register class for joystick autodetect");
SDL_CleanupDeviceNotification(data);
return -1;
}
data->messageWindow = (HWND)CreateWindowEx(0, L"Message", NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
if (!data->messageWindow) {
WIN_SetError("Failed to create message window for joystick autodetect");
SDL_CleanupDeviceNotification(data);
return -1;
}
SDL_zero(dbh);
dbh.dbcc_size = sizeof(dbh);
dbh.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
dbh.dbcc_classguid = GUID_DEVINTERFACE_HID;
data->hNotify = RegisterDeviceNotification(data->messageWindow, &dbh, DEVICE_NOTIFY_WINDOW_HANDLE);
if (!data->hNotify) {
WIN_SetError("Failed to create notify device for joystick autodetect");
SDL_CleanupDeviceNotification(data);
return -1;
}
Nov 27, 2020
Nov 27, 2020
200
201
202
203
#if SDL_JOYSTICK_RAWINPUT
RAWINPUT_RegisterNotifications(data->messageWindow);
#endif
Sep 8, 2017
Sep 8, 2017
207
208
static SDL_bool
SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_mutex *mutex)
Sep 8, 2017
Sep 8, 2017
211
int lastret = 1;
212
213
if (!data->messageWindow) {
Sep 8, 2017
Sep 8, 2017
214
return SDL_FALSE; /* device notifications require a window */
Sep 8, 2017
Sep 8, 2017
217
218
219
220
SDL_UnlockMutex(mutex);
while (lastret > 0 && s_bWindowsDeviceChanged == SDL_FALSE) {
lastret = GetMessage(&msg, NULL, 0, 0); /* WM_QUIT causes return value of 0 */
if (lastret > 0) {
221
222
223
224
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Sep 8, 2017
Sep 8, 2017
225
226
SDL_LockMutex(mutex);
return (lastret != -1) ? SDL_TRUE : SDL_FALSE;
227
228
229
230
231
232
233
234
235
236
237
238
}
#endif /* __WINRT__ */
/* Function/thread to scan the system for joysticks. */
static int
SDL_JoystickThread(void *_data)
{
SDL_DeviceNotificationData notification_data;
#if SDL_JOYSTICK_XINPUT
SDL_bool bOpenedXInputDevices[XUSER_MAX_COUNT];
Jul 31, 2019
Jul 31, 2019
239
SDL_zeroa(bOpenedXInputDevices);
240
241
242
243
244
245
246
247
248
249
#endif
if (SDL_CreateDeviceNotification(&notification_data) < 0) {
return -1;
}
SDL_LockMutex(s_mutexJoyStickEnum);
while (s_bJoystickThreadQuit == SDL_FALSE) {
SDL_bool bXInputChanged = SDL_FALSE;
Sep 8, 2017
Sep 8, 2017
250
if (SDL_WaitForDeviceNotification(&notification_data, s_mutexJoyStickEnum) == SDL_FALSE) {
251
#if SDL_JOYSTICK_XINPUT
Sep 8, 2017
Sep 8, 2017
252
253
254
255
256
257
258
259
260
261
262
263
264
/* WM_DEVICECHANGE not working, poll for new XINPUT controllers */
SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000);
if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) {
/* scan for any change in XInput devices */
Uint8 userId;
for (userId = 0; userId < XUSER_MAX_COUNT; userId++) {
XINPUT_CAPABILITIES capabilities;
const DWORD result = XINPUTGETCAPABILITIES(userId, XINPUT_FLAG_GAMEPAD, &capabilities);
const SDL_bool available = (result == ERROR_SUCCESS);
if (bOpenedXInputDevices[userId] != available) {
bXInputChanged = SDL_TRUE;
bOpenedXInputDevices[userId] = available;
}
Sep 8, 2017
Sep 8, 2017
267
268
269
#else
/* WM_DEVICECHANGE not working, no XINPUT, no point in keeping thread alive */
break;
270
#endif /* SDL_JOYSTICK_XINPUT */
Sep 24, 2018
Sep 24, 2018
271
}
272
273
274
275
276
277
278
279
280
281
282
283
284
285
if (s_bWindowsDeviceChanged || bXInputChanged) {
s_bDeviceRemoved = SDL_TRUE;
s_bDeviceAdded = SDL_TRUE;
s_bWindowsDeviceChanged = SDL_FALSE;
}
}
SDL_UnlockMutex(s_mutexJoyStickEnum);
SDL_CleanupDeviceNotification(&notification_data);
return 1;
}
Aug 9, 2018
Aug 9, 2018
286
void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device)
287
288
{
device->send_add_event = SDL_TRUE;
Aug 9, 2018
Aug 9, 2018
289
device->nInstanceID = SDL_GetNextJoystickInstanceID();
290
291
292
293
294
295
device->pNext = SYS_Joystick;
SYS_Joystick = device;
s_bDeviceAdded = SDL_TRUE;
}
Aug 9, 2018
Aug 9, 2018
296
297
298
static void WINDOWS_JoystickDetect(void);
static void WINDOWS_JoystickQuit(void);
299
300
301
302
/* Function to scan the system for joysticks.
* Joystick 0 should be the system default joystick.
* It should return 0, or -1 on an unrecoverable fatal error.
*/
Aug 9, 2018
Aug 9, 2018
303
304
static int
WINDOWS_JoystickInit(void)
305
306
{
if (SDL_DINPUT_JoystickInit() < 0) {
Aug 9, 2018
Aug 9, 2018
307
WINDOWS_JoystickQuit();
308
309
310
311
return -1;
}
if (SDL_XINPUT_JoystickInit() < 0) {
Aug 9, 2018
Aug 9, 2018
312
WINDOWS_JoystickQuit();
313
314
315
316
317
318
319
return -1;
}
s_mutexJoyStickEnum = SDL_CreateMutex();
s_condJoystickThread = SDL_CreateCond();
s_bDeviceAdded = SDL_TRUE; /* force a scan of the system for joysticks this first time */
Aug 9, 2018
Aug 9, 2018
320
WINDOWS_JoystickDetect();
321
322
323
if (!s_threadJoystick) {
/* spin up the thread to detect hotplug of devices */
Apr 12, 2016
Apr 12, 2016
324
325
s_bJoystickThreadQuit = SDL_FALSE;
s_threadJoystick = SDL_CreateThreadInternal(SDL_JoystickThread, "SDL_joystick", 64 * 1024, NULL);
Aug 9, 2018
Aug 9, 2018
327
return 0;
328
329
330
}
/* return the number of joysticks that are connected right now */
Aug 9, 2018
Aug 9, 2018
331
332
static int
WINDOWS_JoystickGetCount(void)
333
334
335
336
337
338
339
340
341
342
343
344
{
int nJoysticks = 0;
JoyStick_DeviceData *device = SYS_Joystick;
while (device) {
nJoysticks++;
device = device->pNext;
}
return nJoysticks;
}
/* detect any new joysticks being inserted into the system */
Aug 9, 2018
Aug 9, 2018
345
346
static void
WINDOWS_JoystickDetect(void)
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
{
JoyStick_DeviceData *pCurList = NULL;
/* only enum the devices if the joystick thread told us something changed */
if (!s_bDeviceAdded && !s_bDeviceRemoved) {
return; /* thread hasn't signaled, nothing to do right now. */
}
SDL_LockMutex(s_mutexJoyStickEnum);
s_bDeviceAdded = SDL_FALSE;
s_bDeviceRemoved = SDL_FALSE;
pCurList = SYS_Joystick;
SYS_Joystick = NULL;
/* Look for DirectInput joysticks, wheels, head trackers, gamepads, etc.. */
SDL_DINPUT_JoystickDetect(&pCurList);
/* Look for XInput devices. Do this last, so they're first in the final list. */
SDL_XINPUT_JoystickDetect(&pCurList);
SDL_UnlockMutex(s_mutexJoyStickEnum);
while (pCurList) {
JoyStick_DeviceData *pListNext = NULL;
if (pCurList->bXInputDevice) {
Jul 8, 2020
Jul 8, 2020
375
#if SDL_HAPTIC_XINPUT
376
SDL_XINPUT_MaybeRemoveDevice(pCurList->XInputUserId);
Jul 8, 2020
Jul 8, 2020
377
#endif
Jul 8, 2020
Jul 8, 2020
379
#if SDL_HAPTIC_DINPUT
380
SDL_DINPUT_MaybeRemoveDevice(&pCurList->dxdevice);
Jul 8, 2020
Jul 8, 2020
381
#endif
Aug 26, 2016
Aug 26, 2016
384
SDL_PrivateJoystickRemoved(pCurList->nInstanceID);
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
pListNext = pCurList->pNext;
SDL_free(pCurList->joystickname);
SDL_free(pCurList);
pCurList = pListNext;
}
if (s_bDeviceAdded) {
JoyStick_DeviceData *pNewJoystick;
int device_index = 0;
s_bDeviceAdded = SDL_FALSE;
pNewJoystick = SYS_Joystick;
while (pNewJoystick) {
if (pNewJoystick->send_add_event) {
if (pNewJoystick->bXInputDevice) {
Jul 8, 2020
Jul 8, 2020
400
#if SDL_HAPTIC_XINPUT
401
SDL_XINPUT_MaybeAddDevice(pNewJoystick->XInputUserId);
Jul 8, 2020
Jul 8, 2020
402
#endif
Jul 8, 2020
Jul 8, 2020
404
#if SDL_HAPTIC_DINPUT
405
SDL_DINPUT_MaybeAddDevice(&pNewJoystick->dxdevice);
Jul 8, 2020
Jul 8, 2020
406
#endif
Aug 9, 2018
Aug 9, 2018
409
SDL_PrivateJoystickAdded(pNewJoystick->nInstanceID);
410
411
412
413
414
415
416
417
418
419
pNewJoystick->send_add_event = SDL_FALSE;
}
device_index++;
pNewJoystick = pNewJoystick->pNext;
}
}
}
/* Function to get the device-dependent name of a joystick */
Aug 9, 2018
Aug 9, 2018
420
421
static const char *
WINDOWS_JoystickGetDeviceName(int device_index)
422
423
{
JoyStick_DeviceData *device = SYS_Joystick;
May 29, 2020
May 29, 2020
424
int index;
May 29, 2020
May 29, 2020
426
for (index = device_index; index > 0; index--)
427
428
429
430
431
device = device->pNext;
return device->joystickname;
}
Oct 25, 2018
Oct 25, 2018
432
433
434
435
436
437
438
439
440
441
442
443
static int
WINDOWS_JoystickGetDevicePlayerIndex(int device_index)
{
JoyStick_DeviceData *device = SYS_Joystick;
int index;
for (index = device_index; index > 0; index--)
device = device->pNext;
return device->bXInputDevice ? (int)device->XInputUserId : -1;
}
Dec 21, 2019
Dec 21, 2019
444
445
446
447
448
static void
WINDOWS_JoystickSetDevicePlayerIndex(int device_index, int player_index)
{
}
Aug 9, 2018
Aug 9, 2018
449
450
451
452
453
454
455
456
457
458
459
460
461
/* return the stable device guid for this device index */
static SDL_JoystickGUID
WINDOWS_JoystickGetDeviceGUID(int device_index)
{
JoyStick_DeviceData *device = SYS_Joystick;
int index;
for (index = device_index; index > 0; index--)
device = device->pNext;
return device->guid;
}
462
/* Function to perform the mapping between current device instance and this joysticks instance id */
Aug 9, 2018
Aug 9, 2018
463
464
static SDL_JoystickID
WINDOWS_JoystickGetDeviceInstanceID(int device_index)
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
{
JoyStick_DeviceData *device = SYS_Joystick;
int index;
for (index = device_index; index > 0; index--)
device = device->pNext;
return device->nInstanceID;
}
/* Function to open a joystick for use.
The joystick to open is specified by the device index.
This should fill the nbuttons and naxes fields of the joystick structure.
It returns 0, or -1 if there is an error.
*/
Aug 9, 2018
Aug 9, 2018
480
481
static int
WINDOWS_JoystickOpen(SDL_Joystick * joystick, int device_index)
May 29, 2020
May 29, 2020
483
484
JoyStick_DeviceData *device = SYS_Joystick;
int index;
May 29, 2020
May 29, 2020
486
487
for (index = device_index; index > 0; index--)
device = device->pNext;
488
489
/* allocate memory for system specific hardware data */
May 29, 2020
May 29, 2020
490
joystick->instance_id = device->nInstanceID;
491
492
493
494
495
496
joystick->hwdata =
(struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata));
if (joystick->hwdata == NULL) {
return SDL_OutOfMemory();
}
SDL_zerop(joystick->hwdata);
May 29, 2020
May 29, 2020
497
joystick->hwdata->guid = device->guid;
May 29, 2020
May 29, 2020
499
500
if (device->bXInputDevice) {
return SDL_XINPUT_JoystickOpen(joystick, device);
May 29, 2020
May 29, 2020
502
return SDL_DINPUT_JoystickOpen(joystick, device);
Aug 9, 2018
Aug 9, 2018
506
static int
Feb 4, 2020
Feb 4, 2020
507
WINDOWS_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
Aug 9, 2018
Aug 9, 2018
508
509
{
if (joystick->hwdata->bXInputDevice) {
Feb 4, 2020
Feb 4, 2020
510
return SDL_XINPUT_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble);
Aug 9, 2018
Aug 9, 2018
511
} else {
Feb 4, 2020
Feb 4, 2020
512
return SDL_DINPUT_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble);
Aug 9, 2018
Aug 9, 2018
513
514
515
}
}
Nov 12, 2020
Nov 12, 2020
516
517
518
519
520
521
static int
WINDOWS_JoystickRumbleTriggers(SDL_Joystick * joystick, Uint16 left_rumble, Uint16 right_rumble)
{
return SDL_Unsupported();
}
Nov 5, 2020
Nov 5, 2020
522
523
524
525
526
527
static SDL_bool
WINDOWS_JoystickHasLED(SDL_Joystick * joystick)
{
return SDL_FALSE;
}
Apr 30, 2020
Apr 30, 2020
528
529
530
531
532
533
static int
WINDOWS_JoystickSetLED(SDL_Joystick * joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
}
Nov 17, 2020
Nov 17, 2020
534
535
536
537
538
539
static int
WINDOWS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
{
return SDL_Unsupported();
}
Aug 9, 2018
Aug 9, 2018
540
541
static void
WINDOWS_JoystickUpdate(SDL_Joystick * joystick)
Aug 9, 2018
Aug 9, 2018
543
if (!joystick->hwdata) {
544
545
546
547
548
549
550
551
552
553
554
return;
}
if (joystick->hwdata->bXInputDevice) {
SDL_XINPUT_JoystickUpdate(joystick);
} else {
SDL_DINPUT_JoystickUpdate(joystick);
}
}
/* Function to close a joystick after use */
Aug 9, 2018
Aug 9, 2018
555
556
static void
WINDOWS_JoystickClose(SDL_Joystick * joystick)
557
558
559
560
561
562
563
564
565
566
567
{
if (joystick->hwdata->bXInputDevice) {
SDL_XINPUT_JoystickClose(joystick);
} else {
SDL_DINPUT_JoystickClose(joystick);
}
SDL_free(joystick->hwdata);
}
/* Function to perform any system-specific joystick related cleanup */
Aug 9, 2018
Aug 9, 2018
568
569
static void
WINDOWS_JoystickQuit(void)
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
{
JoyStick_DeviceData *device = SYS_Joystick;
while (device) {
JoyStick_DeviceData *device_next = device->pNext;
SDL_free(device->joystickname);
SDL_free(device);
device = device_next;
}
SYS_Joystick = NULL;
if (s_threadJoystick) {
SDL_LockMutex(s_mutexJoyStickEnum);
s_bJoystickThreadQuit = SDL_TRUE;
SDL_CondBroadcast(s_condJoystickThread); /* signal the joystick thread to quit */
SDL_UnlockMutex(s_mutexJoyStickEnum);
Sep 8, 2017
Sep 8, 2017
586
587
588
#ifndef __WINRT__
PostThreadMessage(SDL_GetThreadID(s_threadJoystick), WM_QUIT, 0, 0);
#endif
589
590
591
592
593
594
595
596
597
598
599
SDL_WaitThread(s_threadJoystick, NULL); /* wait for it to bugger off */
SDL_DestroyMutex(s_mutexJoyStickEnum);
SDL_DestroyCond(s_condJoystickThread);
s_condJoystickThread= NULL;
s_mutexJoyStickEnum = NULL;
s_threadJoystick = NULL;
}
SDL_DINPUT_JoystickQuit();
SDL_XINPUT_JoystickQuit();
Oct 7, 2016
Oct 7, 2016
600
601
602
s_bDeviceAdded = SDL_FALSE;
s_bDeviceRemoved = SDL_FALSE;
May 29, 2020
May 29, 2020
605
606
607
608
609
610
static SDL_bool
WINDOWS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
{
return SDL_FALSE;
}
Aug 9, 2018
Aug 9, 2018
611
SDL_JoystickDriver SDL_WINDOWS_JoystickDriver =
Aug 9, 2018
Aug 9, 2018
613
614
615
616
WINDOWS_JoystickInit,
WINDOWS_JoystickGetCount,
WINDOWS_JoystickDetect,
WINDOWS_JoystickGetDeviceName,
Oct 25, 2018
Oct 25, 2018
617
WINDOWS_JoystickGetDevicePlayerIndex,
Dec 21, 2019
Dec 21, 2019
618
WINDOWS_JoystickSetDevicePlayerIndex,
Aug 9, 2018
Aug 9, 2018
619
620
621
622
WINDOWS_JoystickGetDeviceGUID,
WINDOWS_JoystickGetDeviceInstanceID,
WINDOWS_JoystickOpen,
WINDOWS_JoystickRumble,
Nov 12, 2020
Nov 12, 2020
623
WINDOWS_JoystickRumbleTriggers,
Nov 5, 2020
Nov 5, 2020
624
WINDOWS_JoystickHasLED,
Apr 30, 2020
Apr 30, 2020
625
WINDOWS_JoystickSetLED,
Nov 17, 2020
Nov 17, 2020
626
WINDOWS_JoystickSetSensorsEnabled,
Aug 9, 2018
Aug 9, 2018
627
628
629
WINDOWS_JoystickUpdate,
WINDOWS_JoystickClose,
WINDOWS_JoystickQuit,
May 29, 2020
May 29, 2020
630
WINDOWS_JoystickGetGamepadMapping
Aug 9, 2018
Aug 9, 2018
631
};
632
633
634
635
#endif /* SDL_JOYSTICK_DINPUT || SDL_JOYSTICK_XINPUT */
/* vi: set ts=4 sw=4 expandtab: */