Ubuntu Platform API  1.2.0
A library helping with tight integration into the Ubuntu platform
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
event.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 #ifndef UBUNTU_APPLICATION_UI_INPUT_EVENT_H_
19 #define UBUNTU_APPLICATION_UI_INPUT_EVENT_H_
20 
21 #include <ubuntu/visibility.h>
22 
23 #include <stddef.h>
24 #include <stdint.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 // TODO<papi>: Perhaps we should update the struct to use these enum types. But then we need to move action/flags
31 // in to the internal typed event structs.
32 
33 typedef enum {
37 } UKeyAction;
38 
39 typedef enum {
51 } UKeyFlag;
52 
53 typedef enum {
73 
74 #define U_MOTION_ACTION_POINTER_INDEX_SHIFT 8
75 #define U_MOTION_ACTION_MASK 0xff
76 #define U_MOTION_ACTION_POINTER_INDEX_MASK 0xff00
77 
78 typedef enum {
91 
92 typedef enum {
94 } UMotionFlag;
95 
96 typedef enum {
103 
104 
106 #define UBUNTU_APPLICATION_UI_INPUT_EVENT_MAX_POINTER_COUNT (16)
107 
109  typedef int64_t nsecs_t;
110 
112  typedef enum
113  {
117  } EventType;
118 
120  typedef struct
121  {
123  int32_t device_id;
124  int32_t source_id;
125  int32_t action;
126  int32_t flags;
127  int32_t meta_state;
128 
129  union
130  {
132  struct HardwareSwitchEvent
133  {
134  nsecs_t event_time;
135  uint32_t policy_flags;
136  int32_t switch_code;
137  int32_t switch_value;
138  } hw_switch;
140  struct KeyEvent
141  {
142  int32_t key_code;
143  int32_t scan_code;
144  int32_t repeat_count;
145  nsecs_t down_time;
146  nsecs_t event_time;
148  } key;
153  struct MotionEvent
154  {
155  int32_t edge_flags;
156  int32_t button_state;
157  float x_offset;
158  float y_offset;
159  float x_precision;
160  float y_precision;
161  nsecs_t down_time;
162  nsecs_t event_time;
163  size_t pointer_count;
164  struct PointerCoordinate
165  {
166  int id;
167  float x, raw_x;
168  float y, raw_y;
169  float touch_major;
170  float touch_minor;
171  float size;
172  float pressure;
173  float orientation;
175  } motion;
176  } details;
177  } Event;
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif // UBUNTU_APPLICATION_UI_INPUT_EVENT_H_
float y_offset
Movement in y direction since down event.
Definition: event.h:158
size_t pointer_count
Number of pointers reported in this event.
Definition: event.h:163
int32_t key_code
Definition: event.h:142
int32_t button_state
State of buttons of the device.
Definition: event.h:156
Event originates from an additional button attached to the device's HW, e.g., power button...
Definition: event.h:116
float y
Definition: event.h:168
UKeyModifierMask
Definition: event.h:53
#define UBUNTU_APPLICATION_UI_INPUT_EVENT_MAX_POINTER_COUNT
Definition: event.h:106
Event originates from a keyboard.
Definition: event.h:114
Event originates from something moving, e.g., a wheel, a mouse, a finger on a touchpad.
Definition: event.h:115
int32_t flags
Flags associated with this event.
Definition: event.h:126
int32_t switch_value
The value reported by the switch.
Definition: event.h:137
UKeyAction
Definition: event.h:33
float pressure
Pressure of the touch.
Definition: event.h:172
float orientation
Orientation.
Definition: event.h:173
int32_t repeat_count
Definition: event.h:144
float touch_major
Touch major coordinate.
Definition: event.h:169
Definition: event.h:120
int32_t action
Action signalled by this event.
Definition: event.h:125
UMotionAction
Definition: event.h:78
UKeyFlag
Definition: event.h:39
float x_precision
Sampling precision in x direction.
Definition: event.h:159
int is_system_key
Definition: event.h:147
int id
Unique id of the pointer.
Definition: event.h:166
float x
Definition: event.h:167
UMotionFlag
Definition: event.h:92
int32_t scan_code
Definition: event.h:143
float size
Size of the pointer/touch.
Definition: event.h:171
float touch_minor
Touch minor coordinate.
Definition: event.h:170
int32_t meta_state
State of the meta modifiers (ALT, CTRL, SHIFT).
Definition: event.h:127
uint32_t policy_flags
Policy flags.
Definition: event.h:135
int32_t edge_flags
Set for touches intersecting a touchscreen's edges, requires HW support.
Definition: event.h:155
float x_offset
Movement in x direction since down event.
Definition: event.h:157
nsecs_t event_time
Timestamp when the event happened.
Definition: event.h:134
float y_precision
Sampling precision in y direction.
Definition: event.h:160
EventType type
Type of the event.
Definition: event.h:122
int32_t switch_code
The scan code of the switch.
Definition: event.h:136
int32_t source_id
Source that this event originated from.
Definition: event.h:124
UMotionButtonMask
Definition: event.h:96
int64_t nsecs_t
Definition: event.h:109
EventType
Definition: event.h:112
nsecs_t down_time
Timestamp that marks the down event.
Definition: event.h:145
int32_t device_id
Device that this event originated from.
Definition: event.h:123