OLD | NEW |
1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 #ifndef PPAPI_C_PP_INPUT_EVENT_H_ | 5 #ifndef PPAPI_C_PP_INPUT_EVENT_H_ |
6 #define PPAPI_C_PP_INPUT_EVENT_H_ | 6 #define PPAPI_C_PP_INPUT_EVENT_H_ |
7 | 7 |
8 /** | 8 /** |
9 * @file | 9 * @file |
10 * Defines the API ... | 10 * Defines the API ... |
11 * | |
12 * @addtogroup PP | |
13 * @{ | |
14 */ | 11 */ |
15 | 12 |
16 #include "ppapi/c/pp_bool.h" | 13 #include "ppapi/c/pp_bool.h" |
17 #include "ppapi/c/pp_macros.h" | 14 #include "ppapi/c/pp_macros.h" |
18 #include "ppapi/c/pp_stdint.h" | 15 #include "ppapi/c/pp_stdint.h" |
19 #include "ppapi/c/pp_time.h" | 16 #include "ppapi/c/pp_time.h" |
20 | 17 |
| 18 /** |
| 19 * |
| 20 * @addtogroup Enums |
| 21 * @{ |
| 22 */ |
21 typedef enum { | 23 typedef enum { |
22 PP_INPUTEVENT_MOUSEBUTTON_NONE = -1, | 24 PP_INPUTEVENT_MOUSEBUTTON_NONE = -1, |
23 PP_INPUTEVENT_MOUSEBUTTON_LEFT = 0, | 25 PP_INPUTEVENT_MOUSEBUTTON_LEFT = 0, |
24 PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1, | 26 PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1, |
25 PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2 | 27 PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2 |
26 } PP_InputEvent_MouseButton; | 28 } PP_InputEvent_MouseButton; |
27 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4); | 29 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4); |
| 30 /** |
| 31 * @} |
| 32 */ |
28 | 33 |
| 34 /** |
| 35 * |
| 36 * @addtogroup Enums |
| 37 * @{ |
| 38 */ |
29 typedef enum { | 39 typedef enum { |
30 PP_INPUTEVENT_TYPE_UNDEFINED = -1, | 40 PP_INPUTEVENT_TYPE_UNDEFINED = -1, |
31 PP_INPUTEVENT_TYPE_MOUSEDOWN = 0, // PP_InputEvent_Mouse | 41 PP_INPUTEVENT_TYPE_MOUSEDOWN = 0, // PP_InputEvent_Mouse |
32 PP_INPUTEVENT_TYPE_MOUSEUP = 1, // PP_InputEvent_Mouse | 42 PP_INPUTEVENT_TYPE_MOUSEUP = 1, // PP_InputEvent_Mouse |
33 PP_INPUTEVENT_TYPE_MOUSEMOVE = 2, // PP_InputEvent_Mouse | 43 PP_INPUTEVENT_TYPE_MOUSEMOVE = 2, // PP_InputEvent_Mouse |
34 PP_INPUTEVENT_TYPE_MOUSEENTER = 3, // PP_InputEvent_Mouse | 44 PP_INPUTEVENT_TYPE_MOUSEENTER = 3, // PP_InputEvent_Mouse |
35 PP_INPUTEVENT_TYPE_MOUSELEAVE = 4, // PP_InputEvent_Mouse | 45 PP_INPUTEVENT_TYPE_MOUSELEAVE = 4, // PP_InputEvent_Mouse |
36 PP_INPUTEVENT_TYPE_MOUSEWHEEL = 5, // PP_InputEvent_Wheel | 46 PP_INPUTEVENT_TYPE_MOUSEWHEEL = 5, // PP_InputEvent_Wheel |
37 PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6, // PP_InputEvent_Key | 47 PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6, // PP_InputEvent_Key |
38 PP_INPUTEVENT_TYPE_KEYDOWN = 7, // PP_InputEvent_Key | 48 PP_INPUTEVENT_TYPE_KEYDOWN = 7, // PP_InputEvent_Key |
39 PP_INPUTEVENT_TYPE_KEYUP = 8, // PP_InputEvent_Key | 49 PP_INPUTEVENT_TYPE_KEYUP = 8, // PP_InputEvent_Key |
40 PP_INPUTEVENT_TYPE_CHAR = 9, // PP_InputEvent_Character | 50 PP_INPUTEVENT_TYPE_CHAR = 9, // PP_InputEvent_Character |
41 PP_INPUTEVENT_TYPE_CONTEXTMENU = 10 // PP_InputEvent_Mouse | 51 PP_INPUTEVENT_TYPE_CONTEXTMENU = 10 // PP_InputEvent_Mouse |
42 } PP_InputEvent_Type; | 52 } PP_InputEvent_Type; |
43 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4); | 53 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4); |
| 54 /** |
| 55 * @} |
| 56 */ |
44 | 57 |
| 58 /** |
| 59 * |
| 60 * @addtogroup Enums |
| 61 * @{ |
| 62 */ |
45 typedef enum { | 63 typedef enum { |
46 PP_INPUTEVENT_MODIFIER_SHIFTKEY = 1 << 0, | 64 PP_INPUTEVENT_MODIFIER_SHIFTKEY = 1 << 0, |
47 PP_INPUTEVENT_MODIFIER_CONTROLKEY = 1 << 1, | 65 PP_INPUTEVENT_MODIFIER_CONTROLKEY = 1 << 1, |
48 PP_INPUTEVENT_MODIFIER_ALTKEY = 1 << 2, | 66 PP_INPUTEVENT_MODIFIER_ALTKEY = 1 << 2, |
49 PP_INPUTEVENT_MODIFIER_METAKEY = 1 << 3, | 67 PP_INPUTEVENT_MODIFIER_METAKEY = 1 << 3, |
50 PP_INPUTEVENT_MODIFIER_ISKEYPAD = 1 << 4, | 68 PP_INPUTEVENT_MODIFIER_ISKEYPAD = 1 << 4, |
51 PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT = 1 << 5, | 69 PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT = 1 << 5, |
52 PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN = 1 << 6, | 70 PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN = 1 << 6, |
53 PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7, | 71 PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7, |
54 PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN = 1 << 8, | 72 PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN = 1 << 8, |
55 PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9, | 73 PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9, |
56 PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10 | 74 PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10 |
57 } PP_InputEvent_Modifier; | 75 } PP_InputEvent_Modifier; |
58 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier, 4); | 76 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier, 4); |
| 77 /** |
| 78 * @} |
| 79 */ |
| 80 |
| 81 /** |
| 82 * @addtogroup Structs |
| 83 * @{ |
| 84 */ |
59 | 85 |
60 /** | 86 /** |
61 * An event representing a key up or down event. | 87 * An event representing a key up or down event. |
62 * | 88 * |
63 * Key up and down events correspond to physical keys on the keyboard. The | 89 * Key up and down events correspond to physical keys on the keyboard. The |
64 * actual character that the user typed (if any) will be delivered in a | 90 * actual character that the user typed (if any) will be delivered in a |
65 * "character" event. | 91 * "character" event. |
66 * | 92 * |
67 * If the user kills focus on the plugin while a key is down, you may not get | 93 * If the user kills focus on the plugin while a key is down, you may not get |
68 * a key up event. For example, if the plugin has focus and the user presses | 94 * a key up event. For example, if the plugin has focus and the user presses |
69 * and holds shift, the plugin will see a "shift down" message. Then if they | 95 * and holds shift, the plugin will see a "shift down" message. Then if they |
70 * click elsewhere on the web page, the plugin focus will be lost and no more | 96 * click elsewhere on the web page, the plugin focus will be lost and no more |
71 * input events will be delivered. If you depend on getting key up events, you | 97 * input events will be delivered. If you depend on getting key up events, you |
72 * will also want to handle "lost focus" as the equivalent of "all keys up." | 98 * will also want to handle "lost focus" as the equivalent of "all keys up." |
| 99 * |
73 */ | 100 */ |
74 struct PP_InputEvent_Key { | 101 struct PP_InputEvent_Key { |
75 /** A combination of the EVENT_MODIFIER flags. */ | 102 /** A combination of the EVENT_MODIFIER flags. */ |
76 uint32_t modifier; | 103 uint32_t modifier; |
77 | 104 |
78 /** | 105 /** |
79 * The key code. | 106 * The key code. |
80 * | 107 * |
81 * TODO(brettw) define what these actually are. | 108 * TODO(brettw) define what these actually are. |
82 */ | 109 */ |
83 uint32_t key_code; | 110 uint32_t key_code; |
84 }; | 111 }; |
85 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Key, 8); | 112 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Key, 8); |
| 113 /** |
| 114 * @} |
| 115 */ |
| 116 |
| 117 /** |
| 118 * @addtogroup Structs |
| 119 * @{ |
| 120 */ |
86 | 121 |
87 /** | 122 /** |
88 * An event representing a typed character. | 123 * An event representing a typed character. |
89 * | 124 * |
90 * Normally, the program will receive a key down event, followed by a character | 125 * Normally, the program will receive a key down event, followed by a character |
91 * event, followed by a key up event. The character event will have any | 126 * event, followed by a key up event. The character event will have any |
92 * modifier keys applied. Obvious examples are symbols, where Shift-5 gives you | 127 * modifier keys applied. Obvious examples are symbols, where Shift-5 gives you |
93 * a '%'. The key down and up events will give you the scan code for the "5" | 128 * a '%'. The key down and up events will give you the scan code for the "5" |
94 * key, and the character event will give you the '%' character. | 129 * key, and the character event will give you the '%' character. |
95 * | 130 * |
96 * You may not get a character event for all key down if the key doesn't | 131 * You may not get a character event for all key down if the key doesn't |
97 * generate a character. Likewise, you may actually get multiple character | 132 * generate a character. Likewise, you may actually get multiple character |
98 * events in a row. For example, some locales have an accent key that modifies | 133 * events in a row. For example, some locales have an accent key that modifies |
99 * the next character typed. You might get this stream of events: accent down, | 134 * the next character typed. You might get this stream of events: accent down, |
100 * accent up (it didn't generate a character), letter key down, letter with | 135 * accent up (it didn't generate a character), letter key down, letter with |
101 * accent character event (it was modified by the previous accent key), letter | 136 * accent character event (it was modified by the previous accent key), letter |
102 * key up. If the letter can't be combined with the accent, like an umlaut and | 137 * key up. If the letter can't be combined with the accent, like an umlaut and |
103 * an 'R', the system might send unlaut down, umlaut up, 'R' key down, umlaut | 138 * an 'R', the system might send unlaut down, umlaut up, 'R' key down, umlaut |
104 * character ("whoops, I can't combine it with 'R', I better just send the raw | 139 * character ("whoops, I can't combine it with 'R', I better just send the raw |
105 * unlaut so it isn't lost"), 'R' character event, 'R' key up. | 140 * unlaut so it isn't lost"), 'R' character event, 'R' key up. |
| 141 * |
106 */ | 142 */ |
107 struct PP_InputEvent_Character { | 143 struct PP_InputEvent_Character { |
108 /** A combination of the EVENT_MODIFIER flags. */ | 144 /** A combination of the EVENT_MODIFIER flags. */ |
109 uint32_t modifier; | 145 uint32_t modifier; |
110 | 146 |
111 /** | 147 /** |
112 * The character the user typed, as a single null-terminated UTF-8 character. | 148 * The character the user typed, as a single null-terminated UTF-8 character. |
113 * Any unused bytes will be filled with null bytes. Since the maximum UTF-8 | 149 * Any unused bytes will be filled with null bytes. Since the maximum UTF-8 |
114 * character is 4 bytes, there will always be at least one null at the end | 150 * character is 4 bytes, there will always be at least one null at the end |
115 * so you can treat this as a null-termianted UTF-8 string. | 151 * so you can treat this as a null-termianted UTF-8 string. |
116 */ | 152 */ |
117 char text[5]; | 153 char text[5]; |
118 }; | 154 }; |
119 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Character, 12); | 155 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Character, 12); |
| 156 /** |
| 157 * @} |
| 158 */ |
| 159 |
| 160 /** |
| 161 * @addtogroup Structs |
| 162 * @{ |
| 163 */ |
120 | 164 |
121 /** Represents a mouse event for everything other than the mouse wheel. */ | 165 /** Represents a mouse event for everything other than the mouse wheel. */ |
122 struct PP_InputEvent_Mouse { | 166 struct PP_InputEvent_Mouse { |
123 /** A combination of the EVENT_MODIFIER flags. */ | 167 /** A combination of the EVENT_MODIFIER flags. */ |
124 uint32_t modifier; | 168 uint32_t modifier; |
125 | 169 |
126 /** | 170 /** |
127 * Which button changed in the case of mouse down or up events. For mouse | 171 * Which button changed in the case of mouse down or up events. For mouse |
128 * move, enter, and leave events, this will be PP_EVENT_MOUSEBUTTON_NONE. | 172 * move, enter, and leave events, this will be PP_EVENT_MOUSEBUTTON_NONE. |
129 */ | 173 */ |
130 PP_InputEvent_MouseButton button; | 174 PP_InputEvent_MouseButton button; |
131 | 175 |
132 /** | 176 /** |
133 * The coordinates of the mouse when the event occurred. | 177 * The coordinates of the mouse when the event occurred. |
134 * | 178 * |
135 * In most cases these coordinates will just be integers, but they may not | 179 * In most cases these coordinates will just be integers, but they may not |
136 * be in some cases. For example, the plugin element might be arbitrarily | 180 * be in some cases. For example, the plugin element might be arbitrarily |
137 * scaled or transformed in the DOM, and translating a mouse event into the | 181 * scaled or transformed in the DOM, and translating a mouse event into the |
138 * coordinate space of the plugin will give non-integer values. | 182 * coordinate space of the plugin will give non-integer values. |
139 */ | 183 */ |
140 float x; | 184 float x; |
141 float y; | 185 float y; |
142 | 186 |
143 /** TODO(brettw) figure out exactly what this means. */ | 187 /** TODO(brettw) figure out exactly what this means. */ |
144 int32_t click_count; | 188 int32_t click_count; |
145 }; | 189 }; |
146 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Mouse, 20); | 190 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Mouse, 20); |
| 191 /** |
| 192 * @} |
| 193 */ |
147 | 194 |
| 195 /** |
| 196 * @addtogroup Structs |
| 197 * @{ |
| 198 */ |
148 struct PP_InputEvent_Wheel { | 199 struct PP_InputEvent_Wheel { |
149 /** A combination of the EVENT_MODIFIER flags. */ | 200 /** A combination of the EVENT_MODIFIER flags. */ |
150 uint32_t modifier; | 201 uint32_t modifier; |
151 | 202 |
152 float delta_x; | 203 float delta_x; |
153 float delta_y; | 204 float delta_y; |
154 float wheel_ticks_x; | 205 float wheel_ticks_x; |
155 float wheel_ticks_y; | 206 float wheel_ticks_y; |
156 | 207 |
157 PP_Bool scroll_by_page; | 208 PP_Bool scroll_by_page; |
158 }; | 209 }; |
159 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Wheel, 24); | 210 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Wheel, 24); |
| 211 /** |
| 212 * @} |
| 213 */ |
160 | 214 |
| 215 /** |
| 216 * |
| 217 * @addtogroup Structs |
| 218 * @{ |
| 219 */ |
161 struct PP_InputEvent { | 220 struct PP_InputEvent { |
162 /** Identifies the type of the event. */ | 221 /** Identifies the type of the event. */ |
163 PP_InputEvent_Type type; | 222 PP_InputEvent_Type type; |
164 | 223 |
165 /* Ensure the time_stamp is aligned on an 8-byte boundary relative to the | 224 /* Ensure the time_stamp is aligned on an 8-byte boundary relative to the |
166 start of the struct. Some compilers align doubles on 8-byte boundaries | 225 start of the struct. Some compilers align doubles on 8-byte boundaries |
167 for 32-bit x86, and some align on 4-byte boundaries. */ | 226 for 32-bit x86, and some align on 4-byte boundaries. */ |
168 int32_t padding; | 227 int32_t padding; |
169 | 228 |
170 /** | 229 /** |
(...skipping 10 matching lines...) Expand all Loading... |
181 struct PP_InputEvent_Wheel wheel; | 240 struct PP_InputEvent_Wheel wheel; |
182 | 241 |
183 /** | 242 /** |
184 * Allows new events to be added without changing the size of this | 243 * Allows new events to be added without changing the size of this |
185 * struct. | 244 * struct. |
186 */ | 245 */ |
187 char padding[64]; | 246 char padding[64]; |
188 } u; | 247 } u; |
189 }; | 248 }; |
190 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent, 80); | 249 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent, 80); |
191 | |
192 /** | 250 /** |
193 * @} | 251 * @} |
194 * End of addtogroup PP | |
195 */ | 252 */ |
196 | 253 |
197 #endif /* PPAPI_C_PP_INPUT_EVENT_H_ */ | 254 #endif /* PPAPI_C_PP_INPUT_EVENT_H_ */ |
OLD | NEW |