Skip repeated haptic requests

This commit is contained in:
Kamil Trzciński 2022-12-04 19:10:59 +01:00
parent 40da017804
commit f4431105e3
2 changed files with 7 additions and 1 deletions

View file

@ -20,3 +20,4 @@ It does help this project on being supported.
- Re-open Neptune controller every 10 failures
- Manage Steam default controller configs to prevent double inputs (in DEBUG, change Settings)
- Fix bug with unable to select controller profile from OSD
- Skip repeated haptic requests

View file

@ -62,8 +62,13 @@ namespace SteamController.Devices
public SDCHapticPacket2() { }
}
private Task? hapticTask;
public bool SendHaptic(byte position, sbyte intensity)
{
if (hapticTask?.IsCompleted == false)
return false;
var ts = Random.Shared.Next();
var haptic = new SDCHapticPacket2()
@ -82,7 +87,7 @@ namespace SteamController.Devices
try
{
Marshal.StructureToPtr(haptic, handle.AddrOfPinnedObject(), false);
neptuneDevice.RequestFeatureReportAsync(bytes);
hapticTask = neptuneDevice.RequestFeatureReportAsync(bytes);
return true;
}
catch (Exception e)