Merge pull request #1804 from pcca-matrix/master

Fix N-rage X-Input Controller
This commit is contained in:
zilmar 2020-06-14 19:41:23 +09:30 committed by GitHub
commit 3fe612096c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View File

@ -409,7 +409,7 @@ EXPORT void CALL InitiateControllers(
if (g_pcControllers[i].fXInput) if (g_pcControllers[i].fXInput)
{ {
InitiateXInputController(&g_pcControllers[i].xiController, i); InitiateXInputController(&g_pcControllers[i].xiController, i);
continue; //continue;
} }
// Search for right Controller // Search for right Controller
@ -923,7 +923,7 @@ void FillControls(CONTROL * Controls)
{ {
case PAK_MEM: case PAK_MEM:
Controls[i].Plugin = PLUGIN_MEMPAK; Controls[i].Plugin = PLUGIN_MEMPAK;
Controls[i].RawData = false; //Controls[i].RawData = false;
break; break;
case PAK_RUMBLE: case PAK_RUMBLE:
Controls[i].Plugin = PLUGIN_RUMBLE_PAK; Controls[i].Plugin = PLUGIN_RUMBLE_PAK;
@ -1053,7 +1053,7 @@ void DoShortcut( int iControl, int iShortcut )
{ {
EnterCriticalSection( &g_critical ); EnterCriticalSection( &g_critical );
g_pcControllers[iControl].PakType = PAK_RUMBLE; g_pcControllers[iControl].PakType = PAK_RUMBLE;
g_pcControllers[iControl].fPakInitialized = false; g_pcControllers[iControl].fPakInitialized = true;
if( g_pcControllers[iControl].fRawData ) if( g_pcControllers[iControl].fRawData )
if (CreateEffectHandle( iControl, g_pcControllers[iControl].bRumbleTyp, g_pcControllers[iControl].bRumbleStrength ) ) if (CreateEffectHandle( iControl, g_pcControllers[iControl].bRumbleTyp, g_pcControllers[iControl].bRumbleStrength ) )

View File

@ -155,6 +155,8 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER
unsigned bBackgroundInput; // allow input while main window isn't focused? unsigned bBackgroundInput; // allow input while main window isn't focused?
unsigned XcheckTime; // checks for newly connected gamepads timer
BYTE bRumbleTyp; // what type of rumble effect? none, constant, ramp, or direct? BYTE bRumbleTyp; // what type of rumble effect? none, constant, ramp, or direct?
GUID guidFFDevice; // GUID of the device that rumble gets sent to GUID guidFFDevice; // GUID of the device that rumble gets sent to

View File

@ -178,13 +178,21 @@ void GetXInputControllerKeys( const int indexController, LPDWORD Keys )
if ( !gController->bConfigured ) if ( !gController->bConfigured )
return; return;
ULONGLONG time = GetTickCount() / 1000;
if (g_pcControllers[indexController].XcheckTime != NULL && (time - g_pcControllers[indexController].XcheckTime) < 3)
return;
DWORD result; DWORD result;
XINPUT_STATE state; XINPUT_STATE state;
result = fnXInputGetState(gController->nControl, &state); result = fnXInputGetState(gController->nControl, &state);
if( result != ERROR_SUCCESS ) if (result == ERROR_DEVICE_NOT_CONNECTED) {
return; g_pcControllers[indexController].XcheckTime = time;
}
else {
g_pcControllers[indexController].XcheckTime = NULL;
}
DWORD wButtons = state.Gamepad.wButtons; DWORD wButtons = state.Gamepad.wButtons;