Skip to content

Commit

Permalink
Fix Random input in N-Rage Plugin (#1876)
Browse files Browse the repository at this point in the history
This should fix the issue.
  • Loading branch information
pcca-matrix committed Apr 29, 2021
1 parent d4ec1f7 commit 7616a26
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Source/nragev20/XInputController.cpp
Expand Up @@ -163,11 +163,12 @@ void AxisDeadzone( SHORT &AxisValue, long lDeadZoneValue, float fDeadZoneRelati

void GetXInputControllerKeys( const int indexController, LPDWORD Keys )
{
if (fnXInputGetState == NULL)

if (fnXInputGetState == NULL)
{
return;
}

using namespace N64_BUTTONS;

LPCONTROLLER pcController = &g_pcControllers[indexController];
Expand All @@ -178,22 +179,25 @@ void GetXInputControllerKeys( const int indexController, LPDWORD Keys )
if ( !gController->bConfigured )
return;

ULONGLONG time = GetTickCount() / 1000;
if (g_pcControllers[indexController].XcheckTime != NULL && (time - g_pcControllers[indexController].XcheckTime) < 3)
return;

DWORD result;
XINPUT_STATE state;

ULONGLONG time = GetTickCount() / 1000;
if (g_pcControllers[indexController].XcheckTime != NULL && (time - g_pcControllers[indexController].XcheckTime) < 3)
return;

result = fnXInputGetState(gController->nControl, &state);

if (result == ERROR_DEVICE_NOT_CONNECTED) {
g_pcControllers[indexController].XcheckTime = time;
}
else {
g_pcControllers[indexController].XcheckTime = NULL;
}
if (result == ERROR_DEVICE_NOT_CONNECTED) {
g_pcControllers[indexController].XcheckTime = time;
}
else {
g_pcControllers[indexController].XcheckTime = NULL;
}

if( result != ERROR_SUCCESS )
return;

DWORD wButtons = state.Gamepad.wButtons;

if( pcController->bPadDeadZone > 0 )
Expand Down

0 comments on commit 7616a26

Please sign in to comment.