scoop:scoop.window:0.1.0
src/input/time.scoop
Selected production source · src/input/time.scoop
1
package scoop.window3
import scoop.platform.time.MonotonicInstant5
/** Native occurrence time, or receipt time when the original clock is unavailable. */6
public enum InputTime {7
Event(MonotonicInstant), Observed(MonotonicInstant)8
}10
/** Returns the captured time in the same clock domain used for frames and deadlines. */11
public fun InputTime.mark(): MonotonicInstant =12
when (this) {13
case Event(val value) -> value14
case Observed(val value) -> value15
}17
internal 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()))21
}