Pepper_42_C_interfaces
ppb_input_event.h
Go to the documentation of this file.
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 Thu Apr 3 14:52:10 2014. */
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_1_2 "PPB_KeyboardInputEvent;1.2"
33 #define PPB_KEYBOARD_INPUT_EVENT_INTERFACE \
34  PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_2
35 
36 #define PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0 "PPB_TouchInputEvent;1.0"
37 #define PPB_TOUCH_INPUT_EVENT_INTERFACE PPB_TOUCH_INPUT_EVENT_INTERFACE_1_0
38 
39 #define PPB_IME_INPUT_EVENT_INTERFACE_1_0 "PPB_IMEInputEvent;1.0"
40 #define PPB_IME_INPUT_EVENT_INTERFACE PPB_IME_INPUT_EVENT_INTERFACE_1_0
41 
42 /**
43  * @file
44  * This file defines the Input Event interfaces.
45  */
46 
47 
48 /**
49  * @addtogroup Enums
50  * @{
51  */
52 /**
53  * This enumeration contains the types of input events.
54  */
55 typedef enum {
57  /**
58  * Notification that a mouse button was pressed.
59  *
60  * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
61  */
63  /**
64  * Notification that a mouse button was released.
65  *
66  * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
67  */
69  /**
70  * Notification that a mouse button was moved when it is over the instance
71  * or dragged out of it.
72  *
73  * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
74  */
76  /**
77  * Notification that the mouse entered the instance's bounds.
78  *
79  * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
80  */
82  /**
83  * Notification that a mouse left the instance's bounds.
84  *
85  * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
86  */
88  /**
89  * Notification that the scroll wheel was used.
90  *
91  * Register for this event using the PP_INPUTEVENT_CLASS_WHEEL class.
92  */
94  /**
95  * Notification that a key transitioned from "up" to "down".
96  *
97  * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
98  */
99  /*
100  * TODO(brettw) differentiate from KEYDOWN.
101  */
103  /**
104  * Notification that a key was pressed. This does not necessarily correspond
105  * to a character depending on the key and language. Use the
106  * PP_INPUTEVENT_TYPE_CHAR for character input.
107  *
108  * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
109  */
111  /**
112  * Notification that a key was released.
113  *
114  * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
115  */
117  /**
118  * Notification that a character was typed. Use this for text input. Key
119  * down events may generate 0, 1, or more than one character event depending
120  * on the key, locale, and operating system.
121  *
122  * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
123  */
125  /**
126  * Notification that a context menu should be shown.
127  *
128  * This message will be sent when the user right-clicks or performs another
129  * OS-specific mouse command that should open a context menu. When this event
130  * is delivered depends on the system, on some systems (Mac) it will
131  * delivered after the mouse down event, and on others (Windows) it will be
132  * delivered after the mouse up event.
133  *
134  * You will always get the normal mouse events. For example, you may see
135  * MOUSEDOWN,CONTEXTMENU,MOUSEUP or MOUSEDOWN,MOUSEUP,CONTEXTMENU.
136  *
137  * The return value from the event handler determines if the context menu
138  * event will be passed to the page when you are using filtered input events
139  * (via RequestFilteringInputEvents()). In non-filtering mode the event will
140  * never be propagated and no context menu will be displayed. If you are
141  * handling mouse events in filtering mode, you may want to return true from
142  * this event even if you do not support a context menu to suppress the
143  * default one.
144  *
145  * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
146  */
148  /**
149  * Notification that an input method composition process has just started.
150  *
151  * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
152  */
154  /**
155  * Notification that the input method composition string is updated.
156  *
157  * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
158  */
160  /**
161  * Notification that an input method composition process has completed.
162  *
163  * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
164  */
166  /**
167  * Notification that an input method committed a string.
168  *
169  * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
170  */
172  /**
173  * Notification that a finger was placed on a touch-enabled device.
174  *
175  * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
176  */
178  /**
179  * Notification that a finger was moved on a touch-enabled device.
180  *
181  * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
182  */
184  /**
185  * Notification that a finger was released on a touch-enabled device.
186  *
187  * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
188  */
190  /**
191  * Notification that a touch event was canceled.
192  *
193  * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
194  */
199 
200 /**
201  * This enumeration contains event modifier constants. Each modifier is one
202  * bit. Retrieve the modifiers from an input event using the GetEventModifiers
203  * function on PPB_InputEvent.
204  */
205 typedef enum {
221 
222 /**
223  * This enumeration contains constants representing each mouse button. To get
224  * the mouse button for a mouse down or up event, use GetMouseButton on
225  * PPB_InputEvent.
226  */
227 typedef enum {
234 
235 typedef enum {
236  /**
237  * Request mouse input events.
238  *
239  * Normally you will request mouse events by calling RequestInputEvents().
240  * The only use case for filtered events (via RequestFilteringInputEvents())
241  * is for instances that have irregular outlines and you want to perform hit
242  * testing, which is very uncommon. Requesting non-filtered mouse events will
243  * lead to higher performance.
244  */
246  /**
247  * Requests keyboard events. Often you will want to request filtered mode
248  * (via RequestFilteringInputEvents) for keyboard events so you can pass on
249  * events (by returning false) that you don't handle. For example, if you
250  * don't request filtered mode and the user pressed "Page Down" when your
251  * instance has focus, the page won't scroll which will be a poor experience.
252  *
253  * A small number of tab and window management commands like Alt-F4 are never
254  * sent to the page. You can not request these keyboard commands since it
255  * would allow pages to trap users on a page.
256  */
258  /**
259  * Identifies scroll wheel input event. Wheel events must be requested in
260  * filtering mode via RequestFilteringInputEvents(). This is because many
261  * wheel commands should be forwarded to the page.
262  *
263  * Most instances will not need this event. Consuming wheel events by
264  * returning true from your filtered event handler will prevent the user from
265  * scrolling the page when the mouse is over the instance which can be very
266  * annoying.
267  *
268  * If you handle wheel events (for example, you have a document viewer which
269  * the user can scroll), the recommended behavior is to return false only if
270  * the wheel event actually causes your document to scroll. When the user
271  * reaches the end of the document, return false to indicating that the event
272  * was not handled. This will then forward the event to the containing page
273  * for scrolling, producing the nested scrolling behavior users expect from
274  * frames in a page.
275  */
277  /**
278  * Identifies touch input events.
279  *
280  * Request touch events only if you intend to handle them. If the browser
281  * knows you do not need to handle touch events, it can handle them at a
282  * higher level and achieve higher performance. If the plugin does not
283  * register for touch-events, then it will receive synthetic mouse events that
284  * are generated from the touch events (e.g. mouse-down for touch-start,
285  * mouse-move for touch-move (with left-button down), and mouse-up for
286  * touch-end. If the plugin does register for touch events, then the synthetic
287  * mouse events are not created.
288  */
290  /**
291  * Identifies IME composition input events.
292  *
293  * Request this input event class if you allow on-the-spot IME input.
294  */
296  /**
297  * Identifies gesture input events.
298  */
302 /**
303  * @}
304  */
305 
306 /**
307  * @addtogroup Interfaces
308  * @{
309  */
310 /**
311  * The <code>PPB_InputEvent</code> interface contains pointers to several
312  * functions related to generic input events on the browser.
313  */
315  /**
316  * RequestInputEvent() requests that input events corresponding to the given
317  * input events are delivered to the instance.
318  *
319  * It's recommended that you use RequestFilteringInputEvents() for keyboard
320  * events instead of this function so that you don't interfere with normal
321  * browser accelerators.
322  *
323  * By default, no input events are delivered. Call this function with the
324  * classes of events you are interested in to have them be delivered to
325  * the instance. Calling this function will override any previous setting for
326  * each specified class of input events (for example, if you previously
327  * called RequestFilteringInputEvents(), this function will set those events
328  * to non-filtering mode).
329  *
330  * Input events may have high overhead, so you should only request input
331  * events that your plugin will actually handle. For example, the browser may
332  * do optimizations for scroll or touch events that can be processed
333  * substantially faster if it knows there are no non-default receivers for
334  * that message. Requesting that such messages be delivered, even if they are
335  * processed very quickly, may have a noticeable effect on the performance of
336  * the page.
337  *
338  * Note that synthetic mouse events will be generated from touch events if
339  * (and only if) you do not request touch events.
340  *
341  * When requesting input events through this function, the events will be
342  * delivered and <i>not</i> bubbled to the default handlers.
343  *
344  * <strong>Example:</strong>
345  * @code
346  * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
347  * RequestFilteringInputEvents(instance,
348  * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
349  * @endcode
350  *
351  * @param instance The <code>PP_Instance</code> of the instance requesting
352  * the given events.
353  *
354  * @param event_classes A combination of flags from
355  * <code>PP_InputEvent_Class</code> that identifies the classes of events the
356  * instance is requesting. The flags are combined by logically ORing their
357  * values.
358  *
359  * @return <code>PP_OK</code> if the operation succeeded,
360  * <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or
361  * <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were
362  * illegal. In the case of an invalid bit, all valid bits will be applied
363  * and only the illegal bits will be ignored. The most common cause of a
364  * <code>PP_ERROR_NOTSUPPORTED</code> return value is requesting keyboard
365  * events, these must use RequestFilteringInputEvents().
366  */
367  int32_t (*RequestInputEvents)(PP_Instance instance, uint32_t event_classes);
368  /**
369  * RequestFilteringInputEvents() requests that input events corresponding to
370  * the given input events are delivered to the instance for filtering.
371  *
372  * By default, no input events are delivered. In most cases you would
373  * register to receive events by calling RequestInputEvents(). In some cases,
374  * however, you may wish to filter events such that they can be bubbled up
375  * to the default handlers. In this case, register for those classes of
376  * events using this function instead of RequestInputEvents().
377  *
378  * Filtering input events requires significantly more overhead than just
379  * delivering them to the instance. As such, you should only request
380  * filtering in those cases where it's absolutely necessary. The reason is
381  * that it requires the browser to stop and block for the instance to handle
382  * the input event, rather than sending the input event asynchronously. This
383  * can have significant overhead.
384  *
385  * <strong>Example:</strong>
386  * @code
387  * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
388  * RequestFilteringInputEvents(instance,
389  * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
390  * @endcode
391  *
392  * @return <code>PP_OK</code> if the operation succeeded,
393  * <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or
394  * <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were
395  * illegal. In the case of an invalid bit, all valid bits will be applied
396  * and only the illegal bits will be ignored.
397  */
399  uint32_t event_classes);
400  /**
401  * ClearInputEventRequest() requests that input events corresponding to the
402  * given input classes no longer be delivered to the instance.
403  *
404  * By default, no input events are delivered. If you have previously
405  * requested input events via RequestInputEvents() or
406  * RequestFilteringInputEvents(), this function will unregister handling
407  * for the given instance. This will allow greater browser performance for
408  * those events.
409  *
410  * Note that you may still get some input events after clearing the flag if
411  * they were dispatched before the request was cleared. For example, if
412  * there are 3 mouse move events waiting to be delivered, and you clear the
413  * mouse event class during the processing of the first one, you'll still
414  * receive the next two. You just won't get more events generated.
415  *
416  * @param instance The <code>PP_Instance</code> of the instance requesting
417  * to no longer receive the given events.
418  *
419  * @param event_classes A combination of flags from
420  * <code>PP_InputEvent_Class</code> that identify the classes of events the
421  * instance is no longer interested in.
422  */
423  void (*ClearInputEventRequest)(PP_Instance instance, uint32_t event_classes);
424  /**
425  * IsInputEvent() returns true if the given resource is a valid input event
426  * resource.
427  *
428  * @param[in] resource A <code>PP_Resource</code> corresponding to a generic
429  * resource.
430  *
431  * @return <code>PP_TRUE</code> if the given resource is a valid input event
432  * resource.
433  */
435  /**
436  * GetType() returns the type of input event for the given input event
437  * resource.
438  *
439  * @param[in] resource A <code>PP_Resource</code> corresponding to an input
440  * event.
441  *
442  * @return A <code>PP_InputEvent_Type</code> if its a valid input event or
443  * <code>PP_INPUTEVENT_TYPE_UNDEFINED</code> if the resource is invalid.
444  */
446  /**
447  * GetTimeStamp() Returns the time that the event was generated. This will be
448  * before the current time since processing and dispatching the event has
449  * some overhead. Use this value to compare the times the user generated two
450  * events without being sensitive to variable processing time.
451  *
452  * @param[in] resource A <code>PP_Resource</code> corresponding to the event.
453  *
454  * @return The return value is in time ticks, which is a monotonically
455  * increasing clock not related to the wall clock time. It will not change
456  * if the user changes their clock or daylight savings time starts, so can
457  * be reliably used to compare events. This means, however, that you can't
458  * correlate event times to a particular time of day on the system clock.
459  */
461  /**
462  * GetModifiers() returns a bitfield indicating which modifiers were down
463  * at the time of the event. This is a combination of the flags in the
464  * <code>PP_InputEvent_Modifier</code> enum.
465  *
466  * @param[in] resource A <code>PP_Resource</code> corresponding to an input
467  * event.
468  *
469  * @return The modifiers associated with the event, or 0 if the given
470  * resource is not a valid event resource.
471  */
472  uint32_t (*GetModifiers)(PP_Resource event);
473 };
474 
476 
477 /**
478  * The <code>PPB_MouseInputEvent</code> interface contains pointers to several
479  * functions related to mouse input events.
480  */
482  /**
483  * Create() creates a mouse input event with the given parameters. Normally
484  * you will get a mouse event passed through the
485  * <code>HandleInputEvent</code> and will not need to create them, but some
486  * applications may want to create their own for internal use. The type must
487  * be one of the mouse event types.
488  *
489  * @param[in] instance The instance for which this event occurred.
490  *
491  * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
492  * input event.
493  *
494  * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
495  * when the event occurred.
496  *
497  * @param[in] modifiers A bit field combination of the
498  * <code>PP_InputEvent_Modifier</code> flags.
499  *
500  * @param[in] mouse_button The button that changed for mouse down or up
501  * events. This value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for
502  * mouse move, enter, and leave events.
503  *
504  * @param[in] mouse_position A <code>Point</code> containing the x and y
505  * position of the mouse when the event occurred.
506  *
507  * @param[in] mouse_movement The change in position of the mouse.
508  *
509  * @return A <code>PP_Resource</code> containing the new mouse input event.
510  */
512  PP_InputEvent_Type type,
513  PP_TimeTicks time_stamp,
514  uint32_t modifiers,
515  PP_InputEvent_MouseButton mouse_button,
516  const struct PP_Point* mouse_position,
517  int32_t click_count,
518  const struct PP_Point* mouse_movement);
519  /**
520  * IsMouseInputEvent() determines if a resource is a mouse event.
521  *
522  * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
523  *
524  * @return <code>PP_TRUE</code> if the given resource is a valid mouse input
525  * event, otherwise <code>PP_FALSE</code>.
526  */
528  /**
529  * GetButton() returns the mouse button that generated a mouse down or up
530  * event.
531  *
532  * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
533  * mouse event.
534  *
535  * @return The mouse button associated with mouse down and up events. This
536  * value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for mouse move,
537  * enter, and leave events, and for all non-mouse events.
538  */
540  /**
541  * GetPosition() returns the pixel location of a mouse input event. When
542  * the mouse is locked, it returns the last known mouse position just as
543  * mouse lock was entered.
544  *
545  * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
546  * mouse event.
547  *
548  * @return The point associated with the mouse event, relative to the upper-
549  * left of the instance receiving the event. These values can be negative for
550  * mouse drags. The return value will be (0, 0) for non-mouse events.
551  */
552  struct PP_Point (*GetPosition)(PP_Resource mouse_event);
553  /*
554  * TODO(brettw) figure out exactly what this means.
555  */
556  int32_t (*GetClickCount)(PP_Resource mouse_event);
557  /**
558  * Returns the change in position of the mouse. When the mouse is locked,
559  * although the mouse position doesn't actually change, this function
560  * still provides movement information, which indicates what the change in
561  * position would be had the mouse not been locked.
562  *
563  * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
564  * mouse event.
565  *
566  * @return The change in position of the mouse, relative to the previous
567  * position.
568  */
569  struct PP_Point (*GetMovement)(PP_Resource mouse_event);
570 };
571 
573 
576  PP_InputEvent_Type type,
577  PP_TimeTicks time_stamp,
578  uint32_t modifiers,
579  PP_InputEvent_MouseButton mouse_button,
580  const struct PP_Point* mouse_position,
581  int32_t click_count);
584  struct PP_Point (*GetPosition)(PP_Resource mouse_event);
585  int32_t (*GetClickCount)(PP_Resource mouse_event);
586 };
587 
588 /**
589  * The <code>PPB_WheelIputEvent</code> interface contains pointers to several
590  * functions related to wheel input events.
591  */
593  /**
594  * Create() creates a wheel input event with the given parameters. Normally
595  * you will get a wheel event passed through the
596  * <code>HandleInputEvent</code> and will not need to create them, but some
597  * applications may want to create their own for internal use.
598  *
599  * @param[in] instance The instance for which this event occurred.
600  *
601  * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
602  * when the event occurred.
603  *
604  * @param[in] modifiers A bit field combination of the
605  * <code>PP_InputEvent_Modifier</code> flags.
606  *
607  * @param[in] wheel_delta The scroll wheel's horizontal and vertical scroll
608  * amounts.
609  *
610  * @param[in] wheel_ticks The number of "clicks" of the scroll wheel that
611  * have produced the event.
612  *
613  * @param[in] scroll_by_page When true, the user is requesting to scroll
614  * by pages. When false, the user is requesting to scroll by lines.
615  *
616  * @return A <code>PP_Resource</code> containing the new wheel input event.
617  */
619  PP_TimeTicks time_stamp,
620  uint32_t modifiers,
621  const struct PP_FloatPoint* wheel_delta,
622  const struct PP_FloatPoint* wheel_ticks,
623  PP_Bool scroll_by_page);
624  /**
625  * IsWheelInputEvent() determines if a resource is a wheel event.
626  *
627  * @param[in] wheel_event A <code>PP_Resource</code> corresponding to an
628  * event.
629  *
630  * @return <code>PP_TRUE</code> if the given resource is a valid wheel input
631  * event.
632  */
634  /**
635  * GetDelta() returns the amount vertically and horizontally the user has
636  * requested to scroll by with their mouse wheel. A scroll down or to the
637  * right (where the content moves up or left) is represented as positive
638  * values, and a scroll up or to the left (where the content moves down or
639  * right) is represented as negative values.
640  *
641  * This amount is system dependent and will take into account the user's
642  * preferred scroll sensitivity and potentially also nonlinear acceleration
643  * based on the speed of the scrolling.
644  *
645  * Devices will be of varying resolution. Some mice with large detents will
646  * only generate integer scroll amounts. But fractional values are also
647  * possible, for example, on some trackpads and newer mice that don't have
648  * "clicks".
649  *
650  * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
651  * event.
652  *
653  * @return The vertical and horizontal scroll values. The units are either in
654  * pixels (when scroll_by_page is false) or pages (when scroll_by_page is
655  * true). For example, y = -3 means scroll up 3 pixels when scroll_by_page
656  * is false, and scroll up 3 pages when scroll_by_page is true.
657  */
658  struct PP_FloatPoint (*GetDelta)(PP_Resource wheel_event);
659  /**
660  * GetTicks() returns the number of "clicks" of the scroll wheel
661  * that have produced the event. The value may have system-specific
662  * acceleration applied to it, depending on the device. The positive and
663  * negative meanings are the same as for GetDelta().
664  *
665  * If you are scrolling, you probably want to use the delta values. These
666  * tick events can be useful if you aren't doing actual scrolling and don't
667  * want or pixel values. An example may be cycling between different items in
668  * a game.
669  *
670  * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
671  * event.
672  *
673  * @return The number of "clicks" of the scroll wheel. You may receive
674  * fractional values for the wheel ticks if the mouse wheel is high
675  * resolution or doesn't have "clicks". If your program wants discrete
676  * events (as in the "picking items" example) you should accumulate
677  * fractional click values from multiple messages until the total value
678  * reaches positive or negative one. This should represent a similar amount
679  * of scrolling as for a mouse that has a discrete mouse wheel.
680  */
681  struct PP_FloatPoint (*GetTicks)(PP_Resource wheel_event);
682  /**
683  * GetScrollByPage() indicates if the scroll delta x/y indicates pages or
684  * lines to scroll by.
685  *
686  * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
687  * event.
688  *
689  * @return <code>PP_TRUE</code> if the event is a wheel event and the user is
690  * scrolling by pages. <code>PP_FALSE</code> if not or if the resource is not
691  * a wheel event.
692  */
694 };
695 
697 
698 /**
699  * The <code>PPB_KeyboardInputEvent</code> interface contains pointers to
700  * several functions related to keyboard input events.
701  */
703  /**
704  * Creates a keyboard input event with the given parameters. Normally you
705  * will get a keyboard event passed through the HandleInputEvent and will not
706  * need to create them, but some applications may want to create their own
707  * for internal use. The type must be one of the keyboard event types.
708  *
709  * @param[in] instance The instance for which this event occurred.
710  *
711  * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
712  * input event.
713  *
714  * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
715  * when the event occurred.
716  *
717  * @param[in] modifiers A bit field combination of the
718  * <code>PP_InputEvent_Modifier</code> flags.
719  *
720  * @param[in] key_code This value reflects the DOM KeyboardEvent
721  * <code>keyCode</code> field, which is the Windows-style Virtual Key
722  * code of the key.
723  *
724  * @param[in] character_text This value represents the typed character as a
725  * UTF-8 string.
726  *
727  * @param[in] code This value represents the DOM3 |code| string that
728  * corresponds to the physical key being pressed.
729  *
730  * @return A <code>PP_Resource</code> containing the new keyboard input
731  * event.
732  */
734  PP_InputEvent_Type type,
735  PP_TimeTicks time_stamp,
736  uint32_t modifiers,
737  uint32_t key_code,
738  struct PP_Var character_text,
739  struct PP_Var code);
740  /**
741  * IsKeyboardInputEvent() determines if a resource is a keyboard event.
742  *
743  * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
744  *
745  * @return <code>PP_TRUE</code> if the given resource is a valid input event.
746  */
748  /**
749  * GetKeyCode() returns the DOM keyCode field for the keyboard event.
750  * Chrome populates this with the Windows-style Virtual Key code of the key.
751  *
752  * @param[in] key_event A <code>PP_Resource</code> corresponding to a
753  * keyboard event.
754  *
755  * @return The DOM keyCode field for the keyboard event.
756  */
757  uint32_t (*GetKeyCode)(PP_Resource key_event);
758  /**
759  * GetCharacterText() returns the typed character as a UTF-8 string for the
760  * given character event.
761  *
762  * @param[in] character_event A <code>PP_Resource</code> corresponding to a
763  * keyboard event.
764  *
765  * @return A string var representing a single typed character for character
766  * input events. For non-character input events the return value will be an
767  * undefined var.
768  */
769  struct PP_Var (*GetCharacterText)(PP_Resource character_event);
770  /**
771  * GetCode() returns the DOM |code| field for this keyboard event, as
772  * defined in the DOM3 Events spec:
773  * http://www.w3.org/TR/DOM-Level-3-Events/
774  *
775  * @param[in] key_event The key event for which to return the key code.
776  *
777  * @return The string that contains the DOM |code| for the keyboard event.
778  */
779  struct PP_Var (*GetCode)(PP_Resource key_event);
780 };
781 
783 
786  PP_InputEvent_Type type,
787  PP_TimeTicks time_stamp,
788  uint32_t modifiers,
789  uint32_t key_code,
790  struct PP_Var character_text);
792  uint32_t (*GetKeyCode)(PP_Resource key_event);
793  struct PP_Var (*GetCharacterText)(PP_Resource character_event);
794 };
795 /**
796  * @}
797  */
798 
799 /**
800  * @addtogroup Enums
801  * @{
802  */
803 typedef enum {
804  /**
805  * The list of all TouchPoints which are currently down.
806  */
808  /**
809  * The list of all TouchPoints whose state has changed since the last
810  * TouchInputEvent.
811  */
813  /**
814  * The list of all TouchPoints which are targeting this plugin. This is a
815  * subset of Touches.
816  */
820 /**
821  * @}
822  */
823 
824 /**
825  * @addtogroup Interfaces
826  * @{
827  */
828 /**
829  * The <code>PPB_TouchInputEvent</code> interface contains pointers to several
830  * functions related to touch events.
831  */
833  /**
834  * Creates a touch input event with the given parameters. Normally you
835  * will get a touch event passed through the HandleInputEvent and will not
836  * need to create them, but some applications may want to create their own
837  * for internal use. The type must be one of the touch event types.
838  * This newly created touch input event does not have any touch point in any
839  * of the touch-point lists. <code>AddTouchPoint</code> should be called to
840  * add the touch-points.
841  *
842  * @param[in] instance The instance for which this event occurred.
843  *
844  * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
845  * input event.
846  *
847  * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
848  * when the event occurred.
849  *
850  * @param[in] modifiers A bit field combination of the
851  * <code>PP_InputEvent_Modifier</code> flags.
852  *
853  * @return A <code>PP_Resource</code> containing the new touch input event.
854  */
856  PP_InputEvent_Type type,
857  PP_TimeTicks time_stamp,
858  uint32_t modifiers);
859  /**
860  * Adds a touch point to the touch event in the specified touch-list.
861  *
862  * @param[in] touch_event A <code>PP_Resource</code> corresponding to a touch
863  * event.
864  *
865  * @param[in] list The list to add the touch point to.
866  *
867  * @param[in] point The point to add to the list.
868  */
869  void (*AddTouchPoint)(PP_Resource touch_event,
870  PP_TouchListType list,
871  const struct PP_TouchPoint* point);
872  /**
873  * IsTouchInputEvent() determines if a resource is a touch event.
874  *
875  * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
876  *
877  * @return <code>PP_TRUE</code> if the given resource is a valid touch input
878  * event, otherwise <code>PP_FALSE</code>.
879  */
881  /**
882  * Returns the number of touch-points in the specified list.
883  *
884  * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
885  * event.
886  *
887  * @param[in] list The list.
888  *
889  * @return The number of touch-points in the specified list.
890  */
891  uint32_t (*GetTouchCount)(PP_Resource resource, PP_TouchListType list);
892  /**
893  * Returns the touch-point at the specified index from the specified list.
894  *
895  * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
896  * event.
897  *
898  * @param[in] list The list.
899  *
900  * @param[in] index The index.
901  *
902  * @return A <code>PP_TouchPoint</code> representing the touch-point.
903  */
905  PP_TouchListType list,
906  uint32_t index);
907  /**
908  * Returns the touch-point with the specified touch-id in the specified list.
909  *
910  * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
911  * event.
912  *
913  * @param[in] list The list.
914  *
915  * @param[in] touch_id The id of the touch-point.
916  *
917  * @return A <code>PP_TouchPoint</code> representing the touch-point.
918  */
920  PP_TouchListType list,
921  uint32_t touch_id);
922 };
923 
925 
927  /**
928  * Create() creates an IME input event with the given parameters. Normally
929  * you will get an IME event passed through the <code>HandleInputEvent</code>
930  * and will not need to create them, but some applications may want to create
931  * their own for internal use.
932  *
933  * @param[in] instance The instance for which this event occurred.
934  *
935  * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
936  * input event. The type must be one of the IME event types.
937  *
938  * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
939  * when the event occurred.
940  *
941  * @param[in] text The string returned by <code>GetText</code>.
942  *
943  * @param[in] segment_number The number returned by
944  * <code>GetSegmentNumber</code>.
945  *
946  * @param[in] segment_offsets The array of numbers returned by
947  * <code>GetSegmentOffset</code>. If <code>segment_number</code> is zero,
948  * the number of elements of the array should be zero. If
949  * <code>segment_number</code> is non-zero, the length of the array must be
950  * <code>segment_number</code> + 1.
951  *
952  * @param[in] target_segment The number returned by
953  * <code>GetTargetSegment</code>.
954  *
955  * @param[in] selection_start The start index returned by
956  * <code>GetSelection</code>.
957  *
958  * @param[in] selection_end The end index returned by
959  * <code>GetSelection</code>.
960  *
961  * @return A <code>PP_Resource</code> containing the new IME input event.
962  */
964  PP_InputEvent_Type type,
965  PP_TimeTicks time_stamp,
966  struct PP_Var text,
967  uint32_t segment_number,
968  const uint32_t segment_offsets[],
969  int32_t target_segment,
970  uint32_t selection_start,
971  uint32_t selection_end);
972  /**
973  * IsIMEInputEvent() determines if a resource is an IME event.
974  *
975  * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
976  *
977  * @return <code>PP_TRUE</code> if the given resource is a valid input event.
978  */
980  /**
981  * GetText() returns the composition text as a UTF-8 string for the given IME
982  * event.
983  *
984  * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
985  * event.
986  *
987  * @return A string var representing the composition text. For non-IME input
988  * events the return value will be an undefined var.
989  */
990  struct PP_Var (*GetText)(PP_Resource ime_event);
991  /**
992  * GetSegmentNumber() returns the number of segments in the composition text.
993  *
994  * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
995  * event.
996  *
997  * @return The number of segments. For events other than COMPOSITION_UPDATE,
998  * returns 0.
999  */
1000  uint32_t (*GetSegmentNumber)(PP_Resource ime_event);
1001  /**
1002  * GetSegmentOffset() returns the position of the index-th segmentation point
1003  * in the composition text. The position is given by a byte-offset (not a
1004  * character-offset) of the string returned by GetText(). It always satisfies
1005  * 0=GetSegmentOffset(0) < ... < GetSegmentOffset(i) < GetSegmentOffset(i+1)
1006  * < ... < GetSegmentOffset(GetSegmentNumber())=(byte-length of GetText()).
1007  * Note that [GetSegmentOffset(i), GetSegmentOffset(i+1)) represents the range
1008  * of the i-th segment, and hence GetSegmentNumber() can be a valid argument
1009  * to this function instead of an off-by-1 error.
1010  *
1011  * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1012  * event.
1013  *
1014  * @param[in] index An integer indicating a segment.
1015  *
1016  * @return The byte-offset of the segmentation point. If the event is not
1017  * COMPOSITION_UPDATE or index is out of range, returns 0.
1018  */
1019  uint32_t (*GetSegmentOffset)(PP_Resource ime_event, uint32_t index);
1020  /**
1021  * GetTargetSegment() returns the index of the current target segment of
1022  * composition.
1023  *
1024  * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1025  * event.
1026  *
1027  * @return An integer indicating the index of the target segment. When there
1028  * is no active target segment, or the event is not COMPOSITION_UPDATE,
1029  * returns -1.
1030  */
1031  int32_t (*GetTargetSegment)(PP_Resource ime_event);
1032  /**
1033  * GetSelection() returns the range selected by caret in the composition text.
1034  *
1035  * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1036  * event.
1037  *
1038  * @param[out] start The start position of the current selection.
1039  *
1040  * @param[out] end The end position of the current selection.
1041  */
1042  void (*GetSelection)(PP_Resource ime_event, uint32_t* start, uint32_t* end);
1043 };
1044 
1046 /**
1047  * @}
1048  */
1049 
1050 #endif /* PPAPI_C_PPB_INPUT_EVENT_H_ */
1051 
struct PP_Var(* GetCharacterText)(PP_Resource character_event)
PP_TimeTicks(* GetTimeStamp)(PP_Resource event)
PP_Bool(* IsMouseInputEvent)(PP_Resource resource)
struct PP_Var(* GetCode)(PP_Resource key_event)
int32_t(* GetTargetSegment)(PP_Resource ime_event)
struct PP_Point(* GetPosition)(PP_Resource mouse_event)
int32_t(* RequestFilteringInputEvents)(PP_Instance instance, uint32_t event_classes)
PP_Bool(* GetScrollByPage)(PP_Resource wheel_event)
void(* AddTouchPoint)(PP_Resource touch_event, PP_TouchListType list, const struct PP_TouchPoint *point)
PP_Bool(* IsInputEvent)(PP_Resource resource)
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4)
PP_Resource(* Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text, struct PP_Var code)
struct PP_Point(* GetPosition)(PP_Resource mouse_event)
PP_InputEvent_MouseButton(* GetButton)(PP_Resource mouse_event)
uint32_t(* GetKeyCode)(PP_Resource key_event)
void(* GetSelection)(PP_Resource ime_event, uint32_t *start, uint32_t *end)
int32_t PP_Resource
Definition: pp_resource.h:40
double PP_TimeTicks
Definition: pp_time.h:42
PP_InputEvent_MouseButton(* GetButton)(PP_Resource mouse_event)
uint32_t(* GetKeyCode)(PP_Resource key_event)
PP_Resource(* Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, struct PP_Var text, uint32_t segment_number, const uint32_t segment_offsets[], int32_t target_segment, uint32_t selection_start, uint32_t selection_end)
int32_t(* RequestInputEvents)(PP_Instance instance, uint32_t event_classes)
uint32_t(* GetSegmentNumber)(PP_Resource ime_event)
PP_InputEvent_Class
PP_Bool(* IsIMEInputEvent)(PP_Resource resource)
uint32_t(* GetSegmentOffset)(PP_Resource ime_event, uint32_t index)
PP_Bool(* IsTouchInputEvent)(PP_Resource resource)
struct PP_FloatPoint(* GetDelta)(PP_Resource wheel_event)
PP_TouchListType
PP_Bool(* IsMouseInputEvent)(PP_Resource resource)
struct PP_FloatPoint(* GetTicks)(PP_Resource wheel_event)
Definition: pp_var.h:166
void(* ClearInputEventRequest)(PP_Instance instance, uint32_t event_classes)
PP_Resource(* Create)(PP_Instance instance, PP_TimeTicks time_stamp, uint32_t modifiers, const struct PP_FloatPoint *wheel_delta, const struct PP_FloatPoint *wheel_ticks, PP_Bool scroll_by_page)
PP_InputEvent_MouseButton
int32_t PP_Instance
Definition: pp_instance.h:34
struct PP_TouchPoint(* GetTouchById)(PP_Resource resource, PP_TouchListType list, uint32_t touch_id)
int32_t(* GetClickCount)(PP_Resource mouse_event)
struct PP_Var(* GetCharacterText)(PP_Resource character_event)
PP_Bool(* IsWheelInputEvent)(PP_Resource resource)
struct PP_Var(* GetText)(PP_Resource ime_event)
PP_Resource(* Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, PP_InputEvent_MouseButton mouse_button, const struct PP_Point *mouse_position, int32_t click_count, const struct PP_Point *mouse_movement)
PP_Resource(* Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text)
struct PP_Point(* GetMovement)(PP_Resource mouse_event)
PP_Bool
Definition: pp_bool.h:30
PP_Resource(* Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, PP_InputEvent_MouseButton mouse_button, const struct PP_Point *mouse_position, int32_t click_count)
PP_InputEvent_Modifier
PP_InputEvent_Type
uint32_t(* GetTouchCount)(PP_Resource resource, PP_TouchListType list)
PP_InputEvent_Type(* GetType)(PP_Resource event)
uint32_t(* GetModifiers)(PP_Resource event)
PP_Bool(* IsKeyboardInputEvent)(PP_Resource resource)
PP_Resource(* Create)(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers)
struct PP_TouchPoint(* GetTouchByIndex)(PP_Resource resource, PP_TouchListType list, uint32_t index)
PP_Bool(* IsKeyboardInputEvent)(PP_Resource resource)
int32_t(* GetClickCount)(PP_Resource mouse_event)