Skip to content

Commit

Permalink
strokeStartThreshold -> strokeAccelerationMeasurementTime
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Oct 15, 2023
1 parent c34a8c6 commit 87f71ac
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions appendix/GamePadViewer/src/StickManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public class StickManager: ObservableObject {
@Published var holdingAcceleration = 0.0
@Published var holdingMagnitude = 0.0
var histories: [History] = []
let strokeStartThreshold = 0.1 // 100 ms
let strokeAccelerationMeasurementTime = 0.05 // 50 ms

var deadzoneTask: Task<(), Never>?

@MainActor
Expand Down Expand Up @@ -77,7 +78,7 @@ public class StickManager: ObservableObject {
deadzoneLeftAt = now
}

if now.timeIntervalSince(deadzoneLeftAt) > strokeStartThreshold {
if now.timeIntervalSince(deadzoneLeftAt) > strokeAccelerationMeasurementTime {
startingStroke = false
} else {
startingStroke = true
Expand All @@ -89,7 +90,7 @@ public class StickManager: ObservableObject {
return true
}

return now.timeIntervalSince($0.timeStamp) > 0.1 // 100 ms
return now.timeIntervalSince($0.timeStamp) > strokeAccelerationMeasurementTime
})

histories.append(
Expand Down

0 comments on commit 87f71ac

Please sign in to comment.