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.
6 /* From ppb_input_event.idl modified Thu Mar 28 10:51:06 2013. */
8 #ifndef PPAPI_C_PPB_INPUT_EVENT_H_
9 #define PPAPI_C_PPB_INPUT_EVENT_H_
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"
21 #define PPB_INPUT_EVENT_INTERFACE_1_0 "PPB_InputEvent;1.0"
22 #define PPB_INPUT_EVENT_INTERFACE PPB_INPUT_EVENT_INTERFACE_1_0
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
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
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
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
40 * This file defines the Input Event interfaces.
49 * This enumeration contains the types of input events.
52 PP_INPUTEVENT_TYPE_UNDEFINED
= -1,
54 * Notification that a mouse button was pressed.
56 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
58 PP_INPUTEVENT_TYPE_MOUSEDOWN
= 0,
60 * Notification that a mouse button was released.
62 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
64 PP_INPUTEVENT_TYPE_MOUSEUP
= 1,
66 * Notification that a mouse button was moved when it is over the instance
67 * or dragged out of it.
69 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
71 PP_INPUTEVENT_TYPE_MOUSEMOVE
= 2,
73 * Notification that the mouse entered the instance's bounds.
75 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
77 PP_INPUTEVENT_TYPE_MOUSEENTER
= 3,
79 * Notification that a mouse left the instance's bounds.
81 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
83 PP_INPUTEVENT_TYPE_MOUSELEAVE
= 4,
85 * Notification that the scroll wheel was used.
87 * Register for this event using the PP_INPUTEVENT_CLASS_WHEEL class.
89 PP_INPUTEVENT_TYPE_WHEEL
= 5,
91 * Notification that a key transitioned from "up" to "down".
93 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
96 * TODO(brettw) differentiate from KEYDOWN.
98 PP_INPUTEVENT_TYPE_RAWKEYDOWN
= 6,
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.
104 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
106 PP_INPUTEVENT_TYPE_KEYDOWN
= 7,
108 * Notification that a key was released.
110 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
112 PP_INPUTEVENT_TYPE_KEYUP
= 8,
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.
118 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
120 PP_INPUTEVENT_TYPE_CHAR
= 9,
122 * Notification that a context menu should be shown.
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.
130 * You will always get the normal mouse events. For example, you may see
131 * MOUSEDOWN,CONTEXTMENU,MOUSEUP or MOUSEDOWN,MOUSEUP,CONTEXTMENU.
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
141 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
143 PP_INPUTEVENT_TYPE_CONTEXTMENU
= 10,
145 * Notification that an input method composition process has just started.
147 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
149 PP_INPUTEVENT_TYPE_IME_COMPOSITION_START
= 11,
151 * Notification that the input method composition string is updated.
153 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
155 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE
= 12,
157 * Notification that an input method composition process has completed.
159 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
161 PP_INPUTEVENT_TYPE_IME_COMPOSITION_END
= 13,
163 * Notification that an input method committed a string.
165 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
167 PP_INPUTEVENT_TYPE_IME_TEXT
= 14,
169 * Notification that a finger was placed on a touch-enabled device.
171 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
173 PP_INPUTEVENT_TYPE_TOUCHSTART
= 15,
175 * Notification that a finger was moved on a touch-enabled device.
177 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
179 PP_INPUTEVENT_TYPE_TOUCHMOVE
= 16,
181 * Notification that a finger was released on a touch-enabled device.
183 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
185 PP_INPUTEVENT_TYPE_TOUCHEND
= 17,
187 * Notification that a touch event was canceled.
189 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
191 PP_INPUTEVENT_TYPE_TOUCHCANCEL
= 18
192 } PP_InputEvent_Type
;
193 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type
, 4);
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.
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
;
215 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier
, 4);
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
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
;
228 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton
, 4);
232 * Request mouse input events.
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.
240 PP_INPUTEVENT_CLASS_MOUSE
= 1 << 0,
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.
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.
252 PP_INPUTEVENT_CLASS_KEYBOARD
= 1 << 1,
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.
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
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
271 PP_INPUTEVENT_CLASS_WHEEL
= 1 << 2,
273 * Identifies touch input events.
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.
284 PP_INPUTEVENT_CLASS_TOUCH
= 1 << 3,
286 * Identifies IME composition input events.
288 * Request this input event class if you allow on-the-spot IME input.
290 PP_INPUTEVENT_CLASS_IME
= 1 << 4
291 } PP_InputEvent_Class
;
292 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Class
, 4);
298 * @addtogroup Interfaces
302 * The <code>PPB_InputEvent</code> interface contains pointers to several
303 * functions related to generic input events on the browser.
305 struct PPB_InputEvent_1_0
{
307 * RequestInputEvent() requests that input events corresponding to the given
308 * input events are delivered to the instance.
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.
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).
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
329 * Note that synthetic mouse events will be generated from touch events if
330 * (and only if) the you do not request touch events.
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.
337 * <strong>Example:</strong>
339 * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
340 * RequestFilteringInputEvents(instance,
341 * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
344 * @param instance The <code>PP_Instance</code> of the instance requesting
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
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().
360 int32_t (*RequestInputEvents
)(PP_Instance instance
, uint32_t event_classes
);
362 * RequestFilteringInputEvents() requests that input events corresponding to
363 * the given input events are delivered to the instance for filtering.
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().
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.
378 * <strong>Example:</strong>
380 * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
381 * RequestFilteringInputEvents(instance,
382 * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
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.
391 int32_t (*RequestFilteringInputEvents
)(PP_Instance instance
,
392 uint32_t event_classes
);
394 * ClearInputEventRequest() requests that input events corresponding to the
395 * given input classes no longer be delivered to the instance.
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
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.
409 * @param instance The <code>PP_Instance</code> of the instance requesting
410 * to no longer receive the given events.
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.
416 void (*ClearInputEventRequest
)(PP_Instance instance
, uint32_t event_classes
);
418 * IsInputEvent() returns true if the given resource is a valid input event
421 * @param[in] resource A <code>PP_Resource</code> corresponding to a generic
424 * @return <code>PP_TRUE</code> if the given resource is a valid input event
427 PP_Bool (*IsInputEvent
)(PP_Resource resource
);
429 * GetType() returns the type of input event for the given input event
432 * @param[in] resource A <code>PP_Resource</code> corresponding to an input
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.
438 PP_InputEvent_Type (*GetType
)(PP_Resource event
);
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.
445 * @param[in] resource A <code>PP_Resource</code> corresponding to the event.
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.
453 PP_TimeTicks (*GetTimeStamp
)(PP_Resource event
);
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.
459 * @param[in] resource A <code>PP_Resource</code> corresponding to an input
462 * @return The modifiers associated with the event, or 0 if the given
463 * resource is not a valid event resource.
465 uint32_t (*GetModifiers
)(PP_Resource event
);
468 typedef struct PPB_InputEvent_1_0 PPB_InputEvent
;
471 * The <code>PPB_MouseInputEvent</code> interface contains pointers to several
472 * functions related to mouse input events.
474 struct PPB_MouseInputEvent_1_1
{
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.
482 * @param[in] instance The instance for which this event occurred.
484 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
487 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
488 * when the event occurred.
490 * @param[in] modifiers A bit field combination of the
491 * <code>PP_InputEvent_Modifier</code> flags.
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.
497 * @param[in] mouse_position A <code>Point</code> containing the x and y
498 * position of the mouse when the event occurred.
500 * @param[in] mouse_movement The change in position of the mouse.
502 * @return A <code>PP_Resource</code> containing the new mouse input event.
504 PP_Resource (*Create
)(PP_Instance instance
,
505 PP_InputEvent_Type type
,
506 PP_TimeTicks time_stamp
,
508 PP_InputEvent_MouseButton mouse_button
,
509 const struct PP_Point
* mouse_position
,
511 const struct PP_Point
* mouse_movement
);
513 * IsMouseInputEvent() determines if a resource is a mouse event.
515 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
517 * @return <code>PP_TRUE</code> if the given resource is a valid mouse input
518 * event, otherwise <code>PP_FALSE</code>.
520 PP_Bool (*IsMouseInputEvent
)(PP_Resource resource
);
522 * GetButton() returns the mouse button that generated a mouse down or up
525 * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
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.
532 PP_InputEvent_MouseButton (*GetButton
)(PP_Resource mouse_event
);
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.
538 * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
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.
545 struct PP_Point (*GetPosition
)(PP_Resource mouse_event
);
547 * TODO(brettw) figure out exactly what this means.
549 int32_t (*GetClickCount
)(PP_Resource mouse_event
);
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.
556 * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
559 * @return The change in position of the mouse, relative to the previous
562 struct PP_Point (*GetMovement
)(PP_Resource mouse_event
);
565 typedef struct PPB_MouseInputEvent_1_1 PPB_MouseInputEvent
;
567 struct PPB_MouseInputEvent_1_0
{
568 PP_Resource (*Create
)(PP_Instance instance
,
569 PP_InputEvent_Type type
,
570 PP_TimeTicks time_stamp
,
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
);
582 * The <code>PPB_WheelIputEvent</code> interface contains pointers to several
583 * functions related to wheel input events.
585 struct PPB_WheelInputEvent_1_0
{
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.
592 * @param[in] instance The instance for which this event occurred.
594 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
595 * when the event occurred.
597 * @param[in] modifiers A bit field combination of the
598 * <code>PP_InputEvent_Modifier</code> flags.
600 * @param[in] wheel_delta The scroll wheel's horizontal and vertical scroll
603 * @param[in] wheel_ticks The number of "clicks" of the scroll wheel that
604 * have produced the event.
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.
609 * @return A <code>PP_Resource</code> containing the new wheel input event.
611 PP_Resource (*Create
)(PP_Instance instance
,
612 PP_TimeTicks time_stamp
,
614 const struct PP_FloatPoint
* wheel_delta
,
615 const struct PP_FloatPoint
* wheel_ticks
,
616 PP_Bool scroll_by_page
);
618 * IsWheelInputEvent() determines if a resource is a wheel event.
620 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to an
623 * @return <code>PP_TRUE</code> if the given resource is a valid wheel input
626 PP_Bool (*IsWheelInputEvent
)(PP_Resource resource
);
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.
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.
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
643 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
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.
651 struct PP_FloatPoint (*GetDelta
)(PP_Resource wheel_event
);
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().
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
663 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
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.
674 struct PP_FloatPoint (*GetTicks
)(PP_Resource wheel_event
);
676 * GetScrollByPage() indicates if the scroll delta x/y indicates pages or
677 * lines to scroll by.
679 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
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
686 PP_Bool (*GetScrollByPage
)(PP_Resource wheel_event
);
689 typedef struct PPB_WheelInputEvent_1_0 PPB_WheelInputEvent
;
692 * The <code>PPB_KeyboardInputEvent</code> interface contains pointers to
693 * several functions related to keyboard input events.
695 struct PPB_KeyboardInputEvent_1_0
{
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.
702 * @param[in] instance The instance for which this event occurred.
704 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
707 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
708 * when the event occurred.
710 * @param[in] modifiers A bit field combination of the
711 * <code>PP_InputEvent_Modifier</code> flags.
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.
717 * @param[in] character_text This value represents the typed character as a
720 * @return A <code>PP_Resource</code> containing the new keyboard input
723 PP_Resource (*Create
)(PP_Instance instance
,
724 PP_InputEvent_Type type
,
725 PP_TimeTicks time_stamp
,
728 struct PP_Var character_text
);
730 * IsKeyboardInputEvent() determines if a resource is a keyboard event.
732 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
734 * @return <code>PP_TRUE</code> if the given resource is a valid input event.
736 PP_Bool (*IsKeyboardInputEvent
)(PP_Resource resource
);
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.
741 * @param[in] key_event A <code>PP_Resource</code> corresponding to a
744 * @return The DOM keyCode field for the keyboard event.
746 uint32_t (*GetKeyCode
)(PP_Resource key_event
);
748 * GetCharacterText() returns the typed character as a UTF-8 string for the
749 * given character event.
751 * @param[in] character_event A <code>PP_Resource</code> corresponding to a
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
758 struct PP_Var (*GetCharacterText
)(PP_Resource character_event
);
761 typedef struct PPB_KeyboardInputEvent_1_0 PPB_KeyboardInputEvent
;
772 * The list of all TouchPoints which are currently down.
774 PP_TOUCHLIST_TYPE_TOUCHES
= 0,
776 * The list of all TouchPoints whose state has changed since the last
779 PP_TOUCHLIST_TYPE_CHANGEDTOUCHES
= 1,
781 * The list of all TouchPoints which are targeting this plugin. This is a
784 PP_TOUCHLIST_TYPE_TARGETTOUCHES
= 2
786 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TouchListType
, 4);
792 * @addtogroup Interfaces
796 * The <code>PPB_TouchInputEvent</code> interface contains pointers to several
797 * functions related to touch events.
799 struct PPB_TouchInputEvent_1_0
{
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.
809 * @param[in] instance The instance for which this event occurred.
811 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
814 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
815 * when the event occurred.
817 * @param[in] modifiers A bit field combination of the
818 * <code>PP_InputEvent_Modifier</code> flags.
820 * @return A <code>PP_Resource</code> containing the new touch input event.
822 PP_Resource (*Create
)(PP_Instance instance
,
823 PP_InputEvent_Type type
,
824 PP_TimeTicks time_stamp
,
827 * Adds a touch point to the touch event in the specified touch-list.
829 * @param[in] touch_event A <code>PP_Resource</code> corresponding to a touch
832 * @param[in] list The list to add the touch point to.
834 * @param[in] point The point to add to the list.
836 void (*AddTouchPoint
)(PP_Resource touch_event
,
837 PP_TouchListType list
,
838 const struct PP_TouchPoint
* point
);
840 * IsTouchInputEvent() determines if a resource is a touch event.
842 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
844 * @return <code>PP_TRUE</code> if the given resource is a valid touch input
845 * event, otherwise <code>PP_FALSE</code>.
847 PP_Bool (*IsTouchInputEvent
)(PP_Resource resource
);
849 * Returns the number of touch-points in the specified list.
851 * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
854 * @param[in] list The list.
856 * @return The number of touch-points in the specified list.
858 uint32_t (*GetTouchCount
)(PP_Resource resource
, PP_TouchListType list
);
860 * Returns the touch-point at the specified index from the specified list.
862 * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
865 * @param[in] list The list.
867 * @param[in] index The index.
869 * @return A <code>PP_TouchPoint</code> representing the touch-point.
871 struct PP_TouchPoint (*GetTouchByIndex
)(PP_Resource resource
,
872 PP_TouchListType list
,
875 * Returns the touch-point with the specified touch-id in the specified list.
877 * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
880 * @param[in] list The list.
882 * @param[in] touch_id The id of the touch-point.
884 * @return A <code>PP_TouchPoint</code> representing the touch-point.
886 struct PP_TouchPoint (*GetTouchById
)(PP_Resource resource
,
887 PP_TouchListType list
,
891 typedef struct PPB_TouchInputEvent_1_0 PPB_TouchInputEvent
;
896 #endif /* PPAPI_C_PPB_INPUT_EVENT_H_ */