| OLD | NEW | 
|    1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #ifndef PPAPI_C_PP_INPUT_EVENT_H_ |    5 #ifndef PPAPI_C_PP_INPUT_EVENT_H_ | 
|    6 #define PPAPI_C_PP_INPUT_EVENT_H_ |    6 #define PPAPI_C_PP_INPUT_EVENT_H_ | 
|    7  |    7  | 
|    8 /** |    8 /** | 
|    9  * @file |    9  * @file | 
|   10  * Defines the API ... |   10  * Defines the API ... | 
|   11  * |   11  * | 
|   12  * @addtogroup PP |   12  * @addtogroup PP | 
|   13  * @{ |   13  * @{ | 
|   14  */ |   14  */ | 
|   15  |   15  | 
|   16 #include "ppapi/c/pp_bool.h" |   16 #include "ppapi/c/pp_bool.h" | 
|   17 #include "ppapi/c/pp_macros.h" |   17 #include "ppapi/c/pp_macros.h" | 
|   18 #include "ppapi/c/pp_stdint.h" |   18 #include "ppapi/c/pp_stdint.h" | 
|   19 #include "ppapi/c/pp_time.h" |   19 #include "ppapi/c/pp_time.h" | 
|   20  |   20  | 
|   21 typedef enum { |   21 typedef enum { | 
|   22   PP_INPUTEVENT_MOUSEBUTTON_NONE   = -1, |   22   PP_INPUTEVENT_MOUSEBUTTON_NONE   = -1, | 
|   23   PP_INPUTEVENT_MOUSEBUTTON_LEFT   = 0, |   23   PP_INPUTEVENT_MOUSEBUTTON_LEFT   = 0, | 
|   24   PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1, |   24   PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1, | 
|   25   PP_INPUTEVENT_MOUSEBUTTON_RIGHT  = 2 |   25   PP_INPUTEVENT_MOUSEBUTTON_RIGHT  = 2 | 
|   26 } PP_InputEvent_MouseButton; |   26 } PP_InputEvent_MouseButton; | 
 |   27 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_MouseButton, 4); | 
|   27  |   28  | 
|   28 typedef enum { |   29 typedef enum { | 
|   29   PP_INPUTEVENT_TYPE_UNDEFINED  = -1, |   30   PP_INPUTEVENT_TYPE_UNDEFINED  = -1, | 
|   30   PP_INPUTEVENT_TYPE_MOUSEDOWN  = 0, |   31   PP_INPUTEVENT_TYPE_MOUSEDOWN  = 0, | 
|   31   PP_INPUTEVENT_TYPE_MOUSEUP    = 1, |   32   PP_INPUTEVENT_TYPE_MOUSEUP    = 1, | 
|   32   PP_INPUTEVENT_TYPE_MOUSEMOVE  = 2, |   33   PP_INPUTEVENT_TYPE_MOUSEMOVE  = 2, | 
|   33   PP_INPUTEVENT_TYPE_MOUSEENTER = 3, |   34   PP_INPUTEVENT_TYPE_MOUSEENTER = 3, | 
|   34   PP_INPUTEVENT_TYPE_MOUSELEAVE = 4, |   35   PP_INPUTEVENT_TYPE_MOUSELEAVE = 4, | 
|   35   PP_INPUTEVENT_TYPE_MOUSEWHEEL = 5, |   36   PP_INPUTEVENT_TYPE_MOUSEWHEEL = 5, | 
|   36   PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6, |   37   PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6, | 
|   37   PP_INPUTEVENT_TYPE_KEYDOWN    = 7, |   38   PP_INPUTEVENT_TYPE_KEYDOWN    = 7, | 
|   38   PP_INPUTEVENT_TYPE_KEYUP      = 8, |   39   PP_INPUTEVENT_TYPE_KEYUP      = 8, | 
|   39   PP_INPUTEVENT_TYPE_CHAR       = 9 |   40   PP_INPUTEVENT_TYPE_CHAR       = 9 | 
|   40 } PP_InputEvent_Type; |   41 } PP_InputEvent_Type; | 
 |   42 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Type, 4); | 
