Skip to content

Commit

Permalink
Fix: Some controller buttons do not work after restoring system for h…
Browse files Browse the repository at this point in the history
…ibernation #3630
  • Loading branch information
JosefNemec committed Dec 20, 2023
1 parent 413a65b commit aba112c
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions source/Playnite/Input/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -441,18 +441,43 @@ private void ProcessButtonState(byte currentState, ControllerInput button, Loade
logger.Error($"Failed to get controller button state: {SDL_GetError()}");
}

if (pressed && ShouldResendKey(button))
if (button == ControllerInput.A)
{
SendControllerInput(button, true);
controller.LastInputState[button] = ControllerInputState.Pressed;
SimulateKeyInput(MapPadToKeyboard(button), true);
logger.Debug("Button A pressed: " + pressed);
logger.Debug("Button A prev state: " + controller.LastInputState[button]);
}
else if (!pressed && controller.LastInputState[button] == ControllerInputState.Pressed)

if (IsButtonNotNavigation(button))
{
ResetButtonResend(button);
SendControllerInput(button, false);
controller.LastInputState[button] = ControllerInputState.Released;
SimulateKeyInput(MapPadToKeyboard(button), false);
var lastState = controller.LastInputState[button];
if (pressed && lastState == ControllerInputState.Released)
{
SendControllerInput(button, true);
SimulateKeyInput(MapPadToKeyboard(button), true);
}
else if (!pressed && lastState == ControllerInputState.Pressed)
{
SendControllerInput(button, false);
SimulateKeyInput(MapPadToKeyboard(button), false);
}

controller.LastInputState[button] = pressed ? ControllerInputState.Pressed : ControllerInputState.Released;
}
else
{
if (pressed && ShouldResendKey(button))
{
SendControllerInput(button, true);
controller.LastInputState[button] = ControllerInputState.Pressed;
SimulateKeyInput(MapPadToKeyboard(button), true);
}
else if (!pressed && controller.LastInputState[button] == ControllerInputState.Pressed)
{
ResetButtonResend(button);
SendControllerInput(button, false);
controller.LastInputState[button] = ControllerInputState.Released;
SimulateKeyInput(MapPadToKeyboard(button), false);
}
}
}

Expand Down

0 comments on commit aba112c

Please sign in to comment.