Overview
Comment: | OHXInputExtendedGamepad -> OHXbox360Gamepad |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
318e342850e74af8016bc5ee31000f4c |
User & Date: | js on 2024-06-16 21:54:59 |
Other Links: | manifest | tags |
Context
2024-06-17
| ||
00:37 | ObjFWHID: Make profiles implementation independent check-in: ddaa4f35d0 user: js tags: trunk | |
2024-06-16
| ||
21:54 | OHXInputExtendedGamepad -> OHXbox360Gamepad check-in: 318e342850 user: js tags: trunk | |
20:52 | ObjFWHID: Move Wiimote profile to separate files check-in: be1b426a45 user: js tags: trunk | |
Changes
Modified src/hid/Makefile from [7120998aed] to [761e5efb16].
︙ | ︙ | |||
33 34 35 36 37 38 39 | OHNintendoDSGameController.m SRCS_NINTENDO_SWITCH = OHNintendoSwitchExtendedGamepad.m \ OHNintendoSwitchGameController.m SRCS_WII = OHWiiClassicController.m \ OHWiiGameController.m \ OHWiimote.m \ OHWiimoteWithNunchuk.m | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | OHNintendoDSGameController.m SRCS_NINTENDO_SWITCH = OHNintendoSwitchExtendedGamepad.m \ OHNintendoSwitchGameController.m SRCS_WII = OHWiiClassicController.m \ OHWiiGameController.m \ OHWiimote.m \ OHWiimoteWithNunchuk.m SRCS_XINPUT = OHXbox360Gamepad.m \ OHXInputGameController.m INCLUDES := ${SRCS:.m=.h} \ OHExtendedGamepad.h \ OHGameControllerProfile.h \ OHGamepad.h \ ObjFWHID.h |
︙ | ︙ |
Modified src/hid/OHXInputGameController.h from [2ab30cd6c3] to [2116ecadbe].
︙ | ︙ | |||
19 20 21 22 23 24 25 | #import "OHGameController.h" #include <windows.h> OF_ASSUME_NONNULL_BEGIN | | | < < < < < < < < | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #import "OHGameController.h" #include <windows.h> OF_ASSUME_NONNULL_BEGIN @class OHXbox360Gamepad; @interface OHXInputGameController: OHGameController { DWORD _index; OFNumber *_Nullable _vendorID, *_Nullable _productID; OHXbox360Gamepad *_extendedGamepad; } - (instancetype)initWithIndex: (DWORD)index; @end OF_ASSUME_NONNULL_END |
Modified src/hid/OHXInputGameController.m from [cf9b9c985f] to [ee160f8921].
︙ | ︙ | |||
22 23 24 25 26 27 28 | #import "OHXInputGameController.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFNumber.h" #import "OHGameControllerAxis.h" #import "OHGameControllerButton.h" #import "OHGameControllerDirectionalPad.h" | | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #import "OHXInputGameController.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFNumber.h" #import "OHGameControllerAxis.h" #import "OHGameControllerButton.h" #import "OHGameControllerDirectionalPad.h" #import "OHXbox360Gamepad.h" #import "OFInitializationFailedException.h" #import "OFReadFailedException.h" #include <xinput.h> #ifndef XINPUT_GAMEPAD_GUIDE # define XINPUT_GAMEPAD_GUIDE 0x400 #endif struct XInputCapabilitiesEx { XINPUT_CAPABILITIES capabilities; WORD vendorID; WORD productID; WORD versionNumber; WORD unknown1; DWORD unknown2; }; static int XInputVersion; static WINAPI DWORD (*XInputGetStateFuncPtr)(DWORD, XINPUT_STATE *); static WINAPI DWORD (*XInputGetCapabilitiesExFuncPtr)(DWORD, DWORD, DWORD, struct XInputCapabilitiesEx *); @implementation OHXInputGameController @synthesize vendorID = _vendorID, productID = _productID; @synthesize extendedGamepad = _extendedGamepad; |
︙ | ︙ | |||
65 66 67 68 69 70 71 | 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); | | | | | 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 | 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); XInputVersion = 14; } else if ((module = LoadLibrary("xinput1_3.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, (LPCSTR)100); XInputVersion = 13; } else if ((module = LoadLibrary("xinput9_1_0.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, "XInputGetState"); XInputVersion = 910; } } + (OFArray OF_GENERIC(OHGameController *) *)controllers { OFMutableArray *controllers = [OFMutableArray array]; |
︙ | ︙ | |||
137 138 139 140 141 142 143 | capabilities.vendorID]; _productID = [[OFNumber alloc] initWithUnsignedShort: capabilities.productID]; } } | | > | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | capabilities.vendorID]; _productID = [[OFNumber alloc] initWithUnsignedShort: capabilities.productID]; } } _extendedGamepad = [[OHXbox360Gamepad alloc] initWithHasGuideButton: (XInputVersion != 910)]; [self retrieveState]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
186 187 188 189 190 191 192 | !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB); _extendedGamepad.rightThumbstickButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB); _extendedGamepad.menuButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_START); _extendedGamepad.optionsButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK); | | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB); _extendedGamepad.rightThumbstickButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB); _extendedGamepad.menuButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_START); _extendedGamepad.optionsButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK); if (XInputVersion != 910) _extendedGamepad.homeButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_GUIDE); _extendedGamepad.leftTriggerButton.value = (float)state.Gamepad.bLeftTrigger / 255; _extendedGamepad.rightTriggerButton.value = (float)state.Gamepad.bRightTrigger / 255; |
︙ | ︙ | |||
220 221 222 223 224 225 226 | !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT); _extendedGamepad.dPad.right.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT); } - (OFString *)name { | | | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT); _extendedGamepad.dPad.right.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT); } - (OFString *)name { switch (XInputVersion) { case 14: return @"XInput 1.4 device"; case 13: return @"XInput 1.3 device"; case 910: return @"XInput 9.1.0 device"; } |
︙ | ︙ |
Renamed and modified src/hid/OHXInputExtendedGamepad.h [0e601afe16] to src/hid/OHXbox360Gamepad.h [8f67ee8fff].
︙ | ︙ | |||
17 18 19 20 21 22 23 | * <https://www.gnu.org/licenses/>. */ #import "OHExtendedGamepad.h" OF_ASSUME_NONNULL_BEGIN | | > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | * <https://www.gnu.org/licenses/>. */ #import "OHExtendedGamepad.h" OF_ASSUME_NONNULL_BEGIN @interface OHXbox360Gamepad: OFObject <OHExtendedGamepad> { OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *_buttons; OFDictionary OF_GENERIC(OFString *, OHGameControllerDirectionalPad *) *_directionalPads; } - (instancetype)initWithHasGuideButton: (bool)hasGuideButton; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/hid/OHXInputExtendedGamepad.m [c47a92c25d] to src/hid/OHXbox360Gamepad.m [f7be1c6812].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" | | < | > > > > > | | 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 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 | * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OHXbox360Gamepad.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); @implementation OHXbox360Gamepad @synthesize buttons = _buttons, directionalPads = _directionalPads; - (instancetype)init { return [self initWithHasGuideButton: true]; } - (instancetype)initWithHasGuideButton: (bool)hasGuideButton { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFMutableDictionary *buttons = [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"] && !hasGuideButton) continue; button = [[OHGameControllerButton alloc] initWithName: buttonNames[i]]; [buttons setObject: button forKey: buttonNames[i]]; } [buttons makeImmutable]; |
︙ | ︙ |