| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "ppapi/c/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
| 6 #include "ppapi/thunk/thunk.h" | 6 #include "ppapi/thunk/thunk.h" |
| 7 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/ppb_input_event_api.h" | 8 #include "ppapi/thunk/ppb_input_event_api.h" |
| 9 #include "ppapi/thunk/ppb_instance_api.h" | 9 #include "ppapi/thunk/ppb_instance_api.h" |
| 10 #include "ppapi/thunk/resource_creation_api.h" | 10 #include "ppapi/thunk/resource_creation_api.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 &GetWheelScrollByPage | 224 &GetWheelScrollByPage |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 // Keyboard -------------------------------------------------------------------- | 227 // Keyboard -------------------------------------------------------------------- |
| 228 | 228 |
| 229 PP_Resource CreateKeyboardInputEvent(PP_Instance instance, | 229 PP_Resource CreateKeyboardInputEvent(PP_Instance instance, |
| 230 PP_InputEvent_Type type, | 230 PP_InputEvent_Type type, |
| 231 PP_TimeTicks time_stamp, | 231 PP_TimeTicks time_stamp, |
| 232 uint32_t modifiers, | 232 uint32_t modifiers, |
| 233 uint32_t key_code, | 233 uint32_t key_code, |
| 234 uint32_t usb_scan_code, |
| 234 struct PP_Var character_text) { | 235 struct PP_Var character_text) { |
| 235 EnterFunction<ResourceCreationAPI> enter(instance, true); | 236 EnterFunction<ResourceCreationAPI> enter(instance, true); |
| 236 if (enter.failed()) | 237 if (enter.failed()) |
| 237 return 0; | 238 return 0; |
| 238 return enter.functions()->CreateKeyboardInputEvent(instance, type, time_stamp, | 239 return enter.functions()->CreateKeyboardInputEvent(instance, type, time_stamp, |
| 239 modifiers, key_code, | 240 modifiers, key_code, |
| 241 usb_scan_code, |
| 240 character_text); | 242 character_text); |
| 241 } | 243 } |
| 242 | 244 |
| 243 PP_Bool IsKeyboardInputEvent(PP_Resource resource) { | 245 PP_Bool IsKeyboardInputEvent(PP_Resource resource) { |
| 244 if (!IsInputEvent(resource)) | 246 if (!IsInputEvent(resource)) |
| 245 return PP_FALSE; // Prevent warning log in GetType. | 247 return PP_FALSE; // Prevent warning log in GetType. |
| 246 PP_InputEvent_Type type = GetType(resource); | 248 PP_InputEvent_Type type = GetType(resource); |
| 247 return PP_FromBool(type == PP_INPUTEVENT_TYPE_KEYDOWN || | 249 return PP_FromBool(type == PP_INPUTEVENT_TYPE_KEYDOWN || |
| 248 type == PP_INPUTEVENT_TYPE_KEYUP || | 250 type == PP_INPUTEVENT_TYPE_KEYUP || |
| 249 type == PP_INPUTEVENT_TYPE_RAWKEYDOWN || | 251 type == PP_INPUTEVENT_TYPE_RAWKEYDOWN || |
| 250 type == PP_INPUTEVENT_TYPE_CHAR); | 252 type == PP_INPUTEVENT_TYPE_CHAR); |
| 251 } | 253 } |
| 252 | 254 |
| 253 uint32_t GetKeyCode(PP_Resource key_event) { | 255 uint32_t GetKeyCode(PP_Resource key_event) { |
| 254 EnterInputEvent enter(key_event, true); | 256 EnterInputEvent enter(key_event, true); |
| 255 if (enter.failed()) | 257 if (enter.failed()) |
| 256 return 0; | 258 return 0; |
| 257 return enter.object()->GetKeyCode(); | 259 return enter.object()->GetKeyCode(); |
| 258 } | 260 } |
| 259 | 261 |
| 262 uint32_t GetUsbScanCode_Dev(PP_Resource key_event) { |
| 263 EnterInputEvent enter(key_event, true); |
| 264 if (enter.failed()) |
| 265 return 0; |
| 266 return enter.object()->GetUsbScanCode_Dev(); |
| 267 } |
| 268 |
| 260 PP_Var GetCharacterText(PP_Resource character_event) { | 269 PP_Var GetCharacterText(PP_Resource character_event) { |
| 261 EnterInputEvent enter(character_event, true); | 270 EnterInputEvent enter(character_event, true); |
| 262 if (enter.failed()) | 271 if (enter.failed()) |
| 263 return PP_MakeUndefined(); | 272 return PP_MakeUndefined(); |
| 264 return enter.object()->GetCharacterText(); | 273 return enter.object()->GetCharacterText(); |
| 265 } | 274 } |
| 266 | 275 |
| 267 const PPB_KeyboardInputEvent g_ppb_keyboard_input_event_thunk = { | 276 const PPB_KeyboardInputEvent g_ppb_keyboard_input_event_thunk = { |
| 268 &CreateKeyboardInputEvent, | 277 &CreateKeyboardInputEvent, |
| 269 &IsKeyboardInputEvent, | 278 &IsKeyboardInputEvent, |
| 270 &GetKeyCode, | 279 &GetKeyCode, |
| 280 &GetUsbScanCode_Dev, |
| 271 &GetCharacterText | 281 &GetCharacterText |
| 272 }; | 282 }; |
| 273 | 283 |
| 274 // Composition ----------------------------------------------------------------- | 284 // Composition ----------------------------------------------------------------- |
| 275 | 285 |
| 276 PP_Bool IsIMEInputEvent(PP_Resource resource) { | 286 PP_Bool IsIMEInputEvent(PP_Resource resource) { |
| 277 if (!IsInputEvent(resource)) | 287 if (!IsInputEvent(resource)) |
| 278 return PP_FALSE; // Prevent warning log in GetType. | 288 return PP_FALSE; // Prevent warning log in GetType. |
| 279 PP_InputEvent_Type type = GetType(resource); | 289 PP_InputEvent_Type type = GetType(resource); |
| 280 return PP_FromBool(type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_START || | 290 return PP_FromBool(type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_START || |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 const PPB_WheelInputEvent_1_0* GetPPB_WheelInputEvent_1_0_Thunk() { | 360 const PPB_WheelInputEvent_1_0* GetPPB_WheelInputEvent_1_0_Thunk() { |
| 351 return &g_ppb_wheel_input_event_thunk; | 361 return &g_ppb_wheel_input_event_thunk; |
| 352 } | 362 } |
| 353 | 363 |
| 354 const PPB_IMEInputEvent_Dev_0_1* GetPPB_IMEInputEvent_Dev_0_1_Thunk() { | 364 const PPB_IMEInputEvent_Dev_0_1* GetPPB_IMEInputEvent_Dev_0_1_Thunk() { |
| 355 return &g_ppb_ime_input_event_thunk; | 365 return &g_ppb_ime_input_event_thunk; |
| 356 } | 366 } |
| 357 | 367 |
| 358 } // namespace thunk | 368 } // namespace thunk |
| 359 } // namespace ppapi | 369 } // namespace ppapi |
| OLD | NEW |