1/* 2 * Copyright 2024 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 17syntax = "proto2"; 18 19package perfetto.protos; 20 21import "protos/perfetto/trace/android/typedef.proto"; 22 23// A representation of an Android MotionEvent. 24// See: https://developer.android.com/reference/android/view/MotionEvent 25// 26// The timestamp of the TracePacket that contains this event corresponds to the time at which 27// this event was processed by InputDispatcher. 28message AndroidMotionEvent { 29 // A representation of one pointer inside a MotionEvent. 30 // Each Pointer contains the values present in its corresponding 31 // MotionEvent.PointerCoords and MotionEvent.PointerProperties. 32 message Pointer { 33 message AxisValue { 34 optional int32 axis = 1 [(.perfetto.protos.typedef) = "android.view.MotionEvent.Axis"]; 35 optional float value = 2; 36 } 37 repeated AxisValue axis_value = 1; 38 optional int32 pointer_id = 2; 39 optional int32 tool_type = 3 [(.perfetto.protos.typedef) = "android.view.MotionEvent.ToolType"]; 40 } 41 42 // The randomly-generated ID used to track the event through the pipeline. 43 optional fixed32 event_id = 1; 44 // The event's timestamp - generated by the kernel. 45 optional int64 event_time_nanos = 2; 46 optional uint32 source = 3 [(.perfetto.protos.typedef) = "android.view.InputDevice.Source"]; 47 optional int32 action = 4 [(.perfetto.protos.typedef) = "android.view.MotionEvent.ActionMasked"]; 48 optional int32 device_id = 5; 49 // Use a signed int for display_id, because -1 (DISPLAY_IS_NONE) is a common value. 50 optional sint32 display_id = 6; 51 optional int32 classification = 7 52 [(.perfetto.protos.typedef) = "android.view.MotionEvent.Classification"]; 53 optional uint32 flags = 8 [(.perfetto.protos.typedef) = "android.view.MotionEvent.Flag"]; 54 repeated Pointer pointer = 9; 55 56 // Field numbers 10-15 are reserved for commonly used fields. 57 58 // If this event was synthesized as a result of one or more different 59 // event, original_event_ids are the event_ids associated with the original events. 60 // For example, if this is an ACTION_HOVER_ENTER event that is synthesized 61 // due to an ACTION_HOVER_MOVE event entering the bounds of a window, the 62 // id of the original hover move event will be listed here. 63 repeated fixed32 original_event_id = 16 [packed = true]; 64 // The timestamp of the ACTION_DOWN event associated with this gesture. 65 optional int64 down_time_nanos = 17; 66 optional float cursor_position_x = 18; 67 optional float cursor_position_y = 19; 68 optional int32 action_button = 20 [(.perfetto.protos.typedef) ="android.view.MotionEvent.Button"]; 69 optional uint32 button_state = 21 [(.perfetto.protos.typedef) ="android.view.MotionEvent.Button"]; 70 optional uint32 meta_state = 22 [(.perfetto.protos.typedef) ="android.view.KeyEvent.MetaState"]; 71 optional uint32 policy_flags = 23; 72 optional float precision_x = 24; 73 optional float precision_y = 25; 74} 75 76// A representation of an Android KeyEvent. 77// See: https://developer.android.com/reference/android/view/KeyEvent 78// 79// The timestamp of the TracePacket that contains this event corresponds to the time at which 80// this event was processed by InputDispatcher. 81message AndroidKeyEvent { 82 // The randomly-generated ID used to track the event through the pipeline. 83 optional fixed32 event_id = 1; 84 // The event's timestamp - generated by the kernel. 85 optional int64 event_time_nanos = 2; 86 // The timestamp of the ACTION_DOWN event associated with this gesture. 87 optional int64 down_time_nanos = 3; 88 optional uint32 source = 4 [(.perfetto.protos.typedef) = "android.view.InputDevice.Source"]; 89 optional int32 action = 5 [(.perfetto.protos.typedef) = "android.view.KeyEvent.Action"]; 90 optional int32 device_id = 6; 91 // Use a signed int for display_id, because -1 (DISPLAY_IS_NONE) is a common value. 92 optional sint32 display_id = 7; 93 optional int32 key_code = 8 [(.perfetto.protos.typedef) = "android.view.KeyEvent.KeyCode"]; 94 optional uint32 scan_code = 9; 95 optional uint32 meta_state = 10 [(.perfetto.protos.typedef) ="android.view.KeyEvent.MetaState"]; 96 optional int32 repeat_count = 11; 97 optional uint32 flags = 12 [(.perfetto.protos.typedef) = "android.view.KeyEvent.Flag"]; 98 optional uint32 policy_flags = 13; 99} 100 101// An event that traces an input event being dispatched by the system to one window. 102// 103// The timestamp of the TracePacket that contains this event corresponds to the time at which 104// this event was dispatched to the target window by InputDispatcher, also known as "delivery time". 105message AndroidWindowInputDispatchEvent { 106 // Stores x/y values for each pointer sent to the window for events 107 // that are dispatched to a certain location on the screen. This is not relevant 108 // for KeyEvents and MotionEvents that are dispatched to focused windows. 109 message DispatchedPointer { 110 optional int32 pointer_id = 1; 111 // The coordinates of the pointer in the logical display space, AKA "raw coordinates". 112 optional float x_in_display = 2; 113 optional float y_in_display = 3; 114 // The axis values for this pointer that were modified by the window transform. 115 repeated AndroidMotionEvent.Pointer.AxisValue axis_value_in_window = 4; 116 } 117 118 // The event_id of the event that was dispatched to the window. 119 optional fixed32 event_id = 1; 120 // The vsync_id of the frame in which the decision was made to dispatch the event to 121 // the window. 122 optional int64 vsync_id = 2; 123 // The id of the window to which the event was dispatched. 124 optional int32 window_id = 3; 125 // Only relevant for MotionEvents that are dispatched to a screen location. 126 // Each DispatchedPointer has a 1:1 correspondence with the Pointers in the AndroidMotionEvent. 127 repeated DispatchedPointer dispatched_pointer = 4; 128 // The event flags that were used when dispatching the event to this window. 129 // If the same event is dispatched to more than one window, it is possible that they 130 // were dispatched using different flag values for each window. 131 optional uint32 resolved_flags = 5; 132} 133 134// A wrapper type for input tracing on Android. 135// The meaning of the timestamp of the TracePacket that contains this message will depend on 136// the event that this message contains. 137message AndroidInputEvent { 138 oneof event { 139 // Traces input events received by or generated by InputDispatcher 140 AndroidMotionEvent dispatcher_motion_event = 1; 141 AndroidMotionEvent dispatcher_motion_event_redacted = 2; 142 AndroidKeyEvent dispatcher_key_event = 3; 143 AndroidKeyEvent dispatcher_key_event_redacted = 4; 144 145 // Traces an event being dispatched to a window. 146 AndroidWindowInputDispatchEvent dispatcher_window_dispatch_event = 5; 147 AndroidWindowInputDispatchEvent dispatcher_window_dispatch_event_redacted = 6; 148 } 149} 150