| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 PP_Bool GetWheelScrollByPage(PP_Resource wheel_event) { | 259 PP_Bool GetWheelScrollByPage(PP_Resource wheel_event) { |
| 260 IMPLEMENT_RESOURCE_THUNK(GetWheelScrollByPage, wheel_event, PP_FALSE); | 260 IMPLEMENT_RESOURCE_THUNK(GetWheelScrollByPage, wheel_event, PP_FALSE); |
| 261 } | 261 } |
| 262 | 262 |
| 263 PP_Resource CreateKeyboardInputEvent(PP_Instance instance, | 263 PP_Resource CreateKeyboardInputEvent(PP_Instance instance, |
| 264 PP_InputEvent_Type type, | 264 PP_InputEvent_Type type, |
| 265 PP_TimeTicks time_stamp, | 265 PP_TimeTicks time_stamp, |
| 266 uint32_t modifiers, | 266 uint32_t modifiers, |
| 267 uint32_t key_code, | 267 uint32_t key_code, |
| 268 uint32_t usb_scan_code, |
| 268 struct PP_Var character_text) { | 269 struct PP_Var character_text) { |
| 269 DebugPrintf("PPB_InputEvent::CreateKeyboardInputEvent: instance=" | 270 DebugPrintf("PPB_InputEvent::CreateKeyboardInputEvent: instance=" |
| 270 "%"NACL_PRId32", type=%d, time_stamp=%lf, modifiers=" | 271 "%"NACL_PRId32", type=%d, time_stamp=%lf, modifiers=" |
| 271 "%"NACL_PRIu32", key_code=%"NACL_PRIu32"\n", | 272 "%"NACL_PRIu32", key_code=%"NACL_PRIu32", usb_scan_code=" |
| 272 instance, type, time_stamp, modifiers, key_code); | 273 "%"NACL_PRIu32"\n", |
| 274 instance, type, time_stamp, modifiers, key_code, usb_scan_code); |
| 273 // Serialize the character_text Var. | 275 // Serialize the character_text Var. |
| 274 uint32_t text_size = 0; | 276 uint32_t text_size = 0; |
| 275 nacl::scoped_array<char> text_bytes(Serialize(&character_text, 1, | 277 nacl::scoped_array<char> text_bytes(Serialize(&character_text, 1, |
| 276 &text_size)); | 278 &text_size)); |
| 277 PP_Resource resource_id = kInvalidResourceId; | 279 PP_Resource resource_id = kInvalidResourceId; |
| 278 NaClSrpcError srpc_result = | 280 NaClSrpcError srpc_result = |
| 279 PpbInputEventRpcClient::PPB_InputEvent_CreateKeyboardInputEvent( | 281 PpbInputEventRpcClient::PPB_InputEvent_CreateKeyboardInputEvent( |
| 280 GetMainSrpcChannel(), | 282 GetMainSrpcChannel(), |
| 281 instance, | 283 instance, |
| 282 static_cast<int32_t>(type), | 284 static_cast<int32_t>(type), |
| 283 static_cast<double>(time_stamp), | 285 static_cast<double>(time_stamp), |
| 284 static_cast<int32_t>(modifiers), | 286 static_cast<int32_t>(modifiers), |
| 285 static_cast<int32_t>(key_code), | 287 static_cast<int32_t>(key_code), |
| 288 static_cast<int32_t>(usb_scan_code), |
| 286 text_size, | 289 text_size, |
| 287 text_bytes.get(), | 290 text_bytes.get(), |
| 288 &resource_id); | 291 &resource_id); |
| 289 if (srpc_result == NACL_SRPC_RESULT_OK) | 292 if (srpc_result == NACL_SRPC_RESULT_OK) |
| 290 return resource_id; | 293 return resource_id; |
| 291 return kInvalidResourceId; | 294 return kInvalidResourceId; |
| 292 } | 295 } |
| 293 | 296 |
| 294 PP_Bool IsKeyboardInputEvent(PP_Resource resource) { | 297 PP_Bool IsKeyboardInputEvent(PP_Resource resource) { |
| 295 if (!IsInputEvent(resource)) | 298 if (!IsInputEvent(resource)) |
| 296 return PP_FALSE; | 299 return PP_FALSE; |
| 297 PP_InputEvent_Type type = GetType(resource); | 300 PP_InputEvent_Type type = GetType(resource); |
| 298 return PP_FromBool(type == PP_INPUTEVENT_TYPE_KEYDOWN || | 301 return PP_FromBool(type == PP_INPUTEVENT_TYPE_KEYDOWN || |
| 299 type == PP_INPUTEVENT_TYPE_KEYUP || | 302 type == PP_INPUTEVENT_TYPE_KEYUP || |
| 300 type == PP_INPUTEVENT_TYPE_CHAR); | 303 type == PP_INPUTEVENT_TYPE_CHAR); |
| 301 } | 304 } |
| 302 | 305 |
| 303 uint32_t GetKeyCode(PP_Resource key_event) { | 306 uint32_t GetKeyCode(PP_Resource key_event) { |
| 304 IMPLEMENT_RESOURCE_THUNK(GetKeyCode, key_event, 0); | 307 IMPLEMENT_RESOURCE_THUNK(GetKeyCode, key_event, 0); |
| 305 } | 308 } |
| 306 | 309 |
| 310 uint32_t GetUsbScanCode_Dev(PP_Resource key_event) { |
| 311 IMPLEMENT_RESOURCE_THUNK(GetUsbScanCode_Dev, key_event, 0); |
| 312 } |
| 313 |
| 307 PP_Var GetCharacterText(PP_Resource character_event) { | 314 PP_Var GetCharacterText(PP_Resource character_event) { |
| 308 IMPLEMENT_RESOURCE_THUNK(GetCharacterText, character_event, | 315 IMPLEMENT_RESOURCE_THUNK(GetCharacterText, character_event, |
| 309 PP_MakeUndefined()); | 316 PP_MakeUndefined()); |
| 310 } | 317 } |
| 311 | 318 |
| 312 } // namespace | 319 } // namespace |
| 313 | 320 |
| 314 namespace ppapi_proxy { | 321 namespace ppapi_proxy { |
| 315 | 322 |
| 316 // static | 323 // static |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 }; | 370 }; |
| 364 return &wheel_input_event_interface; | 371 return &wheel_input_event_interface; |
| 365 } | 372 } |
| 366 | 373 |
| 367 // static | 374 // static |
| 368 const PPB_KeyboardInputEvent* PluginInputEvent::GetKeyboardInterface() { | 375 const PPB_KeyboardInputEvent* PluginInputEvent::GetKeyboardInterface() { |
| 369 static const PPB_KeyboardInputEvent keyboard_input_event_interface = { | 376 static const PPB_KeyboardInputEvent keyboard_input_event_interface = { |
| 370 CreateKeyboardInputEvent, | 377 CreateKeyboardInputEvent, |
| 371 IsKeyboardInputEvent, | 378 IsKeyboardInputEvent, |
| 372 ::GetKeyCode, | 379 ::GetKeyCode, |
| 380 ::GetUsbScanCode_Dev, |
| 373 ::GetCharacterText | 381 ::GetCharacterText |
| 374 }; | 382 }; |
| 375 return &keyboard_input_event_interface; | 383 return &keyboard_input_event_interface; |
| 376 } | 384 } |
| 377 | 385 |
| 378 PluginInputEvent::PluginInputEvent() | 386 PluginInputEvent::PluginInputEvent() |
| 379 : character_text_(PP_MakeUndefined()) { | 387 : character_text_(PP_MakeUndefined()) { |
| 380 } | 388 } |
| 381 | 389 |
| 382 void PluginInputEvent::Init(const InputEventData& input_event_data, | 390 void PluginInputEvent::Init(const InputEventData& input_event_data, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 } | 435 } |
| 428 | 436 |
| 429 PP_Bool PluginInputEvent::GetWheelScrollByPage() const { | 437 PP_Bool PluginInputEvent::GetWheelScrollByPage() const { |
| 430 return input_event_data_.wheel_scroll_by_page; | 438 return input_event_data_.wheel_scroll_by_page; |
| 431 } | 439 } |
| 432 | 440 |
| 433 uint32_t PluginInputEvent::GetKeyCode() const { | 441 uint32_t PluginInputEvent::GetKeyCode() const { |
| 434 return input_event_data_.key_code; | 442 return input_event_data_.key_code; |
| 435 } | 443 } |
| 436 | 444 |
| 445 uint32_t PluginInputEvent::GetUsbScanCode_Dev() const { |
| 446 return input_event_data_.usb_scan_code; |
| 447 } |
| 448 |
| 437 PP_Var PluginInputEvent::GetCharacterText() const { | 449 PP_Var PluginInputEvent::GetCharacterText() const { |
| 438 PPBVarInterface()->AddRef(character_text_); | 450 PPBVarInterface()->AddRef(character_text_); |
| 439 return character_text_; | 451 return character_text_; |
| 440 } | 452 } |
| 441 | 453 |
| 442 } // namespace ppapi_proxy | 454 } // namespace ppapi_proxy |
| OLD | NEW |