diff --git a/Audio/SoundStreamInstance.cpp b/Audio/SoundStreamInstance.cpp index 710fd686..74f64ccb 100644 --- a/Audio/SoundStreamInstance.cpp +++ b/Audio/SoundStreamInstance.cpp @@ -579,11 +579,7 @@ HRESULT SoundStreamInstance::Impl::PlayBuffers() noexcept if (mPackets[j].state == State::PENDING) { DWORD cb = 0; - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) const BOOL result = GetOverlappedResultEx(async, &mPackets[j].request, &cb, 0, FALSE); - #else - const BOOL result = GetOverlappedResult(async, &mPackets[j].request, &cb, FALSE); - #endif if (result) { mPackets[j].state = State::READY; diff --git a/Audio/WAVFileReader.cpp b/Audio/WAVFileReader.cpp index d6acd160..70e52b89 100644 --- a/Audio/WAVFileReader.cpp +++ b/Audio/WAVFileReader.cpp @@ -540,20 +540,10 @@ namespace return E_INVALIDARG; // open the file - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2( szFileName, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); - #else - ScopedHandle hFile(safe_handle(CreateFileW( - szFileName, - GENERIC_READ, FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - nullptr))); - #endif - if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); diff --git a/Audio/WaveBankReader.cpp b/Audio/WaveBankReader.cpp index 0bb4a152..95d4c45e 100644 --- a/Audio/WaveBankReader.cpp +++ b/Audio/WaveBankReader.cpp @@ -526,7 +526,6 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false) return HRESULT_FROM_WIN32(GetLastError()); } -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) CREATEFILE2_EXTENDED_PARAMETERS params = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), 0, 0, 0, {}, nullptr }; params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; params.dwFileFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN; @@ -534,15 +533,6 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false) szFileName, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, ¶ms))); -#else - ScopedHandle hFile(safe_handle(CreateFileW( - szFileName, - GENERIC_READ, FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN, - nullptr))); -#endif - if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -552,29 +542,15 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false) OVERLAPPED request = {}; request.hEvent = m_event.get(); - bool wait = false; if (!ReadFile(hFile.get(), &m_header, sizeof(m_header), nullptr, &request)) { const DWORD error = GetLastError(); if (error != ERROR_IO_PENDING) return HRESULT_FROM_WIN32(error); - wait = true; } DWORD bytes; -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - std::ignore = wait; - BOOL result = GetOverlappedResultEx(hFile.get(), &request, &bytes, INFINITE, FALSE); -#else - if (wait) - { - std::ignore = WaitForSingleObject(m_event.get(), INFINITE); - } - - BOOL result = GetOverlappedResult(hFile.get(), &request, &bytes, FALSE); -#endif - if (!result || (bytes != sizeof(m_header))) { return HRESULT_FROM_WIN32(GetLastError()); @@ -602,26 +578,14 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false) request.Offset = m_header.Segments[HEADER::SEGIDX_BANKDATA].dwOffset; request.hEvent = m_event.get(); - wait = false; if (!ReadFile(hFile.get(), &m_data, sizeof(m_data), nullptr, &request)) { const DWORD error = GetLastError(); if (error != ERROR_IO_PENDING) return HRESULT_FROM_WIN32(error); - wait = true; } -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) result = GetOverlappedResultEx(hFile.get(), &request, &bytes, INFINITE, FALSE); -#else - if (wait) - { - std::ignore = WaitForSingleObject(m_event.get(), INFINITE); - } - - result = GetOverlappedResult(hFile.get(), &request, &bytes, FALSE); -#endif - if (!result || (bytes != sizeof(m_data))) { return HRESULT_FROM_WIN32(GetLastError()); @@ -688,26 +652,14 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false) request.Offset = m_header.Segments[HEADER::SEGIDX_ENTRYNAMES].dwOffset; request.hEvent = m_event.get(); - wait = false; if (!ReadFile(hFile.get(), temp.get(), namesBytes, nullptr, &request)) { const DWORD error = GetLastError(); if (error != ERROR_IO_PENDING) return HRESULT_FROM_WIN32(error); - wait = true; } - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) result = GetOverlappedResultEx(hFile.get(), &request, &bytes, INFINITE, FALSE); - #else - if (wait) - { - std::ignore = WaitForSingleObject(m_event.get(), INFINITE); - } - - result = GetOverlappedResult(hFile.get(), &request, &bytes, FALSE); - #endif - if (!result || (namesBytes != bytes)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -741,26 +693,14 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false) request.Offset = m_header.Segments[HEADER::SEGIDX_ENTRYMETADATA].dwOffset; request.hEvent = m_event.get(); - wait = false; if (!ReadFile(hFile.get(), m_entries.get(), metadataBytes, nullptr, &request)) { const DWORD error = GetLastError(); if (error != ERROR_IO_PENDING) return HRESULT_FROM_WIN32(error); - wait = true; } -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) result = GetOverlappedResultEx(hFile.get(), &request, &bytes, INFINITE, FALSE); -#else - if (wait) - { - std::ignore = WaitForSingleObject(m_event.get(), INFINITE); - } - - result = GetOverlappedResult(hFile.get(), &request, &bytes, FALSE); -#endif - if (!result || (metadataBytes != bytes)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -794,26 +734,14 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false) request.Offset = m_header.Segments[HEADER::SEGIDX_SEEKTABLES].dwOffset; request.hEvent = m_event.get(); - wait = false; if (!ReadFile(hFile.get(), m_seekData.get(), seekLen, nullptr, &request)) { const DWORD error = GetLastError(); if (error != ERROR_IO_PENDING) return HRESULT_FROM_WIN32(error); - wait = true; } - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) result = GetOverlappedResultEx(hFile.get(), &request, &bytes, INFINITE, FALSE); - #else - if (wait) - { - std::ignore = WaitForSingleObject(m_event.get(), INFINITE); - } - - result = GetOverlappedResult(hFile.get(), &request, &bytes, FALSE); - #endif - if (!result || (seekLen != bytes)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -840,25 +768,13 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false) // If streaming, reopen without buffering hFile.reset(); - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) CREATEFILE2_EXTENDED_PARAMETERS params2 = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), 0, 0, 0, {}, nullptr }; params2.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; params2.dwFileFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING; - m_async = CreateFile2(szFileName, - GENERIC_READ, - FILE_SHARE_READ, - OPEN_EXISTING, + m_async = CreateFile2( + szFileName, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, ¶ms2); - #else - m_async = CreateFileW(szFileName, - GENERIC_READ, - FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, - nullptr); - #endif - if (m_async == INVALID_HANDLE_VALUE) { return HRESULT_FROM_WIN32(GetLastError()); @@ -942,13 +858,7 @@ void WaveBankReader::Impl::Close() noexcept if (m_request.hEvent) { DWORD bytes; - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) std::ignore = GetOverlappedResultEx(m_async, &m_request, &bytes, INFINITE, FALSE); - #else - std::ignore = WaitForSingleObject(m_request.hEvent, INFINITE); - - std::ignore = GetOverlappedResult(m_async, &m_request, &bytes, FALSE); - #endif } CloseHandle(m_async); @@ -1279,12 +1189,8 @@ bool WaveBankReader::Impl::UpdatePrepared() noexcept if (m_request.hEvent) { - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) DWORD bytes; const BOOL result = GetOverlappedResultEx(m_async, &m_request, &bytes, 0, FALSE); - #else - const bool result = HasOverlappedIoCompleted(&m_request); - #endif if (result) { m_prepared = true; diff --git a/Inc/Audio.h b/Inc/Audio.h index cf21fa51..d09f1235 100644 --- a/Inc/Audio.h +++ b/Inc/Audio.h @@ -36,10 +36,8 @@ #if defined(USING_XAUDIO2_REDIST) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/) || defined(_XBOX_ONE) #define USING_XAUDIO2_9 -#elif (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) +#elif (_WIN32_WINNT >= 0x0603 /*_WIN32_WINNT_WINBLUE*/) #define USING_XAUDIO2_8 -#elif (_WIN32_WINNT >= 0x0601 /*_WIN32_WINNT_WIN7*/) -#error Windows 7 SP1 requires the XAudio2Redist NuGet package https://aka.ms/xaudio2redist #else #error DirectX Tool Kit for Audio not supported on this platform #endif 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/BinaryReader.cpp b/Src/BinaryReader.cpp index e1cf1436..4bb53aff 100644 --- a/Src/BinaryReader.cpp +++ b/Src/BinaryReader.cpp @@ -55,20 +55,10 @@ HRESULT BinaryReader::ReadEntireFile( *dataSize = 0; // Open the file. -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2( fileName, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW( - fileName, - GENERIC_READ, FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - nullptr))); -#endif - if (!hFile) return HRESULT_FROM_WIN32(GetLastError()); 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() diff --git a/Src/LoaderHelpers.h b/Src/LoaderHelpers.h index 7c2eed9e..a402e779 100644 --- a/Src/LoaderHelpers.h +++ b/Src/LoaderHelpers.h @@ -395,20 +395,10 @@ namespace DirectX *bitSize = 0; // open the file - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2( fileName, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); - #else - ScopedHandle hFile(safe_handle(CreateFileW( - fileName, - GENERIC_READ, FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - nullptr))); - #endif - if (!hFile) { return HRESULT_FROM_WIN32(GetLastError());