Overview
Comment: | ObjFWHID: Ignore Guide button on XInput 9.1.0 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
256c4a696fc07baae81664ac77625ff6 |
User & Date: | js on 2024-06-08 19:36:39 |
Other Links: | manifest | tags |
Context
2024-06-08
| ||
19:38 | OHXInputGamepad: Fix missed rename check-in: 7be631239e user: js tags: trunk | |
19:36 | ObjFWHID: Ignore Guide button on XInput 9.1.0 check-in: 256c4a696f user: js tags: trunk | |
19:32 | OHGameControllerDirectionalPad: Rename methods check-in: 35e4d04158 user: js tags: trunk | |
Changes
Modified src/hid/OHXInputGameController.h from [9cb565dbba] to [2da83182e9].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 | DWORD _index; OFNumber *_Nullable _vendorID, *_Nullable _productID; OHXInputGamepad *_gamepad; } - (instancetype)oh_initWithIndex: (DWORD)index OF_METHOD_FAMILY(init); @end OF_ASSUME_NONNULL_END | > > > > > > > > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | DWORD _index; OFNumber *_Nullable _vendorID, *_Nullable _productID; OHXInputGamepad *_gamepad; } - (instancetype)oh_initWithIndex: (DWORD)index OF_METHOD_FAMILY(init); @end #ifdef __cplusplus extern "C" { #endif extern int OHXInputVersion; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/hid/OHXInputGameController.m from [4922b1a2cf] to [c422cbe7b4].
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 51 | WORD vendorID; WORD productID; WORD versionNumber; WORD unknown1; DWORD unknown2; }; static WINAPI DWORD (*XInputGetStateFuncPtr)(DWORD, XINPUT_STATE *); static WINAPI DWORD (*XInputGetCapabilitiesExFuncPtr)(DWORD, DWORD, DWORD, struct XInputCapabilitiesEx *); | > < | | | | 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 | WORD vendorID; WORD productID; WORD versionNumber; WORD unknown1; DWORD unknown2; }; int OHXInputVersion; static WINAPI DWORD (*XInputGetStateFuncPtr)(DWORD, XINPUT_STATE *); static WINAPI DWORD (*XInputGetCapabilitiesExFuncPtr)(DWORD, DWORD, DWORD, struct XInputCapabilitiesEx *); @implementation OHXInputGameController @synthesize vendorID = _vendorID, productID = _productID, gamepad = _gamepad; + (void)initialize { HMODULE module; if (self != [OHXInputGameController class]) return; if ((module = LoadLibraryA("xinput1_4.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, (LPCSTR)100); XInputGetCapabilitiesExFuncPtr = (WINAPI DWORD (*)(DWORD, DWORD, DWORD, struct XInputCapabilitiesEx *)) GetProcAddress(module, (LPCSTR)108); OHXInputVersion = 14; } else if ((module = LoadLibrary("xinput1_3.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, (LPCSTR)100); OHXInputVersion = 13; } else if ((module = LoadLibrary("xinput9_1_0.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, "XInputGetState"); OHXInputVersion = 910; } } + (OFArray OF_GENERIC(OHGameController *) *)controllers { OFMutableArray *controllers = [OFMutableArray array]; |
︙ | ︙ | |||
185 186 187 188 189 190 191 | !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB); _gamepad.rightThumbstickButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB); _gamepad.menuButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_START); _gamepad.optionsButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK); | | | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB); _gamepad.rightThumbstickButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB); _gamepad.menuButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_START); _gamepad.optionsButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK); if (OHXInputVersion != 910) _gamepad.homeButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_GUIDE); _gamepad.leftTriggerButton.value = (float)state.Gamepad.bLeftTrigger / 255; _gamepad.rightTriggerButton.value = (float)state.Gamepad.bRightTrigger / 255; |
︙ | ︙ | |||
219 220 221 222 223 224 225 | !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT); _gamepad.dPad.right.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT); } - (OFString *)name { | | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT); _gamepad.dPad.right.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT); } - (OFString *)name { switch (OHXInputVersion) { case 14: return @"XInput 1.4 device"; case 13: return @"XInput 1.3 device"; case 910: return @"XInput 9.1.0 device"; } |
︙ | ︙ |
Modified src/hid/OHXInputGamepad.m from [254b2085d9] to [3ff2d7703f].
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include "config.h" #import "OHXInputGamepad.h" #import "OFDictionary.h" #import "OHGameControllerAxis.h" #import "OHGameControllerButton.h" #import "OHGameControllerDirectionalPad.h" static OFString *const buttonNames[] = { @"A", @"B", @"X", @"Y", @"LB", @"RB", @"LT", @"RT", @"LSB", @"RSB", @"Start", @"Back", @"Guide" }; static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames); | > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include "config.h" #import "OHXInputGamepad.h" #import "OFDictionary.h" #import "OHGameControllerAxis.h" #import "OHGameControllerButton.h" #import "OHGameControllerDirectionalPad.h" #import "OHXInputGameController.h" static OFString *const buttonNames[] = { @"A", @"B", @"X", @"Y", @"LB", @"RB", @"LT", @"RT", @"LSB", @"RSB", @"Start", @"Back", @"Guide" }; static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames); |
︙ | ︙ | |||
42 43 44 45 46 47 48 | [OFMutableDictionary dictionaryWithCapacity: numButtons]; OFMutableDictionary *directionalPads; OHGameControllerAxis *xAxis, *yAxis; OHGameControllerDirectionalPad *directionalPad; OHGameControllerButton *up, *down, *left, *right; for (size_t i = 0; i < numButtons; i++) { | | > > > > > | < | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | [OFMutableDictionary dictionaryWithCapacity: numButtons]; OFMutableDictionary *directionalPads; OHGameControllerAxis *xAxis, *yAxis; OHGameControllerDirectionalPad *directionalPad; OHGameControllerButton *up, *down, *left, *right; for (size_t i = 0; i < numButtons; i++) { OHGameControllerButton *button; if ([buttonNames[i] isEqual: @"Guide"] && OHXInputVersion == 910) continue; button = [[OHGameControllerButton alloc] initWithName: buttonNames[i]]; @try { [buttons setObject: button forKey: buttonNames[i]]; } @finally { [button release]; } } |
︙ | ︙ |