| 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 "native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "native_client/src/include/nacl_scoped_ptr.h" | 10 #include "native_client/src/include/nacl_scoped_ptr.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 PP_Bool IsInputEvent(PP_Resource resource) { | 109 PP_Bool IsInputEvent(PP_Resource resource) { |
| 110 BEGIN_RESOURCE_THUNK("IsInputEvent", resource, PP_FALSE); | 110 BEGIN_RESOURCE_THUNK("IsInputEvent", resource, PP_FALSE); |
| 111 return PP_TRUE; | 111 return PP_TRUE; |
| 112 } | 112 } |
| 113 | 113 |
| 114 #define IMPLEMENT_RESOURCE_THUNK(function, resource_arg, error_return) \ | 114 #define IMPLEMENT_RESOURCE_THUNK(function, resource_arg, error_return) \ |
| 115 BEGIN_RESOURCE_THUNK(#function, resource_arg, error_return); \ | 115 BEGIN_RESOURCE_THUNK(#function, resource_arg, error_return); \ |
| 116 return input_event.get()->function() | 116 return input_event.get()->function() |
| 117 | 117 |
| 118 #define IMPLEMENT_RESOURCE_THUNK1(function, resource_arg, arg, error_return) \ |
| 119 BEGIN_RESOURCE_THUNK(#function, resource_arg, error_return); \ |
| 120 return input_event.get()->function(arg) |
| 121 |
| 118 PP_InputEvent_Type GetType(PP_Resource event) { | 122 PP_InputEvent_Type GetType(PP_Resource event) { |
| 119 IMPLEMENT_RESOURCE_THUNK(GetType, event, PP_INPUTEVENT_TYPE_UNDEFINED); | 123 IMPLEMENT_RESOURCE_THUNK(GetType, event, PP_INPUTEVENT_TYPE_UNDEFINED); |
| 120 } | 124 } |
| 121 | 125 |
| 122 PP_TimeTicks GetTimeStamp(PP_Resource event) { | 126 PP_TimeTicks GetTimeStamp(PP_Resource event) { |
| 123 IMPLEMENT_RESOURCE_THUNK(GetTimeStamp, event, 0.0); | 127 IMPLEMENT_RESOURCE_THUNK(GetTimeStamp, event, 0.0); |
| 124 } | 128 } |
| 125 | 129 |
| 126 uint32_t GetModifiers(PP_Resource event) { | 130 uint32_t GetModifiers(PP_Resource event) { |
| 127 IMPLEMENT_RESOURCE_THUNK(GetModifiers, event, 0); | 131 IMPLEMENT_RESOURCE_THUNK(GetModifiers, event, 0); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } | 257 } |
| 254 | 258 |
| 255 PP_FloatPoint GetWheelTicks(PP_Resource wheel_event) { | 259 PP_FloatPoint GetWheelTicks(PP_Resource wheel_event) { |
| 256 IMPLEMENT_RESOURCE_THUNK(GetWheelTicks, wheel_event, PP_MakeFloatPoint(0, 0)); | 260 IMPLEMENT_RESOURCE_THUNK(GetWheelTicks, wheel_event, PP_MakeFloatPoint(0, 0)); |
| 257 } | 261 } |
| 258 | 262 |
| 259 PP_Bool GetWheelScrollByPage(PP_Resource wheel_event) { | 263 PP_Bool GetWheelScrollByPage(PP_Resource wheel_event) { |
| 260 IMPLEMENT_RESOURCE_THUNK(GetWheelScrollByPage, wheel_event, PP_FALSE); | 264 IMPLEMENT_RESOURCE_THUNK(GetWheelScrollByPage, wheel_event, PP_FALSE); |
| 261 } | 265 } |
| 262 | 266 |
| 267 // Keyboard -------------------------------------------------------------------- |
| 268 |
| 263 PP_Resource CreateKeyboardInputEvent(PP_Instance instance, | 269 PP_Resource CreateKeyboardInputEvent(PP_Instance instance, |
| 264 PP_InputEvent_Type type, | 270 PP_InputEvent_Type type, |
| 265 PP_TimeTicks time_stamp, | 271 PP_TimeTicks time_stamp, |
| 266 uint32_t modifiers, | 272 uint32_t modifiers, |
| 267 uint32_t key_code, | 273 uint32_t key_code, |
| 268 struct PP_Var character_text) { | 274 struct PP_Var character_text) { |
| 269 DebugPrintf("PPB_InputEvent::CreateKeyboardInputEvent: instance=" | 275 DebugPrintf("PPB_InputEvent::CreateKeyboardInputEvent: instance=" |
| 270 "%"NACL_PRId32", type=%d, time_stamp=%lf, modifiers=" | 276 "%"NACL_PRId32", type=%d, time_stamp=%lf, modifiers=" |
| 271 "%"NACL_PRIu32", key_code=%"NACL_PRIu32"\n", | 277 "%"NACL_PRIu32", key_code=%"NACL_PRIu32"\n", |
| 272 instance, type, time_stamp, modifiers, key_code); | 278 instance, type, time_stamp, modifiers, key_code); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 302 | 308 |
| 303 uint32_t GetKeyCode(PP_Resource key_event) { | 309 uint32_t GetKeyCode(PP_Resource key_event) { |
| 304 IMPLEMENT_RESOURCE_THUNK(GetKeyCode, key_event, 0); | 310 IMPLEMENT_RESOURCE_THUNK(GetKeyCode, key_event, 0); |
| 305 } | 311 } |
| 306 | 312 |
| 307 PP_Var GetCharacterText(PP_Resource character_event) { | 313 PP_Var GetCharacterText(PP_Resource character_event) { |
| 308 IMPLEMENT_RESOURCE_THUNK(GetCharacterText, character_event, | 314 IMPLEMENT_RESOURCE_THUNK(GetCharacterText, character_event, |
| 309 PP_MakeUndefined()); | 315 PP_MakeUndefined()); |
| 310 } | 316 } |
| 311 | 317 |
| 318 // Keyboard_Dev ---------------------------------------------------------------- |
| 319 |
| 320 PP_Bool SetUsbKeyCode(PP_Resource key_event, uint32_t usb_key_code) { |
| 321 IMPLEMENT_RESOURCE_THUNK1(SetUsbKeyCode, key_event, usb_key_code, |
| 322 PP_FALSE); |
| 323 } |
| 324 |
| 325 uint32_t GetUsbKeyCode(PP_Resource key_event) { |
| 326 IMPLEMENT_RESOURCE_THUNK(GetUsbKeyCode, key_event, 0); |
| 327 } |
| 328 |
| 312 } // namespace | 329 } // namespace |
| 313 | 330 |
| 314 namespace ppapi_proxy { | 331 namespace ppapi_proxy { |
| 315 | 332 |
| 316 // static | 333 // static |
| 317 const PPB_InputEvent* PluginInputEvent::GetInterface() { | 334 const PPB_InputEvent* PluginInputEvent::GetInterface() { |
| 318 static const PPB_InputEvent input_event_interface = { | 335 static const PPB_InputEvent input_event_interface = { |
| 319 RequestInputEvents, | 336 RequestInputEvents, |
| 320 RequestFilteringInputEvents, | 337 RequestFilteringInputEvents, |
| 321 ClearInputEventRequest, | 338 ClearInputEventRequest, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 const PPB_KeyboardInputEvent* PluginInputEvent::GetKeyboardInterface() { | 385 const PPB_KeyboardInputEvent* PluginInputEvent::GetKeyboardInterface() { |
| 369 static const PPB_KeyboardInputEvent keyboard_input_event_interface = { | 386 static const PPB_KeyboardInputEvent keyboard_input_event_interface = { |
| 370 CreateKeyboardInputEvent, | 387 CreateKeyboardInputEvent, |
| 371 IsKeyboardInputEvent, | 388 IsKeyboardInputEvent, |
| 372 ::GetKeyCode, | 389 ::GetKeyCode, |
| 373 ::GetCharacterText | 390 ::GetCharacterText |
| 374 }; | 391 }; |
| 375 return &keyboard_input_event_interface; | 392 return &keyboard_input_event_interface; |
| 376 } | 393 } |
| 377 | 394 |
| 395 // static |
| 396 const PPB_KeyboardInputEvent_Dev* PluginInputEvent::GetKeyboardInterface_Dev() { |
| 397 static const PPB_KeyboardInputEvent_Dev keyboard_input_event_dev_interface = { |
| 398 ::SetUsbKeyCode, |
| 399 ::GetUsbKeyCode, |
| 400 }; |
| 401 return &keyboard_input_event_dev_interface; |
| 402 } |
| 403 |
| 378 PluginInputEvent::PluginInputEvent() | 404 PluginInputEvent::PluginInputEvent() |
| 379 : character_text_(PP_MakeUndefined()) { | 405 : character_text_(PP_MakeUndefined()) { |
| 380 } | 406 } |
| 381 | 407 |
| 382 void PluginInputEvent::Init(const InputEventData& input_event_data, | 408 void PluginInputEvent::Init(const InputEventData& input_event_data, |
| 383 PP_Var character_text) { | 409 PP_Var character_text) { |
| 384 input_event_data_ = input_event_data; | 410 input_event_data_ = input_event_data; |
| 385 character_text_ = character_text; | 411 character_text_ = character_text; |
| 386 } | 412 } |
| 387 | 413 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 458 |
| 433 uint32_t PluginInputEvent::GetKeyCode() const { | 459 uint32_t PluginInputEvent::GetKeyCode() const { |
| 434 return input_event_data_.key_code; | 460 return input_event_data_.key_code; |
| 435 } | 461 } |
| 436 | 462 |
| 437 PP_Var PluginInputEvent::GetCharacterText() const { | 463 PP_Var PluginInputEvent::GetCharacterText() const { |
| 438 PPBVarInterface()->AddRef(character_text_); | 464 PPBVarInterface()->AddRef(character_text_); |
| 439 return character_text_; | 465 return character_text_; |
| 440 } | 466 } |
| 441 | 467 |
| 468 PP_Bool PluginInputEvent::SetUsbKeyCode(uint32_t usb_key_code) { |
| 469 input_event_data_.usb_key_code = usb_key_code; |
| 470 return PP_TRUE; |
| 471 } |
| 472 |
| 473 uint32_t PluginInputEvent::GetUsbKeyCode() const { |
| 474 return input_event_data_.usb_key_code; |
| 475 } |
| 476 |
| 442 } // namespace ppapi_proxy | 477 } // namespace ppapi_proxy |
| OLD | NEW |