ppb_input_event.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
1/* Copyright (c) 2012 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
6/* From ppb_input_event.idl modified Mon Nov 26 19:51:21 2012. */
7
8#ifndef PPAPI_C_PPB_INPUT_EVENT_H_
9#define PPAPI_C_PPB_INPUT_EVENT_H_
10
11#include "ppapi/c/pp_bool.h"
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_touch_point.h"
19#include "ppapi/c/pp_var.h"
20
21#define PPB_INPUT_EVENT_INTERFACE_1_0 "PPB_InputEvent;1.0"
22#define PPB_INPUT_EVENT_INTERFACE PPB_INPUT_EVENT_INTERFACE_1_0
23
24#define PPB_MOUSE_INPUT_EVENT_INTERFACE_1_0 "PPB_MouseInputEvent;1.0"
25#define PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1 "PPB_MouseInputEvent;1.1"
26#define PPB_MOUSE_INPUT_EVENT_INTERFACE PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1
27
28#define PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0 "PPB_WheelInputEvent;1.0"
29#define PPB_WHEEL_INPUT_EVENT_INTERFACE PPB_WHEEL_INPUT_EVENT_INTERFACE_1_0
30
31#define PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0 "PPB_KeyboardInputEvent;1.0"
32#define PPB_KEYBOARD_INPUT_EVENT_INTERFACE \
33    PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_0
34
35#define PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0 "PPB_TouchInputEvent;1.0"
36#define PPB_TOUCH_INPUT_EVENT_INTERFACE PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0
37
38/**
39 * @file
40 * This file defines the Input Event interfaces.
41 */
42
43
44/**
45 * @addtogroup Enums
46 * @{
47 */
48/**
49 * This enumeration contains the types of input events.
50 */
51typedef enum {
52  PP_INPUTEVENT_TYPE_UNDEFINED = -1,
53  /**
54   * Notification that a mouse button was pressed.
55   *
56   * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
57   */
58  PP_INPUTEVENT_TYPE_MOUSEDOWN = 0,
59  /**
60   * Notification that a mouse button was released.
61   *
62   * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
63   */
64  PP_INPUTEVENT_TYPE_MOUSEUP = 1,
65  /**
66   * Notification that a mouse button was moved when it is over the instance
67   * or dragged out of it.
68   *
69   * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
70   */
71  PP_INPUTEVENT_TYPE_MOUSEMOVE = 2,
72  /**
73   * Notification that the mouse entered the instance's bounds.
74   *
75   * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
76   */
77  PP_INPUTEVENT_TYPE_MOUSEENTER = 3,
78  /**
79   * Notification that a mouse left the instance's bounds.
80   *
81   * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
82   */
83  PP_INPUTEVENT_TYPE_MOUSELEAVE = 4,
84  /**
85   * Notification that the scroll wheel was used.
86   *
87   * Register for this event using the PP_INPUTEVENT_CLASS_WHEEL class.
88   */
89  PP_INPUTEVENT_TYPE_WHEEL = 5,
90  /**
91   * Notification that a key transitioned from "up" to "down".
92   *
93   * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
94   */
95  /*
96   * TODO(brettw) differentiate from KEYDOWN.
97   */
98  PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6,
99  /**
100   * Notification that a key was pressed. This does not necessarily correspond
101   * to a character depending on the key and language. Use the
102   * PP_INPUTEVENT_TYPE_CHAR for character input.
103   *
104   * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
105   */
106  PP_INPUTEVENT_TYPE_KEYDOWN = 7,
107  /**
108   * Notification that a key was released.
109   *
110   * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
111   */
112  PP_INPUTEVENT_TYPE_KEYUP = 8,
113  /**
114   * Notification that a character was typed. Use this for text input. Key
115   * down events may generate 0, 1, or more than one character event depending
116   * on the key, locale, and operating system.
117   *
118   * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
119   */
120  PP_INPUTEVENT_TYPE_CHAR = 9,
121  /**
122   * Notification that a context menu should be shown.
123   *
124   * This message will be sent when the user right-clicks or performs another
125   * OS-specific mouse command that should open a context menu. When this event
126   * is delivered depends on the system, on some systems (Mac) it will
127   * delivered after the mouse down event, and on others (Windows) it will be
128   * delivered after the mouse up event.
129   *
130   * You will always get the normal mouse events. For example, you may see
131   * MOUSEDOWN,CONTEXTMENU,MOUSEUP or MOUSEDOWN,MOUSEUP,CONTEXTMENU.
132   *
133   * The return value from the event handler determines if the context menu
134   * event will be passed to the page when you are using filtered input events
135   * (via RequestFilteringInputEvents()). In non-filtering mode the event will
136   * never be propagated and no context menu will be displayed. If you are
137   * handling mouse events in filtering mode, you may want to return true from
138   * this event even if you do not support a context menu to suppress the
139   * default one.
140   *
141   * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
142   */
143  PP_INPUTEVENT_TYPE_CONTEXTMENU = 10,
144  /**
145   * Notification that an input method composition process has just started.
146   *
147   * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
148   */
149  PP_INPUTEVENT_TYPE_IME_COMPOSITION_START = 11,
150  /**
151   * Notification that the input method composition string is updated.
152   *
153   * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
154   */
155  PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE = 12,
156  /**
157   * Notification that an input method composition process has completed.
158   *
159   * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
160   */
161  PP_INPUTEVENT_TYPE_IME_COMPOSITION_END = 13,
162  /**
163   * Notification that an input method committed a string.
164   *
165   * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
166   */
167  PP_INPUTEVENT_TYPE_IME_TEXT = 14,
168  /**
169   * Notification that a finger was placed on a touch-enabled device.
170   *
171   * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
172   */
173  PP_INPUTEVENT_TYPE_TOUCHSTART = 15,
174  /**
175   * Notification that a finger was moved on a touch-enabled device.
176   *
177   * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
178   */
179  PP_INPUTEVENT_TYPE_TOUCHMOVE = 16,
180  /**
181   * Notification that a finger was released on a touch-enabled device.
182   *
183   * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
184   */
185  PP_INPUTEVENT_TYPE_TOUCHEND = 17,
186  /**
187   * Notification that a touch event was canceled.
188   *
189   * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
190   */
191  PP_INPUTEVENT_TYPE_TOUCHCANCEL = 18
192} PP_InputEvent_Type;
193PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4);
194
195/**
196 * This enumeration contains event modifier constants. Each modifier is one
197 * bit. Retrieve the modifiers from an input event using the GetEventModifiers
198 * function on PPB_InputEvent.
199 */
200typedef enum {
201  PP_INPUTEVENT_MODIFIER_SHIFTKEY = 1 << 0,
202  PP_INPUTEVENT_MODIFIER_CONTROLKEY = 1 << 1,
203  PP_INPUTEVENT_MODIFIER_ALTKEY = 1 << 2,
204  PP_INPUTEVENT_MODIFIER_METAKEY = 1 << 3,
205  PP_INPUTEVENT_MODIFIER_ISKEYPAD = 1 << 4,
206  PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT = 1 << 5,
207  PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN = 1 << 6,
208  PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7,
209  PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN = 1 << 8,
210  PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9,
211  PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10,
212  PP_INPUTEVENT_MODIFIER_ISLEFT = 1 << 11,
213  PP_INPUTEVENT_MODIFIER_ISRIGHT = 1 << 12
214} PP_InputEvent_Modifier;
215PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier, 4);
216
217/**
218 * This enumeration contains constants representing each mouse button. To get
219 * the mouse button for a mouse down or up event, use GetMouseButton on
220 * PPB_InputEvent.
221 */
222typedef enum {
223  PP_INPUTEVENT_MOUSEBUTTON_NONE = -1,
224  PP_INPUTEVENT_MOUSEBUTTON_LEFT = 0,
225  PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1,
226  PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2
227} PP_InputEvent_MouseButton;
228PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4);
229
230typedef enum {
231  /**
232   * Request mouse input events.
233   *
234   * Normally you will request mouse events by calling RequestInputEvents().
235   * The only use case for filtered events (via RequestFilteringInputEvents())
236   * is for instances that have irregular outlines and you want to perform hit
237   * testing, which is very uncommon. Requesting non-filtered mouse events will
238   * lead to higher performance.
239   */
240  PP_INPUTEVENT_CLASS_MOUSE = 1 << 0,
241  /**
242   * Requests keyboard events. Often you will want to request filtered mode
243   * (via RequestFilteringInputEvents) for keyboard events so you can pass on
244   * events (by returning false) that you don't handle. For example, if you
245   * don't request filtered mode and the user pressed "Page Down" when your
246   * instance has focus, the page won't scroll which will be a poor experience.
247   *
248   * A small number of tab and window management commands like Alt-F4 are never
249   * sent to the page. You can not request these keyboard commands since it
250   * would allow pages to trap users on a page.
251   */
252  PP_INPUTEVENT_CLASS_KEYBOARD = 1 << 1,
253  /**
254   * Identifies scroll wheel input event. Wheel events must be requested in
255   * filtering mode via RequestFilteringInputEvents(). This is because many
256   * wheel commands should be forwarded to the page.
257   *
258   * Most instances will not need this event. Consuming wheel events by
259   * returning true from your filtered event handler will prevent the user from
260   * scrolling the page when the mouse is over the instance which can be very
261   * annoying.
262   *
263   * If you handle wheel events (for example, you have a document viewer which
264   * the user can scroll), the recommended behavior is to return false only if
265   * the wheel event actually causes your document to scroll. When the user
266   * reaches the end of the document, return false to indicating that the event
267   * was not handled. This will then forward the event to the containing page
268   * for scrolling, producing the nested scrolling behavior users expect from
269   * frames in a page.
270   */
271  PP_INPUTEVENT_CLASS_WHEEL = 1 << 2,
272  /**
273   * Identifies touch input events.
274   *
275   * Request touch events only if you intend to handle them. If the browser
276   * knows you do not need to handle touch events, it can handle them at a
277   * higher level and achieve higher performance. If the plugin does not
278   * register for touch-events, then it will receive synthetic mouse events that
279   * are generated from the touch events (e.g. mouse-down for touch-start,
280   * mouse-move for touch-move (with left-button down), and mouse-up for
281   * touch-end. If the plugin does register for touch events, then the synthetic
282   * mouse events are not created.
283   */
284  PP_INPUTEVENT_CLASS_TOUCH = 1 << 3,
285  /**
286   * Identifies IME composition input events.
287   *
288   * Request this input event class if you allow on-the-spot IME input.
289   */
290  PP_INPUTEVENT_CLASS_IME = 1 << 4
291} PP_InputEvent_Class;
292PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Class, 4);
293/**
294 * @}
295 */
296
297/**
298 * @addtogroup Interfaces
299 * @{
300 */
301/**
302 * The <code>PPB_InputEvent</code> interface contains pointers to several
303 * functions related to generic input events on the browser.
304 */
305struct PPB_InputEvent_1_0 {
306  /**
307   * RequestInputEvent() requests that input events corresponding to the given
308   * input events are delivered to the instance.
309   *
310   * It's recommended that you use RequestFilteringInputEvents() for keyboard
311   * events instead of this function so that you don't interfere with normal
312   * browser accelerators.
313   *
314   * By default, no input events are delivered. Call this function with the
315   * classes of events you are interested in to have them be delivered to
316   * the instance. Calling this function will override any previous setting for
317   * each specified class of input events (for example, if you previously
318   * called RequestFilteringInputEvents(), this function will set those events
319   * to non-filtering mode).
320   *
321   * Input events may have high overhead, so you should only request input
322   * events that your plugin will actually handle. For example, the browser may
323   * do optimizations for scroll or touch events that can be processed
324   * substantially faster if it knows there are no non-default receivers for
325   * that message. Requesting that such messages be delivered, even if they are
326   * processed very quickly, may have a noticeable effect on the performance of
327   * the page.
328   *
329   * Note that synthetic mouse events will be generated from touch events if
330   * (and only if) the you do not request touch events.
331   *
332   * When requesting input events through this function, the events will be
333   * delivered and <i>not</i> bubbled to the page. This means that even if you
334   * aren't interested in the message, no other parts of the page will get
335   * a crack at the message.
336   *
337   * <strong>Example:</strong>
338   * <code>
339   *   RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
340   *   RequestFilteringInputEvents(instance,
341   *       PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
342   * </code>
343   *
344   * @param instance The <code>PP_Instance</code> of the instance requesting
345   * the given events.
346   *
347   * @param event_classes A combination of flags from
348   * <code>PP_InputEvent_Class</code> that identifies the classes of events the
349   * instance is requesting. The flags are combined by logically ORing their
350   * values.
351   *
352   * @return <code>PP_OK</code> if the operation succeeded,
353   * <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or
354   * <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were
355   * illegal. In the case of an invalid bit, all valid bits will be applied
356   * and only the illegal bits will be ignored. The most common cause of a
357   * <code>PP_ERROR_NOTSUPPORTED</code> return value is requesting keyboard
358   * events, these must use RequestFilteringInputEvents().
359   */
360  int32_t (*RequestInputEvents)(PP_Instance instance, uint32_t event_classes);
361  /**
362   * RequestFilteringInputEvents() requests that input events corresponding to
363   * the given input events are delivered to the instance for filtering.
364   *
365   * By default, no input events are delivered. In most cases you would
366   * register to receive events by calling RequestInputEvents(). In some cases,
367   * however, you may wish to filter events such that they can be bubbled up
368   * to the DOM. In this case, register for those classes of events using
369   * this function instead of RequestInputEvents().
370   *
371   * Filtering input events requires significantly more overhead than just
372   * delivering them to the instance. As such, you should only request
373   * filtering in those cases where it's absolutely necessary. The reason is
374   * that it requires the browser to stop and block for the instance to handle
375   * the input event, rather than sending the input event asynchronously. This
376   * can have significant overhead.
377   *
378   * <strong>Example:</strong>
379   * <code>
380   *   RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
381   *   RequestFilteringInputEvents(instance,
382   *       PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
383   * </code>
384   *
385   * @return <code>PP_OK</code> if the operation succeeded,
386   * <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or
387   * <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were
388   * illegal. In the case of an invalid bit, all valid bits will be applied
389   * and only the illegal bits will be ignored.
390   */
391  int32_t (*RequestFilteringInputEvents)(PP_Instance instance,
392                                         uint32_t event_classes);
393  /**
394   * ClearInputEventRequest() requests that input events corresponding to the
395   * given input classes no longer be delivered to the instance.
396   *
397   * By default, no input events are delivered. If you have previously
398   * requested input events via RequestInputEvents() or
399   * RequestFilteringInputEvents(), this function will unregister handling
400   * for the given instance. This will allow greater browser performance for
401   * those events.
402   *
403   * Note that you may still get some input events after clearing the flag if
404   * they were dispatched before the request was cleared. For example, if
405   * there are 3 mouse move events waiting to be delivered, and you clear the
406   * mouse event class during the processing of the first one, you'll still
407   * receive the next two. You just won't get more events generated.
408   *
409   * @param instance The <code>PP_Instance</code> of the instance requesting
410   * to no longer receive the given events.
411   *
412   * @param event_classes A combination of flags from
413   * <code>PP_InputEvent_Class</code> that identify the classes of events the
414   * instance is no longer interested in.
415   */
416  void (*ClearInputEventRequest)(PP_Instance instance, uint32_t event_classes);
417  /**
418   * IsInputEvent() returns true if the given resource is a valid input event
419   * resource.
420   *
421   * @param[in] resource A <code>PP_Resource</code> corresponding to a generic
422   * resource.
423   *
424   * @return <code>PP_TRUE</code> if the given resource is a valid input event
425   * resource.
426   */
427  PP_Bool (*IsInputEvent)(PP_Resource resource);
428  /**
429   * GetType() returns the type of input event for the given input event
430   * resource.
431   *
432   * @param[in] resource A <code>PP_Resource</code> corresponding to an input
433   * event.
434   *
435   * @return A <code>PP_InputEvent_Type</code> if its a valid input event or
436   * <code>PP_INPUTEVENT_TYPE_UNDEFINED</code> if the resource is invalid.
437   */
438  PP_InputEvent_Type (*GetType)(PP_Resource event);
439  /**
440   * GetTimeStamp() Returns the time that the event was generated. This will be
441   *  before the current time since processing and dispatching the event has
442   * some overhead. Use this value to compare the times the user generated two
443   * events without being sensitive to variable processing time.
444   *
445   * @param[in] resource A <code>PP_Resource</code> corresponding to the event.
446   *
447   * @return The return value is in time ticks, which is a monotonically
448   * increasing clock not related to the wall clock time. It will not change
449   * if the user changes their clock or daylight savings time starts, so can
450   * be reliably used to compare events. This means, however, that you can't
451   * correlate event times to a particular time of day on the system clock.
452   */
453  PP_TimeTicks (*GetTimeStamp)(PP_Resource event);
454  /**
455   * GetModifiers() returns a bitfield indicating which modifiers were down
456   * at the time of the event. This is a combination of the flags in the
457   * <code>PP_InputEvent_Modifier</code> enum.
458   *
459   * @param[in] resource A <code>PP_Resource</code> corresponding to an input
460   * event.
461   *
462   * @return The modifiers associated with the event, or 0 if the given
463   * resource is not a valid event resource.
464   */
465  uint32_t (*GetModifiers)(PP_Resource event);
466};
467
468typedef struct PPB_InputEvent_1_0 PPB_InputEvent;
469
470/**
471 * The <code>PPB_MouseInputEvent</code> interface contains pointers to several
472 * functions related to mouse input events.
473 */
474struct PPB_MouseInputEvent_1_1 {
475  /**
476   * Create() creates a mouse input event with the given parameters. Normally
477   * you will get a mouse event passed through the
478   * <code>HandleInputEvent</code> and will not need to create them, but some
479   * applications may want to create their own for internal use. The type must
480   * be one of the mouse event types.
481   *
482   * @param[in] instance The instance for which this event occurred.
483   *
484   * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
485   * input event.
486   *
487   * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
488   * when the event occurred.
489   *
490   * @param[in] modifiers A bit field combination of the
491   * <code>PP_InputEvent_Modifier</code> flags.
492   *
493   * @param[in] mouse_button The button that changed for mouse down or up
494   * events. This value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for
495   * mouse move, enter, and leave events.
496   *
497   * @param[in] mouse_position A <code>Point</code> containing the x and y
498   * position of the mouse when the event occurred.
499   *
500   * @param[in] mouse_movement The change in position of the mouse.
501   *
502   * @return A <code>PP_Resource</code> containing the new mouse input event.
503   */
504  PP_Resource (*Create)(PP_Instance instance,
505                        PP_InputEvent_Type type,
506                        PP_TimeTicks time_stamp,
507                        uint32_t modifiers,
508                        PP_InputEvent_MouseButton mouse_button,
509                        const struct PP_Point* mouse_position,
510                        int32_t click_count,
511                        const struct PP_Point* mouse_movement);
512  /**
513   * IsMouseInputEvent() determines if a resource is a mouse event.
514   *
515   * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
516   *
517   * @return <code>PP_TRUE</code> if the given resource is a valid mouse input
518   * event, otherwise <code>PP_FALSE</code>.
519   */
520  PP_Bool (*IsMouseInputEvent)(PP_Resource resource);
521  /**
522   * GetButton() returns the mouse button that generated a mouse down or up
523   * event.
524   *
525   * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
526   * mouse event.
527   *
528   * @return The mouse button associated with mouse down and up events. This
529   * value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for mouse move,
530   * enter, and leave events, and for all non-mouse events.
531   */
532  PP_InputEvent_MouseButton (*GetButton)(PP_Resource mouse_event);
533  /**
534   * GetPosition() returns the pixel location of a mouse input event. When
535   * the mouse is locked, it returns the last known mouse position just as
536   * mouse lock was entered.
537   *
538   * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
539   * mouse event.
540   *
541   * @return The point associated with the mouse event, relative to the upper-
542   * left of the instance receiving the event. These values can be negative for
543   * mouse drags. The return value will be (0, 0) for non-mouse events.
544   */
545  struct PP_Point (*GetPosition)(PP_Resource mouse_event);
546  /*
547   * TODO(brettw) figure out exactly what this means.
548   */
549  int32_t (*GetClickCount)(PP_Resource mouse_event);
550  /**
551   * Returns the change in position of the mouse. When the mouse is locked,
552   * although the mouse position doesn't actually change, this function
553   * still provides movement information, which indicates what the change in
554   * position would be had the mouse not been locked.
555   *
556   * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
557   * mouse event.
558   *
559   * @return The change in position of the mouse, relative to the previous
560   * position.
561   */
562  struct PP_Point (*GetMovement)(PP_Resource mouse_event);
563};
564
565typedef struct PPB_MouseInputEvent_1_1 PPB_MouseInputEvent;
566
567struct PPB_MouseInputEvent_1_0 {
568  PP_Resource (*Create)(PP_Instance instance,
569                        PP_InputEvent_Type type,
570                        PP_TimeTicks time_stamp,
571                        uint32_t modifiers,
572                        PP_InputEvent_MouseButton mouse_button,
573                        const struct PP_Point* mouse_position,
574                        int32_t click_count);
575  PP_Bool (*IsMouseInputEvent)(PP_Resource resource);
576  PP_InputEvent_MouseButton (*GetButton)(PP_Resource mouse_event);
577  struct PP_Point (*GetPosition)(PP_Resource mouse_event);
578  int32_t (*GetClickCount)(PP_Resource mouse_event);
579};
580
581/**
582 * The <code>PPB_WheelIputEvent</code> interface contains pointers to several
583 * functions related to wheel input events.
584 */
585struct PPB_WheelInputEvent_1_0 {
586  /**
587   * Create() creates a wheel input event with the given parameters. Normally
588   * you will get a wheel event passed through the
589   * <code>HandleInputEvent</code> and will not need to create them, but some
590   * applications may want to create their own for internal use.
591   *
592   * @param[in] instance The instance for which this event occurred.
593   *
594   * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
595   * when the event occurred.
596   *
597   * @param[in] modifiers A bit field combination of the
598   * <code>PP_InputEvent_Modifier</code> flags.
599   *
600   * @param[in] wheel_delta The scroll wheel's horizontal and vertical scroll
601   * amounts.
602   *
603   * @param[in] wheel_ticks The number of "clicks" of the scroll wheel that
604   * have produced the event.
605   *
606   * @param[in] scroll_by_page When true, the user is requesting to scroll
607   * by pages. When false, the user is requesting to scroll by lines.
608   *
609   * @return A <code>PP_Resource</code> containing the new wheel input event.
610   */
611  PP_Resource (*Create)(PP_Instance instance,
612                        PP_TimeTicks time_stamp,
613                        uint32_t modifiers,
614                        const struct PP_FloatPoint* wheel_delta,
615                        const struct PP_FloatPoint* wheel_ticks,
616                        PP_Bool scroll_by_page);
617  /**
618   * IsWheelInputEvent() determines if a resource is a wheel event.
619   *
620   * @param[in] wheel_event A <code>PP_Resource</code> corresponding to an
621   * event.
622   *
623   * @return <code>PP_TRUE</code> if the given resource is a valid wheel input
624   * event.
625   */
626  PP_Bool (*IsWheelInputEvent)(PP_Resource resource);
627  /**
628   * GetDelta() returns the amount vertically and horizontally the user has
629   * requested to scroll by with their mouse wheel. A scroll down or to the
630   * right (where the content moves up or left) is represented as positive
631   * values, and a scroll up or to the left (where the content moves down or
632   * right) is represented as negative values.
633   *
634   * This amount is system dependent and will take into account the user's
635   * preferred scroll sensitivity and potentially also nonlinear acceleration
636   * based on the speed of the scrolling.
637   *
638   * Devices will be of varying resolution. Some mice with large detents will
639   * only generate integer scroll amounts. But fractional values are also
640   * possible, for example, on some trackpads and newer mice that don't have
641   * "clicks".
642   *
643   * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
644   * event.
645   *
646   * @return The vertical and horizontal scroll values. The units are either in
647   * pixels (when scroll_by_page is false) or pages (when scroll_by_page is
648   * true). For example, y = -3 means scroll up 3 pixels when scroll_by_page
649   * is false, and scroll up 3 pages when scroll_by_page is true.
650   */
651  struct PP_FloatPoint (*GetDelta)(PP_Resource wheel_event);
652  /**
653   * GetTicks() returns the number of "clicks" of the scroll wheel
654   * that have produced the event. The value may have system-specific
655   * acceleration applied to it, depending on the device. The positive and
656   * negative meanings are the same as for GetDelta().
657   *
658   * If you are scrolling, you probably want to use the delta values.  These
659   * tick events can be useful if you aren't doing actual scrolling and don't
660   * want or pixel values. An example may be cycling between different items in
661   * a game.
662   *
663   * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
664   * event.
665   *
666   * @return The number of "clicks" of the scroll wheel. You may receive
667   * fractional values for the wheel ticks if the mouse wheel is high
668   * resolution or doesn't have "clicks". If your program wants discrete
669   * events (as in the "picking items" example) you should accumulate
670   * fractional click values from multiple messages until the total value
671   * reaches positive or negative one. This should represent a similar amount
672   * of scrolling as for a mouse that has a discrete mouse wheel.
673   */
674  struct PP_FloatPoint (*GetTicks)(PP_Resource wheel_event);
675  /**
676   * GetScrollByPage() indicates if the scroll delta x/y indicates pages or
677   * lines to scroll by.
678   *
679   * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
680   * event.
681   *
682   * @return <code>PP_TRUE</code> if the event is a wheel event and the user is
683   * scrolling by pages. <code>PP_FALSE</code> if not or if the resource is not
684   * a wheel event.
685   */
686  PP_Bool (*GetScrollByPage)(PP_Resource wheel_event);
687};
688
689typedef struct PPB_WheelInputEvent_1_0 PPB_WheelInputEvent;
690
691/**
692 * The <code>PPB_KeyboardInputEvent</code> interface contains pointers to
693 * several functions related to keyboard input events.
694 */
695struct PPB_KeyboardInputEvent_1_0 {
696  /**
697   * Creates a keyboard input event with the given parameters. Normally you
698   * will get a keyboard event passed through the HandleInputEvent and will not
699   * need to create them, but some applications may want to create their own
700   * for internal use. The type must be one of the keyboard event types.
701   *
702   * @param[in] instance The instance for which this event occurred.
703   *
704   * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
705   * input event.
706   *
707   * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
708   * when the event occurred.
709   *
710   * @param[in]  modifiers A bit field combination of the
711   * <code>PP_InputEvent_Modifier</code> flags.
712   *
713   * @param[in] key_code This value reflects the DOM KeyboardEvent
714   * <code>keyCode</code> field. Chrome populates this with the Windows-style
715   * Virtual Key code of the key.
716   *
717   * @param[in] character_text This value represents the typed character as a
718   * UTF-8 string.
719   *
720   * @return A <code>PP_Resource</code> containing the new keyboard input
721   * event.
722   */
723  PP_Resource (*Create)(PP_Instance instance,
724                        PP_InputEvent_Type type,
725                        PP_TimeTicks time_stamp,
726                        uint32_t modifiers,
727                        uint32_t key_code,
728                        struct PP_Var character_text);
729  /**
730   * IsKeyboardInputEvent() determines if a resource is a keyboard event.
731   *
732   * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
733   *
734   * @return <code>PP_TRUE</code> if the given resource is a valid input event.
735   */
736  PP_Bool (*IsKeyboardInputEvent)(PP_Resource resource);
737  /**
738   * GetKeyCode() returns the DOM keyCode field for the keyboard event.
739   * Chrome populates this with the Windows-style Virtual Key code of the key.
740   *
741   * @param[in] key_event A <code>PP_Resource</code> corresponding to a
742   * keyboard event.
743   *
744   * @return The DOM keyCode field for the keyboard event.
745   */
746  uint32_t (*GetKeyCode)(PP_Resource key_event);
747  /**
748   * GetCharacterText() returns the typed character as a UTF-8 string for the
749   * given character event.
750   *
751   * @param[in] character_event A <code>PP_Resource</code> corresponding to a
752   * keyboard event.
753   *
754   * @return A string var representing a single typed character for character
755   * input events. For non-character input events the return value will be an
756   * undefined var.
757   */
758  struct PP_Var (*GetCharacterText)(PP_Resource character_event);
759};
760
761typedef struct PPB_KeyboardInputEvent_1_0 PPB_KeyboardInputEvent;
762/**
763 * @}
764 */
765
766/**
767 * @addtogroup Enums
768 * @{
769 */
770typedef enum {
771  /**
772   * The list of all TouchPoints which are currently down.
773   */
774  PP_TOUCHLIST_TYPE_TOUCHES = 0,
775  /**
776   * The list of all TouchPoints whose state has changed since the last
777   * TouchInputEvent.
778   */
779  PP_TOUCHLIST_TYPE_CHANGEDTOUCHES = 1,
780  /**
781   * The list of all TouchPoints which are targeting this plugin.  This is a
782   * subset of Touches.
783   */
784  PP_TOUCHLIST_TYPE_TARGETTOUCHES = 2
785} PP_TouchListType;
786PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TouchListType, 4);
787/**
788 * @}
789 */
790
791/**
792 * @addtogroup Interfaces
793 * @{
794 */
795/**
796 * The <code>PPB_TouchInputEvent</code> interface contains pointers to several
797 * functions related to touch events.
798 */
799struct PPB_TouchInputEvent_1_0 {
800  /**
801   * Creates a touch input event with the given parameters. Normally you
802   * will get a touch event passed through the HandleInputEvent and will not
803   * need to create them, but some applications may want to create their own
804   * for internal use. The type must be one of the touch event types.
805   * This newly created touch input event does not have any touch point in any
806   * of the touch-point lists. <code>AddTouchPoint</code> should be called to
807   * add the touch-points.
808   *
809   * @param[in] instance The instance for which this event occurred.
810   *
811   * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
812   * input event.
813   *
814   * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
815   * when the event occurred.
816   *
817   * @param[in]  modifiers A bit field combination of the
818   * <code>PP_InputEvent_Modifier</code> flags.
819   *
820   * @return A <code>PP_Resource</code> containing the new touch input event.
821   */
822  PP_Resource (*Create)(PP_Instance instance,
823                        PP_InputEvent_Type type,
824                        PP_TimeTicks time_stamp,
825                        uint32_t modifiers);
826  /**
827   * Adds a touch point to the touch event in the specified touch-list.
828   *
829   * @param[in] touch_event A <code>PP_Resource</code> corresponding to a touch
830   * event.
831   *
832   * @param[in] list The list to add the touch point to.
833   *
834   * @param[in] point The point to add to the list.
835   */
836  void (*AddTouchPoint)(PP_Resource touch_event,
837                        PP_TouchListType list,
838                        const struct PP_TouchPoint* point);
839  /**
840   * IsTouchInputEvent() determines if a resource is a touch event.
841   *
842   * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
843   *
844   * @return <code>PP_TRUE</code> if the given resource is a valid touch input
845   * event, otherwise <code>PP_FALSE</code>.
846   */
847  PP_Bool (*IsTouchInputEvent)(PP_Resource resource);
848  /**
849   * Returns the number of touch-points in the specified list.
850   *
851   * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
852   * event.
853   *
854   * @param[in] list The list.
855   *
856   * @return The number of touch-points in the specified list.
857   */
858  uint32_t (*GetTouchCount)(PP_Resource resource, PP_TouchListType list);
859  /**
860   * Returns the touch-point at the specified index from the specified list.
861   *
862   * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
863   * event.
864   *
865   * @param[in] list The list.
866   *
867   * @param[in] index The index.
868   *
869   * @return A <code>PP_TouchPoint</code> representing the touch-point.
870   */
871  struct PP_TouchPoint (*GetTouchByIndex)(PP_Resource resource,
872                                          PP_TouchListType list,
873                                          uint32_t index);
874  /**
875   * Returns the touch-point with the spcified touch-id in the specified list.
876   *
877   * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
878   * event.
879   *
880   * @param[in] list The list.
881   *
882   * @param[in] touch_id The id of the touch-point.
883   *
884   * @return A <code>PP_TouchPoint</code> representing the touch-point.
885   */
886  struct PP_TouchPoint (*GetTouchById)(PP_Resource resource,
887                                       PP_TouchListType list,
888                                       uint32_t touch_id);
889};
890
891typedef struct PPB_TouchInputEvent_1_0 PPB_TouchInputEvent;
892/**
893 * @}
894 */
895
896#endif  /* PPAPI_C_PPB_INPUT_EVENT_H_ */
897
898