blob: 351560a3712549168034fb49d669b9e919220b9e [file] [log] [blame]
[email protected]db5523b2011-01-21 21:12:551/* Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]6ea69542010-12-20 18:15:592 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
[email protected]9b37f4802011-07-19 00:09:285
[email protected]b6cf7682011-08-12 15:59:496/* From pp_input_event.idl modified Thu Aug 11 14:47:50 2011. */
[email protected]9b37f4802011-07-19 00:09:287
[email protected]1758e882010-11-01 16:16:508#ifndef PPAPI_C_PP_INPUT_EVENT_H_
9#define PPAPI_C_PP_INPUT_EVENT_H_
10
[email protected]6f2e3912010-11-05 14:45:4411#include "ppapi/c/pp_bool.h"
[email protected]41ec3282010-11-12 21:45:1012#include "ppapi/c/pp_macros.h"
[email protected]1758e882010-11-01 16:16:5013#include "ppapi/c/pp_stdint.h"
[email protected]493d14212011-07-07 15:38:4814#include "ppapi/c/ppb_input_event.h"
[email protected]040d5e82011-01-28 15:38:3815
16/**
[email protected]9b37f4802011-07-19 00:09:2817 * @file
18 * This file defines the API used to handle mouse and keyboard input events.
19 */
20
21
22/**
[email protected]040d5e82011-01-28 15:38:3823 * @addtogroup Structs
24 * @{
25 */
[email protected]1758e882010-11-01 16:16:5026/**
[email protected]c5495952011-06-30 22:57:1727 * The <code>PP_InputEvent_Key</code> struct represents a key up or key down
28 * event.
[email protected]1758e882010-11-01 16:16:5029 *
[email protected]3bcd2cc2011-02-16 22:47:1830 * Key up and key down events correspond to physical keys on the keyboard. The
[email protected]1758e882010-11-01 16:16:5031 * actual character that the user typed (if any) will be delivered in a
32 * "character" event.
33 *
[email protected]3bcd2cc2011-02-16 22:47:1834 * If the user loses focus on the module while a key is down, a key up
35 * event might not occur. For example, if the module has focus and the user
36 * presses and holds the shift key, the module will see a "shift down" message.
37 * Then if the user clicks elsewhere on the web page, the module's focus will
38 * be lost and no more input events will be delivered.
[email protected]040d5e82011-01-28 15:38:3839 *
[email protected]3bcd2cc2011-02-16 22:47:1840 * If your module depends on receiving key up events, it should also handle
41 * "lost focus" as the equivalent of "all keys up."
[email protected]1758e882010-11-01 16:16:5042 */
43struct PP_InputEvent_Key {
[email protected]3bcd2cc2011-02-16 22:47:1844 /** This value is a bit field combination of the EVENT_MODIFIER flags. */
[email protected]1758e882010-11-01 16:16:5045 uint32_t modifier;
[email protected]1758e882010-11-01 16:16:5046 /**
[email protected]c5495952011-06-30 22:57:1747 * This value reflects the DOM KeyboardEvent <code>keyCode</code> field.
[email protected]06b5f9d2011-04-08 10:12:5648 * Chrome populates this with the Windows-style Virtual Key code of the key.
[email protected]1758e882010-11-01 16:16:5049 */
50 uint32_t key_code;
51};
[email protected]bb2bd5ee2011-04-26 17:26:0552PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Key, 8);
[email protected]1758e882010-11-01 16:16:5053
54/**
[email protected]c5495952011-06-30 22:57:1755 * The <code>PP_InputEvent_Character</code> struct represents a typed character
56 * event.
[email protected]1758e882010-11-01 16:16:5057 *
58 * Normally, the program will receive a key down event, followed by a character
59 * event, followed by a key up event. The character event will have any
60 * modifier keys applied. Obvious examples are symbols, where Shift-5 gives you
61 * a '%'. The key down and up events will give you the scan code for the "5"
62 * key, and the character event will give you the '%' character.
63 *
[email protected]3bcd2cc2011-02-16 22:47:1864 * You may not get a character event for all key down events if the key doesn't
[email protected]1758e882010-11-01 16:16:5065 * generate a character. Likewise, you may actually get multiple character
66 * events in a row. For example, some locales have an accent key that modifies
67 * the next character typed. You might get this stream of events: accent down,
68 * accent up (it didn't generate a character), letter key down, letter with
69 * accent character event (it was modified by the previous accent key), letter
70 * key up. If the letter can't be combined with the accent, like an umlaut and
71 * an 'R', the system might send unlaut down, umlaut up, 'R' key down, umlaut
[email protected]3bcd2cc2011-02-16 22:47:1872 * character (can't combine it with 'R', so just send the raw unlaut so it
73 * isn't lost"), 'R' character event, 'R' key up.
[email protected]1758e882010-11-01 16:16:5074 */
75struct PP_InputEvent_Character {
[email protected]c5495952011-06-30 22:57:1776 /** A combination of the <code>PP_InputEvent_Modifier</code> flags. */
[email protected]1758e882010-11-01 16:16:5077 uint32_t modifier;
[email protected]1758e882010-11-01 16:16:5078 /**
[email protected]3bcd2cc2011-02-16 22:47:1879 * This value represents the typed character as a single null-terminated UTF-8
80 * character. Any unused bytes will be filled with null bytes. Since the
81 * maximum UTF-8 character is 4 bytes, there will always be at least one null
82 * at the end so you can treat this as a null-termianted UTF-8 string.
[email protected]1758e882010-11-01 16:16:5083 */
84 char text[5];
85};
[email protected]1ad2a1db2010-12-13 20:04:3186PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Character, 12);
[email protected]1758e882010-11-01 16:16:5087
[email protected]3bcd2cc2011-02-16 22:47:1888/**
[email protected]c5495952011-06-30 22:57:1789 * The <code>PP_InputEvent_Mouse</code> struct represents all mouse events
90 * except mouse wheel events.
[email protected]3bcd2cc2011-02-16 22:47:1891 */
[email protected]1758e882010-11-01 16:16:5092struct PP_InputEvent_Mouse {
[email protected]c5495952011-06-30 22:57:1793 /**
94 * This value is a bit field combination of the
95 * <code>PP_InputEvent_Modifier</code> flags.
96 */
[email protected]1758e882010-11-01 16:16:5097 uint32_t modifier;
[email protected]1758e882010-11-01 16:16:5098 /**
[email protected]3bcd2cc2011-02-16 22:47:1899 * This value represents the button that changed for mouse down or up events.
[email protected]c5495952011-06-30 22:57:17100 * This value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for mouse move,
101 * enter, and leave events.
[email protected]1758e882010-11-01 16:16:50102 */
103 PP_InputEvent_MouseButton button;
[email protected]1758e882010-11-01 16:16:50104 /**
[email protected]3bcd2cc2011-02-16 22:47:18105 * This values represents the x coordinate of the mouse when the event
106 * occurred.
[email protected]1758e882010-11-01 16:16:50107 *
[email protected]3bcd2cc2011-02-16 22:47:18108 * In most, but not all, cases these coordinates will just be integers.
109 * For example, the plugin element might be arbitrarily scaled or transformed
110 * in the DOM, and translating a mouse event into the coordinate space of the
111 * plugin will give non-integer values.
[email protected]1758e882010-11-01 16:16:50112 */
113 float x;
[email protected]3bcd2cc2011-02-16 22:47:18114 /**
115 * This values represents the y coordinate of the mouse when the event
116 * occurred.
117 *
118 * In most, but not all, cases these coordinates will just be integers.
119 * For example, the plugin element might be arbitrarily scaled or transformed
120 * in the DOM, and translating a mouse event into the coordinate space of the
121 * plugin will give non-integer values.
122 */
[email protected]1758e882010-11-01 16:16:50123 float y;
[email protected]9b37f4802011-07-19 00:09:28124 /* TODO(brettw) figure out exactly what this means. */
[email protected]1758e882010-11-01 16:16:50125 int32_t click_count;
126};
[email protected]1ad2a1db2010-12-13 20:04:31127PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Mouse, 20);
[email protected]3bcd2cc2011-02-16 22:47:18128
129/**
[email protected]c5495952011-06-30 22:57:17130 * The <code>PP_InputEvent_Wheel</code> struct represents all mouse wheel
131 * events.
[email protected]3bcd2cc2011-02-16 22:47:18132 */
[email protected]1758e882010-11-01 16:16:50133struct PP_InputEvent_Wheel {
[email protected]c5495952011-06-30 22:57:17134 /**
135 * This value represents a combination of the <code>EVENT_MODIFIER</code>
136 * flags.
137 */
[email protected]1758e882010-11-01 16:16:50138 uint32_t modifier;
[email protected]cd7873e52011-02-15 23:01:07139 /**
[email protected]b6cf7682011-08-12 15:59:49140 * The mouse wheel's horizontal scroll amount. A scroll to the right
141 * (where the content moves left) is represented as positive values,
142 * and a scroll to the left (where the content moves right) is
[email protected]cd7873e52011-02-15 23:01:07143 * represented as negative values.
144 *
145 * The units are either in pixels (when scroll_by_page is false) or pages
146 * (when scroll_by_page is true). For example, delta_y = -3 means scroll up 3
147 * pixels when scroll_by_page is false, and scroll up 3 pages when
148 * scroll_by_page is true.
149 *
150 * This amount is system dependent and will take into account the user's
151 * preferred scroll sensitivity and potentially also nonlinear acceleration
152 * based on the speed of the scrolling.
153 *
154 * Devices will be of varying resolution. Some mice with large detents will
155 * only generate integer scroll amounts. But fractional values are also
156 * possible, for example, on some trackpads and newer mice that don't have
157 * "clicks".
158 */
[email protected]1758e882010-11-01 16:16:50159 float delta_x;
[email protected]b6cf7682011-08-12 15:59:49160 /**
161 * The mouse wheel's vertical scroll amount. A scroll down (where the
162 * content moves up) is represented as positive values, and a scroll up
163 * (where the content moves down) is represented as negative values.
164 *
165 * The units are either in pixels (when scroll_by_page is false) or pages
166 * (when scroll_by_page is true). For example, delta_y = -3 means scroll up 3
167 * pixels when scroll_by_page is false, and scroll up 3 pages when
168 * scroll_by_page is true.
169 *
170 * This amount is system dependent and will take into account the user's
171 * preferred scroll sensitivity and potentially also nonlinear acceleration
172 * based on the speed of the scrolling.
173 *
174 * Devices will be of varying resolution. Some mice with large detents will
175 * only generate integer scroll amounts. But fractional values are also
176 * possible, for example, on some trackpads and newer mice that don't have
177 * "clicks".
178 */
[email protected]1758e882010-11-01 16:16:50179 float delta_y;
[email protected]cd7873e52011-02-15 23:01:07180 /**
181 * The number of "clicks" of the scroll wheel that have produced the
182 * event. The value may have system-specific acceleration applied to it,
183 * depending on the device. The positive and negative meanings are the same
[email protected]c5495952011-06-30 22:57:17184 * as for <code>delta_x</code> and <code>delta_y</code>.
[email protected]cd7873e52011-02-15 23:01:07185 *
186 * If you are scrolling, you probably want to use the delta values above.
187 * These tick events can be useful if you aren't doing actual scrolling and
188 * don't want or pixel values. An example may be cycling between different
189 * items in a game.
190 *
191 * You may receive fractional values for the wheel ticks if the mouse wheel
192 * is high resolution or doesn't have "clicks". If your program wants
193 * discrete events (as in the "picking items" example) you should accumulate
194 * fractional click values from multiple messages until the total value
195 * reaches positive or negative one. This should represent a similar amount
196 * of scrolling as for a mouse that has a discrete mouse wheel.
197 */
[email protected]1758e882010-11-01 16:16:50198 float wheel_ticks_x;
[email protected]3bcd2cc2011-02-16 22:47:18199 /** This value represents */
[email protected]1758e882010-11-01 16:16:50200 float wheel_ticks_y;
[email protected]cd7873e52011-02-15 23:01:07201 /**
[email protected]c5495952011-06-30 22:57:17202 * Indicates if the scroll <code>delta_x</code>/<code>delta_y</code>
203 * indicates pages or lines to scroll by. When true, the user is requesting
204 * to scroll by pages.
[email protected]cd7873e52011-02-15 23:01:07205 */
[email protected]6f2e3912010-11-05 14:45:44206 PP_Bool scroll_by_page;
[email protected]1758e882010-11-01 16:16:50207};
[email protected]1ad2a1db2010-12-13 20:04:31208PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Wheel, 24);
[email protected]3bcd2cc2011-02-16 22:47:18209/**
[email protected]1758e882010-11-01 16:16:50210 * @}
[email protected]1758e882010-11-01 16:16:50211 */
212
[email protected]6ea69542010-12-20 18:15:59213#endif /* PPAPI_C_PP_INPUT_EVENT_H_ */
[email protected]9b37f4802011-07-19 00:09:28214