|   41  |   43  | 
|   42 typedef enum { |   44 typedef enum { | 
|   43   PP_INPUTEVENT_MODIFIER_SHIFTKEY         = 1 << 0, |   45   PP_INPUTEVENT_MODIFIER_SHIFTKEY         = 1 << 0, | 
|   44   PP_INPUTEVENT_MODIFIER_CONTROLKEY       = 1 << 1, |   46   PP_INPUTEVENT_MODIFIER_CONTROLKEY       = 1 << 1, | 
|   45   PP_INPUTEVENT_MODIFIER_ALTKEY           = 1 << 2, |   47   PP_INPUTEVENT_MODIFIER_ALTKEY           = 1 << 2, | 
|   46   PP_INPUTEVENT_MODIFIER_METAKEY          = 1 << 3, |   48   PP_INPUTEVENT_MODIFIER_METAKEY          = 1 << 3, | 
|   47   PP_INPUTEVENT_MODIFIER_ISKEYPAD         = 1 << 4, |   49   PP_INPUTEVENT_MODIFIER_ISKEYPAD         = 1 << 4, | 
|   48   PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT     = 1 << 5, |   50   PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT     = 1 << 5, | 
|   49   PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN   = 1 << 6, |   51   PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN   = 1 << 6, | 
|   50   PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7, |   52   PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7, | 
|   51   PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN  = 1 << 8, |   53   PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN  = 1 << 8, | 
|   52   PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY      = 1 << 9, |   54   PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY      = 1 << 9, | 
|   53   PP_INPUTEVENT_MODIFIER_NUMLOCKKEY       = 1 << 10 |   55   PP_INPUTEVENT_MODIFIER_NUMLOCKKEY       = 1 << 10 | 
|   54 } PP_InputEvent_Modifier; |   56 } PP_InputEvent_Modifier; | 
 |   57 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InputEvent_Modifier, 4); | 
|   55  |   58  | 
|   56 /** |   59 /** | 
|   57  * An event representing a key up or down event. |   60  * An event representing a key up or down event. | 
|   58  * |   61  * | 
|   59  * Key up and down events correspond to physical keys on the keyboard. The |   62  * Key up and down events correspond to physical keys on the keyboard. The | 
|   60  * actual character that the user typed (if any) will be delivered in a |   63  * actual character that the user typed (if any) will be delivered in a | 
|   61  * "character" event. |   64  * "character" event. | 
|   62  * |   65  * | 
|   63  * If the user kills focus on the plugin while a key is down, you may not get |   66  * If the user kills focus on the plugin while a key is down, you may not get | 
|   64  * a key up event. For example, if the plugin has focus and the user presses |   67  * a key up event. For example, if the plugin has focus and the user presses | 
|   65  * and holds shift, the plugin will see a "shift down" message. Then if they |   68  * and holds shift, the plugin will see a "shift down" message. Then if they | 
|   66  * click elsewhere on the web page, the plugin focus will be lost and no more |   69  * click elsewhere on the web page, the plugin focus will be lost and no more | 
|   67  * input events will be delivered. If you depend on getting key up events, you |   70  * input events will be delivered. If you depend on getting key up events, you | 
|   68  * will also want to handle "lost focus" as the equivalent of "all keys up." |   71  * will also want to handle "lost focus" as the equivalent of "all keys up." | 
|   69  */ |   72  */ | 
|   70 struct PP_InputEvent_Key { |   73 struct PP_InputEvent_Key { | 
|   71   /** A combination of the EVENT_MODIFIER flags. */ |   74   /** A combination of the EVENT_MODIFIER flags. */ | 
|   72   uint32_t modifier; |   75   uint32_t modifier; | 
|   73  |   76  | 
|   74   /** |   77   /** | 
|   75    * The key code. |   78    * The key code. | 
|   76    * |   79    * | 
|   77    * TODO(brettw) define what these actually are. |   80    * TODO(brettw) define what these actually are. | 
|   78    */ |   81    */ | 
|   79   uint32_t key_code; |   82   uint32_t key_code; | 
|   80 }; |   83 }; | 
 |   84 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Key, 8); | 
|   81  |   85  | 
|   82 /** |   86 /** | 
|   83  * An event representing a typed character. |   87  * An event representing a typed character. | 
|   84  * |   88  * | 
|   85  * Normally, the program will receive a key down event, followed by a character |   89  * Normally, the program will receive a key down event, followed by a character | 
|   86  * event, followed by a key up event. The character event will have any |   90  * event, followed by a key up event. The character event will have any | 
|   87  * modifier keys applied. Obvious examples are symbols, where Shift-5 gives you |   91  * modifier keys applied. Obvious examples are symbols, where Shift-5 gives you | 
|   88  * a '%'. The key down and up events will give you the scan code for the "5" |   92  * a '%'. The key down and up events will give you the scan code for the "5" | 
|   89  * key, and the character event will give you the '%' character. |   93  * key, and the character event will give you the '%' character. | 
|   90  * |   94  * | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  104   uint32_t modifier; |  108   uint32_t modifier; | 
|  105  |  109  | 
|  106   /** |  110   /** | 
|  107    * The character the user typed, as a single null-terminated UTF-8 character. |  111    * The character the user typed, as a single null-terminated UTF-8 character. | 
|  108    * Any unused bytes will be filled with null bytes. Since the maximum UTF-8 |  112    * Any unused bytes will be filled with null bytes. Since the maximum UTF-8 | 
|  109    * character is 4 bytes, there will always be at least one null at the end |  113    * character is 4 bytes, there will always be at least one null at the end | 
|  110    * so you can treat this as a null-termianted UTF-8 string. |  114    * so you can treat this as a null-termianted UTF-8 string. | 
|  111    */ |  115    */ | 
|  112   char text[5]; |  116   char text[5]; | 
|  113 }; |  117 }; | 
 |  118 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Character, 12); | 
