blob: 2ad6741e124668991554ee3f653450aae4732fd3 [file] [log] [blame]
[email protected]493d14212011-07-07 15:38:481/* 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]49aa13872011-08-17 20:45:576/* From ppb_input_event.idl modified Wed Aug 17 11:16:34 2011. */
[email protected]9b37f4802011-07-19 00:09:287
[email protected]493d14212011-07-07 15:38:488#ifndef PPAPI_C_PPB_INPUT_EVENT_H_
9#define PPAPI_C_PPB_INPUT_EVENT_H_
10
[email protected]9b37f4802011-07-19 00:09:2811#include "ppapi/c/pp_bool.h"
[email protected]493d14212011-07-07 15:38:4812#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]49aa13872011-08-17 20:45:5720#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]9b37f4802011-07-19 00:09:2833/**
34 * @file
35 * This file defines the Input Event interfaces.
36 */
[email protected]493d14212011-07-07 15:38:4837
[email protected]493d14212011-07-07 15:38:4838
39/**
40 * @addtogroup Enums
41 * @{
42 */
[email protected]493d14212011-07-07 15:38:4843/**
44 * This enumeration contains the types of input events.
45 */
46typedef enum {
[email protected]9b37f4802011-07-19 00:09:2847 PP_INPUTEVENT_TYPE_UNDEFINED = -1,
[email protected]493d14212011-07-07 15:38:4848 /**
49 * Notification that a mouse button was pressed.
50 *
51 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
52 */
[email protected]9b37f4802011-07-19 00:09:2853 PP_INPUTEVENT_TYPE_MOUSEDOWN = 0,
[email protected]493d14212011-07-07 15:38:4854 /**
55 * Notification that a mouse button was released.
56 *
57 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
58 */
[email protected]9b37f4802011-07-19 00:09:2859 PP_INPUTEVENT_TYPE_MOUSEUP = 1,
[email protected]493d14212011-07-07 15:38:4860 /**
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]9b37f4802011-07-19 00:09:2866 PP_INPUTEVENT_TYPE_MOUSEMOVE = 2,
[email protected]493d14212011-07-07 15:38:4867 /**
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]9b37f4802011-07-19 00:09:2872 PP_INPUTEVENT_TYPE_MOUSEENTER = 3,
[email protected]493d14212011-07-07 15:38:4873 /**
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]9b37f4802011-07-19 00:09:2878 PP_INPUTEVENT_TYPE_MOUSELEAVE = 4,
[email protected]493d14212011-07-07 15:38:4879 /**
80 * Notification that the scroll wheel was used.
81 *
82 * Register for this event using the PP_INPUTEVENT_CLASS_WHEEL class.
83 */
[email protected]d912c6982011-07-20 22:04:3284 PP_INPUTEVENT_TYPE_WHEEL = 5,
[email protected]493d14212011-07-07 15:38:4885 /**
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]9b37f4802011-07-19 00:09:2891 PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6,
[email protected]493d14212011-07-07 15:38:4892 /**
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]9b37f4802011-07-19 00:09:2899 PP_INPUTEVENT_TYPE_KEYDOWN = 7,
[email protected]493d14212011-07-07 15:38:48100 /**
101 * Notification that a key was released.
102 *
103 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
104 */
[email protected]9b37f4802011-07-19 00:09:28105 PP_INPUTEVENT_TYPE_KEYUP = 8,
[email protected]493d14212011-07-07 15:38:48106 /**
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]9b37f4802011-07-19 00:09:28113 PP_INPUTEVENT_TYPE_CHAR = 9,
[email protected]493d14212011-07-07 15:38:48114 /**
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;
121PP_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 */
128typedef enum {
[email protected]9b37f4802011-07-19 00:09:28129 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]493d14212011-07-07 15:38:48136 PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7,
[email protected]9b37f4802011-07-19 00:09:28137 PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN = 1 << 8,
138 PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9,
139 PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10
[email protected]493d14212011-07-07 15:38:48140} PP_InputEvent_Modifier;
141PP_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 */
148typedef enum {
[email protected]9b37f4802011-07-19 00:09:28149 PP_INPUTEVENT_MOUSEBUTTON_NONE = -1,
150 PP_INPUTEVENT_MOUSEBUTTON_LEFT = 0,
[email protected]493d14212011-07-07 15:38:48151 PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1,
[email protected]9b37f4802011-07-19 00:09:28152 PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2
[email protected]493d14212011-07-07 15:38:48153} PP_InputEvent_MouseButton;
154PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4);
155
[email protected]493d14212011-07-07 15:38:48156typedef 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]493d14212011-07-07 15:38:48167 /**
[email protected]b599a9f2011-07-22 15:49:34168 * 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]493d14212011-07-07 15:38:48173 *
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]493d14212011-07-07 15:38:48179 /**
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]493d14212011-07-07 15:38:48198 /**
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]493d14212011-07-07 15:38:48206 /**
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;
213PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Class, 4);
[email protected]9b37f4802011-07-19 00:09:28214/**
215 * @}
216 */
217
218/**
219 * @addtogroup Interfaces
220 * @{
221 */
[email protected]c078e9c2011-08-16 18:39:38222/**
223 * The <code>PPB_InputEvent</code> interface contains pointers to several
224 * functions related to generic input events on the browser.
225 */
[email protected]493d14212011-07-07 15:38:48226struct PPB_InputEvent {
227 /**
[email protected]c078e9c2011-08-16 18:39:38228 * RequestInputEvent() requests that input events corresponding to the given
229 * input events are delivered to the instance.
[email protected]493d14212011-07-07 15:38:48230 *
[email protected]b599a9f2011-07-22 15:49:34231 * 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]493d14212011-07-07 15:38:48234 *
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]c078e9c2011-08-16 18:39:38247 * processed very quickly, may have a noticeable effect on the performance of
[email protected]493d14212011-07-07 15:38:48248 * 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]c078e9c2011-08-16 18:39:38255 * <strong>Example:</strong>
256 * <code>
[email protected]493d14212011-07-07 15:38:48257 * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
258 * RequestFilteringInputEvents(instance,
259 * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
[email protected]c078e9c2011-08-16 18:39:38260 * </code>
[email protected]493d14212011-07-07 15:38:48261 *
262 * @param instance The <code>PP_Instance</code> of the instance requesting
263 * the given events.
264 *
[email protected]c078e9c2011-08-16 18:39:38265 * @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]493d14212011-07-07 15:38:48269 *
[email protected]c078e9c2011-08-16 18:39:38270 * @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]493d14212011-07-07 15:38:48273 * 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]c078e9c2011-08-16 18:39:38275 * <code>PP_ERROR_NOTSUPPORTED</code> return value is requesting keyboard
276 * events, these must use RequestFilteringInputEvents().
[email protected]493d14212011-07-07 15:38:48277 */
[email protected]9b37f4802011-07-19 00:09:28278 int32_t (*RequestInputEvents)(PP_Instance instance, uint32_t event_classes);
[email protected]493d14212011-07-07 15:38:48279 /**
[email protected]c078e9c2011-08-16 18:39:38280 * RequestFilteringInputEvents() requests that input events corresponding to
281 * the given input events are delivered to the instance for filtering.
[email protected]493d14212011-07-07 15:38:48282 *
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]b599a9f2011-07-22 15:49:34287 * this function instead of RequestInputEvents().
[email protected]493d14212011-07-07 15:38:48288 *
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]c078e9c2011-08-16 18:39:38296 * <strong>Example:</strong>
297 * <code>
[email protected]493d14212011-07-07 15:38:48298 * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
299 * RequestFilteringInputEvents(instance,
300 * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
[email protected]c078e9c2011-08-16 18:39:38301 * </code>
[email protected]493d14212011-07-07 15:38:48302 *
[email protected]c078e9c2011-08-16 18:39:38303 * @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]493d14212011-07-07 15:38:48306 * 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]493d14212011-07-07 15:38:48311 /**
[email protected]c078e9c2011-08-16 18:39:38312 * ClearInputEventRequest() requests that input events corresponding to the
313 * given input classes no longer be delivered to the instance.
[email protected]493d14212011-07-07 15:38:48314 *
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]c078e9c2011-08-16 18:39:38330 * @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]493d14212011-07-07 15:38:48333 */
[email protected]9b37f4802011-07-19 00:09:28334 void (*ClearInputEventRequest)(PP_Instance instance, uint32_t event_classes);
[email protected]493d14212011-07-07 15:38:48335 /**
[email protected]c078e9c2011-08-16 18:39:38336 * 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]493d14212011-07-07 15:38:48343 */
344 PP_Bool (*IsInputEvent)(PP_Resource resource);
[email protected]493d14212011-07-07 15:38:48345 /**
[email protected]c078e9c2011-08-16 18:39:38346 * 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]493d14212011-07-07 15:38:48353 */
354 PP_InputEvent_Type (*GetType)(PP_Resource event);
[email protected]493d14212011-07-07 15:38:48355 /**
[email protected]c078e9c2011-08-16 18:39:38356 * 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]493d14212011-07-07 15:38:48360 *
[email protected]c078e9c2011-08-16 18:39:38361 * @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]493d14212011-07-07 15:38:48368 */
369 PP_TimeTicks (*GetTimeStamp)(PP_Resource event);
[email protected]493d14212011-07-07 15:38:48370 /**
[email protected]c078e9c2011-08-16 18:39:38371 * 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]493d14212011-07-07 15:38:48376 *
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]c078e9c2011-08-16 18:39:38383/**
384 * The <code>PPB_MouseInputEvent</code> interface contains pointers to several
385 * functions related to mouse input events.
386 */
[email protected]493d14212011-07-07 15:38:48387struct PPB_MouseInputEvent {
388 /**
[email protected]c078e9c2011-08-16 18:39:38389 * 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]aa0c8652011-07-19 19:33:55414 */
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]d912c6982011-07-20 22:04:32420 const struct PP_Point* mouse_position,
[email protected]aa0c8652011-07-19 19:33:55421 int32_t click_count);
[email protected]aa0c8652011-07-19 19:33:55422 /**
[email protected]c078e9c2011-08-16 18:39:38423 * IsMouseInputEvent() determines if a resource is a mouse event.
[email protected]493d14212011-07-07 15:38:48424 *
[email protected]c078e9c2011-08-16 18:39:38425 * @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]493d14212011-07-07 15:38:48429 */
430 PP_Bool (*IsMouseInputEvent)(PP_Resource resource);
[email protected]493d14212011-07-07 15:38:48431 /**
[email protected]c078e9c2011-08-16 18:39:38432 * 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]493d14212011-07-07 15:38:48437 *
438 * @return The mouse button associated with mouse down and up events. This
[email protected]c078e9c2011-08-16 18:39:38439 * 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]493d14212011-07-07 15:38:48441 */
[email protected]d912c6982011-07-20 22:04:32442 PP_InputEvent_MouseButton (*GetButton)(PP_Resource mouse_event);
[email protected]493d14212011-07-07 15:38:48443 /**
[email protected]c078e9c2011-08-16 18:39:38444 * 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]493d14212011-07-07 15:38:48448 *
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]d912c6982011-07-20 22:04:32453 struct PP_Point (*GetPosition)(PP_Resource mouse_event);
[email protected]493d14212011-07-07 15:38:48454 /**
455 * TODO(brettw) figure out exactly what this means.
456 */
[email protected]d912c6982011-07-20 22:04:32457 int32_t (*GetClickCount)(PP_Resource mouse_event);
[email protected]493d14212011-07-07 15:38:48458};
459
[email protected]c078e9c2011-08-16 18:39:38460/**
461 * The <code>PPB_WheelIputEvent</code> interface contains pointers to several
462 * functions related to wheel input events.
463 */
[email protected]493d14212011-07-07 15:38:48464struct PPB_WheelInputEvent {
465 /**
[email protected]c078e9c2011-08-16 18:39:38466 * 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]aa0c8652011-07-19 19:33:55489 */
490 PP_Resource (*Create)(PP_Instance instance,
491 PP_TimeTicks time_stamp,
492 uint32_t modifiers,
[email protected]d912c6982011-07-20 22:04:32493 const struct PP_FloatPoint* wheel_delta,
494 const struct PP_FloatPoint* wheel_ticks,
[email protected]aa0c8652011-07-19 19:33:55495 PP_Bool scroll_by_page);
[email protected]aa0c8652011-07-19 19:33:55496 /**
[email protected]c078e9c2011-08-16 18:39:38497 * IsWheelInputEvent() determines if a resource is a wheel event.
[email protected]493d14212011-07-07 15:38:48498 *
[email protected]c078e9c2011-08-16 18:39:38499 * @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]493d14212011-07-07 15:38:48503 */
504 PP_Bool (*IsWheelInputEvent)(PP_Resource resource);
[email protected]493d14212011-07-07 15:38:48505 /**
[email protected]c078e9c2011-08-16 18:39:38506 * 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]493d14212011-07-07 15:38:48511 *
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]c078e9c2011-08-16 18:39:38520 *
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]493d14212011-07-07 15:38:48528 */
[email protected]d912c6982011-07-20 22:04:32529 struct PP_FloatPoint (*GetDelta)(PP_Resource wheel_event);
[email protected]493d14212011-07-07 15:38:48530 /**
[email protected]c078e9c2011-08-16 18:39:38531 * 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]493d14212011-07-07 15:38:48535 *
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]c078e9c2011-08-16 18:39:38541 * @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]493d14212011-07-07 15:38:48548 * 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]d912c6982011-07-20 22:04:32552 struct PP_FloatPoint (*GetTicks)(PP_Resource wheel_event);
[email protected]493d14212011-07-07 15:38:48553 /**
[email protected]c078e9c2011-08-16 18:39:38554 * GetScrollByPage() indicates if the scroll delta x/y indicates pages or
555 * lines to scroll by.
[email protected]493d14212011-07-07 15:38:48556 *
[email protected]c078e9c2011-08-16 18:39:38557 * @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]493d14212011-07-07 15:38:48563 */
564 PP_Bool (*GetScrollByPage)(PP_Resource wheel_event);
565};
566
[email protected]c078e9c2011-08-16 18:39:38567/**
568 * The <code>PPB_KeyboardInputEvent</code> interface contains pointers to
569 * several functions related to keyboard input events.
570 */
[email protected]493d14212011-07-07 15:38:48571struct PPB_KeyboardInputEvent {
572 /**
[email protected]aa0c8652011-07-19 19:33:55573 * 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]c078e9c2011-08-16 18:39:38577 *
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]aa0c8652011-07-19 19:33:55598 */
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]aa0c8652011-07-19 19:33:55605 /**
[email protected]c078e9c2011-08-16 18:39:38606 * IsKeyboardInputEvent() determines if a resource is a keyboard event.
[email protected]493d14212011-07-07 15:38:48607 *
[email protected]c078e9c2011-08-16 18:39:38608 * @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]493d14212011-07-07 15:38:48611 */
612 PP_Bool (*IsKeyboardInputEvent)(PP_Resource resource);
[email protected]493d14212011-07-07 15:38:48613 /**
[email protected]c078e9c2011-08-16 18:39:38614 * GetKeyCode() returns the DOM keyCode field for the keyboard event.
[email protected]493d14212011-07-07 15:38:48615 * Chrome populates this with the Windows-style Virtual Key code of the key.
[email protected]c078e9c2011-08-16 18:39:38616 *
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]493d14212011-07-07 15:38:48621 */
622 uint32_t (*GetKeyCode)(PP_Resource key_event);
[email protected]493d14212011-07-07 15:38:48623 /**
[email protected]c078e9c2011-08-16 18:39:38624 * 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]493d14212011-07-07 15:38:48629 *
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]9b37f4802011-07-19 00:09:28636/**
637 * @}
638 */
[email protected]493d14212011-07-07 15:38:48639
[email protected]b2b420d72011-07-12 00:59:31640#endif /* PPAPI_C_PPB_INPUT_EVENT_H_ */
[email protected]9b37f4802011-07-19 00:09:28641