From f25e86792d60bc4d1c4864b2cf5fd40ea6dd35be Mon Sep 17 00:00:00 2001 From: pcca-matrix Date: Fri, 14 Feb 2025 14:54:23 +0100 Subject: [PATCH] Fix: NRage plugin gets stuck in initialization in certain cases The function wscanf was incorrectly used to parse VID_ and PID_ values from a string, causing failures in device detection. wscanf expects input from stdin, whereas in this case, the device ID string is stored in memory. Using swscanf ensures correct parsing from memory instead of waiting for stdin This fixes the issue where XInput devices not being detected properly at plugin init. --- Source/nragev20/XInputController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/nragev20/XInputController.cpp b/Source/nragev20/XInputController.cpp index b14418a74..52b1bf3f1 100644 --- a/Source/nragev20/XInputController.cpp +++ b/Source/nragev20/XInputController.cpp @@ -105,10 +105,10 @@ BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput ) // If it does, then get the VID/PID from var.bstrVal DWORD dwPid = 0, dwVid = 0; WCHAR* strVid = wcsstr( var.bstrVal, L"VID_" ); - if (strVid && wscanf(strVid, L"VID_%4X", &dwVid) != 1) + if (strVid && swscanf(strVid, L"VID_%4X", &dwVid) != 1) dwVid = 0; WCHAR* strPid = wcsstr( var.bstrVal, L"PID_" ); - if (strPid && wscanf(strPid, L"PID_%4X", &dwPid) != 1) + if (strPid && swscanf(strPid, L"PID_%4X", &dwPid) != 1) dwPid = 0; // Compare the VID/PID to the DInput device