Fix savestate and rumble
* When you switch from mempak to rumble , rumble pack is never initialized. * Rumble stops working after loading a savestate. * No shortcut working when you have 4 xinput controller plugged. There is a performance hit when you check for a controller that wasn't attached last time you called it. This fix minimizes a performance issue with XInput on Windows when checking for a disconnected controller. If you get ERROR_DEVICE_NOT_CONNECTED from XInputGetState, you shouldn't call that slot for a little while.
This commit is contained in:
parent
32fe7b7672
commit
da734b552a
|
@ -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 ) )
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue