21 #include "../../SDL_internal.h"
23 #ifdef SDL_JOYSTICK_WGI
27 #include "../SDL_sysjoystick.h"
28 #include "../hidapi/SDL_hidapijoystick_c.h"
31 #include "../../core/windows/SDL_windows.h"
33 #include "windows.gaming.input.h"
38 __x_ABI_CWindows_CGaming_CInput_CIRawGameController *
controller;
40 __x_ABI_CWindows_CGaming_CInput_CIGameControllerBatteryInfo *battery;
41 __x_ABI_CWindows_CGaming_CInput_CIGamepad *gamepad;
42 __x_ABI_CWindows_CGaming_CInput_CGamepadVibration vibration;
46 typedef struct WindowsGamingInputControllerState {
48 __x_ABI_CWindows_CGaming_CInput_CIRawGameController *controller;
55 } WindowsGamingInputControllerState;
58 __x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics *statics;
59 __x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics *arcade_stick_statics;
60 __x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics2 *arcade_stick_statics2;
61 __x_ABI_CWindows_CGaming_CInput_CIFlightStickStatics *flight_stick_statics;
62 __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics *gamepad_statics;
63 __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics2 *gamepad_statics2;
64 __x_ABI_CWindows_CGaming_CInput_CIRacingWheelStatics *racing_wheel_statics;
65 __x_ABI_CWindows_CGaming_CInput_CIRacingWheelStatics2 *racing_wheel_statics2;
66 EventRegistrationToken controller_added_token;
67 EventRegistrationToken controller_removed_token;
72 static const IID IID_IRawGameControllerStatics = { 0xEB8D0792, 0xE95A, 0x4B19, { 0xAF, 0xC7, 0x0A, 0x59, 0xF8, 0xBF, 0x75, 0x9E } };
73 static const IID IID_IRawGameController = { 0x7CAD6D91, 0xA7E1, 0x4F71, { 0x9A, 0x78, 0x33, 0xE9, 0xC5, 0xDF, 0xEA, 0x62 } };
74 static const IID IID_IRawGameController2 = { 0x43C0C035, 0xBB73, 0x4756, { 0xA7, 0x87, 0x3E, 0xD6, 0xBE, 0xA6, 0x17, 0xBD } };
75 static const IID IID_IEventHandler_RawGameController = { 0x00621c22, 0x42e8, 0x529f, { 0x92, 0x70, 0x83, 0x6b, 0x32, 0x93, 0x1d, 0x72 } };
76 static const IID IID_IGameController = { 0x1BAF6522, 0x5F64, 0x42C5, { 0x82, 0x67, 0xB9, 0xFE, 0x22, 0x15, 0xBF, 0xBD } };
77 static const IID IID_IGameControllerBatteryInfo = { 0xDCECC681, 0x3963, 0x4DA6, { 0x95, 0x5D, 0x55, 0x3F, 0x3B, 0x6F, 0x61, 0x61 } };
78 static const IID IID_IArcadeStickStatics = { 0x5C37B8C8, 0x37B1, 0x4AD8, { 0x94, 0x58, 0x20, 0x0F, 0x1A, 0x30, 0x01, 0x8E } };
79 static const IID IID_IArcadeStickStatics2 = { 0x52B5D744, 0xBB86, 0x445A, { 0xB5, 0x9C, 0x59, 0x6F, 0x0E, 0x2A, 0x49, 0xDF } };
80 static const IID IID_IArcadeStick = { 0xB14A539D, 0xBEFB, 0x4C81, { 0x80, 0x51, 0x15, 0xEC, 0xF3, 0xB1, 0x30, 0x36 } };
81 static const IID IID_IFlightStickStatics = { 0x5514924A, 0xFECC, 0x435E, { 0x83, 0xDC, 0x5C, 0xEC, 0x8A, 0x18, 0xA5, 0x20 } };
82 static const IID IID_IFlightStick = { 0xB4A2C01C, 0xB83B, 0x4459, { 0xA1, 0xA9, 0x97, 0xB0, 0x3C, 0x33, 0xDA, 0x7C } };
83 static const IID IID_IGamepadStatics = { 0x8BBCE529, 0xD49C, 0x39E9, { 0x95, 0x60, 0xE4, 0x7D, 0xDE, 0x96, 0xB7, 0xC8 } };
84 static const IID IID_IGamepadStatics2 = { 0x42676DC5, 0x0856, 0x47C4, { 0x92, 0x13, 0xB3, 0x95, 0x50, 0x4C, 0x3A, 0x3C } };
85 static const IID IID_IGamepad = { 0xBC7BB43C, 0x0A69, 0x3903, { 0x9E, 0x9D, 0xA5, 0x0F, 0x86, 0xA4, 0x5D, 0xE5 } };
86 static const IID IID_IRacingWheelStatics = { 0x3AC12CD5, 0x581B, 0x4936, { 0x9F, 0x94, 0x69, 0xF1, 0xE6, 0x51, 0x4C, 0x7D } };
87 static const IID IID_IRacingWheelStatics2 = { 0xE666BCAA, 0xEDFD, 0x4323, { 0xA9, 0xF6, 0x3C, 0x38, 0x40, 0x48, 0xD1, 0xED } };
88 static const IID IID_IRacingWheel = { 0xF546656F, 0xE106, 0x4C82, { 0xA9, 0x0F, 0x55, 0x40, 0x12, 0x90, 0x4B, 0x85 } };
96 PRAWINPUTDEVICELIST raw_devices =
NULL;
97 UINT
i, raw_device_count = 0;
98 LONG vidpid = MAKELONG(vendor, product);
105 if ((GetRawInputDeviceList(
NULL, &raw_device_count,
sizeof(RAWINPUTDEVICELIST)) == -1) || (!raw_device_count)) {
109 raw_devices = (PRAWINPUTDEVICELIST)
SDL_malloc(
sizeof(RAWINPUTDEVICELIST) * raw_device_count);
110 if (raw_devices ==
NULL) {
115 if (GetRawInputDeviceList(raw_devices, &raw_device_count,
sizeof(RAWINPUTDEVICELIST)) == -1) {
121 for (
i = 0;
i < raw_device_count;
i++) {
123 char devName[MAX_PATH];
124 UINT rdiSize =
sizeof(rdi);
127 rdi.cbSize =
sizeof(rdi);
128 if ((raw_devices[
i].dwType == RIM_TYPEHID) &&
129 (GetRawInputDeviceInfoA(raw_devices[
i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) &&
130 (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == vidpid) &&
131 (GetRawInputDeviceInfoA(raw_devices[
i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) &&
140 static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, REFIID riid,
void **ppvObject)
154 static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_AddRef(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This)
159 static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This)
164 static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdded(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIRawGameController *
e)
167 __x_ABI_CWindows_CGaming_CInput_CIRawGameController *controller =
NULL;
169 hr = IUnknown_QueryInterface((IUnknown *)
e, &IID_IRawGameController, (
void **)&controller);
178 __x_ABI_CWindows_CGaming_CInput_CIRawGameController2 *controller2 =
NULL;
182 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_HardwareVendorId(controller, &vendor);
183 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_HardwareProductId(controller, &product);
185 hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(controller, &IID_IRawGameController2, (
void **)&controller2);
187 HMODULE hModule = LoadLibraryA(
"combase.dll");
188 if (hModule !=
NULL) {
189 typedef PCWSTR (WINAPI *WindowsGetStringRawBuffer_t)(HSTRING
string, UINT32 *
length);
190 typedef HRESULT (WINAPI *WindowsDeleteString_t)(HSTRING
string);
192 WindowsGetStringRawBuffer_t WindowsGetStringRawBufferFunc = (WindowsGetStringRawBuffer_t)GetProcAddress(hModule,
"WindowsGetStringRawBuffer");
193 WindowsDeleteString_t WindowsDeleteStringFunc = (WindowsDeleteString_t)GetProcAddress(hModule,
"WindowsDeleteString");
194 if (WindowsGetStringRawBufferFunc && WindowsDeleteStringFunc) {
196 hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController2_get_DisplayName(controller2, &hString);
198 PCWSTR
string = WindowsGetStringRawBufferFunc(hString,
NULL);
202 WindowsDeleteStringFunc(hString);
205 FreeLibrary(hModule);
207 __x_ABI_CWindows_CGaming_CInput_CIRawGameController2_Release(controller2);
210 hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(controller, &IID_IGameController, (
void **)&
gamecontroller);
212 __x_ABI_CWindows_CGaming_CInput_CIArcadeStick *arcade_stick =
NULL;
213 __x_ABI_CWindows_CGaming_CInput_CIFlightStick *flight_stick =
NULL;
214 __x_ABI_CWindows_CGaming_CInput_CIGamepad *gamepad =
NULL;
215 __x_ABI_CWindows_CGaming_CInput_CIRacingWheel *racing_wheel =
NULL;
217 if (wgi.gamepad_statics2 &&
SUCCEEDED(__x_ABI_CWindows_CGaming_CInput_CIGamepadStatics2_FromGameController(wgi.gamepad_statics2,
gamecontroller, &gamepad)) && gamepad) {
219 __x_ABI_CWindows_CGaming_CInput_CIGamepad_Release(gamepad);
220 }
else if (wgi.arcade_stick_statics2 &&
SUCCEEDED(__x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics2_FromGameController(wgi.arcade_stick_statics2,
gamecontroller, &arcade_stick)) && arcade_stick) {
222 __x_ABI_CWindows_CGaming_CInput_CIArcadeStick_Release(arcade_stick);
223 }
else if (wgi.flight_stick_statics &&
SUCCEEDED(__x_ABI_CWindows_CGaming_CInput_CIFlightStickStatics_FromGameController(wgi.flight_stick_statics,
gamecontroller, &flight_stick)) && flight_stick) {
225 __x_ABI_CWindows_CGaming_CInput_CIFlightStick_Release(flight_stick);
226 }
else if (wgi.racing_wheel_statics2 &&
SUCCEEDED(__x_ABI_CWindows_CGaming_CInput_CIRacingWheelStatics2_FromGameController(wgi.racing_wheel_statics2,
gamecontroller, &racing_wheel)) && racing_wheel) {
228 __x_ABI_CWindows_CGaming_CInput_CIRacingWheel_Release(racing_wheel);
230 __x_ABI_CWindows_CGaming_CInput_CIGameController_Release(
gamecontroller);
247 #ifdef SDL_JOYSTICK_HIDAPI
253 #ifdef SDL_JOYSTICK_RAWINPUT
263 if (!ignore_joystick && SDL_IsXInputDevice(vendor, product)) {
271 if (ignore_joystick) {
275 WindowsGamingInputControllerState *
controllers =
SDL_realloc(wgi.controllers,
sizeof(wgi.controllers[0]) * (wgi.controller_count + 1));
277 WindowsGamingInputControllerState *
state = &
controllers[wgi.controller_count];
281 state->instance_id = joystickID;
282 state->controller = controller;
287 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_ButtonCount(controller, &
state->nbuttons);
288 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_AxisCount(controller, &
state->naxes);
289 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_SwitchCount(controller, &
state->nhats);
291 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_AddRef(controller);
293 ++wgi.controller_count;
300 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_Release(controller);
305 static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeRemoved(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIRawGameController *
e)
308 __x_ABI_CWindows_CGaming_CInput_CIRawGameController *controller =
NULL;
310 hr = IUnknown_QueryInterface((IUnknown *)
e, &IID_IRawGameController, (
void **)&controller);
314 for (
i = 0;
i < wgi.controller_count ;
i++) {
315 if (wgi.controllers[
i].controller == controller) {
316 WindowsGamingInputControllerState *
state = &wgi.controllers[
i];
319 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_Release(
state->controller);
323 --wgi.controller_count;
324 if (
i < wgi.controller_count) {
325 SDL_memmove(&wgi.controllers[
i], &wgi.controllers[
i + 1], (wgi.controller_count -
i) *
sizeof(wgi.controllers[
i]));
333 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_Release(controller);
338 static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameControllerVtbl controller_added_vtbl = {
339 IEventHandler_CRawGameControllerVtbl_QueryInterface,
340 IEventHandler_CRawGameControllerVtbl_AddRef,
341 IEventHandler_CRawGameControllerVtbl_Release,
342 IEventHandler_CRawGameControllerVtbl_InvokeAdded
344 static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameController controller_added = {
345 &controller_added_vtbl
348 static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameControllerVtbl controller_removed_vtbl = {
349 IEventHandler_CRawGameControllerVtbl_QueryInterface,
350 IEventHandler_CRawGameControllerVtbl_AddRef,
351 IEventHandler_CRawGameControllerVtbl_Release,
352 IEventHandler_CRawGameControllerVtbl_InvokeRemoved
354 static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameController controller_removed = {
355 &controller_removed_vtbl
359 WGI_JoystickInit(
void)
366 HMODULE hModule = LoadLibraryA(
"combase.dll");
367 if (hModule !=
NULL) {
368 typedef HRESULT (WINAPI *WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32
length, HSTRING_HEADER *hstringHeader, HSTRING*
string);
369 typedef HRESULT (WINAPI *WindowsDeleteString_t)(HSTRING
string);
370 typedef HRESULT (WINAPI *RoGetActivationFactory_t)(HSTRING activatableClassId, REFIID iid,
void**
factory);
372 WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = (WindowsCreateStringReference_t)GetProcAddress(hModule,
"WindowsCreateStringReference");
373 RoGetActivationFactory_t RoGetActivationFactoryFunc = (RoGetActivationFactory_t)GetProcAddress(hModule,
"RoGetActivationFactory");
374 if (WindowsCreateStringReferenceFunc && RoGetActivationFactoryFunc) {
376 HSTRING_HEADER hNamespaceStringHeader;
377 HSTRING hNamespaceString;
379 pNamespace = L
"Windows.Gaming.Input.RawGameController";
380 hr = WindowsCreateStringReferenceFunc(pNamespace, (UINT32)
SDL_wcslen(pNamespace), &hNamespaceStringHeader, &hNamespaceString);
382 hr = RoGetActivationFactoryFunc(hNamespaceString, &IID_IRawGameControllerStatics, &wgi.statics);
384 SDL_SetError(
"Couldn't find IRawGameControllerStatics: 0x%x", hr);
388 pNamespace = L
"Windows.Gaming.Input.ArcadeStick";
389 hr = WindowsCreateStringReferenceFunc(pNamespace, (UINT32)
SDL_wcslen(pNamespace), &hNamespaceStringHeader, &hNamespaceString);
391 hr = RoGetActivationFactoryFunc(hNamespaceString, &IID_IArcadeStickStatics, &wgi.arcade_stick_statics);
393 __x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics_QueryInterface(wgi.arcade_stick_statics, &IID_IArcadeStickStatics2, &wgi.arcade_stick_statics2);
395 SDL_SetError(
"Couldn't find IID_IArcadeStickStatics: 0x%x", hr);
399 pNamespace = L
"Windows.Gaming.Input.FlightStick";
400 hr = WindowsCreateStringReferenceFunc(pNamespace, (UINT32)
SDL_wcslen(pNamespace), &hNamespaceStringHeader, &hNamespaceString);
402 hr = RoGetActivationFactoryFunc(hNamespaceString, &IID_IFlightStickStatics, &wgi.flight_stick_statics);
404 SDL_SetError(
"Couldn't find IID_IFlightStickStatics: 0x%x", hr);
408 pNamespace = L
"Windows.Gaming.Input.Gamepad";
409 hr = WindowsCreateStringReferenceFunc(pNamespace, (UINT32)
SDL_wcslen(pNamespace), &hNamespaceStringHeader, &hNamespaceString);
411 hr = RoGetActivationFactoryFunc(hNamespaceString, &IID_IGamepadStatics, &wgi.gamepad_statics);
413 __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics_QueryInterface(wgi.gamepad_statics, &IID_IGamepadStatics2, &wgi.gamepad_statics2);
415 SDL_SetError(
"Couldn't find IGamepadStatics: 0x%x", hr);
419 pNamespace = L
"Windows.Gaming.Input.RacingWheel";
420 hr = WindowsCreateStringReferenceFunc(pNamespace, (UINT32)
SDL_wcslen(pNamespace), &hNamespaceStringHeader, &hNamespaceString);
422 hr = RoGetActivationFactoryFunc(hNamespaceString, &IID_IRacingWheelStatics, &wgi.racing_wheel_statics);
424 __x_ABI_CWindows_CGaming_CInput_CIRacingWheelStatics_QueryInterface(wgi.racing_wheel_statics, &IID_IRacingWheelStatics2, &wgi.racing_wheel_statics2);
426 SDL_SetError(
"Couldn't find IRacingWheelStatics: 0x%x", hr);
430 FreeLibrary(hModule);
434 hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_add_RawGameControllerAdded(wgi.statics, &controller_added, &wgi.controller_added_token);
436 SDL_SetError(
"add_RawGameControllerAdded() failed: 0x%x\n", hr);
439 hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_add_RawGameControllerRemoved(wgi.statics, &controller_removed, &wgi.controller_removed_token);
441 SDL_SetError(
"add_RawGameControllerRemoved() failed: 0x%x\n", hr);
449 WGI_JoystickGetCount(
void)
451 return wgi.controller_count;
455 WGI_JoystickDetect(
void)
460 WGI_JoystickGetDeviceName(
int device_index)
462 return wgi.controllers[device_index].name;
466 WGI_JoystickGetDevicePlayerIndex(
int device_index)
472 WGI_JoystickSetDevicePlayerIndex(
int device_index,
int player_index)
477 WGI_JoystickGetDeviceGUID(
int device_index)
479 return wgi.controllers[device_index].guid;
483 WGI_JoystickGetDeviceInstanceID(
int device_index)
485 return wgi.controllers[device_index].instance_id;
489 WGI_JoystickOpen(SDL_Joystick *
joystick,
int device_index)
491 WindowsGamingInputControllerState *
state = &wgi.controllers[device_index];
502 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_AddRef(hwdata->
controller);
503 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(hwdata->
controller, &IID_IGameController, (
void **)&hwdata->gamecontroller);
504 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(hwdata->
controller, &IID_IGameControllerBatteryInfo, (
void **)&hwdata->battery);
506 if (wgi.gamepad_statics2) {
507 __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics2_FromGameController(wgi.gamepad_statics2, hwdata->gamecontroller, &hwdata->gamepad);
510 if (hwdata->gamecontroller) {
511 __x_ABI_CWindows_CGaming_CInput_CIGameController_get_IsWireless(hwdata->gamecontroller, &wireless);
520 if (wireless && hwdata->battery) {
522 __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *report;
524 hr = __x_ABI_CWindows_CGaming_CInput_CIGameControllerBatteryInfo_TryGetBatteryReport(hwdata->battery, &report);
526 int full_capacity = 0, curr_capacity = 0;
527 __FIReference_1_int *full_capacityP, *curr_capacityP;
529 hr = __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_FullChargeCapacityInMilliwattHours(report, &full_capacityP);
531 __FIReference_1_int_get_Value(full_capacityP, &full_capacity);
532 __FIReference_1_int_Release(full_capacityP);
535 hr = __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_RemainingCapacityInMilliwattHours(report, &curr_capacityP);
537 __FIReference_1_int_get_Value(curr_capacityP, &curr_capacity);
538 __FIReference_1_int_Release(curr_capacityP);
541 if (full_capacity > 0) {
542 float ratio = (float)curr_capacity / full_capacity;
544 if (ratio <= 0.05f) {
546 }
else if (ratio <= 0.20f) {
548 }
else if (ratio <= 0.70f) {
554 __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_Release(report);
561 WGI_JoystickRumble(SDL_Joystick *
joystick,
Uint16 low_frequency_rumble,
Uint16 high_frequency_rumble)
565 if (hwdata->gamepad) {
568 hwdata->vibration.LeftMotor = (DOUBLE)low_frequency_rumble /
SDL_MAX_UINT16;
569 hwdata->vibration.RightMotor = (DOUBLE)high_frequency_rumble /
SDL_MAX_UINT16;
570 hr = __x_ABI_CWindows_CGaming_CInput_CIGamepad_put_Vibration(hwdata->gamepad, hwdata->vibration);
574 return SDL_SetError(
"Setting vibration failed: 0x%x\n", hr);
586 if (hwdata->gamepad) {
589 hwdata->vibration.LeftTrigger = (DOUBLE)left_rumble /
SDL_MAX_UINT16;
590 hwdata->vibration.RightTrigger = (DOUBLE)right_rumble /
SDL_MAX_UINT16;
591 hr = __x_ABI_CWindows_CGaming_CInput_CIGamepad_put_Vibration(hwdata->gamepad, hwdata->vibration);
595 return SDL_SetError(
"Setting vibration failed: 0x%x\n", hr);
603 WGI_JoystickHasLED(SDL_Joystick *
joystick)
621 ConvertHatValue(__x_ABI_CWindows_CGaming_CInput_CGameControllerSwitchPosition
value)
624 case GameControllerSwitchPosition_Up:
626 case GameControllerSwitchPosition_UpRight:
628 case GameControllerSwitchPosition_Right:
630 case GameControllerSwitchPosition_DownRight:
632 case GameControllerSwitchPosition_Down:
634 case GameControllerSwitchPosition_DownLeft:
636 case GameControllerSwitchPosition_Left:
638 case GameControllerSwitchPosition_UpLeft:
646 WGI_JoystickUpdate(SDL_Joystick *
joystick)
653 __x_ABI_CWindows_CGaming_CInput_CGameControllerSwitchPosition *
hats =
SDL_stack_alloc(__x_ABI_CWindows_CGaming_CInput_CGameControllerSwitchPosition,
nhats);
659 if (
SUCCEEDED(hr) && timestamp != hwdata->timestamp) {
671 hwdata->timestamp = timestamp;
680 WGI_JoystickClose(SDL_Joystick *
joystick)
686 __x_ABI_CWindows_CGaming_CInput_CIRawGameController_Release(hwdata->
controller);
688 if (hwdata->gamecontroller) {
689 __x_ABI_CWindows_CGaming_CInput_CIGameController_Release(hwdata->gamecontroller);
691 if (hwdata->battery) {
692 __x_ABI_CWindows_CGaming_CInput_CIGameControllerBatteryInfo_Release(hwdata->battery);
694 if (hwdata->gamepad) {
695 __x_ABI_CWindows_CGaming_CInput_CIGamepad_Release(hwdata->gamepad);
703 WGI_JoystickQuit(
void)
706 while (wgi.controller_count > 0) {
707 IEventHandler_CRawGameControllerVtbl_InvokeRemoved(&controller_removed,
NULL, (__x_ABI_CWindows_CGaming_CInput_CIRawGameController *)wgi.controllers[wgi.controller_count - 1].controller);
709 if (wgi.controllers) {
713 if (wgi.arcade_stick_statics) {
714 __x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics_Release(wgi.arcade_stick_statics);
716 if (wgi.arcade_stick_statics2) {
717 __x_ABI_CWindows_CGaming_CInput_CIArcadeStickStatics2_Release(wgi.arcade_stick_statics2);
719 if (wgi.flight_stick_statics) {
720 __x_ABI_CWindows_CGaming_CInput_CIFlightStickStatics_Release(wgi.flight_stick_statics);
722 if (wgi.gamepad_statics) {
723 __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics_Release(wgi.gamepad_statics);
725 if (wgi.gamepad_statics2) {
726 __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics2_Release(wgi.gamepad_statics2);
728 if (wgi.racing_wheel_statics) {
729 __x_ABI_CWindows_CGaming_CInput_CIRacingWheelStatics_Release(wgi.racing_wheel_statics);
731 if (wgi.racing_wheel_statics2) {
732 __x_ABI_CWindows_CGaming_CInput_CIRacingWheelStatics2_Release(wgi.racing_wheel_statics2);
735 __x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_remove_RawGameControllerAdded(wgi.statics, wgi.controller_added_token);
736 __x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_remove_RawGameControllerRemoved(wgi.statics, wgi.controller_removed_token);
737 __x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_Release(wgi.statics);
753 WGI_JoystickGetCount,
755 WGI_JoystickGetDeviceName,
756 WGI_JoystickGetDevicePlayerIndex,
757 WGI_JoystickSetDevicePlayerIndex,
758 WGI_JoystickGetDeviceGUID,
759 WGI_JoystickGetDeviceInstanceID,
762 WGI_JoystickRumbleTriggers,
765 WGI_JoystickSetSensorsEnabled,
769 WGI_JoystickGetGamepadMapping
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 * e
#define SDL_OutOfMemory()
#define SDL_Unsupported()
SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance)
int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid)
void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance)
SDL_JoystickID SDL_GetNextJoystickInstanceID()
int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
@ SDL_JOYSTICK_TYPE_UNKNOWN
@ SDL_JOYSTICK_TYPE_ARCADE_STICK
@ SDL_JOYSTICK_TYPE_WHEEL
@ SDL_JOYSTICK_TYPE_FLIGHT_STICK
@ SDL_JOYSTICK_TYPE_GAMECONTROLLER
@ SDL_JOYSTICK_POWER_FULL
@ SDL_JOYSTICK_POWER_MEDIUM
@ SDL_JOYSTICK_POWER_EMPTY
@ SDL_JOYSTICK_POWER_UNKNOWN
@ SDL_JOYSTICK_POWER_WIRED
#define SDL_HAT_RIGHTDOWN
GLuint GLuint GLsizei GLenum type
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLuint const GLchar * name
GLuint GLsizei GLsizei * length
GLsizei const GLfloat * value
GLsizei const GLchar *const * string
#define SDL_arraysize(array)
#define SDL_stack_alloc(type, count)
#define SDL_MAX_UINT16
An unsigned 16-bit integer type.
#define SDL_stack_free(data)
SDL_JoystickDriver SDL_WGI_JoystickDriver
#define SDL_HARDWARE_BUS_USB
HRESULT WIN_CoInitialize(void)
void WIN_CoUninitialize(void)
BOOL WIN_IsEqualIID(REFIID a, REFIID b)
#define WIN_StringToUTF8(S)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
GCController __unsafe_unretained * controller
SDL_GameController * gamecontroller
static SDL_Joystick * joystick
static NativeWindowFactory * factory