Scoop API

scoop:scoop.window:0.1.0

src/input/contact.scoop

Selected production source · src/input/contact.scoop

1package scoop.window
3/** Identifies one contact lifetime within a window; native values may be reused. */
4public struct ContactId(val value: Long): Equals<ContactId>, Hash {
5 public override operator fun equals(other: ContactId): Boolean = value == other.value
6 public override fun hash(): Long = value.hash()
7}
9/** Direct screen contact or a pen tip, separate from indirect native gestures. */
10public enum ContactKind {
11 Touch, Pen
14/** Pressure is present only when the device supplies a normalized value. */
15public struct ContactState(
16 val id: ContactId,
17 val kind: ContactKind,
18 val pointer: PointerState,
19 val pressure: Double? = None
22public enum ContactEvent {
23 Began(ContactState), Moved(ContactState), Ended(ContactState),
24 Cancelled(ContactId, PointerCancelReason, InputTime)
27public val ContactEvent.id: ContactId get() =
28 when (this) {
29 case Began(val value) -> value.id
30 case Moved(val value) -> value.id
31 case Ended(val value) -> value.id
32 case Cancelled(val value, _, _) -> value
33 }
35public val ContactEvent.time: InputTime get() =
36 when (this) {
37 case Began(val value) -> value.pointer.time
38 case Moved(val value) -> value.pointer.time
39 case Ended(val value) -> value.pointer.time
40 case Cancelled(_, _, val value) -> value
41 }