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)
{
InitiateXInputController(&g_pcControllers[i].xiController, i);
continue;
//continue;
}
// Search for right Controller
@ -923,7 +923,7 @@ void FillControls(CONTROL * Controls)
{
case PAK_MEM:
Controls[i].Plugin = PLUGIN_MEMPAK;
Controls[i].RawData = false;
//Controls[i].RawData = false;
break;
case PAK_RUMBLE:
Controls[i].Plugin = PLUGIN_RUMBLE_PAK;
@ -1053,7 +1053,7 @@ void DoShortcut( int iControl, int iShortcut )
{
EnterCriticalSection( &g_critical );
g_pcControllers[iControl].PakType = PAK_RUMBLE;
g_pcControllers[iControl].fPakInitialized = false;
g_pcControllers[iControl].fPakInitialized = true;
if( g_pcControllers[iControl].fRawData )
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 XcheckTime; // checks for newly connected gamepads timer
BYTE bRumbleTyp; // what type of rumble effect? none, constant, ramp, or direct?
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 )
return;
ULONGLONG time = GetTickCount() / 1000;
if (g_pcControllers[indexController].XcheckTime != NULL && (time - g_pcControllers[indexController].XcheckTime) < 3)
return;
DWORD result;
XINPUT_STATE state;
result = fnXInputGetState(gController->nControl, &state);
if( result != ERROR_SUCCESS )
return;
if (result == ERROR_DEVICE_NOT_CONNECTED) {
g_pcControllers[indexController].XcheckTime = time;
}
else {
g_pcControllers[indexController].XcheckTime = NULL;
}
DWORD wButtons = state.Gamepad.wButtons;