How do I access the value in Settings → Accessibility → Double-tap Timeout?
More details:
I'm making a game with a SpriteView
in SwiftUI that needs to react immediate to a touch while also detecting and responding to double, triple, and quadruple taps. To do this, I have the following:
var touch: some Gesture {
var lastTouchTime = Date.now
var tapCounter = 1
return DragGesture(minimumDistance: 0, coordinateSpace: .local)
.onChanged() { touch in
// Respond immediately to touch.
}
.onEnded() { touch in
if lastTouchTime.timeIntervalSinceNow > -0.25 {
tapCounter += 1
} else {
tapCounter = 1
}
switch tapCounter {
case 1:
break
case 2:
// Respond to double-tap.
case 3:
// Respond to triple-tap.
default:
// Respond to quadruple tap.
// Quintuple, sextuple, etc. taps also resolve here, which is fine.
}
lastTouchTime = Date.now
}
}
I would like to substitute 0.25
with the user's value in Accessibility settings, but I do not know how to access this value.
The following does not work:
.gesture(doubleTap)
.gesture(singleTap)
SwiftUI waits for the double-tap to fail before reacting to the single tap, which is not what I need, plus stacking triple and quadruple taps on top of this just fails.