xref: /aosp_15_r20/external/libpalmrejection/ui/events/ozone/evdev/touch_evdev_types.h (revision 385f2b9352baca56113422de7d5392250974f582)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_EVDEV_TYPES_H_
6 #define UI_EVENTS_OZONE_EVDEV_TOUCH_EVDEV_TYPES_H_
7 
8 #if defined(__ANDROID__) || defined(__ANDROID_HOST__)
9 #include <compare>
10 #endif
11 #include <stddef.h>
12 
13 #include "base/component_export.h"
14 #include "base/time/time.h"
15 #include "ui/events/event_constants.h"
16 
17 namespace ui {
18 
19 // Number of supported touch slots. ABS_MT_SLOT messages with
20 // value >= kNumTouchEvdevSlots are ignored.
21 const int kNumTouchEvdevSlots = 20;
22 
23 // Contains information about an in progress touch.
COMPONENT_EXPORT(EVDEV)24 struct COMPONENT_EXPORT(EVDEV) InProgressTouchEvdev {
25   InProgressTouchEvdev();
26   InProgressTouchEvdev(const InProgressTouchEvdev& other);
27   ~InProgressTouchEvdev();
28 
29 #if defined(__ANDROID__) || defined(__ANDROID_HOST__)
30   auto operator<=>(const InProgressTouchEvdev&) const = default;
31 #endif
32 
33   // Current touch major of this slot.
34   int major = 0;
35 
36   // Current touch minor of this slot.
37   int minor = 0;
38 
39   // Current tool type of this slot.
40   int tool_type = 0;
41 
42   // Whether there is new information for the touch.
43   bool altered = false;
44 
45   // Whether the touch was cancelled. Touch events should be ignored till a
46   // new touch is initiated.
47   bool was_cancelled = false;
48 
49   // Whether the touch is going to be canceled.
50   bool cancelled = false;
51 
52   // Whether the touch is delayed at first appearance. Will not be reported yet.
53   bool delayed = false;
54 
55   // Whether the touch was delayed before.
56   bool was_delayed = false;
57 
58   // Whether the touch is held until end or no longer held.
59   bool held = false;
60 
61   // Whether this touch was held before being sent.
62   bool was_held = false;
63 
64   bool was_touching = false;
65   bool touching = false;
66   float x = 0;
67   float y = 0;
68   int tracking_id = -1;
69   size_t slot = 0;
70   float radius_x = 0;
71   float radius_y = 0;
72   float pressure = 0;
73   int tool_code = 0;
74   int orientation = 0;
75   float tilt_x = 0;
76   float tilt_y = 0;
77   ui::EventPointerType reported_tool_type = ui::EventPointerType::kTouch;
78   bool stylus_button = false;
79 };
80 
81 std::ostream& operator<<(std::ostream& out, const InProgressTouchEvdev& touch);
82 
83 // Contains information about stylus event, the useful relate ddevice info and
84 // the timestamp.
COMPONENT_EXPORT(EVDEV)85 struct COMPONENT_EXPORT(EVDEV) InProgressStylusState {
86   InProgressStylusState();
87   InProgressStylusState(const InProgressStylusState& other);
88   ~InProgressStylusState();
89 
90   InProgressTouchEvdev stylus_event;
91   // Stylus x and y resolution, used for normalization.
92   int x_res = 1;
93   int y_res = 1;
94 
95   base::TimeTicks timestamp = base::TimeTicks();
96 };
97 
98 }  // namespace ui
99 
100 #endif  // UI_EVENTS_OZONE_EVDEV_TOUCH_EVDEV_TYPES_H_
101