Overview
Comment: | OFGameController: Try all XInput versions |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | gamecontroller |
Files: | files | file ages | folders |
SHA3-256: |
6032aeea5516c24f34bf1f0c2b13d80e |
User & Date: | js on 2024-05-14 20:56:07 |
Other Links: | branch diff | manifest | tags |
Context
2024-05-14
| ||
21:27 | OFGameController: Correctly handle unknown buttons check-in: dd18e20cea user: js tags: gamecontroller | |
20:56 | OFGameController: Try all XInput versions check-in: 6032aeea55 user: js tags: gamecontroller | |
20:41 | OFGameController: Use more generic button names check-in: 2c2412d3df user: js tags: gamecontroller | |
Changes
Modified src/hid/platform/Windows/OFGameController.m from [c31f521172] to [b049972691].
︙ | ︙ | |||
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 | WORD unknown1; DWORD unknown2; }; static WINAPI DWORD (*XInputGetStateFuncPtr)(DWORD, XINPUT_STATE *); static WINAPI DWORD (*XInputGetCapabilitiesExFuncPtr)(DWORD, DWORD, DWORD, struct XInputCapabilitiesEx *); @implementation OFGameController @synthesize vendorID = _vendorID, productID = _productID; @synthesize leftAnalogStickPosition = _leftAnalogStickPosition; @synthesize rightAnalogStickPosition = _rightAnalogStickPosition; + (void)initialize { HMODULE module; if (self != [OFGameController class]) return; if ((module = LoadLibraryA("xinput1_4.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, "XInputGetState"); XInputGetCapabilitiesExFuncPtr = (WINAPI DWORD (*)(DWORD, DWORD, DWORD, struct XInputCapabilitiesEx *)) GetProcAddress(module, "XInputGetCapabilitiesEx"); } } + (OFArray OF_GENERIC(OFGameController *) *)controllers { OFMutableArray *controllers = [OFMutableArray array]; | > > > > > > > > > > > > | 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 | WORD unknown1; DWORD unknown2; }; static WINAPI DWORD (*XInputGetStateFuncPtr)(DWORD, XINPUT_STATE *); static WINAPI DWORD (*XInputGetCapabilitiesExFuncPtr)(DWORD, DWORD, DWORD, struct XInputCapabilitiesEx *); static const char *XInputVersion; @implementation OFGameController @synthesize vendorID = _vendorID, productID = _productID; @synthesize leftAnalogStickPosition = _leftAnalogStickPosition; @synthesize rightAnalogStickPosition = _rightAnalogStickPosition; + (void)initialize { HMODULE module; if (self != [OFGameController class]) return; if ((module = LoadLibraryA("xinput1_4.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, "XInputGetState"); XInputGetCapabilitiesExFuncPtr = (WINAPI DWORD (*)(DWORD, DWORD, DWORD, struct XInputCapabilitiesEx *)) GetProcAddress(module, "XInputGetCapabilitiesEx"); XInputVersion = "1.4"; } else if ((module = LoadLibraryA("xinput1_3.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, "XInputGetState"); XInputVersion = "1.3"; } else if ((module = LoadLibraryA("xinput9_1_0.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, "XInputGetState"); XInputVersion = "9.1.0"; } } + (OFArray OF_GENERIC(OFGameController *) *)controllers { OFMutableArray *controllers = [OFMutableArray array]; |
︙ | ︙ | |||
209 210 211 212 213 214 215 | (state.Gamepad.sThumbRX < 0 ? -INT16_MIN : INT16_MAX), -(float)state.Gamepad.sThumbRY / (state.Gamepad.sThumbRY < 0 ? -INT16_MIN : INT16_MAX)); } - (OFString *)name { | | | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | (state.Gamepad.sThumbRX < 0 ? -INT16_MIN : INT16_MAX), -(float)state.Gamepad.sThumbRY / (state.Gamepad.sThumbRY < 0 ? -INT16_MIN : INT16_MAX)); } - (OFString *)name { return [OFString stringWithFormat: @"XInput %s device", XInputVersion]; } - (OFSet OF_GENERIC(OFGameControllerButton) *)buttons { return [OFSet setWithObjects: OFGameControllerNorthButton, OFGameControllerSouthButton, |
︙ | ︙ |