From b68ed397a372971bbe11fde4f0354af215557102 Mon Sep 17 00:00:00 2001 From: araghon007 Date: Wed, 10 Apr 2019 17:02:53 +0200 Subject: [PATCH] Added check for Windows version before initialization. --- .../Private/WindowsGamingInputBPLibrary.cpp | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Source/WindowsGamingInput/Private/WindowsGamingInputBPLibrary.cpp b/Source/WindowsGamingInput/Private/WindowsGamingInputBPLibrary.cpp index 04052bd..902422d 100644 --- a/Source/WindowsGamingInput/Private/WindowsGamingInputBPLibrary.cpp +++ b/Source/WindowsGamingInput/Private/WindowsGamingInputBPLibrary.cpp @@ -282,11 +282,24 @@ BOOL CALLBACK InitHandleFunction( #pragma endregion +bool CompatibilityCheck() { + OSVERSIONINFOEX info; + ZeroMemory(&info, sizeof(OSVERSIONINFOEX)); + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + GetVersionEx((LPOSVERSIONINFO)& info); + + if (info.dwMajorVersion >= 10) { + return true; + } + else { + return false; + } +} + UWindowsGamingInputBPLibrary::UWindowsGamingInputBPLibrary(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { - - InitializeGamepad(); + if (CompatibilityCheck()) InitializeGamepad(); } bool UWindowsGamingInputBPLibrary::ApplyVibration(int ControllerIndex, float LeftTrigger, float RightTrigger, float LeftMotor, float RightMotor) @@ -306,17 +319,6 @@ bool UWindowsGamingInputBPLibrary::ApplyVibration(int ControllerIndex, float Lef } bool UWindowsGamingInputBPLibrary::Compatibility() { - OSVERSIONINFOEX info; - ZeroMemory(&info, sizeof(OSVERSIONINFOEX)); - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - GetVersionEx((LPOSVERSIONINFO)& info); - - if (info.dwMajorVersion >= 10) { - return true; - } - else { - return false; - } + return CompatibilityCheck(); } -