mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-24 01:10:25 +01:00
Debounce controller changes from Steam
This commit is contained in:
parent
4a7909b485
commit
c2fa6c3a9d
|
|
@ -23,3 +23,4 @@ It does help this project on being supported.
|
|||
- Skip repeated haptic requests
|
||||
- Allow to select Default profile (Desktop-mode profile)
|
||||
- Allow to change scroll direction
|
||||
- Debounce controller changes from Steam
|
||||
|
|
|
|||
|
|
@ -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…
Reference in a new issue