Scoop API

scoop:scoop.window:0.1.0

src/input/time.scoop

Selected production source · src/input/time.scoop

1package scoop.window
3import scoop.platform.time.MonotonicInstant
5/** Native occurrence time, or receipt time when the original clock is unavailable. */
6public enum InputTime {
7 Event(MonotonicInstant), Observed(MonotonicInstant)
8}
10/** Returns the captured time in the same clock domain used for frames and deadlines. */
11public fun InputTime.mark(): MonotonicInstant =
12 when (this) {
13 case Event(val value) -> value
14 case Observed(val value) -> value
15 }
17internal fun copyInputTime(event: NativeEventHeader): InputTime {
18 if (event.timeNanoseconds < 0L || event.timeNanoseconds >= 1000000000L)
19 throw WindowException("native input clock failed", WindowErrorKind.NativeFailure)
20 return InputTime.Observed(MonotonicInstant(event.timeSeconds, event.timeNanoseconds.toInt()))