From fa0f1e5a57051888c25ccb2ba2202e29b3c4e48e Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 5 Dec 2024 23:08:42 -0800 Subject: [PATCH] Remove support for XInput 9.1.0 --- Inc/GamePad.h | 4 --- Src/GamePad.cpp | 82 ++----------------------------------------------- 2 files changed, 2 insertions(+), 84 deletions(-) diff --git a/Inc/GamePad.h b/Inc/GamePad.h index 24a8770b..8d3158f8 100644 --- a/Inc/GamePad.h +++ b/Inc/GamePad.h @@ -43,11 +43,7 @@ #elif defined(USING_XINPUT) #ifdef _MSC_VER -#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/ ) #pragma comment(lib,"xinput.lib") -#else -#pragma comment(lib,"xinput9_1_0.lib") -#endif #endif #endif diff --git a/Src/GamePad.cpp b/Src/GamePad.cpp index 302a6bd3..0259d8c5 100644 --- a/Src/GamePad.cpp +++ b/Src/GamePad.cpp @@ -1286,11 +1286,6 @@ class GamePad::Impl mOwner(owner), mConnected{}, mLastReadTime{} - #if (_WIN32_WINNT < _WIN32_WINNT_WIN8) - , mLeftMotor{} - , mRightMotor{} - , mSuspended(false) - #endif { for (int j = 0; j < XUSER_MAX_COUNT; ++j) { @@ -1319,15 +1314,6 @@ class GamePad::Impl if (!ThrottleRetry(player, time)) { - #if (_WIN32_WINNT < _WIN32_WINNT_WIN8) - if (mSuspended) - { - memset(&state, 0, sizeof(State)); - state.connected = mConnected[player]; - return; - } - #endif - XINPUT_STATE xstate; const DWORD result = XInputGetState(DWORD(player), &xstate); if (result == ERROR_DEVICE_NOT_CONNECTED) @@ -1414,7 +1400,6 @@ class GamePad::Impl if (xcaps.Type == XINPUT_DEVTYPE_GAMEPAD) { static_assert(Capabilities::GAMEPAD == XINPUT_DEVSUBTYPE_GAMEPAD, "xinput.h mismatch"); - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) static_assert(XINPUT_DEVSUBTYPE_WHEEL == Capabilities::WHEEL, "xinput.h mismatch"); static_assert(XINPUT_DEVSUBTYPE_ARCADE_STICK == Capabilities::ARCADE_STICK, "xinput.h mismatch"); #ifndef __MINGW32__ @@ -1426,19 +1411,13 @@ class GamePad::Impl static_assert(XINPUT_DEVSUBTYPE_DRUM_KIT == Capabilities::DRUM_KIT, "xinput.h mismatch"); static_assert(XINPUT_DEVSUBTYPE_GUITAR_BASS == Capabilities::GUITAR_BASS, "xinput.h mismatch"); static_assert(XINPUT_DEVSUBTYPE_ARCADE_PAD == Capabilities::ARCADE_PAD, "xinput.h mismatch"); - #endif caps.gamepadType = Capabilities::Type(xcaps.SubType); } // Hard-coded VID/PID caps.vid = 0x045E; - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) caps.pid = (xcaps.Flags & XINPUT_CAPS_WIRELESS) ? 0x0719 : 0; - #else - caps.pid = 0; - #endif - return; } } @@ -1463,14 +1442,6 @@ class GamePad::Impl UNREFERENCED_PARAMETER(leftTrigger); UNREFERENCED_PARAMETER(rightTrigger); - #if (_WIN32_WINNT < _WIN32_WINNT_WIN8) - mLeftMotor[player] = leftMotor; - mRightMotor[player] = rightMotor; - - if (mSuspended) - return mConnected[player]; - #endif - XINPUT_VIBRATION xvibration; xvibration.wLeftMotorSpeed = WORD(leftMotor * 0xFFFF); xvibration.wRightMotorSpeed = WORD(rightMotor * 0xFFFF); @@ -1494,24 +1465,8 @@ class GamePad::Impl { #if (_WIN32_WINNT >= _WIN32_WINNT_WIN10) // XInput focus is handled automatically on Windows 10 - #elif (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - XInputEnable(FALSE); #else - // For XInput 9.1.0, we have to emulate the behavior of XInputEnable( FALSE ) - if (!mSuspended) - { - for (size_t j = 0; j < XUSER_MAX_COUNT; ++j) - { - if (mConnected[j]) - { - XINPUT_VIBRATION xvibration; - xvibration.wLeftMotorSpeed = xvibration.wRightMotorSpeed = 0; - std::ignore = XInputSetState(DWORD(j), &xvibration); - } - } - - mSuspended = true; - } + XInputEnable(FALSE); #endif } @@ -1519,31 +1474,8 @@ class GamePad::Impl { #if (_WIN32_WINNT >= _WIN32_WINNT_WIN10) // XInput focus is handled automatically on Windows 10 - #elif (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - XInputEnable(TRUE); #else - // For XInput 9.1.0, we have to emulate the behavior of XInputEnable( TRUE ) - if (mSuspended) - { - const ULONGLONG time = GetTickCount64(); - - for (int j = 0; j < XUSER_MAX_COUNT; ++j) - { - if (mConnected[j]) - { - XINPUT_VIBRATION xvibration; - xvibration.wLeftMotorSpeed = WORD(mLeftMotor[j] * 0xFFFF); - xvibration.wRightMotorSpeed = WORD(mRightMotor[j] * 0xFFFF); - const DWORD result = XInputSetState(DWORD(j), &xvibration); - if (result == ERROR_DEVICE_NOT_CONNECTED) - { - ClearSlot(j, time); - } - } - } - - mSuspended = false; - } + XInputEnable(TRUE); #endif } @@ -1555,13 +1487,6 @@ class GamePad::Impl bool mConnected[XUSER_MAX_COUNT]; ULONGLONG mLastReadTime[XUSER_MAX_COUNT]; -#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) - // Variables for emulating XInputEnable on XInput 9.1.0 - float mLeftMotor[XUSER_MAX_COUNT]; - float mRightMotor[XUSER_MAX_COUNT]; - bool mSuspended; -#endif - bool ThrottleRetry(int player, ULONGLONG time) { // This function minimizes a potential performance issue with XInput on Windows when @@ -1596,9 +1521,6 @@ class GamePad::Impl { mConnected[player] = false; mLastReadTime[player] = time; - #if (_WIN32_WINNT < _WIN32_WINNT_WIN8) - mLeftMotor[player] = mRightMotor[player] = 0.f; - #endif } int GetMostRecent()