[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 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 |
| 3 | * found in the LICENSE file. |
| 4 | */ |
| 5 | |
[email protected] | 49aa1387 | 2011-08-17 20:45:57 | [diff] [blame] | 6 | /* From ppb_input_event.idl modified Wed Aug 17 11:16:34 2011. */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 7 | |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 8 | #ifndef PPAPI_C_PPB_INPUT_EVENT_H_ |
| 9 | #define PPAPI_C_PPB_INPUT_EVENT_H_ |
| 10 | |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 11 | #include "ppapi/c/pp_bool.h" |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 12 | #include "ppapi/c/pp_instance.h" |
| 13 | #include "ppapi/c/pp_macros.h" |
| 14 | #include "ppapi/c/pp_point.h" |
| 15 | #include "ppapi/c/pp_resource.h" |
| 16 | #include "ppapi/c/pp_stdint.h" |
| 17 | #include "ppapi/c/pp_time.h" |
| 18 | #include "ppapi/c/pp_var.h" |
| 19 | |
[email protected] | 49aa1387 | 2011-08-17 20:45:57 | [diff] [blame] | 20 | #define PPB_INPUT_EVENT_INTERFACE_1_0 "PPB_InputEvent;1.0" |
| 21 | #define PPB_INPUT_EVENT_INTERFACE PPB_INPUT_EVENT_INTERFACE_1_0 |
| 22 | |
| 23 | #define PPB_MOUSE_INPUT_EVENT_INTERFACE_1_0 "PPB_MouseInputEvent;1.0" |
| 24 | #define PPB_MOUSE_INPUT_EVENT_INTERFACE PPB_MOUSE_INPUT_EVENT_INTERFACE_1_0 |
| 25 | |
| 26 | #define PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0 "PPB_WheelInputEvent;1.0" |
| 27 | #define PPB_WHEEL_INPUT_EVENT_INTERFACE PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0 |
| 28 | |
| 29 | #define PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0 "PPB_KeyboardInputEvent;1.0" |
| 30 | #define PPB_KEYBOARD_INPUT_EVENT_INTERFACE \ |
| 31 | PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0 |
| 32 | |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 33 | /** |
| 34 | * @file |
| 35 | * This file defines the Input Event interfaces. |
| 36 | */ |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 37 | |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * @addtogroup Enums |
| 41 | * @{ |
| 42 | */ |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 43 | /** |
| 44 | * This enumeration contains the types of input events. |
| 45 | */ |
| 46 | typedef enum { |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 47 | PP_INPUTEVENT_TYPE_UNDEFINED = -1, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 48 | /** |
| 49 | * Notification that a mouse button was pressed. |
| 50 | * |
| 51 | * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. |
| 52 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 53 | PP_INPUTEVENT_TYPE_MOUSEDOWN = 0, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 54 | /** |
| 55 | * Notification that a mouse button was released. |
| 56 | * |
| 57 | * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. |
| 58 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 59 | PP_INPUTEVENT_TYPE_MOUSEUP = 1, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 60 | /** |
| 61 | * Notification that a mouse button was moved when it is over the instance |
| 62 | * or dragged out of it. |
| 63 | * |
| 64 | * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. |
| 65 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 66 | PP_INPUTEVENT_TYPE_MOUSEMOVE = 2, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 67 | /** |
| 68 | * Notification that the mouse entered the instance's bounds. |
| 69 | * |
| 70 | * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. |
| 71 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 72 | PP_INPUTEVENT_TYPE_MOUSEENTER = 3, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 73 | /** |
| 74 | * Notification that a mouse left the instance's bounds. |
| 75 | * |
| 76 | * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. |
| 77 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 78 | PP_INPUTEVENT_TYPE_MOUSELEAVE = 4, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 79 | /** |
| 80 | * Notification that the scroll wheel was used. |
| 81 | * |
| 82 | * Register for this event using the PP_INPUTEVENT_CLASS_WHEEL class. |
| 83 | */ |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 84 | PP_INPUTEVENT_TYPE_WHEEL = 5, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 85 | /** |
| 86 | * Notification that a key transitioned from "up" to "down". |
| 87 | * TODO(brettw) differentiate from KEYDOWN. |
| 88 | * |
| 89 | * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class. |
| 90 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 91 | PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 92 | /** |
| 93 | * Notification that a key was pressed. This does not necessarily correspond |
| 94 | * to a character depending on the key and language. Use the |
| 95 | * PP_INPUTEVENT_TYPE_CHAR for character input. |
| 96 | * |
| 97 | * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class. |
| 98 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 99 | PP_INPUTEVENT_TYPE_KEYDOWN = 7, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 100 | /** |
| 101 | * Notification that a key was released. |
| 102 | * |
| 103 | * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class. |
| 104 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 105 | PP_INPUTEVENT_TYPE_KEYUP = 8, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 106 | /** |
| 107 | * Notification that a character was typed. Use this for text input. Key |
| 108 | * down events may generate 0, 1, or more than one character event depending |
| 109 | * on the key, locale, and operating system. |
| 110 | * |
| 111 | * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class. |
| 112 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 113 | PP_INPUTEVENT_TYPE_CHAR = 9, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 114 | /** |
| 115 | * TODO(brettw) when is this used? |
| 116 | * |
| 117 | * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class. |
| 118 | */ |
| 119 | PP_INPUTEVENT_TYPE_CONTEXTMENU = 10 |
| 120 | } PP_InputEvent_Type; |
| 121 | PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4); |
| 122 | |
| 123 | /** |
| 124 | * This enumeration contains event modifier constants. Each modifier is one |
| 125 | * bit. Retrieve the modifiers from an input event using the GetEventModifiers |
| 126 | * function on PPB_InputEvent. |
| 127 | */ |
| 128 | typedef enum { |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 129 | PP_INPUTEVENT_MODIFIER_SHIFTKEY = 1 << 0, |
| 130 | PP_INPUTEVENT_MODIFIER_CONTROLKEY = 1 << 1, |
| 131 | PP_INPUTEVENT_MODIFIER_ALTKEY = 1 << 2, |
| 132 | PP_INPUTEVENT_MODIFIER_METAKEY = 1 << 3, |
| 133 | PP_INPUTEVENT_MODIFIER_ISKEYPAD = 1 << 4, |
| 134 | PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT = 1 << 5, |
| 135 | PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN = 1 << 6, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 136 | PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7, |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 137 | PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN = 1 << 8, |
| 138 | PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9, |
| 139 | PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10 |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 140 | } PP_InputEvent_Modifier; |
| 141 | PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier, 4); |
| 142 | |
| 143 | /** |
| 144 | * This enumeration contains constants representing each mouse button. To get |
| 145 | * the mouse button for a mouse down or up event, use GetMouseButton on |
| 146 | * PPB_InputEvent. |
| 147 | */ |
| 148 | typedef enum { |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 149 | PP_INPUTEVENT_MOUSEBUTTON_NONE = -1, |
| 150 | PP_INPUTEVENT_MOUSEBUTTON_LEFT = 0, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 151 | PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1, |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 152 | PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2 |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 153 | } PP_InputEvent_MouseButton; |
| 154 | PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4); |
| 155 | |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 156 | typedef enum { |
| 157 | /** |
| 158 | * Request mouse input events. |
| 159 | * |
| 160 | * Normally you will request mouse events by calling RequestInputEvents(). |
| 161 | * The only use case for filtered events (via RequestFilteringInputEvents()) |
| 162 | * is for instances that have irregular outlines and you want to perform hit |
| 163 | * testing, which is very uncommon. Requesting non-filtered mouse events will |
| 164 | * lead to higher performance. |
| 165 | */ |
| 166 | PP_INPUTEVENT_CLASS_MOUSE = 1 << 0, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 167 | /** |
[email protected] | b599a9f | 2011-07-22 15:49:34 | [diff] [blame] | 168 | * Requests keyboard events. Often you will want to request filtered mode |
| 169 | * (via RequestFilteringInputEvents) for keyboard events so you can pass on |
| 170 | * events (by returning false) that you don't handle. For example, if you |
| 171 | * don't request filtered mode and the user pressed "Page Down" when your |
| 172 | * instance has focus, the page won't scroll which will be a poor experience. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 173 | * |
| 174 | * A small number of tab and window management commands like Alt-F4 are never |
| 175 | * sent to the page. You can not request these keyboard commands since it |
| 176 | * would allow pages to trap users on a page. |
| 177 | */ |
| 178 | PP_INPUTEVENT_CLASS_KEYBOARD = 1 << 1, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 179 | /** |
| 180 | * Identifies scroll wheel input event. Wheel events must be requested in |
| 181 | * filtering mode via RequestFilteringInputEvents(). This is because many |
| 182 | * wheel commands should be forwarded to the page. |
| 183 | * |
| 184 | * Most instances will not need this event. Consuming wheel events by |
| 185 | * returning true from your filtered event handler will prevent the user from |
| 186 | * scrolling the page when the mouse is over the instance which can be very |
| 187 | * annoying. |
| 188 | * |
| 189 | * If you handle wheel events (for example, you have a document viewer which |
| 190 | * the user can scroll), the recommended behavior is to return false only if |
| 191 | * the wheel event actually causes your document to scroll. When the user |
| 192 | * reaches the end of the document, return false to indicating that the event |
| 193 | * was not handled. This will then forward the event to the containing page |
| 194 | * for scrolling, producing the nested scrolling behavior users expect from |
| 195 | * frames in a page. |
| 196 | */ |
| 197 | PP_INPUTEVENT_CLASS_WHEEL = 1 << 2, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 198 | /** |
| 199 | * Identifies touch input events. |
| 200 | * |
| 201 | * Request touch events only if you intend to handle them. If the browser |
| 202 | * knows you do not need to handle touch events, it can handle them at a |
| 203 | * higher level and achieve higher performance. |
| 204 | */ |
| 205 | PP_INPUTEVENT_CLASS_TOUCH = 1 << 3, |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 206 | /** |
| 207 | * Identifies IME composition input events. |
| 208 | * |
| 209 | * Request this input event class if you allow on-the-spot IME input. |
| 210 | */ |
| 211 | PP_INPUTEVENT_CLASS_IME = 1 << 4 |
| 212 | } PP_InputEvent_Class; |
| 213 | PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Class, 4); |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 214 | /** |
| 215 | * @} |
| 216 | */ |
| 217 | |
| 218 | /** |
| 219 | * @addtogroup Interfaces |
| 220 | * @{ |
| 221 | */ |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 222 | /** |
| 223 | * The <code>PPB_InputEvent</code> interface contains pointers to several |
| 224 | * functions related to generic input events on the browser. |
| 225 | */ |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 226 | struct PPB_InputEvent { |
| 227 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 228 | * RequestInputEvent() requests that input events corresponding to the given |
| 229 | * input events are delivered to the instance. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 230 | * |
[email protected] | b599a9f | 2011-07-22 15:49:34 | [diff] [blame] | 231 | * It's recommended that you use RequestFilteringInputEvents() for keyboard |
| 232 | * events instead of this function so that you don't interfere with normal |
| 233 | * browser accelerators. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 234 | * |
| 235 | * By default, no input events are delivered. Call this function with the |
| 236 | * classes of events you are interested in to have them be delivered to |
| 237 | * the instance. Calling this function will override any previous setting for |
| 238 | * each specified class of input events (for example, if you previously |
| 239 | * called RequestFilteringInputEvents(), this function will set those events |
| 240 | * to non-filtering mode). |
| 241 | * |
| 242 | * Input events may have high overhead, so you should only request input |
| 243 | * events that your plugin will actually handle. For example, the browser may |
| 244 | * do optimizations for scroll or touch events that can be processed |
| 245 | * substantially faster if it knows there are no non-default receivers for |
| 246 | * that message. Requesting that such messages be delivered, even if they are |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 247 | * processed very quickly, may have a noticeable effect on the performance of |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 248 | * the page. |
| 249 | * |
| 250 | * When requesting input events through this function, the events will be |
| 251 | * delivered and <i>not</i> bubbled to the page. This means that even if you |
| 252 | * aren't interested in the message, no other parts of the page will get |
| 253 | * a crack at the message. |
| 254 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 255 | * <strong>Example:</strong> |
| 256 | * <code> |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 257 | * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE); |
| 258 | * RequestFilteringInputEvents(instance, |
| 259 | * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 260 | * </code> |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 261 | * |
| 262 | * @param instance The <code>PP_Instance</code> of the instance requesting |
| 263 | * the given events. |
| 264 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 265 | * @param event_classes A combination of flags from |
| 266 | * <code>PP_InputEvent_Class</code> that identifies the classes of events the |
| 267 | * instance is requesting. The flags are combined by logically ORing their |
| 268 | * values. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 269 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 270 | * @return <code>PP_OK</code> if the operation succeeded, |
| 271 | * <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or |
| 272 | * <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 273 | * illegal. In the case of an invalid bit, all valid bits will be applied |
| 274 | * and only the illegal bits will be ignored. The most common cause of a |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 275 | * <code>PP_ERROR_NOTSUPPORTED</code> return value is requesting keyboard |
| 276 | * events, these must use RequestFilteringInputEvents(). |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 277 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 278 | int32_t (*RequestInputEvents)(PP_Instance instance, uint32_t event_classes); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 279 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 280 | * RequestFilteringInputEvents() requests that input events corresponding to |
| 281 | * the given input events are delivered to the instance for filtering. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 282 | * |
| 283 | * By default, no input events are delivered. In most cases you would |
| 284 | * register to receive events by calling RequestInputEvents(). In some cases, |
| 285 | * however, you may wish to filter events such that they can be bubbled up |
| 286 | * to the DOM. In this case, register for those classes of events using |
[email protected] | b599a9f | 2011-07-22 15:49:34 | [diff] [blame] | 287 | * this function instead of RequestInputEvents(). |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 288 | * |
| 289 | * Filtering input events requires significantly more overhead than just |
| 290 | * delivering them to the instance. As such, you should only request |
| 291 | * filtering in those cases where it's absolutely necessary. The reason is |
| 292 | * that it requires the browser to stop and block for the instance to handle |
| 293 | * the input event, rather than sending the input event asynchronously. This |
| 294 | * can have significant overhead. |
| 295 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 296 | * <strong>Example:</strong> |
| 297 | * <code> |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 298 | * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE); |
| 299 | * RequestFilteringInputEvents(instance, |
| 300 | * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 301 | * </code> |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 302 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 303 | * @return <code>PP_OK</code> if the operation succeeded, |
| 304 | * <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or |
| 305 | * <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 306 | * illegal. In the case of an invalid bit, all valid bits will be applied |
| 307 | * and only the illegal bits will be ignored. |
| 308 | */ |
| 309 | int32_t (*RequestFilteringInputEvents)(PP_Instance instance, |
| 310 | uint32_t event_classes); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 311 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 312 | * ClearInputEventRequest() requests that input events corresponding to the |
| 313 | * given input classes no longer be delivered to the instance. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 314 | * |
| 315 | * By default, no input events are delivered. If you have previously |
| 316 | * requested input events via RequestInputEvents() or |
| 317 | * RequestFilteringInputEvents(), this function will unregister handling |
| 318 | * for the given instance. This will allow greater browser performance for |
| 319 | * those events. |
| 320 | * |
| 321 | * Note that you may still get some input events after clearing the flag if |
| 322 | * they were dispatched before the request was cleared. For example, if |
| 323 | * there are 3 mouse move events waiting to be delivered, and you clear the |
| 324 | * mouse event class during the processing of the first one, you'll still |
| 325 | * receive the next two. You just won't get more events generated. |
| 326 | * |
| 327 | * @param instance The <code>PP_Instance</code> of the instance requesting |
| 328 | * to no longer receive the given events. |
| 329 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 330 | * @param event_classes A combination of flags from |
| 331 | * <code>PP_InputEvent_Class</code> that identify the classes of events the |
| 332 | * instance is no longer interested in. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 333 | */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 334 | void (*ClearInputEventRequest)(PP_Instance instance, uint32_t event_classes); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 335 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 336 | * IsInputEvent() returns true if the given resource is a valid input event |
| 337 | * resource. |
| 338 | * |
| 339 | * @param[in] resource A <code>PP_Resource</code>. |
| 340 | * |
| 341 | * @return True if the given resource is a valid input event |
| 342 | * resource. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 343 | */ |
| 344 | PP_Bool (*IsInputEvent)(PP_Resource resource); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 345 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 346 | * GetType() returns the type of input event for the given input event |
| 347 | * resource. |
| 348 | * |
| 349 | * @param[in] resource A <code>PP_Resource</code> containing the input event. |
| 350 | * |
| 351 | * @return A <code>PP_InputEvent_Type</code> if its a valid input event or |
| 352 | * <code>PP_INPUTEVENT_TYPE_UNDEFINED</code> if the resource is invalid. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 353 | */ |
| 354 | PP_InputEvent_Type (*GetType)(PP_Resource event); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 355 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 356 | * GetTimeStamp() Returns the time that the event was generated. This will be |
| 357 | * before the current time since processing and dispatching the event has |
| 358 | * some overhead. Use this value to compare the times the user generated two |
| 359 | * events without being sensitive to variable processing time. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 360 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 361 | * @param[in] resource A <code>PP_Resource</code> containing the event. |
| 362 | * |
| 363 | * @return The return value is in time ticks, which is a monotonically |
| 364 | * increasing clock not related to the wall clock time. It will not change |
| 365 | * if the user changes their clock or daylight savings time starts, so can |
| 366 | * be reliably used to compare events. This means, however, that you can't |
| 367 | * correlate event times to a particular time of day on the system clock. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 368 | */ |
| 369 | PP_TimeTicks (*GetTimeStamp)(PP_Resource event); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 370 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 371 | * GetModifiers() returns a bitfield indicating which modifiers were down |
| 372 | * at the time of the event. This is a combination of the flags in the |
| 373 | * <code>PP_InputEvent_Modifier</code> enum. |
| 374 | * |
| 375 | * @param[in] resource A <code>PP_Resource</code> containing the input event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 376 | * |
| 377 | * @return The modifiers associated with the event, or 0 if the given |
| 378 | * resource is not a valid event resource. |
| 379 | */ |
| 380 | uint32_t (*GetModifiers)(PP_Resource event); |
| 381 | }; |
| 382 | |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 383 | /** |
| 384 | * The <code>PPB_MouseInputEvent</code> interface contains pointers to several |
| 385 | * functions related to mouse input events. |
| 386 | */ |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 387 | struct PPB_MouseInputEvent { |
| 388 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 389 | * Create() creates a mouse input event with the given parameters. Normally |
| 390 | * you will get a mouse event passed through the |
| 391 | * <code>HandleInputEvent</code> and will not need to create them, but some |
| 392 | * applications may want to create their own for internal use. The type must |
| 393 | * be one of the mouse event types. |
| 394 | * |
| 395 | * @param[in] instance The instance for which this event occurred. |
| 396 | * |
| 397 | * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of |
| 398 | * input event. |
| 399 | * |
| 400 | * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time |
| 401 | * when the event occurred. |
| 402 | * |
| 403 | * @param[in] modifiers A bit field combination of the |
| 404 | * <code>PP_InputEvent_Modifier</code> flags. |
| 405 | * |
| 406 | * @param[in] mouse_button The button that changed for mouse down or up |
| 407 | * events. This value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for |
| 408 | * mouse move, enter, and leave events. |
| 409 | * |
| 410 | * @param[in] mouse_position A <code>Point</code> containing the x and y |
| 411 | * position of the mouse when the event occurred. |
| 412 | * |
| 413 | * @return A <code>PP_Resource</code> containing the new mouse input event. |
[email protected] | aa0c865 | 2011-07-19 19:33:55 | [diff] [blame] | 414 | */ |
| 415 | PP_Resource (*Create)(PP_Instance instance, |
| 416 | PP_InputEvent_Type type, |
| 417 | PP_TimeTicks time_stamp, |
| 418 | uint32_t modifiers, |
| 419 | PP_InputEvent_MouseButton mouse_button, |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 420 | const struct PP_Point* mouse_position, |
[email protected] | aa0c865 | 2011-07-19 19:33:55 | [diff] [blame] | 421 | int32_t click_count); |
[email protected] | aa0c865 | 2011-07-19 19:33:55 | [diff] [blame] | 422 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 423 | * IsMouseInputEvent() determines if a resource is a mouse event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 424 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 425 | * @param[in] resource A <code>PP_Resource</code> containing the event. |
| 426 | * |
| 427 | * @return <code>PP_TRUE</code> if the given resource is a valid mouse input |
| 428 | * event, otherwise <code>PP_FALSE</code>. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 429 | */ |
| 430 | PP_Bool (*IsMouseInputEvent)(PP_Resource resource); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 431 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 432 | * GetButton() returns the mouse button that generated a mouse down or up |
| 433 | * event. |
| 434 | * |
| 435 | * @param[in] mouse_event A <code>PP_Resource</code> containing the mouse |
| 436 | * event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 437 | * |
| 438 | * @return The mouse button associated with mouse down and up events. This |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 439 | * value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for mouse move, |
| 440 | * enter, and leave events, and for all non-mouse events. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 441 | */ |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 442 | PP_InputEvent_MouseButton (*GetButton)(PP_Resource mouse_event); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 443 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 444 | * GetPosition() returns the pixel location of a mouse input event. |
| 445 | * |
| 446 | * @param[in] mouse_event A <code>PP_Resource</code> containing the mouse |
| 447 | * event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 448 | * |
| 449 | * @return The point associated with the mouse event, relative to the upper- |
| 450 | * left of the instance receiving the event. These values can be negative for |
| 451 | * mouse drags. The return value will be (0, 0) for non-mouse events. |
| 452 | */ |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 453 | struct PP_Point (*GetPosition)(PP_Resource mouse_event); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 454 | /** |
| 455 | * TODO(brettw) figure out exactly what this means. |
| 456 | */ |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 457 | int32_t (*GetClickCount)(PP_Resource mouse_event); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 458 | }; |
| 459 | |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 460 | /** |
| 461 | * The <code>PPB_WheelIputEvent</code> interface contains pointers to several |
| 462 | * functions related to wheel input events. |
| 463 | */ |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 464 | struct PPB_WheelInputEvent { |
| 465 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 466 | * Create() creates a wheel input event with the given parameters. Normally |
| 467 | * you will get a wheel event passed through the |
| 468 | * <code>HandleInputEvent</code> and will not need to create them, but some |
| 469 | * applications may want to create their own for internal use. |
| 470 | * |
| 471 | * @param[in] instance The instance for which this event occurred. |
| 472 | * |
| 473 | * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time |
| 474 | * when the event occurred. |
| 475 | * |
| 476 | * @param[in] modifiers A bit field combination of the |
| 477 | * <code>PP_InputEvent_Modifier</code> flags. |
| 478 | * |
| 479 | * @param[in] wheel_delta The scroll wheel's horizontal and vertical scroll |
| 480 | * amounts. |
| 481 | * |
| 482 | * @param[in] wheel_ticks The number of "clicks" of the scroll wheel that |
| 483 | * have produced the event. |
| 484 | * |
| 485 | * @param[in] scroll_by_page When true, the user is requesting to scroll |
| 486 | * by pages. When false, the user is requesting to scroll by lines. |
| 487 | * |
| 488 | * @return A <code>PP_Resource</code> containing the new wheel input event. |
[email protected] | aa0c865 | 2011-07-19 19:33:55 | [diff] [blame] | 489 | */ |
| 490 | PP_Resource (*Create)(PP_Instance instance, |
| 491 | PP_TimeTicks time_stamp, |
| 492 | uint32_t modifiers, |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 493 | const struct PP_FloatPoint* wheel_delta, |
| 494 | const struct PP_FloatPoint* wheel_ticks, |
[email protected] | aa0c865 | 2011-07-19 19:33:55 | [diff] [blame] | 495 | PP_Bool scroll_by_page); |
[email protected] | aa0c865 | 2011-07-19 19:33:55 | [diff] [blame] | 496 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 497 | * IsWheelInputEvent() determines if a resource is a wheel event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 498 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 499 | * @param[in] wheel_event A <code>PP_Resource</code> containing the event. |
| 500 | * |
| 501 | * @return <code>PP_TRUE</code> if the given resource is a valid wheel input |
| 502 | * event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 503 | */ |
| 504 | PP_Bool (*IsWheelInputEvent)(PP_Resource resource); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 505 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 506 | * GetDelta() returns the amount vertically and horizontally the user has |
| 507 | * requested to scroll by with their mouse wheel. A scroll down or to the |
| 508 | * right (where the content moves up or left) is represented as positive |
| 509 | * values, and a scroll up or to the left (where the content moves down or |
| 510 | * right) is represented as negative values. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 511 | * |
| 512 | * This amount is system dependent and will take into account the user's |
| 513 | * preferred scroll sensitivity and potentially also nonlinear acceleration |
| 514 | * based on the speed of the scrolling. |
| 515 | * |
| 516 | * Devices will be of varying resolution. Some mice with large detents will |
| 517 | * only generate integer scroll amounts. But fractional values are also |
| 518 | * possible, for example, on some trackpads and newer mice that don't have |
| 519 | * "clicks". |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 520 | * |
| 521 | * @param[in] wheel_event A <code>PP_Resource</code> containing the wheel |
| 522 | * event. |
| 523 | * |
| 524 | * @return The vertical and horizontal scroll values. The units are either in |
| 525 | * pixels (when scroll_by_page is false) or pages (when scroll_by_page is |
| 526 | * true). For example, y = -3 means scroll up 3 pixels when scroll_by_page |
| 527 | * is false, and scroll up 3 pages when scroll_by_page is true. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 528 | */ |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 529 | struct PP_FloatPoint (*GetDelta)(PP_Resource wheel_event); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 530 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 531 | * GetTicks() returns the number of "clicks" of the scroll wheel |
| 532 | * that have produced the event. The value may have system-specific |
| 533 | * acceleration applied to it, depending on the device. The positive and |
| 534 | * negative meanings are the same as for GetDelta(). |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 535 | * |
| 536 | * If you are scrolling, you probably want to use the delta values. These |
| 537 | * tick events can be useful if you aren't doing actual scrolling and don't |
| 538 | * want or pixel values. An example may be cycling between different items in |
| 539 | * a game. |
| 540 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 541 | * @param[in] wheel_event A <code>PP_Resource</code> containing the wheel |
| 542 | * event. |
| 543 | * |
| 544 | * @return The number of "clicks" of the scroll wheel. You may receive |
| 545 | * fractional values for the wheel ticks if the mouse wheel is high |
| 546 | * resolution or doesn't have "clicks". If your program wants discrete |
| 547 | * events (as in the "picking items" example) you should accumulate |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 548 | * fractional click values from multiple messages until the total value |
| 549 | * reaches positive or negative one. This should represent a similar amount |
| 550 | * of scrolling as for a mouse that has a discrete mouse wheel. |
| 551 | */ |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 552 | struct PP_FloatPoint (*GetTicks)(PP_Resource wheel_event); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 553 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 554 | * GetScrollByPage() indicates if the scroll delta x/y indicates pages or |
| 555 | * lines to scroll by. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 556 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 557 | * @param[in] wheel_event A <code>PP_Resource</code> containing the wheel |
| 558 | * event. |
| 559 | * |
| 560 | * @return <code>PP_TRUE</code> if the event is a wheel event and the user is |
| 561 | * scrolling by pages. <code>PP_FALSE</code> if not or if the resource is not |
| 562 | * a wheel event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 563 | */ |
| 564 | PP_Bool (*GetScrollByPage)(PP_Resource wheel_event); |
| 565 | }; |
| 566 | |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 567 | /** |
| 568 | * The <code>PPB_KeyboardInputEvent</code> interface contains pointers to |
| 569 | * several functions related to keyboard input events. |
| 570 | */ |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 571 | struct PPB_KeyboardInputEvent { |
| 572 | /** |
[email protected] | aa0c865 | 2011-07-19 19:33:55 | [diff] [blame] | 573 | * Creates a keyboard input event with the given parameters. Normally you |
| 574 | * will get a keyboard event passed through the HandleInputEvent and will not |
| 575 | * need to create them, but some applications may want to create their own |
| 576 | * for internal use. The type must be one of the keyboard event types. |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 577 | * |
| 578 | * @param[in] instance The instance for which this event occurred. |
| 579 | * |
| 580 | * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of |
| 581 | * input event. |
| 582 | * |
| 583 | * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time |
| 584 | * when the event occurred. |
| 585 | * |
| 586 | * @param[in] modifiers A bit field combination of the |
| 587 | * <code>PP_InputEvent_Modifier</code> flags. |
| 588 | * |
| 589 | * @param[in] key_code This value reflects the DOM KeyboardEvent |
| 590 | * <code>keyCode</code> field. Chrome populates this with the Windows-style |
| 591 | * Virtual Key code of the key. |
| 592 | * |
| 593 | * @param[in] character_text This value represents the typed character as a |
| 594 | * UTF-8 string. |
| 595 | * |
| 596 | * @return A <code>PP_Resource</code> containing the new keyboard input |
| 597 | * event. |
[email protected] | aa0c865 | 2011-07-19 19:33:55 | [diff] [blame] | 598 | */ |
| 599 | PP_Resource (*Create)(PP_Instance instance, |
| 600 | PP_InputEvent_Type type, |
| 601 | PP_TimeTicks time_stamp, |
| 602 | uint32_t modifiers, |
| 603 | uint32_t key_code, |
| 604 | struct PP_Var character_text); |
[email protected] | aa0c865 | 2011-07-19 19:33:55 | [diff] [blame] | 605 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 606 | * IsKeyboardInputEvent() determines if a resource is a keyboard event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 607 | * |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 608 | * @param[in] resource A <code>PP_Resource</code> containing the event. |
| 609 | * |
| 610 | * @return <code>PP_TRUE</code> if the given resource is a valid input event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 611 | */ |
| 612 | PP_Bool (*IsKeyboardInputEvent)(PP_Resource resource); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 613 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 614 | * GetKeyCode() returns the DOM keyCode field for the keyboard event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 615 | * Chrome populates this with the Windows-style Virtual Key code of the key. |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 616 | * |
| 617 | * @param[in] key_event A <code>PP_Resource</code> containing the keyboard |
| 618 | * event. |
| 619 | * |
| 620 | * @return The DOM keyCode field for the keyboard event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 621 | */ |
| 622 | uint32_t (*GetKeyCode)(PP_Resource key_event); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 623 | /** |
[email protected] | c078e9c | 2011-08-16 18:39:38 | [diff] [blame] | 624 | * GetCharacterText() returns the typed character as a UTF-8 string for the |
| 625 | * given character event. |
| 626 | * |
| 627 | * @param[in] character_event A <code>PP_Resource</code> containing the |
| 628 | * keyboard event. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 629 | * |
| 630 | * @return A string var representing a single typed character for character |
| 631 | * input events. For non-character input events the return value will be an |
| 632 | * undefined var. |
| 633 | */ |
| 634 | struct PP_Var (*GetCharacterText)(PP_Resource character_event); |
| 635 | }; |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 636 | /** |
| 637 | * @} |
| 638 | */ |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 639 | |
[email protected] | b2b420d7 | 2011-07-12 00:59:31 | [diff] [blame] | 640 | #endif /* PPAPI_C_PPB_INPUT_EVENT_H_ */ |
[email protected] | 9b37f480 | 2011-07-19 00:09:28 | [diff] [blame] | 641 | |