summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-11 01:52:14 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-11 01:52:14 +0000
commitf5e7c883310006c711697edc9bf71dcd868335a8 (patch)
treec57b4dc971ec7298faf983197a85ab39ea0f5a2b
parent55097d32fb9f0b18fe8fea1fcdb2a9c89f6698b9 (diff)
downloadchromium_src-f5e7c883310006c711697edc9bf71dcd868335a8.zip
chromium_src-f5e7c883310006c711697edc9bf71dcd868335a8.tar.gz
chromium_src-f5e7c883310006c711697edc9bf71dcd868335a8.tar.bz2
Remove support for Windows-style keycodes.
BUG=145057 Review URL: https://chromiumcodereview.appspot.com/10894050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155905 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/client/key_event_mapper_unittest.cc34
-rw-r--r--remoting/client/plugin/chromoting_instance.cc2
-rw-r--r--remoting/client/plugin/pepper_input_handler.cc5
-rw-r--r--remoting/host/client_session_unittest.cc29
-rw-r--r--remoting/host/event_executor_linux.cc188
-rw-r--r--remoting/host/event_executor_mac.cc200
-rw-r--r--remoting/host/event_executor_win.cc55
-rw-r--r--remoting/host/remote_input_filter_unittest.cc15
-rw-r--r--remoting/proto/event.proto2
-rw-r--r--remoting/protocol/client_event_dispatcher.cc2
-rw-r--r--remoting/protocol/host_event_dispatcher.cc3
-rw-r--r--remoting/protocol/input_event_tracker.cc17
-rw-r--r--remoting/protocol/input_event_tracker.h2
-rw-r--r--remoting/protocol/input_event_tracker_unittest.cc63
-rw-r--r--remoting/protocol/message_decoder_unittest.cc8
15 files changed, 66 insertions, 559 deletions
diff --git a/remoting/client/key_event_mapper_unittest.cc b/remoting/client/key_event_mapper_unittest.cc
index f620dfa..0f5a91d 100644
--- a/remoting/client/key_event_mapper_unittest.cc
+++ b/remoting/client/key_event_mapper_unittest.cc
@@ -19,27 +19,11 @@ using protocol::InputStub;
using protocol::KeyEvent;
using protocol::MockInputStub;
-MATCHER_P2(EqualsVkeyEvent, keycode, pressed, "") {
- return arg.keycode() == keycode && arg.pressed() == pressed;
-}
-
MATCHER_P2(EqualsUsbEvent, usb_keycode, pressed, "") {
return arg.usb_keycode() == static_cast<uint32>(usb_keycode) &&
arg.pressed() == pressed;
}
-static KeyEvent NewVkeyEvent(int keycode, bool pressed) {
- KeyEvent event;
- event.set_keycode(keycode);
- event.set_pressed(pressed);
- return event;
-}
-
-static void PressAndReleaseVkey(InputStub* input_stub, int keycode) {
- input_stub->InjectKeyEvent(NewVkeyEvent(keycode, true));
- input_stub->InjectKeyEvent(NewVkeyEvent(keycode, false));
-}
-
static KeyEvent NewUsbEvent(uint32 usb_keycode, bool pressed) {
KeyEvent event;
event.set_usb_keycode(usb_keycode);
@@ -71,15 +55,15 @@ TEST(KeyEventMapperTest, NoMappingOrTrapping) {
EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(i, false)));
}
- EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(3, true)));
- EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(3, false)));
+ EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(3, true)));
+ EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(3, false)));
}
InjectTestSequence(&event_mapper);
- PressAndReleaseVkey(&event_mapper, 3);
+ PressAndReleaseUsb(&event_mapper, 3);
}
-// Verify that USB keys are remapped at most once, and VKEYs are not mapped.
+// Verify that USB keys are remapped at most once.
TEST(KeyEventMapperTest, RemapKeys) {
MockInputStub mock_stub;
KeyEventMapper event_mapper(&mock_stub);
@@ -100,20 +84,16 @@ TEST(KeyEventMapperTest, RemapKeys) {
EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(3, false)));
EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(3, true)));
EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(3, false)));
-
- EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(3, true)));
- EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(3, false)));
}
InjectTestSequence(&event_mapper);
- PressAndReleaseVkey(&event_mapper, 3);
}
static void HandleTrappedKey(MockInputStub* stub, uint32 keycode, bool down) {
stub->InjectKeyEvent(NewUsbEvent(keycode, down));
}
-// Verify that USB keys are trapped, not remapped, and VKEYs are not trapped.
+// Verify that trapped and mapped USB keys are trapped but not remapped.
TEST(KeyEventMapperTest, TrapKeys) {
MockInputStub mock_stub;
MockInputStub trap_stub;
@@ -141,13 +121,9 @@ TEST(KeyEventMapperTest, TrapKeys) {
EXPECT_CALL(trap_stub, InjectKeyEvent(EqualsUsbEvent(4, false)));
EXPECT_CALL(trap_stub, InjectKeyEvent(EqualsUsbEvent(5, true)));
EXPECT_CALL(trap_stub, InjectKeyEvent(EqualsUsbEvent(5, false)));
-
- EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(3, true)));
- EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(3, false)));
}
InjectTestSequence(&event_mapper);
- PressAndReleaseVkey(&event_mapper, 3);
}
} // namespace remoting
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index a28a8e9..9038b4f 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -299,8 +299,6 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) {
protocol::KeyEvent event;
event.set_usb_keycode(usb_keycode);
event.set_pressed(is_pressed);
- // Even though new hosts will ignore keycode, it's a required field.
- event.set_keycode(0);
InjectKeyEvent(event);
} else if (method == "remapKey") {
int from_keycode = 0;
diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc
index ca49ffd..208bfa0 100644
--- a/remoting/client/plugin/pepper_input_handler.cc
+++ b/remoting/client/plugin/pepper_input_handler.cc
@@ -44,10 +44,7 @@ bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) {
case PP_INPUTEVENT_TYPE_KEYUP: {
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_keycode(keycode);
+ key_event.set_usb_keycode(GetUsbKeyCode(pp_key_event));
key_event.set_pressed(event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN);
input_stub_->InjectKeyEvent(key_event);
return true;
diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc
index bf54230..bc41d67 100644
--- a/remoting/host/client_session_unittest.cc
+++ b/remoting/host/client_session_unittest.cc
@@ -116,8 +116,9 @@ TEST_F(ClientSessionTest, ClipboardStubFilter) {
connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event3);
}
-MATCHER_P2(EqualsKeyEvent, keycode, pressed, "") {
- return arg.keycode() == keycode && arg.pressed() == pressed;
+MATCHER_P2(EqualsUsbEvent, usb_keycode, pressed, "") {
+ return arg.usb_keycode() == (unsigned int)usb_keycode &&
+ arg.pressed() == pressed;
}
MATCHER_P2(EqualsMouseEvent, x, y, "") {
@@ -131,19 +132,19 @@ MATCHER_P2(EqualsMouseButtonEvent, button, down, "") {
TEST_F(ClientSessionTest, InputStubFilter) {
protocol::KeyEvent key_event1;
key_event1.set_pressed(true);
- key_event1.set_keycode(1);
+ key_event1.set_usb_keycode(1);
protocol::KeyEvent key_event2_down;
key_event2_down.set_pressed(true);
- key_event2_down.set_keycode(2);
+ key_event2_down.set_usb_keycode(2);
protocol::KeyEvent key_event2_up;
key_event2_up.set_pressed(false);
- key_event2_up.set_keycode(2);
+ key_event2_up.set_usb_keycode(2);
protocol::KeyEvent key_event3;
key_event3.set_pressed(true);
- key_event3.set_keycode(3);
+ key_event3.set_usb_keycode(3);
protocol::MouseEvent mouse_event1;
mouse_event1.set_x(100);
@@ -160,8 +161,8 @@ TEST_F(ClientSessionTest, InputStubFilter) {
InSequence s;
EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
- EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, true)));
- EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, false)));
+ EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, true)));
+ EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, false)));
EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201)));
EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
@@ -220,11 +221,11 @@ TEST_F(ClientSessionTest, LocalInputTest) {
TEST_F(ClientSessionTest, RestoreEventState) {
protocol::KeyEvent key1;
key1.set_pressed(true);
- key1.set_keycode(1);
+ key1.set_usb_keycode(1);
protocol::KeyEvent key2;
key2.set_pressed(true);
- key2.set_keycode(2);
+ key2.set_usb_keycode(2);
protocol::MouseEvent mousedown;
mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT);
@@ -233,12 +234,12 @@ TEST_F(ClientSessionTest, RestoreEventState) {
InSequence s;
EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
- EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(1, true)));
- EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, true)));
+ EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(1, true)));
+ EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, true)));
EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseButtonEvent(
protocol::MouseEvent::BUTTON_LEFT, true)));
- EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(1, false)));
- EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, false)));
+ EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(1, false)));
+ EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, false)));
EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseButtonEvent(
protocol::MouseEvent::BUTTON_LEFT, false)));
EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
diff --git a/remoting/host/event_executor_linux.cc b/remoting/host/event_executor_linux.cc
index fe64ad2..bbd7985 100644
--- a/remoting/host/event_executor_linux.cc
+++ b/remoting/host/event_executor_linux.cc
@@ -7,8 +7,6 @@
#include <set>
#include <X11/Xlib.h>
-#include <X11/XF86keysym.h>
-#include <X11/keysym.h>
#include <X11/extensions/XTest.h>
#include "base/basictypes.h"
@@ -104,172 +102,6 @@ int VerticalScrollWheelToX11ButtonNumber(int dy) {
return (dy > 0 ? 4 : 5);
}
-// Hard-coded mapping from Virtual Key codes to X11 KeySyms.
-// This mapping is only valid if both client and host are using a
-// US English keyboard layout.
-// Because we're passing VK codes on the wire, with no Scancode,
-// "extended" flag, etc, things like distinguishing left & right
-// Shift keys doesn't work.
-//
-// TODO(wez): Replace this with something more closely tied to what
-// WebInputEventFactory does on Linux/GTK, and which respects the
-// host's keyboard layout (see http://crbug.com/74550 ).
-const int kUsVkeyToKeysym[256] = {
- // 0x00 - 0x07
- -1, -1, -1, XK_Cancel,
- // 0x04 - 0x07
- -1, -1, -1, -1,
- // 0x08 - 0x0B
- XK_BackSpace, XK_Tab, -1, -1,
- // 0x0C - 0x0F
- XK_Clear, XK_Return, -1, -1,
-
- // 0x10 - 0x13
- XK_Shift_L, XK_Control_L, XK_Alt_L, XK_Pause,
- // 0x14 - 0x17
- XK_Caps_Lock, XK_Kana_Shift, -1, XK_Hangul_Jeonja,
- // 0x18 - 0x1B
- XK_Hangul_End, XK_Kanji, -1, XK_Escape,
- // 0x1C - 0x1F
- XK_Henkan, XK_Muhenkan, /* VKEY_ACCEPT */ -1, XK_Mode_switch,
-
- // 0x20 - 0x23
- XK_space, XK_Prior, XK_Next, XK_End,
- // 0x24 - 0x27
- XK_Home, XK_Left, XK_Up, XK_Right,
- // 0x28 - 0x2B
- XK_Down, XK_Select, /* VK_PRINT */ -1, XK_Execute,
- // 0x2C - 0x2F
- XK_Print, XK_Insert, XK_Delete, XK_Help,
-
- // 0x30 - 0x33
- XK_0, XK_1, XK_2, XK_3,
- // 0x34 - 0x37
- XK_4, XK_5, XK_6, XK_7,
- // 0x38 - 0x3B
- XK_8, XK_9, -1, -1,
- // 0x3C - 0x3F
- -1, -1, -1, -1,
-
- // 0x40 - 0x43
- -1, XK_A, XK_B, XK_C,
- // 0x44 - 0x47
- XK_D, XK_E, XK_F, XK_G,
- // 0x48 - 0x4B
- XK_H, XK_I, XK_J, XK_K,
- // 0x4C - 0x4F
- XK_L, XK_M, XK_N, XK_O,
-
- // 0x50 - 0x53
- XK_P, XK_Q, XK_R, XK_S,
- // 0x54 - 0x57
- XK_T, XK_U, XK_V, XK_W,
- // 0x58 - 0x5B
- XK_X, XK_Y, XK_Z, XK_Super_L,
- // 0x5C - 0x5F
- XK_Super_R, XK_Menu, -1, /* VKEY_SLEEP */ -1,
-
- // 0x60 - 0x63
- XK_KP_0, XK_KP_1, XK_KP_2, XK_KP_3,
- // 0x64 - 0x67
- XK_KP_4, XK_KP_5, XK_KP_6, XK_KP_7,
- // 0x68 - 0x6B
- XK_KP_8, XK_KP_9, XK_KP_Multiply, XK_KP_Add,
- // 0x6C - 0x6F
- XK_KP_Separator, XK_KP_Subtract, XK_KP_Decimal, XK_KP_Divide,
-
- // 0x70 - 0x73
- XK_F1, XK_F2, XK_F3, XK_F4,
- // 0x74 - 0x77
- XK_F5, XK_F6, XK_F7, XK_F8,
- // 0x78 - 0x7B
- XK_F9, XK_F10, XK_F11, XK_F12,
- // 0x7C - 0x7F
- XK_F13, XK_F14, XK_F15, XK_F16,
-
- // 0x80 - 0x83
- XK_F17, XK_F18, XK_F19, XK_F20,
- // 0x84 - 0x87
- XK_F21, XK_F22, XK_F23, XK_F24,
- // 0x88 - 0x8B
- -1, -1, -1, -1,
- // 0x8C - 0x8F
- -1, -1, -1, -1,
-
- // 0x90 - 0x93
- XK_Num_Lock, XK_Scroll_Lock, -1, -1,
- // 0x94 - 0x97
- -1, -1, -1, -1,
- // 0x98 - 0x9B
- -1, -1, -1, -1,
- // 0x9C - 0x9F
- -1, -1, -1, -1,
-
- // 0xA0 - 0xA3
- XK_Shift_L, XK_Shift_R, XK_Control_L, XK_Control_R,
- // 0xA4 - 0xA7
- XK_Meta_L, XK_Meta_R, XF86XK_Back, XF86XK_Forward,
- // 0xA8 - 0xAB
- XF86XK_Refresh, XF86XK_Stop, XF86XK_Search, XF86XK_Favorites,
- // 0xAC - 0xAF
- XF86XK_HomePage, XF86XK_AudioMute, XF86XK_AudioLowerVolume,
- XF86XK_AudioRaiseVolume,
-
- // 0xB0 - 0xB3
- XF86XK_AudioNext, XF86XK_AudioPrev, XF86XK_AudioStop, XF86XK_AudioPause,
- // 0xB4 - 0xB7
- XF86XK_Mail, XF86XK_AudioMedia, XF86XK_Launch0, XF86XK_Launch1,
- // 0xB8 - 0xBB
- -1, -1, XK_semicolon, XK_plus,
- // 0xBC - 0xBF
- XK_comma, XK_minus, XK_period, XK_slash,
-
- // 0xC0 - 0xC3
- XK_grave, -1, -1, -1,
- // 0xC4 - 0xC7
- -1, -1, -1, -1,
- // 0xC8 - 0xCB
- -1, -1, -1, -1,
- // 0xCC - 0xCF
- -1, -1, -1, -1,
-
- // 0xD0 - 0xD3
- -1, -1, -1, -1,
- // 0xD4 - 0xD7
- -1, -1, -1, -1,
- // 0xD8 - 0xDB
- -1, -1, -1, XK_bracketleft,
- // 0xDC - 0xDF
- XK_backslash, XK_bracketright, XK_apostrophe,
- /* VKEY_OEM_8 */ -1,
-
- // 0xE0 - 0xE3
- -1, -1, /* VKEY_OEM_102 */ -1, -1,
- // 0xE4 - 0xE7
- -1, /* VKEY_PROCESSKEY */ -1, -1, /* VKEY_PACKET */ -1,
- // 0xE8 - 0xEB
- -1, -1, -1, -1,
- // 0xEC - 0xEF
- -1, -1, -1, -1,
-
- // 0xF0 - 0xF3
- -1, -1, -1, -1,
- // 0xF4 - 0xF7
- -1, -1, /* VKEY_ATTN */ -1, /* VKEY_CRSEL */ -1,
- // 0xF8 - 0xFB
- /* VKEY_EXSEL */ -1, /* VKEY_EREOF */ -1, /* VKEY_PLAY */ -1,
- /* VKEY_ZOOM */ -1,
- // 0xFC - 0xFF
- /* VKEY_NONAME */ -1, /* VKEY_PA1 */ -1, /* VKEY_OEM_CLEAR */ -1, -1
-};
-
-int ChromotocolKeycodeToX11Keysym(int32_t keycode) {
- if (keycode < 0 || keycode > 255)
- return kInvalidKeycode;
-
- return kUsVkeyToKeysym[keycode];
-}
-
EventExecutorLinux::EventExecutorLinux(
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: task_runner_(task_runner),
@@ -310,6 +142,7 @@ void EventExecutorLinux::InjectClipboardEvent(const ClipboardEvent& event) {
void EventExecutorLinux::InjectKeyEvent(const KeyEvent& event) {
// HostEventDispatcher should filter events missing the pressed field.
DCHECK(event.has_pressed());
+ DCHECK(event.has_usb_keycode());
if (!task_runner_->BelongsToCurrentThread()) {
task_runner_->PostTask(
@@ -319,22 +152,11 @@ void EventExecutorLinux::InjectKeyEvent(const KeyEvent& event) {
return;
}
- int keycode = kInvalidKeycode;
- if (event.has_usb_keycode()) {
- keycode = UsbKeycodeToNativeKeycode(event.usb_keycode());
- VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
- << " to keycode: " << keycode << std::dec;
- } else if (event.has_keycode()) {
- // Fall back to keysym translation.
- // TODO(garykac) Remove this once we switch entirely over to USB keycodes.
- int keysym = ChromotocolKeycodeToX11Keysym(event.keycode());
- keycode = XKeysymToKeycode(display_, keysym);
- VLOG(3) << "Converting VKEY: " << std::hex << event.keycode()
- << " to keysym: " << keysym
- << " to keycode: " << keycode << std::dec;
- }
+ int keycode = UsbKeycodeToNativeKeycode(event.usb_keycode());
+ VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
+ << " to keycode: " << keycode << std::dec;
- // Ignore events with no VK- or USB-keycode, or which can't be mapped.
+ // Ignore events which can't be mapped.
if (keycode == kInvalidKeycode)
return;
diff --git a/remoting/host/event_executor_mac.cc b/remoting/host/event_executor_mac.cc
index 47320f9..c5b1ddd 100644
--- a/remoting/host/event_executor_mac.cc
+++ b/remoting/host/event_executor_mac.cc
@@ -89,188 +89,6 @@ EventExecutorMac::EventExecutorMac(
#pragma clang diagnostic pop
}
-// Hard-coded mapping from Virtual Key codes to Mac KeySyms.
-// This mapping is only valid if both client and host are using a
-// US English keyboard layout.
-// Because we're passing VK codes on the wire, with no Scancode,
-// "extended" flag, etc, things like distinguishing left & right
-// Shift keys doesn't work.
-//
-// TODO(wez): Replace this with something more closely tied to what
-// WebInputEventFactory does on Linux/GTK, and which respects the
-// host's keyboard layout.
-//
-// TODO(garykac): Remove this table once we switch to using USB
-// keycodes.
-const int kUsVkeyToKeysym[256] = {
- // 0x00 - 0x07
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0x04 - 0x07
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0x08 - 0x0B
- kVK_Delete, kVK_Tab, kInvalidKeycode, kInvalidKeycode,
- // 0x0C - 0x0F
- kInvalidKeycode, kVK_Return, kInvalidKeycode, kInvalidKeycode,
-
- // 0x10 - 0x13
- kVK_Shift, kVK_Control, kVK_Option, kInvalidKeycode,
- // 0x14 - 0x17
- kVK_CapsLock, kVK_JIS_Kana, /* VKEY_HANGUL */ kInvalidKeycode,
- /* VKEY_JUNJA */ kInvalidKeycode,
- // 0x18 - 0x1B
- /* VKEY_FINAL */ kInvalidKeycode, /* VKEY_Kanji */ kInvalidKeycode,
- kInvalidKeycode, kVK_Escape,
- // 0x1C - 0x1F
- /* VKEY_CONVERT */ kInvalidKeycode, /* VKEY_NONCONVERT */ kInvalidKeycode,
- /* VKEY_ACCEPT */ kInvalidKeycode, /* VKEY_MODECHANGE */ kInvalidKeycode,
-
- // 0x20 - 0x23
- kVK_Space, kVK_PageUp, kVK_PageDown, kVK_End,
- // 0x24 - 0x27
- kVK_Home, kVK_LeftArrow, kVK_UpArrow, kVK_RightArrow,
- // 0x28 - 0x2B
- kVK_DownArrow, /* VKEY_SELECT */ kInvalidKeycode,
- /* VKEY_PRINT */ kInvalidKeycode, /* VKEY_EXECUTE */ kInvalidKeycode,
- // 0x2C - 0x2F
- /* VKEY_SNAPSHOT */ kInvalidKeycode, /* XK_INSERT */ kInvalidKeycode,
- kVK_ForwardDelete, kVK_Help,
-
- // 0x30 - 0x33
- kVK_ANSI_0, kVK_ANSI_1, kVK_ANSI_2, kVK_ANSI_3,
- // 0x34 - 0x37
- kVK_ANSI_4, kVK_ANSI_5, kVK_ANSI_6, kVK_ANSI_7,
- // 0x38 - 0x3B
- kVK_ANSI_8, kVK_ANSI_9, kInvalidKeycode, kInvalidKeycode,
- // 0x3C - 0x3F
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
-
- // 0x40 - 0x43
- kInvalidKeycode, kVK_ANSI_A, kVK_ANSI_B, kVK_ANSI_C,
- // 0x44 - 0x47
- kVK_ANSI_D, kVK_ANSI_E, kVK_ANSI_F, kVK_ANSI_G,
- // 0x48 - 0x4B
- kVK_ANSI_H, kVK_ANSI_I, kVK_ANSI_J, kVK_ANSI_K,
- // 0x4C - 0x4F
- kVK_ANSI_L, kVK_ANSI_M, kVK_ANSI_N, kVK_ANSI_O,
-
- // 0x50 - 0x53
- kVK_ANSI_P, kVK_ANSI_Q, kVK_ANSI_R, kVK_ANSI_S,
- // 0x54 - 0x57
- kVK_ANSI_T, kVK_ANSI_U, kVK_ANSI_V, kVK_ANSI_W,
- // 0x58 - 0x5B
- kVK_ANSI_X, kVK_ANSI_Y, kVK_ANSI_Z, kVK_Command,
- // 0x5C - 0x5F
- kVK_Command, kVK_Command, kInvalidKeycode, /* VKEY_SLEEP */ kInvalidKeycode,
-
- // 0x60 - 0x63
- kVK_ANSI_Keypad0, kVK_ANSI_Keypad1, kVK_ANSI_Keypad2, kVK_ANSI_Keypad3,
- // 0x64 - 0x67
- kVK_ANSI_Keypad4, kVK_ANSI_Keypad5, kVK_ANSI_Keypad6, kVK_ANSI_Keypad7,
- // 0x68 - 0x6B
- kVK_ANSI_Keypad8, kVK_ANSI_Keypad9, kVK_ANSI_KeypadMultiply,
- kVK_ANSI_KeypadPlus,
- // 0x6C - 0x6F
- /* VKEY_SEPARATOR */ kInvalidKeycode, kVK_ANSI_KeypadMinus,
- kVK_ANSI_KeypadDecimal, kVK_ANSI_KeypadDivide,
-
- // 0x70 - 0x73
- kVK_F1, kVK_F2, kVK_F3, kVK_F4,
- // 0x74 - 0x77
- kVK_F5, kVK_F6, kVK_F7, kVK_F8,
- // 0x78 - 0x7B
- kVK_F9, kVK_F10, kVK_F11, kVK_F12,
- // 0x7C - 0x7F
- kVK_F13, kVK_F14, kVK_F15, kVK_F16,
-
- // 0x80 - 0x83
- kVK_F17, kVK_F18, kVK_F19, kVK_F20,
- // 0x84 - 0x87
- /* VKEY_F21 */ kInvalidKeycode, /* VKEY_F22 */ kInvalidKeycode,
- /* VKEY_F23 */ kInvalidKeycode, /* XKEY_F24 */ kInvalidKeycode,
- // 0x88 - 0x8B
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0x8C - 0x8F
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
-
- // 0x90 - 0x93
- /* VKEY_NUMLOCK */ kInvalidKeycode, /* VKEY_SCROLL */ kInvalidKeycode,
- kInvalidKeycode, kInvalidKeycode,
- // 0x94 - 0x97
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0x98 - 0x9B
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0x9C - 0x9F
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
-
- // 0xA0 - 0xA3
- kVK_Shift, kVK_RightShift, kVK_Control, kVK_RightControl,
- // 0xA4 - 0xA7
- kVK_Option, kVK_RightOption,
- /* XF86kVK_Back */ kInvalidKeycode, /* XF86kVK_Forward */ kInvalidKeycode,
- // 0xA8 - 0xAB
- /* XF86kVK_Refresh */ kInvalidKeycode, /* XF86kVK_Stop */ kInvalidKeycode,
- /* XF86kVK_Search */ kInvalidKeycode,
- /* XF86kVK_Favorites */ kInvalidKeycode,
- // 0xAC - 0xAF
- /* XF86kVK_HomePage */ kInvalidKeycode, kVK_Mute, kVK_VolumeDown,
- kVK_VolumeUp,
-
- // 0xB0 - 0xB3
- /* XF86kVK_AudioNext */ kInvalidKeycode,
- /* XF86kVK_AudioPrev */ kInvalidKeycode,
- /* XF86kVK_AudioStop */ kInvalidKeycode,
- /* XF86kVK_AudioPause */ kInvalidKeycode,
- // 0xB4 - 0xB7
- /* XF86kVK_Mail */ kInvalidKeycode, /* XF86kVK_AudioMedia */ kInvalidKeycode,
- /* XF86kVK_Launch0 */ kInvalidKeycode, /* XF86kVK_Launch1 */ kInvalidKeycode,
- // 0xB8 - 0xBB
- kInvalidKeycode, kInvalidKeycode, kVK_ANSI_Semicolon, kVK_ANSI_Equal,
- // 0xBC - 0xBF
- kVK_ANSI_Comma, kVK_ANSI_Minus, kVK_ANSI_Period, kVK_ANSI_Slash,
-
- // 0xC0 - 0xC3
- kVK_ANSI_Grave, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0xC4 - 0xC7
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0xC8 - 0xCB
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0xCC - 0xCF
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
-
- // 0xD0 - 0xD3
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0xD4 - 0xD7
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0xD8 - 0xDB
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kVK_ANSI_LeftBracket,
- // 0xDC - 0xDF
- kVK_ANSI_Backslash, kVK_ANSI_RightBracket, kVK_ANSI_Quote,
- /* VKEY_OEM_8 */ kInvalidKeycode,
-
- // 0xE0 - 0xE3
- kInvalidKeycode, kInvalidKeycode, /* VKEY_OEM_102 */ kInvalidKeycode,
- kInvalidKeycode,
- // 0xE4 - 0xE7
- kInvalidKeycode, /* VKEY_PROCESSKEY */ kInvalidKeycode, kInvalidKeycode,
- /* VKEY_PACKET */ kInvalidKeycode,
- // 0xE8 - 0xEB
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0xEC - 0xEF
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
-
- // 0xF0 - 0xF3
- kInvalidKeycode, kInvalidKeycode, kInvalidKeycode, kInvalidKeycode,
- // 0xF4 - 0xF7
- kInvalidKeycode, kInvalidKeycode, /* VKEY_ATTN */ kInvalidKeycode,
- /* VKEY_CRSEL */ kInvalidKeycode,
- // 0xF8 - 0xFB
- /* VKEY_EXSEL */ kInvalidKeycode, /* VKEY_EREOF */ kInvalidKeycode,
- /* VKEY_PLAY */ kInvalidKeycode, /* VKEY_ZOOM */ kInvalidKeycode,
- // 0xFC - 0xFF
- /* VKEY_NONAME */ kInvalidKeycode, /* VKEY_PA1 */ kInvalidKeycode,
- /* VKEY_OEM_CLEAR */ kInvalidKeycode, kInvalidKeycode
-};
-
void EventExecutorMac::InjectClipboardEvent(const ClipboardEvent& event) {
if (!task_runner_->BelongsToCurrentThread()) {
task_runner_->PostTask(
@@ -287,20 +105,12 @@ void EventExecutorMac::InjectClipboardEvent(const ClipboardEvent& event) {
void EventExecutorMac::InjectKeyEvent(const KeyEvent& event) {
// HostEventDispatcher should filter events missing the pressed field.
DCHECK(event.has_pressed());
+ DCHECK(event.has_usb_keycode());
- int keycode = kInvalidKeycode;
- if (event.has_usb_keycode()) {
- keycode = UsbKeycodeToNativeKeycode(event.usb_keycode());
- VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
- << " to keycode: " << keycode << std::dec;
- } else if (event.has_keycode()) {
- int win_keycode = event.keycode();
- if (win_keycode >= 0 && win_keycode < 256) {
- keycode = kUsVkeyToKeysym[win_keycode];
- }
- VLOG(3) << "Converting VKEY: " << std::hex << event.keycode()
- << " to keycode: " << keycode << std::dec;
- }
+ int keycode = UsbKeycodeToNativeKeycode(event.usb_keycode());
+
+ VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
+ << " to keycode: " << keycode << std::dec;
// If we couldn't determine the Mac virtual key code then ignore the event.
if (keycode == kInvalidKeycode)
diff --git a/remoting/host/event_executor_win.cc b/remoting/host/event_executor_win.cc
index cede6d8..132ef3b 100644
--- a/remoting/host/event_executor_win.cc
+++ b/remoting/host/event_executor_win.cc
@@ -49,7 +49,6 @@ class EventExecutorWin : public EventExecutor {
virtual void OnSessionFinished() OVERRIDE;
private:
- HKL GetForegroundKeyboardLayout();
void HandleKey(const KeyEvent& event);
void HandleMouse(const MouseEvent& event);
@@ -131,64 +130,28 @@ void EventExecutorWin::OnSessionFinished() {
clipboard_->Stop();
}
-HKL EventExecutorWin::GetForegroundKeyboardLayout() {
- HKL layout = 0;
-
- // Can return NULL if a window is losing focus.
- HWND foreground = GetForegroundWindow();
- if (foreground) {
- // Can return 0 if the window no longer exists.
- DWORD thread_id = GetWindowThreadProcessId(foreground, 0);
- if (thread_id) {
- // Can return 0 if the thread no longer exists, or if we're
- // running on Windows Vista and the window is a command-prompt.
- layout = GetKeyboardLayout(thread_id);
- }
- }
-
- // If we couldn't determine a layout then use the system default.
- if (!layout) {
- SystemParametersInfo(SPI_GETDEFAULTINPUTLANG, 0, &layout, 0);
- }
-
- return layout;
-}
-
void EventExecutorWin::HandleKey(const KeyEvent& event) {
// HostEventDispatcher should filter events missing the pressed field.
DCHECK(event.has_pressed());
+ DCHECK(event.has_usb_keycode());
// Reset the system idle suspend timeout.
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
- // The mapping between scancodes and VKEY values depends on the foreground
- // window's current keyboard layout.
- HKL layout = GetForegroundKeyboardLayout();
-
// Populate the a Windows INPUT structure for the event.
INPUT input;
memset(&input, 0, sizeof(input));
input.type = INPUT_KEYBOARD;
input.ki.time = 0;
- input.ki.dwFlags = event.pressed() ? 0 : KEYEVENTF_KEYUP;
-
- int scancode = kInvalidKeycode;
- if (event.has_usb_keycode()) {
- // If the event contains a USB-style code, map to a Windows scancode, and
- // set a flag to have Windows look up the corresponding VK code.
- input.ki.dwFlags |= KEYEVENTF_SCANCODE;
- scancode = UsbKeycodeToNativeKeycode(event.usb_keycode());
- VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
- << " to scancode: " << scancode << std::dec;
- } else {
- // If the event provides only a VKEY then use it, and map to the scancode.
- input.ki.wVk = event.keycode();
- scancode = MapVirtualKeyEx(event.keycode(), MAPVK_VK_TO_VSC_EX, layout);
- VLOG(3) << "Converting VKEY: " << std::hex << event.keycode()
- << " to scancode: " << scancode << std::dec;
- }
+ input.ki.dwFlags = KEYEVENTF_SCANCODE;
+ if (!event.pressed())
+ input.ki.dwFlags |= KEYEVENTF_KEYUP;
+
+ int scancode = UsbKeycodeToNativeKeycode(event.usb_keycode());
+ VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
+ << " to scancode: " << scancode << std::dec;
- // Ignore events with no VK- or USB-keycode, or which can't be mapped.
+ // Ignore events which can't be mapped.
if (scancode == kInvalidKeycode)
return;
diff --git a/remoting/host/remote_input_filter_unittest.cc b/remoting/host/remote_input_filter_unittest.cc
index 079a1c9..94fb360 100644
--- a/remoting/host/remote_input_filter_unittest.cc
+++ b/remoting/host/remote_input_filter_unittest.cc
@@ -19,8 +19,9 @@ namespace remoting {
using protocol::MockInputStub;
using protocol::InputEventTracker;
-MATCHER_P2(EqualsKeyEvent, keycode, pressed, "") {
- return arg.keycode() == keycode && arg.pressed() == pressed;
+MATCHER_P2(EqualsUsbEvent, usb_keycode, pressed, "") {
+ return arg.usb_keycode() == (unsigned int)usb_keycode &&
+ arg.pressed() == pressed;
}
static protocol::MouseEvent MouseMoveEvent(int x, int y) {
@@ -30,9 +31,9 @@ static protocol::MouseEvent MouseMoveEvent(int x, int y) {
return event;
}
-static protocol::KeyEvent KeyEvent(int keycode, bool pressed) {
+static protocol::KeyEvent UsbKeyEvent(int usb_keycode, bool pressed) {
protocol::KeyEvent event;
- event.set_keycode(keycode);
+ event.set_usb_keycode(usb_keycode);
event.set_pressed(pressed);
return event;
}
@@ -109,9 +110,9 @@ TEST(RemoteInputFilterTest, LocalActivityReleasesAll) {
// Use release of a key as a proxy for InputEventTracker::ReleaseAll()
// having been called, rather than mocking it.
- EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsKeyEvent(0, true)));
- EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsKeyEvent(0, false)));
- input_filter.InjectKeyEvent(KeyEvent(0, true));
+ EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(0, true)));
+ EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(0, false)));
+ input_filter.InjectKeyEvent(UsbKeyEvent(0, true));
for (int i = 0; i < 10; ++i) {
input_filter.InjectMouseEvent(MouseMoveEvent(0, 0));
diff --git a/remoting/proto/event.proto b/remoting/proto/event.proto
index e0a469d..5dceab0 100644
--- a/remoting/proto/event.proto
+++ b/remoting/proto/event.proto
@@ -13,7 +13,7 @@ package remoting.protocol;
// Defines a keyboard event.
message KeyEvent {
// The Windows Virtual Key code.
- optional int32 keycode = 1;
+ //optional int32 keycode = 1;
optional bool pressed = 2;
// The USB key code.
diff --git a/remoting/protocol/client_event_dispatcher.cc b/remoting/protocol/client_event_dispatcher.cc
index 49f05f7..afc481f 100644
--- a/remoting/protocol/client_event_dispatcher.cc
+++ b/remoting/protocol/client_event_dispatcher.cc
@@ -30,7 +30,7 @@ void ClientEventDispatcher::OnInitialized() {
}
void ClientEventDispatcher::InjectKeyEvent(const KeyEvent& event) {
- DCHECK(event.has_keycode() || event.has_usb_keycode());
+ DCHECK(event.has_usb_keycode());
DCHECK(event.has_pressed());
EventMessage message;
message.set_sequence_number(base::Time::Now().ToInternalValue());
diff --git a/remoting/protocol/host_event_dispatcher.cc b/remoting/protocol/host_event_dispatcher.cc
index 6ba6dd0..f589e0d 100644
--- a/remoting/protocol/host_event_dispatcher.cc
+++ b/remoting/protocol/host_event_dispatcher.cc
@@ -38,8 +38,7 @@ void HostEventDispatcher::OnMessageReceived(
if (message->has_key_event()) {
const KeyEvent& event = message->key_event();
- if ((event.has_keycode() || event.has_usb_keycode()) &&
- event.has_pressed()) {
+ if (event.has_usb_keycode() && event.has_pressed()) {
input_stub_->InjectKeyEvent(event);
} else {
LOG(WARNING) << "Received invalid key event.";
diff --git a/remoting/protocol/input_event_tracker.cc b/remoting/protocol/input_event_tracker.cc
index 3fb0cf4..ab9e585 100644
--- a/remoting/protocol/input_event_tracker.cc
+++ b/remoting/protocol/input_event_tracker.cc
@@ -24,7 +24,7 @@ bool InputEventTracker::IsKeyPressed(uint32 usb_keycode) const {
}
int InputEventTracker::PressedKeyCount() const {
- return pressed_keys_.size() + pressed_vkeys_.size();
+ return pressed_keys_.size();
}
void InputEventTracker::ReleaseAll() {
@@ -37,15 +37,6 @@ void InputEventTracker::ReleaseAll() {
}
pressed_keys_.clear();
- std::set<int>::iterator j;
- for (j = pressed_vkeys_.begin(); j != pressed_vkeys_.end(); ++j) {
- KeyEvent event;
- event.set_pressed(false);
- event.set_keycode(*j);
- input_stub_->InjectKeyEvent(event);
- }
- pressed_vkeys_.clear();
-
for (int i = MouseEvent::BUTTON_UNDEFINED + 1;
i < MouseEvent::BUTTON_MAX; ++i) {
if (mouse_button_state_ & (1 << (i - 1))) {
@@ -72,12 +63,6 @@ void InputEventTracker::InjectKeyEvent(const KeyEvent& event) {
} else {
pressed_keys_.erase(event.usb_keycode());
}
- } else if (event.has_keycode()) {
- if (event.pressed()) {
- pressed_vkeys_.insert(event.keycode());
- } else {
- pressed_vkeys_.erase(event.keycode());
- }
}
}
input_stub_->InjectKeyEvent(event);
diff --git a/remoting/protocol/input_event_tracker.h b/remoting/protocol/input_event_tracker.h
index 700bbe8..794fffe9 100644
--- a/remoting/protocol/input_event_tracker.h
+++ b/remoting/protocol/input_event_tracker.h
@@ -40,8 +40,6 @@ class InputEventTracker : public InputStub {
private:
protocol::InputStub* input_stub_;
- // TODO(wez): Remove this member when we stop supporting VKEY based clients.
- std::set<int> pressed_vkeys_;
std::set<uint32> pressed_keys_;
SkIPoint mouse_pos_;
diff --git a/remoting/protocol/input_event_tracker_unittest.cc b/remoting/protocol/input_event_tracker_unittest.cc
index 35ae2b0..6f44b9e 100644
--- a/remoting/protocol/input_event_tracker_unittest.cc
+++ b/remoting/protocol/input_event_tracker_unittest.cc
@@ -19,10 +19,6 @@ namespace protocol {
static const MouseEvent::MouseButton BUTTON_LEFT = MouseEvent::BUTTON_LEFT;
static const MouseEvent::MouseButton BUTTON_RIGHT = MouseEvent::BUTTON_RIGHT;
-MATCHER_P2(EqualsVkeyEvent, keycode, pressed, "") {
- return arg.keycode() == keycode && arg.pressed() == pressed;
-}
-
MATCHER_P2(EqualsUsbEvent, usb_keycode, pressed, "") {
return arg.usb_keycode() == static_cast<uint32>(usb_keycode) &&
arg.pressed() == pressed;
@@ -33,18 +29,6 @@ MATCHER_P4(EqualsMouseEvent, x, y, button, down, "") {
arg.button_down() == down;
}
-static KeyEvent NewVkeyEvent(int keycode, bool pressed) {
- KeyEvent event;
- event.set_keycode(keycode);
- event.set_pressed(pressed);
- return event;
-}
-
-static void PressAndReleaseVkey(InputStub* input_stub, int keycode) {
- input_stub->InjectKeyEvent(NewVkeyEvent(keycode, true));
- input_stub->InjectKeyEvent(NewVkeyEvent(keycode, false));
-}
-
static KeyEvent NewUsbEvent(uint32 usb_keycode, bool pressed) {
KeyEvent event;
event.set_usb_keycode(usb_keycode);
@@ -58,15 +42,6 @@ static void PressAndReleaseUsb(InputStub* input_stub,
input_stub->InjectKeyEvent(NewUsbEvent(usb_keycode, false));
}
-static KeyEvent NewVkeyUsbEvent(int keycode, int usb_keycode,
- bool pressed) {
- KeyEvent event;
- event.set_keycode(keycode);
- event.set_usb_keycode(usb_keycode);
- event.set_pressed(pressed);
- return event;
-}
-
static MouseEvent NewMouseEvent(int x, int y,
MouseEvent::MouseButton button, bool down) {
MouseEvent event;
@@ -150,8 +125,8 @@ TEST(InputEventTrackerTest, ReleaseAllKeys) {
input_tracker.ReleaseAll();
}
-// Verify that we track both VK- and USB-based key events correctly.
-TEST(InputEventTrackerTest, TrackVkeyAndUsb) {
+// Verify that we track both USB-based key events correctly.
+TEST(InputEventTrackerTest, TrackUsbKeyEvents) {
MockInputStub mock_stub;
InputEventTracker input_tracker(&mock_stub);
ExpectationSet injects;
@@ -160,10 +135,6 @@ TEST(InputEventTrackerTest, TrackVkeyAndUsb) {
InSequence s;
injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(3, true)));
- injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(1, true)));
- injects += EXPECT_CALL(mock_stub,
- InjectKeyEvent(EqualsVkeyEvent(1, false)));
- injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(4, true)));
injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(6, true)));
injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(7, true)));
injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(5, true)));
@@ -174,8 +145,6 @@ TEST(InputEventTrackerTest, TrackVkeyAndUsb) {
EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(3, false)))
.After(injects);
- EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(4, false)))
- .After(injects);
EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(6, false)))
.After(injects);
EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(7, false)))
@@ -184,22 +153,19 @@ TEST(InputEventTrackerTest, TrackVkeyAndUsb) {
.After(injects);
input_tracker.InjectKeyEvent(NewUsbEvent(3, true));
- PressAndReleaseVkey(&input_tracker, 1);
- input_tracker.InjectKeyEvent(NewVkeyEvent(4, true));
- input_tracker.InjectKeyEvent(NewVkeyUsbEvent(5, 6, true));
- input_tracker.InjectKeyEvent(NewVkeyUsbEvent(5, 7, true));
- input_tracker.InjectKeyEvent(NewVkeyUsbEvent(6, 5, true));
- input_tracker.InjectKeyEvent(NewVkeyUsbEvent(7, 5, true));
+ input_tracker.InjectKeyEvent(NewUsbEvent(6, true));
+ input_tracker.InjectKeyEvent(NewUsbEvent(7, true));
+ input_tracker.InjectKeyEvent(NewUsbEvent(5, true));
+ input_tracker.InjectKeyEvent(NewUsbEvent(5, true));
PressAndReleaseUsb(&input_tracker, 2);
EXPECT_FALSE(input_tracker.IsKeyPressed(1));
EXPECT_FALSE(input_tracker.IsKeyPressed(2));
EXPECT_TRUE(input_tracker.IsKeyPressed(3));
- EXPECT_FALSE(input_tracker.IsKeyPressed(4)); // 4 was a VKEY.
EXPECT_TRUE(input_tracker.IsKeyPressed(5));
EXPECT_TRUE(input_tracker.IsKeyPressed(6));
EXPECT_TRUE(input_tracker.IsKeyPressed(7));
- EXPECT_EQ(5, input_tracker.PressedKeyCount());
+ EXPECT_EQ(4, input_tracker.PressedKeyCount());
input_tracker.ReleaseAll();
}
@@ -216,16 +182,13 @@ TEST(InputEventTrackerTest, InvalidEventsNotTracked) {
injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(3, true)));
injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(1, true)));
injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(1, false)));
- injects += EXPECT_CALL(mock_stub, InjectKeyEvent(_)).Times(3);
- injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(4, true)));
+ injects += EXPECT_CALL(mock_stub, InjectKeyEvent(_)).Times(2);
injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(2, true)));
injects += EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(2, false)));
}
EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(3, false)))
.After(injects);
- EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsVkeyEvent(4, false)))
- .After(injects);
input_tracker.InjectKeyEvent(NewUsbEvent(3, true));
PressAndReleaseUsb(&input_tracker, 1);
@@ -235,21 +198,15 @@ TEST(InputEventTrackerTest, InvalidEventsNotTracked) {
input_tracker.InjectKeyEvent(invalid_event1);
KeyEvent invalid_event2;
- invalid_event2.set_keycode(5);
+ invalid_event2.set_usb_keycode(6);
input_tracker.InjectKeyEvent(invalid_event2);
- KeyEvent invalid_event3;
- invalid_event3.set_usb_keycode(6);
- input_tracker.InjectKeyEvent(invalid_event3);
-
- input_tracker.InjectKeyEvent(NewVkeyEvent(4, true));
PressAndReleaseUsb(&input_tracker, 2);
EXPECT_FALSE(input_tracker.IsKeyPressed(1));
EXPECT_FALSE(input_tracker.IsKeyPressed(2));
EXPECT_TRUE(input_tracker.IsKeyPressed(3));
- EXPECT_FALSE(input_tracker.IsKeyPressed(4)); // Injected as VKEY.
- EXPECT_EQ(2, input_tracker.PressedKeyCount());
+ EXPECT_EQ(1, input_tracker.PressedKeyCount());
input_tracker.ReleaseAll();
}
diff --git a/remoting/protocol/message_decoder_unittest.cc b/remoting/protocol/message_decoder_unittest.cc
index 27a40ad..24e89f4 100644
--- a/remoting/protocol/message_decoder_unittest.cc
+++ b/remoting/protocol/message_decoder_unittest.cc
@@ -16,7 +16,7 @@
namespace remoting {
namespace protocol {
-static const int kTestKey = 142;
+static const unsigned int kTestKey = 142;
static void AppendMessage(const EventMessage& msg,
std::string* buffer) {
@@ -35,7 +35,7 @@ static void PrepareData(uint8** buffer, int* size) {
for (int i = 0; i < 10; ++i) {
EventMessage msg;
msg.set_sequence_number(i);
- msg.mutable_key_event()->set_keycode(kTestKey + i);
+ msg.mutable_key_event()->set_usb_keycode(kTestKey + i);
msg.mutable_key_event()->set_pressed((i % 2) != 0);
AppendMessage(msg, &encoded_data);
}
@@ -87,7 +87,7 @@ void SimulateReadSequence(const int read_sequence[], int sequence_size) {
// Then verify the decoded messages.
EXPECT_EQ(10u, message_list.size());
- int index = 0;
+ unsigned int index = 0;
for (std::list<EventMessage*>::iterator it =
message_list.begin();
it != message_list.end(); ++it) {
@@ -99,7 +99,7 @@ void SimulateReadSequence(const int read_sequence[], int sequence_size) {
// TODO(sergeyu): Don't use index here. Instead store the expected values
// in an array.
- EXPECT_EQ(kTestKey + index, message->key_event().keycode());
+ EXPECT_EQ(kTestKey + index, message->key_event().usb_keycode());
EXPECT_EQ((index % 2) != 0, message->key_event().pressed());
++index;
}