44#include < algorithm>
55
66#include " Common/System/NativeApp.h"
7- #include " Core/Config.h"
87#include " Common/CommonWindows.h"
98#include " Common/Log.h"
9+ #include " Common/StringUtils.h"
1010#include " Common/TimeUtil.h"
1111#include " Common/Input/InputState.h"
1212#include " Common/Input/KeyCodes.h"
1313#include " XinputDevice.h"
14+ #include " Core/Config.h"
1415#include " Core/Core.h"
1516#include " Core/KeyMap.h"
1617#include " Core/HLE/sceCtrl.h"
@@ -21,11 +22,21 @@ static double newVibrationTime = 0.0;
2122
2223#if !PPSSPP_PLATFORM(UWP)
2324
25+ struct XINPUT_CAPABILITIES_EX {
26+ XINPUT_CAPABILITIES Capabilities;
27+ WORD vendorId;
28+ WORD productId;
29+ WORD revisionId;
30+ DWORD a4; // unknown
31+ };
32+
2433typedef DWORD (WINAPI *XInputGetState_t) (DWORD dwUserIndex, XINPUT_STATE* pState);
2534typedef DWORD (WINAPI *XInputSetState_t) (DWORD dwUserIndex, XINPUT_VIBRATION* pVibration);
35+ typedef DWORD (WINAPI *XInputGetCapabilitiesEx_t) (DWORD unknown, DWORD dwUserIndex, DWORD flags, XINPUT_CAPABILITIES_EX *pCapabilities);
2636
2737static XInputGetState_t PPSSPP_XInputGetState = nullptr ;
2838static XInputSetState_t PPSSPP_XInputSetState = nullptr ;
39+ static XInputGetCapabilitiesEx_t PPSSPP_XInputGetCapabilitiesEx = nullptr ;
2940static DWORD PPSSPP_XInputVersion = 0 ;
3041static HMODULE s_pXInputDLL = 0 ;
3142static int s_XInputDLLRefCount = 0 ;
@@ -83,6 +94,10 @@ static int LoadXInputDLL() {
8394 return -1 ;
8495 }
8596
97+ if (PPSSPP_XInputVersion >= ((1 << 16 ) | 4 )) {
98+ PPSSPP_XInputGetCapabilitiesEx = (XInputGetCapabilitiesEx_t)GetProcAddress ((HMODULE)s_pXInputDLL, (LPCSTR)108 );
99+ }
100+
86101 return 0 ;
87102}
88103
@@ -187,10 +202,15 @@ int XinputDevice::UpdateState() {
187202}
188203
189204void XinputDevice::UpdatePad (int pad, const XINPUT_STATE &state, XINPUT_VIBRATION &vibration) {
190- static bool notified = false ;
191- if (!notified) {
192- notified = true ;
193- KeyMap::NotifyPadConnected (" Xbox 360 Pad" );
205+ static bool notified[XUSER_MAX_COUNT]{};
206+ if (!notified[pad]) {
207+ notified[pad] = true ;
208+ XINPUT_CAPABILITIES_EX caps;
209+ if (PPSSPP_XInputGetCapabilitiesEx != nullptr && PPSSPP_XInputGetCapabilitiesEx (1 , pad, 0 , &caps) == ERROR_SUCCESS) {
210+ KeyMap::NotifyPadConnected (DEVICE_ID_XINPUT_0 + pad, StringFromFormat (" Xbox 360 Pad: %d/%d" , caps.vendorId , caps.productId ));
211+ } else {
212+ KeyMap::NotifyPadConnected (DEVICE_ID_XINPUT_0 + pad, " Xbox 360 Pad" );
213+ }
194214 }
195215 ApplyButtons (pad, state);
196216 ApplyVibration (pad, vibration);
0 commit comments