mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-09 00:03:53 +00:00
Debounce controller changes from Steam
This commit is contained in:
parent
4a7909b485
commit
c2fa6c3a9d
2 changed files with 14 additions and 0 deletions
|
|
@ -5,7 +5,10 @@ namespace SteamController.Managers
|
|||
{
|
||||
public sealed class SteamManager : Manager
|
||||
{
|
||||
public const int DebounceStates = 1;
|
||||
|
||||
private string? lastState;
|
||||
private int stateChanged;
|
||||
|
||||
public override void Tick(Context context)
|
||||
{
|
||||
|
|
@ -14,12 +17,21 @@ namespace SteamController.Managers
|
|||
context.State.SteamUsesSteamInput = false;
|
||||
context.State.SteamUsesX360Controller = false;
|
||||
lastState = null;
|
||||
stateChanged = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
var usesController = UsesController();
|
||||
if (lastState == usesController)
|
||||
{
|
||||
stateChanged = 0;
|
||||
return;
|
||||
}
|
||||
else if (stateChanged < DebounceStates)
|
||||
{
|
||||
stateChanged++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (usesController is not null)
|
||||
{
|
||||
|
|
@ -40,6 +52,7 @@ namespace SteamController.Managers
|
|||
}
|
||||
|
||||
lastState = usesController;
|
||||
stateChanged = 0;
|
||||
|
||||
#if DEBUG
|
||||
CommonHelpers.Log.TraceLine(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue