1 /*
2  * Copyright 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.compose.ui.input.indirect
18 
19 import androidx.compose.ui.ExperimentalComposeUiApi
20 import androidx.compose.ui.geometry.Offset
21 import androidx.compose.ui.input.pointer.PointerEvent
22 
23 /**
24  * Represents a touch event that did not result from contact with a touchscreen.
25  *
26  * This event differs from a [PointerEvent] as it does not necessitate an existence of a pointer. If
27  * an event were to have an associated pointer, they will be routed to through [PointerEvent].
28  */
29 @ExperimentalComposeUiApi
30 class IndirectTouchEvent(
31 
32     /** The position relative to the input device. */
33     val position: Offset,
34 
35     /** The time at which this event occurred. */
36     val eventTimeMillis: Long,
37 
38     /** The reason the [IndirectTouchEvent] was sent. */
39     val type: IndirectTouchEventType
40 )
41 
42 /** Indicates the reason that the [IndirectTouchEvent] was sent. */
43 @kotlin.jvm.JvmInline
44 @ExperimentalComposeUiApi
45 value class IndirectTouchEventType private constructor(internal val value: Int) {
46     companion object {
47 
48         /** An unknown reason for the event. */
49         val Unknown = IndirectTouchEventType(0)
50 
51         /** A pressed gesture as started. */
52         val Press = IndirectTouchEventType(1)
53 
54         /** A pressed gesture has finished. */
55         val Release = IndirectTouchEventType(2)
56 
57         /** A change has happened during a press gesture. */
58         val Move = IndirectTouchEventType(3)
59     }
60 
toStringnull61     override fun toString(): String =
62         when (this) {
63             Press -> "Press"
64             Release -> "Release"
65             Move -> "Move"
66             else -> "Unknown"
67         }
68 }
69