Index: src/hid/OHXInputGameController.h ================================================================== --- src/hid/OHXInputGameController.h +++ src/hid/OHXInputGameController.h @@ -32,8 +32,16 @@ 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 Index: src/hid/OHXInputGameController.m ================================================================== --- src/hid/OHXInputGameController.m +++ src/hid/OHXInputGameController.m @@ -44,14 +44,14 @@ WORD versionNumber; WORD unknown1; DWORD unknown2; }; +int OHXInputVersion; static WINAPI DWORD (*XInputGetStateFuncPtr)(DWORD, XINPUT_STATE *); static WINAPI DWORD (*XInputGetCapabilitiesExFuncPtr)(DWORD, DWORD, DWORD, struct XInputCapabilitiesEx *); -static int XInputVersion; @implementation OHXInputGameController @synthesize vendorID = _vendorID, productID = _productID, gamepad = _gamepad; + (void)initialize @@ -66,21 +66,21 @@ (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, (LPCSTR)100); XInputGetCapabilitiesExFuncPtr = (WINAPI DWORD (*)(DWORD, DWORD, DWORD, struct XInputCapabilitiesEx *)) GetProcAddress(module, (LPCSTR)108); - XInputVersion = 14; + OHXInputVersion = 14; } else if ((module = LoadLibrary("xinput1_3.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, (LPCSTR)100); - XInputVersion = 13; + OHXInputVersion = 13; } else if ((module = LoadLibrary("xinput9_1_0.dll")) != NULL) { XInputGetStateFuncPtr = (WINAPI DWORD (*)(DWORD, XINPUT_STATE *)) GetProcAddress(module, "XInputGetState"); - XInputVersion = 910; + OHXInputVersion = 910; } } + (OFArray OF_GENERIC(OHGameController *) *)controllers { @@ -187,11 +187,11 @@ !!(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 (XInputVersion != 910) + if (OHXInputVersion != 910) _gamepad.homeButton.value = !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_GUIDE); _gamepad.leftTriggerButton.value = (float)state.Gamepad.bLeftTrigger / 255; @@ -221,11 +221,11 @@ !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT); } - (OFString *)name { - switch (XInputVersion) { + switch (OHXInputVersion) { case 14: return @"XInput 1.4 device"; case 13: return @"XInput 1.3 device"; case 910: Index: src/hid/OHXInputGamepad.m ================================================================== --- src/hid/OHXInputGamepad.m +++ src/hid/OHXInputGamepad.m @@ -22,10 +22,11 @@ #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" }; @@ -44,14 +45,18 @@ OHGameControllerAxis *xAxis, *yAxis; OHGameControllerDirectionalPad *directionalPad; OHGameControllerButton *up, *down, *left, *right; for (size_t i = 0; i < numButtons; i++) { - OHGameControllerButton *button = - [[OHGameControllerButton alloc] - initWithName: buttonNames[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];