Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: ppapi/c/pp_input_event.h

Issue 6246117: Cleaning up and adding new docs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/c/pp_stdint.h » ('j') | ppapi/c/pp_stdint.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * This file defines the APIs used to handle mouse and keyboard modifier input
dmichael(do not use this one) 2011/02/08 17:04:38 remove 'modifier '
jond 2011/02/09 16:42:04 Done.
11 * events.
11 */ 12 */
12 13
13 #include "ppapi/c/pp_bool.h" 14 #include "ppapi/c/pp_bool.h"
14 #include "ppapi/c/pp_macros.h" 15 #include "ppapi/c/pp_macros.h"
15 #include "ppapi/c/pp_stdint.h" 16 #include "ppapi/c/pp_stdint.h"
16 #include "ppapi/c/pp_time.h" 17 #include "ppapi/c/pp_time.h"
17 18
18 /** 19 /**
19 * 20 *
20 * @addtogroup Enums 21 * @addtogroup Enums
21 * @{ 22 * @{
22 */ 23 */
24
25 /**
26 * This enumeration contains enumorators representing each mouse button.
dmichael(do not use this one) 2011/02/08 17:04:38 Sounds redundant... maybe 'PP_InputEvent_MouseBut
jond 2011/02/09 16:42:04 You're rewrite seemed too verbose. From what I can
dmichael(do not use this one) 2011/02/11 16:42:04 Thanks, Jon. I like your new version.
27 */
23 typedef enum { 28 typedef enum {
24 PP_INPUTEVENT_MOUSEBUTTON_NONE = -1, 29 PP_INPUTEVENT_MOUSEBUTTON_NONE = -1,
25 PP_INPUTEVENT_MOUSEBUTTON_LEFT = 0, 30 PP_INPUTEVENT_MOUSEBUTTON_LEFT = 0,
26 PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1, 31 PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1,
27 PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2 32 PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2
28 } PP_InputEvent_MouseButton; 33 } PP_InputEvent_MouseButton;
29 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4); 34 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4);
30 /** 35 /**
31 * @} 36 * @}
32 */ 37 */
33 38
34 /** 39 /**
35 *
36 * @addtogroup Enums 40 * @addtogroup Enums
37 * @{ 41 * @{
38 */ 42 */
43
44 /**
45 * This enumeration contains mouse and keyboard event enumorators.
dmichael(do not use this one) 2011/02/08 17:04:38 Similarly maybe reword to take out 1 of the 'enum'
jond 2011/02/09 16:42:04 I changed to "constants." On 2011/02/08 17:04:38
46 */
39 typedef enum { 47 typedef enum {
40 PP_INPUTEVENT_TYPE_UNDEFINED = -1, 48 PP_INPUTEVENT_TYPE_UNDEFINED = -1,
41 PP_INPUTEVENT_TYPE_MOUSEDOWN = 0, // PP_InputEvent_Mouse 49 PP_INPUTEVENT_TYPE_MOUSEDOWN = 0, // PP_InputEvent_Mouse
42 PP_INPUTEVENT_TYPE_MOUSEUP = 1, // PP_InputEvent_Mouse 50 PP_INPUTEVENT_TYPE_MOUSEUP = 1, // PP_InputEvent_Mouse
43 PP_INPUTEVENT_TYPE_MOUSEMOVE = 2, // PP_InputEvent_Mouse 51 PP_INPUTEVENT_TYPE_MOUSEMOVE = 2, // PP_InputEvent_Mouse
44 PP_INPUTEVENT_TYPE_MOUSEENTER = 3, // PP_InputEvent_Mouse 52 PP_INPUTEVENT_TYPE_MOUSEENTER = 3, // PP_InputEvent_Mouse
45 PP_INPUTEVENT_TYPE_MOUSELEAVE = 4, // PP_InputEvent_Mouse 53 PP_INPUTEVENT_TYPE_MOUSELEAVE = 4, // PP_InputEvent_Mouse
46 PP_INPUTEVENT_TYPE_MOUSEWHEEL = 5, // PP_InputEvent_Wheel 54 PP_INPUTEVENT_TYPE_MOUSEWHEEL = 5, // PP_InputEvent_Wheel
47 PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6, // PP_InputEvent_Key 55 PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6, // PP_InputEvent_Key
48 PP_INPUTEVENT_TYPE_KEYDOWN = 7, // PP_InputEvent_Key 56 PP_INPUTEVENT_TYPE_KEYDOWN = 7, // PP_InputEvent_Key
49 PP_INPUTEVENT_TYPE_KEYUP = 8, // PP_InputEvent_Key 57 PP_INPUTEVENT_TYPE_KEYUP = 8, // PP_InputEvent_Key
50 PP_INPUTEVENT_TYPE_CHAR = 9, // PP_InputEvent_Character 58 PP_INPUTEVENT_TYPE_CHAR = 9, // PP_InputEvent_Character
51 PP_INPUTEVENT_TYPE_CONTEXTMENU = 10 // PP_InputEvent_Mouse 59 PP_INPUTEVENT_TYPE_CONTEXTMENU = 10 // PP_InputEvent_Mouse
52 } PP_InputEvent_Type; 60 } PP_InputEvent_Type;
53 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4); 61 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4);
54 /** 62 /**
55 * @} 63 * @}
56 */ 64 */
57 65
58 /** 66 /**
59 *
60 * @addtogroup Enums 67 * @addtogroup Enums
61 * @{ 68 * @{
62 */ 69 */
70
71 /**
72 * This enumeration contains modifier key event enumorators.
dmichael(do not use this one) 2011/02/08 17:04:38 Similar... and s/modifier key event/event modifie
jond 2011/02/09 16:42:04 Done.
jond 2011/02/09 16:42:04 Done.
73 */
63 typedef enum { 74 typedef enum {
64 PP_INPUTEVENT_MODIFIER_SHIFTKEY = 1 << 0, 75 PP_INPUTEVENT_MODIFIER_SHIFTKEY = 1 << 0,
65 PP_INPUTEVENT_MODIFIER_CONTROLKEY = 1 << 1, 76 PP_INPUTEVENT_MODIFIER_CONTROLKEY = 1 << 1,
66 PP_INPUTEVENT_MODIFIER_ALTKEY = 1 << 2, 77 PP_INPUTEVENT_MODIFIER_ALTKEY = 1 << 2,
67 PP_INPUTEVENT_MODIFIER_METAKEY = 1 << 3, 78 PP_INPUTEVENT_MODIFIER_METAKEY = 1 << 3,
68 PP_INPUTEVENT_MODIFIER_ISKEYPAD = 1 << 4, 79 PP_INPUTEVENT_MODIFIER_ISKEYPAD = 1 << 4,
69 PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT = 1 << 5, 80 PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT = 1 << 5,
70 PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN = 1 << 6, 81 PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN = 1 << 6,
71 PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7, 82 PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7,
72 PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN = 1 << 8, 83 PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN = 1 << 8,
73 PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9, 84 PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9,
74 PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10 85 PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10
75 } PP_InputEvent_Modifier; 86 } PP_InputEvent_Modifier;
76 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier, 4); 87 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier, 4);
77 /** 88 /**
78 * @} 89 * @}
79 */ 90 */
80 91
81 /** 92 /**
82 * @addtogroup Structs 93 * @addtogroup Structs
83 * @{ 94 * @{
84 */ 95 */
85 96
86 /** 97 /**
87 * An event representing a key up or down event. 98 * The PP_InputEvent_Key struct represents a key up or key down event.
88 * 99 *
89 * Key up and down events correspond to physical keys on the keyboard. The 100 * Key up and key down events correspond to physical keys on the keyboard. The
90 * actual character that the user typed (if any) will be delivered in a 101 * actual character that the user typed (if any) will be delivered in a
91 * "character" event. 102 * "character" event.
92 * 103 *
93 * If the user kills focus on the plugin while a key is down, you may not get 104 * If the user looses focus on the module while a key is down, a key up
dmichael(do not use this one) 2011/02/08 17:04:38 s/looses/loses
jond 2011/02/09 16:42:04 Done.
jond 2011/02/09 16:42:04 Done.
94 * a key up event. For example, if the plugin has focus and the user presses 105 * event might not occur. For example, if the module has focus and the user
95 * and holds shift, the plugin will see a "shift down" message. Then if they 106 * presses and holds the shift key, the module will see a "shift down" message.
96 * click elsewhere on the web page, the plugin focus will be lost and no more 107 * Then if the user clicks elsewhere on the web page, the module's focus will
97 * input events will be delivered. If you depend on getting key up events, you 108 * be lost and no more input events will be delivered.
98 * will also want to handle "lost focus" as the equivalent of "all keys up."
99 * 109 *
110 * If your module depends on receiving key up events, it should also handle
111 * "lost focus" as the equivalent of "all keys up."
100 */ 112 */
101 struct PP_InputEvent_Key { 113 struct PP_InputEvent_Key {
102 /** A combination of the EVENT_MODIFIER flags. */ 114 /** This value represents a combination of the EVENT_MODIFIER flags. */
dmichael(do not use this one) 2011/02/08 17:04:38 maybe should point out it's a bit field...
jond 2011/02/09 16:42:04 Done.
103 uint32_t modifier; 115 uint32_t modifier;
104 116
105 /** 117 /**
106 * The key code. 118 * The key code.
107 * 119 *
108 * TODO(brettw) define what these actually are. 120 * TODO(brettw) define what these actually are.
109 */ 121 */
110 uint32_t key_code; 122 uint32_t key_code;
111 }; 123 };
112 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Key, 8); 124 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Key, 8);
113 /** 125 /**
114 * @} 126 * @}
115 */ 127 */
116 128
117 /** 129 /**
118 * @addtogroup Structs 130 * @addtogroup Structs
119 * @{ 131 * @{
120 */ 132 */
121 133
122 /** 134 /**
123 * An event representing a typed character. 135 * The PP_InputEvent_Character struct represents a typed character event.
124 * 136 *
125 * Normally, the program will receive a key down event, followed by a character 137 * Normally, the program will receive a key down event, followed by a character
126 * event, followed by a key up event. The character event will have any 138 * event, followed by a key up event. The character event will have any
127 * modifier keys applied. Obvious examples are symbols, where Shift-5 gives you 139 * modifier keys applied. Obvious examples are symbols, where Shift-5 gives you
128 * a '%'. The key down and up events will give you the scan code for the "5" 140 * a '%'. The key down and up events will give you the scan code for the "5"
129 * key, and the character event will give you the '%' character. 141 * key, and the character event will give you the '%' character.
130 * 142 *
131 * You may not get a character event for all key down if the key doesn't 143 * You may not get a character event for all key down events if the key doesn't
132 * generate a character. Likewise, you may actually get multiple character 144 * generate a character. Likewise, you may actually get multiple character
133 * events in a row. For example, some locales have an accent key that modifies 145 * events in a row. For example, some locales have an accent key that modifies
134 * the next character typed. You might get this stream of events: accent down, 146 * the next character typed. You might get this stream of events: accent down,
135 * accent up (it didn't generate a character), letter key down, letter with 147 * accent up (it didn't generate a character), letter key down, letter with
136 * accent character event (it was modified by the previous accent key), letter 148 * accent character event (it was modified by the previous accent key), letter
137 * key up. If the letter can't be combined with the accent, like an umlaut and 149 * key up. If the letter can't be combined with the accent, like an umlaut and
138 * an 'R', the system might send unlaut down, umlaut up, 'R' key down, umlaut 150 * an 'R', the system might send unlaut down, umlaut up, 'R' key down, umlaut
139 * character ("whoops, I can't combine it with 'R', I better just send the raw 151 * character (can't combine it with 'R', so just send the raw unlaut so it
140 * unlaut so it isn't lost"), 'R' character event, 'R' key up. 152 * isn't lost"), 'R' character event, 'R' key up.
141 *
142 */ 153 */
143 struct PP_InputEvent_Character { 154 struct PP_InputEvent_Character {
144 /** A combination of the EVENT_MODIFIER flags. */ 155 /** A combination of the EVENT_MODIFIER flags. */
145 uint32_t modifier; 156 uint32_t modifier;
146 157
147 /** 158 /**
148 * The character the user typed, as a single null-terminated UTF-8 character. 159 * This value represents the typed character as a single null-terminated UTF-8
149 * Any unused bytes will be filled with null bytes. Since the maximum UTF-8 160 * character. Any unused bytes will be filled with null bytes. Since the
150 * character is 4 bytes, there will always be at least one null at the end 161 * maximum UTF-8 character is 4 bytes, there will always be at least one null
151 * so you can treat this as a null-termianted UTF-8 string. 162 * at the end so you can treat this as a null-termianted UTF-8 string.
152 */ 163 */
153 char text[5]; 164 char text[5];
154 }; 165 };
155 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Character, 12); 166 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Character, 12);
156 /** 167 /**
157 * @} 168 * @}
158 */ 169 */
159 170
160 /** 171 /**
161 * @addtogroup Structs 172 * @addtogroup Structs
162 * @{ 173 * @{
163 */ 174 */
164 175
165 /** Represents a mouse event for everything other than the mouse wheel. */ 176 /**
177 * The PP_InputEvent_Mouse struct represents all mouse events other except
dmichael(do not use this one) 2011/02/08 17:04:38 remove 'other'
jond 2011/02/09 16:42:04 Done.
178 * mouse wheel events.
179 */
166 struct PP_InputEvent_Mouse { 180 struct PP_InputEvent_Mouse {
167 /** A combination of the EVENT_MODIFIER flags. */ 181 /** This value represents a combination of the EVENT_MODIFIER flags. */
dmichael(do not use this one) 2011/02/08 17:04:38 as a bit field.
jond 2011/02/09 16:42:04 Done.
jond 2011/02/09 16:42:04 Done.
168 uint32_t modifier; 182 uint32_t modifier;
169 183
170 /** 184 /**
171 * Which button changed in the case of mouse down or up events. For mouse 185 * This value represents the button that changed for mouse down or up events.
172 * move, enter, and leave events, this will be PP_EVENT_MOUSEBUTTON_NONE. 186 * This value will be PP_EVENT_MOUSEBUTTON_NONE for mouse move, enter, and
187 * leave events.
173 */ 188 */
174 PP_InputEvent_MouseButton button; 189 PP_InputEvent_MouseButton button;
175 190
176 /** 191 /**
177 * The coordinates of the mouse when the event occurred. 192 * This values represents x coordinate of the mouse when the event
dmichael(do not use this one) 2011/02/08 17:04:38 s/x/the x/
jond 2011/02/09 16:42:04 Done.
jond 2011/02/09 16:42:04 Done.
193 * occurred.
178 * 194 *
179 * In most cases these coordinates will just be integers, but they may not 195 * In most, but not all, cases these coordinates will just be integers.
180 * be in some cases. For example, the plugin element might be arbitrarily 196 * For example, the plugin element might be arbitrarily scaled or transformed
181 * scaled or transformed in the DOM, and translating a mouse event into the 197 * in the DOM, and translating a mouse event into the coordinate space of the
182 * coordinate space of the plugin will give non-integer values. 198 * plugin will give non-integer values.
183 */ 199 */
184 float x; 200 float x;
201 /**
202 * This values represents y coordinate of the mouse when the event
dmichael(do not use this one) 2011/02/08 17:04:38 s/y/the y/
jond 2011/02/09 16:42:04 Done.
203 * occurred.
204 *
205 * In most, but not all, cases these coordinates will just be integers.
206 * For example, the plugin element might be arbitrarily scaled or transformed
207 * in the DOM, and translating a mouse event into the coordinate space of the
208 * plugin will give non-integer values.
209 */
185 float y; 210 float y;
186 211
187 /** TODO(brettw) figure out exactly what this means. */ 212 /** TODO(brettw) figure out exactly what this means. */
188 int32_t click_count; 213 int32_t click_count;
189 }; 214 };
190 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Mouse, 20); 215 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Mouse, 20);
191 /** 216 /**
192 * @} 217 * @}
193 */ 218 */
194 219
195 /** 220 /**
196 * @addtogroup Structs 221 * @addtogroup Structs
197 * @{ 222 * @{
198 */ 223 */
224
225 /**
226 * The PP_InputEvent_Wheel struct represents all mouse wheel events.
227 */
199 struct PP_InputEvent_Wheel { 228 struct PP_InputEvent_Wheel {
200 /** A combination of the EVENT_MODIFIER flags. */ 229 /** This value represents a combination of the EVENT_MODIFIER flags. */
201 uint32_t modifier; 230 uint32_t modifier;
202 231
232 /** This value represents */
dmichael(do not use this one) 2011/02/08 17:04:38 represents what? (I'm not totally clear on that my
dmichael(do not use this one) 2011/02/11 16:42:04 You missed these 'This value represents' things.
203 float delta_x; 233 float delta_x;
234
235 /** This value represents */
204 float delta_y; 236 float delta_y;
237
238 /** This value represents */
205 float wheel_ticks_x; 239 float wheel_ticks_x;
240
241 /** This value represents */
206 float wheel_ticks_y; 242 float wheel_ticks_y;
207 243
244 /** This value represents */
208 PP_Bool scroll_by_page; 245 PP_Bool scroll_by_page;
209 }; 246 };
210 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Wheel, 24); 247 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Wheel, 24);
211 /** 248 /**
212 * @} 249 * @}
213 */ 250 */
214 251
215 /** 252 /**
216 * 253 *
217 * @addtogroup Structs 254 * @addtogroup Structs
218 * @{ 255 * @{
219 */ 256 */
257
258 /**
259 * The PP_InputEvent struct represents all input events.
260 */
220 struct PP_InputEvent { 261 struct PP_InputEvent {
221 /** Identifies the type of the event. */ 262 /** This value represents the type of the event. */
222 PP_InputEvent_Type type; 263 PP_InputEvent_Type type;
223 264
224 /* Ensure the time_stamp is aligned on an 8-byte boundary relative to the 265 /** This value ensure the time_stamp is aligned on an 8-byte boundary
225 start of the struct. Some compilers align doubles on 8-byte boundaries 266 * relative to the start of the struct. Some compilers align doubles
226 for 32-bit x86, and some align on 4-byte boundaries. */ 267 * on 8-byte boundaries for 32-bit x86, and some align on 4-byte boundaries.
268 */
227 int32_t padding; 269 int32_t padding;
228 270
229 /** 271 /**
230 * When this event was generated. This is not relative to any particular 272 * This value represents the time that this event was generated. This value
231 * epoch, the most you can do is compare time stamps. 273 * is not relative to any particular epoch; the most you can do is compare
274 * time stamps.
232 */ 275 */
233 PP_TimeTicks time_stamp; 276 PP_TimeTicks time_stamp;
234 277
235 /** Event-specific data. */ 278 /** This value represents the event type and its specific data. */
236 union { 279 union {
237 struct PP_InputEvent_Key key; 280 struct PP_InputEvent_Key key;
238 struct PP_InputEvent_Character character; 281 struct PP_InputEvent_Character character;
239 struct PP_InputEvent_Mouse mouse; 282 struct PP_InputEvent_Mouse mouse;
240 struct PP_InputEvent_Wheel wheel; 283 struct PP_InputEvent_Wheel wheel;
241 284
242 /** 285 /**
243 * Allows new events to be added without changing the size of this 286 * This value allows new events to be added without changing the size of
244 * struct. 287 * this struct.
245 */ 288 */
246 char padding[64]; 289 char padding[64];
247 } u; 290 } u;
248 }; 291 };
249 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent, 80); 292 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent, 80);
250 /** 293 /**
251 * @} 294 * @}
252 */ 295 */
253 296
254 #endif /* PPAPI_C_PP_INPUT_EVENT_H_ */ 297 #endif /* PPAPI_C_PP_INPUT_EVENT_H_ */
OLDNEW
« no previous file with comments | « no previous file | ppapi/c/pp_stdint.h » ('j') | ppapi/c/pp_stdint.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698