diff options
-rw-r--r-- | remoting/client/plugin/pepper_input_handler.cc | 17 | ||||
-rw-r--r-- | remoting/proto/event.proto | 9 |
2 files changed, 24 insertions, 2 deletions
diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc index e555f06..4457817 100644 --- a/remoting/client/plugin/pepper_input_handler.cc +++ b/remoting/client/plugin/pepper_input_handler.cc @@ -5,7 +5,9 @@ #include "remoting/client/plugin/pepper_input_handler.h" #include "base/logging.h" +#include "ppapi/c/dev/ppb_keyboard_input_event_dev.h" #include "ppapi/cpp/input_event.h" +#include "ppapi/cpp/module_impl.h" #include "ppapi/cpp/point.h" #include "remoting/proto/event.pb.h" @@ -19,6 +21,17 @@ PepperInputHandler::PepperInputHandler(protocol::InputStub* input_stub) PepperInputHandler::~PepperInputHandler() { } +// Helper function to get the USB key code using the Dev InputEvent interface. +uint32_t GetUsbKeyCode(pp::KeyboardInputEvent pp_key_event) { + const PPB_KeyboardInputEvent_Dev* key_event_interface = + reinterpret_cast<const PPB_KeyboardInputEvent_Dev*>( + pp::Module::Get()->GetBrowserInterface( + PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE)); + if (!key_event_interface) + return 0; + return key_event_interface->GetUsbKeyCode(pp_key_event.pp_resource()); +} + bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) { switch (event.GetType()) { case PP_INPUTEVENT_TYPE_CONTEXTMENU: { @@ -32,6 +45,10 @@ bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) { pp::KeyboardInputEvent pp_key_event(event); protocol::KeyEvent key_event; key_event.set_keycode(pp_key_event.GetKeyCode()); + uint32 keycode = GetUsbKeyCode(pp_key_event); + if (keycode != 0) + key_event.set_usb_key_code(keycode); + LOG(INFO) << "keycode: " << std::hex << keycode << std::dec; key_event.set_pressed(event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN); input_stub_->InjectKeyEvent(key_event); return true; diff --git a/remoting/proto/event.proto b/remoting/proto/event.proto index a5c0343..2a83a99 100644 --- a/remoting/proto/event.proto +++ b/remoting/proto/event.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,9 +12,14 @@ package remoting.protocol; // Defines a keyboard event. message KeyEvent { - // The POSIX key code. + // The Windows Virtual Key code. required int32 keycode = 1; required bool pressed = 2; + + // The USB key code. + // The upper 16-bits are the USB Page (0x07 for key events). + // The lower 16-bits are the USB Usage ID (which identifies the actual key). + optional uint32 usb_key_code = 3; } // Defines a mouse event message on the event channel. |