Skip to content

Commit d2e42b0

Browse files
committed
Wooting analog module - Cap refreshrate to 60 FPS instead of 30 FPS
Also implement it in such a way we don't skip frames on 30fps
1 parent a233a61 commit d2e42b0

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/Devices/Artemis.Plugins.Devices.Wooting/Modules/WootingAnalogModule.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class WootingAnalogModule : Module<WootingDataModel>
1313
private readonly WootingAnalogService _analogService;
1414
public override List<IModuleActivationRequirement> ActivationRequirements { get; } = new();
1515
private int _useToken;
16+
private double _totalDeltaTime;
1617

1718
public WootingAnalogModule(WootingAnalogService service)
1819
{
@@ -28,7 +29,12 @@ public override void Enable()
2829

2930
public override void Update(double deltaTime)
3031
{
32+
_totalDeltaTime += deltaTime;
33+
if (_totalDeltaTime < 0.016) // ~60 FPS
34+
return;
35+
3136
UpdateAnalogValues();
37+
_totalDeltaTime = 0;
3238
}
3339

3440
public override void Disable()

src/Devices/Artemis.Plugins.Devices.Wooting/Services/AnalogService/WootingAnalogService.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public sealed class WootingAnalogService : ReusableService
1313
{
1414
private readonly ILogger _logger;
1515
private List<WootingAnalogDevice> _devices;
16-
private DateTime _lastUpdate;
1716
public IEnumerable<WootingAnalogDevice> Devices => _devices;
1817

1918
public WootingAnalogService(ILogger logger)
@@ -27,10 +26,6 @@ public void Update()
2726
if (!IsActivated)
2827
return;
2928

30-
DateTime now = DateTime.Now;
31-
if (now - _lastUpdate < TimeSpan.FromSeconds(1.0 / 30.0))
32-
return;
33-
3429
foreach (WootingAnalogDevice device in _devices)
3530
{
3631
(List<(short, float)> data, WootingAnalogResult res) = WootingAnalogSDK.ReadFullBuffer(deviceID: device.Info.device_id);
@@ -45,8 +40,6 @@ public void Update()
4540
_logger.Verbose("Failed to find mapping for hid code {hidCode}", key);
4641
}
4742
}
48-
49-
_lastUpdate = now;
5043
}
5144

5245
/// <summary>

0 commit comments

Comments
 (0)