|  114  |  119  | 
|  115 /** Represents a mouse event for everything other than the mouse wheel. */ |  120 /** Represents a mouse event for everything other than the mouse wheel. */ | 
|  116 struct PP_InputEvent_Mouse { |  121 struct PP_InputEvent_Mouse { | 
|  117   /** A combination of the EVENT_MODIFIER flags. */ |  122   /** A combination of the EVENT_MODIFIER flags. */ | 
|  118   uint32_t modifier; |  123   uint32_t modifier; | 
|  119  |  124  | 
|  120   /** |  125   /** | 
|  121    * Which button changed in the case of mouse down or up events. For mouse |  126    * Which button changed in the case of mouse down or up events. For mouse | 
|  122    * move, enter, and leave events, this will be PP_EVENT_MOUSEBUTTON_NONE. |  127    * move, enter, and leave events, this will be PP_EVENT_MOUSEBUTTON_NONE. | 
|  123    */ |  128    */ | 
|  124   PP_InputEvent_MouseButton button; |  129   PP_InputEvent_MouseButton button; | 
|  125  |  130  | 
|  126   /** |  131   /** | 
|  127    * The coordinates of the mouse when the event occurred. |  132    * The coordinates of the mouse when the event occurred. | 
|  128    * |  133    * | 
|  129    * In most cases these coordinates will just be integers, but they may not |  134    * In most cases these coordinates will just be integers, but they may not | 
|  130    * be in some cases. For example, the plugin element might be arbitrarily |  135    * be in some cases. For example, the plugin element might be arbitrarily | 
|  131    * scaled or transformed in the DOM, and translating a mouse event into the |  136    * scaled or transformed in the DOM, and translating a mouse event into the | 
|  132    * coordinate space of the plugin will give non-integer values. |  137    * coordinate space of the plugin will give non-integer values. | 
|  133    */ |  138    */ | 
|  134   float x; |  139   float x; | 
|  135   float y; |  140   float y; | 
|  136  |  141  | 
|  137   /** TODO(brettw) figure out exactly what this means. */ |  142   /** TODO(brettw) figure out exactly what this means. */ | 
|  138   int32_t click_count; |  143   int32_t click_count; | 
|  139 }; |  144 }; | 
 |  145 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Mouse, 20); | 
|  140  |  146  | 
|  141 struct PP_InputEvent_Wheel { |  147 struct PP_InputEvent_Wheel { | 
|  142   /** A combination of the EVENT_MODIFIER flags. */ |  148   /** A combination of the EVENT_MODIFIER flags. */ | 
|  143   uint32_t modifier; |  149   uint32_t modifier; | 
|  144  |  150  | 
|  145   float delta_x; |  151   float delta_x; | 
|  146   float delta_y; |  152   float delta_y; | 
|  147   float wheel_ticks_x; |  153   float wheel_ticks_x; | 
|  148   float wheel_ticks_y; |  154   float wheel_ticks_y; | 
|  149  |  155  | 
|  150   PP_Bool scroll_by_page; |  156   PP_Bool scroll_by_page; | 
|  151 }; |  157 }; | 
 |  158 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent_Wheel, 24); | 
|  152  |  159  | 
|  153 struct PP_InputEvent { |  160 struct PP_InputEvent { | 
|  154   /** Identifies the type of the event. */ |  161   /** Identifies the type of the event. */ | 
|  155   PP_InputEvent_Type type; |  162   PP_InputEvent_Type type; | 
|  156  |  163  | 
|  157   /* Ensure the time_stamp is aligned on an 8-byte boundary relative to the |  164   /* Ensure the time_stamp is aligned on an 8-byte boundary relative to the | 
|  158      start of the struct. Some compilers align doubles on 8-byte boundaries |  165      start of the struct. Some compilers align doubles on 8-byte boundaries | 
|  159      for 32-bit x86, and some align on 4-byte boundaries. */ |  166      for 32-bit x86, and some align on 4-byte boundaries. */ | 
|  160   int32_t padding; |  167   int32_t padding; | 
|  161  |  168  | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  180   } u; |  187   } u; | 
|  181 }; |  188 }; | 
|  182 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent, 80); |  189 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_InputEvent, 80); | 
|  183  |  190  | 
|  184 /** |  191 /** | 
|  185  * @} |  192  * @} | 
|  186  * End of addtogroup PP |  193  * End of addtogroup PP | 
|  187  */ |  194  */ | 
|  188  |  195  | 
|  189 #endif  // PPAPI_C_PP_INPUT_EVENT_H_ |  196 #endif  // PPAPI_C_PP_INPUT_EVENT_H_ | 
| OLD | NEW |