Skip to content

Commit

Permalink
Fixing proper keyboard event values for number pad keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Feb 1, 2019
1 parent 5281fb7 commit b01d2ee
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 46 deletions.
8 changes: 4 additions & 4 deletions cpp/iedriver/IEDriver.rc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,141,5,5
PRODUCTVERSION 3,141,5,5
FILEVERSION 3,141,5,6
PRODUCTVERSION 3,141,5,6
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -68,12 +68,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Software Freedom Conservancy"
VALUE "FileDescription", "Driver library for the IE driver"
VALUE "FileVersion", "3.141.5.5"
VALUE "FileVersion", "3.141.5.6"
VALUE "InternalName", "IEDriver.dll"
VALUE "LegalCopyright", "Copyright (C) 2019"
VALUE "OriginalFilename", "IEDriver.dll"
VALUE "ProductName", "Selenium WebDriver"
VALUE "ProductVersion", "3.141.5.5"
VALUE "ProductVersion", "3.141.5.6"
END
END
BLOCK "VarFileInfo"
Expand Down
81 changes: 43 additions & 38 deletions cpp/iedriver/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ void InputManager::AddKeyboardInput(HWND window_handle,

std::vector<WORD>::const_iterator it = modifier_key_codes.begin();
for (; it != modifier_key_codes.end(); ++it) {
KeyInfo modifier_key_info = { 0, 0, false, false, false, character };
KeyInfo modifier_key_info = { 0, 0, false, false, false, false, character };
UINT scan_code = ::MapVirtualKey(*it, MAPVK_VK_TO_VSC);
modifier_key_info.key_code = *it;
modifier_key_info.scan_code = scan_code;
Expand All @@ -778,7 +778,7 @@ void InputManager::AddKeyboardInput(HWND window_handle,
}

if (this->IsModifierKey(character)) {
KeyInfo modifier_key_info = { 0, 0, false, false, false, character };
KeyInfo modifier_key_info = { 0, 0, false, false, false, false, character };
// If the character represents the Shift key, or represents the
// "release all modifiers" key and the Shift key is down, send
// the appropriate down or up keystroke for the Shift key.
Expand Down Expand Up @@ -906,15 +906,15 @@ void InputManager::AddKeyboardInput(HWND window_handle,
!input_state->is_alt_pressed;
if (!key_up) {
if (is_shift_required) {
KeyInfo shift_key_info = { VK_SHIFT, 0, false, false, false, character };
KeyInfo shift_key_info = { VK_SHIFT, 0, false, false, false, false, character };
this->CreateKeyboardInputItem(shift_key_info, 0, false);
}
if (is_control_required) {
KeyInfo control_key_info = { VK_CONTROL, 0, false, false, false, character };
KeyInfo control_key_info = { VK_CONTROL, 0, false, false, false, false, character };
this->CreateKeyboardInputItem(control_key_info, 0, false);
}
if (is_alt_required) {
KeyInfo alt_key_info = { VK_MENU, 0, false, false, false, character };
KeyInfo alt_key_info = { VK_MENU, 0, false, false, false, false, character };
this->CreateKeyboardInputItem(alt_key_info, 0, false);
}
}
Expand All @@ -923,15 +923,15 @@ void InputManager::AddKeyboardInput(HWND window_handle,

if (key_up) {
if (is_shift_required) {
KeyInfo shift_key_info = { VK_SHIFT, 0, false, false, false, character };
KeyInfo shift_key_info = { VK_SHIFT, 0, false, false, false, false, character };
this->CreateKeyboardInputItem(shift_key_info, 0, true);
}
if (is_control_required) {
KeyInfo control_key_info = { VK_CONTROL, 0, false, false, false, character };
KeyInfo control_key_info = { VK_CONTROL, 0, false, false, false, false, character };
this->CreateKeyboardInputItem(control_key_info, 0, true);
}
if (is_alt_required) {
KeyInfo alt_key_info = { VK_MENU, 0, false, false, false, character };
KeyInfo alt_key_info = { VK_MENU, 0, false, false, false, false, character };
this->CreateKeyboardInputItem(alt_key_info, 0, true);
}
}
Expand Down Expand Up @@ -986,6 +986,9 @@ void InputManager::CreateKeyboardInputItem(KeyInfo key_info,
if (is_generating_key_up) {
input_element.ki.dwFlags |= KEYEVENTF_KEYUP;
}
if (key_info.is_force_scan_code) {
input_element.ki.dwFlags |= KEYEVENTF_SCANCODE;
}

this->inputs_.push_back(input_element);
}
Expand All @@ -1007,6 +1010,7 @@ KeyInfo InputManager::GetKeyInfo(HWND window_handle, wchar_t character) {
key_info.is_ignored_key = false;
key_info.is_extended_key = false;
key_info.is_webdriver_key = true;
key_info.is_force_scan_code = false;
key_info.key_code = 0;
key_info.scan_code = 0;
key_info.character = character;
Expand Down Expand Up @@ -1041,6 +1045,7 @@ KeyInfo InputManager::GetKeyInfo(HWND window_handle, wchar_t character) {
else if (character == WD_KEY_ENTER) { // enter
key_info.key_code = VK_RETURN;
key_info.scan_code = VK_RETURN;
key_info.is_extended_key = true;
}
else if (character == WD_KEY_PAUSE) { // pause
key_info.key_code = VK_PAUSE;
Expand Down Expand Up @@ -1194,54 +1199,54 @@ KeyInfo InputManager::GetKeyInfo(HWND window_handle, wchar_t character) {
key_info.is_extended_key = true;
}
else if (character == WD_KEY_R_PAGEUP) {
key_info.key_code = VK_PRIOR;
key_info.scan_code = VK_PRIOR;
key_info.is_extended_key = true;
key_info.key_code = VK_NUMPAD9;
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);
key_info.is_force_scan_code = true;
}
else if (character == WD_KEY_R_PAGEDN) {
key_info.key_code = VK_NEXT;
key_info.scan_code = VK_NEXT;
key_info.is_extended_key = true;
key_info.key_code = VK_NUMPAD3;
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);
key_info.is_force_scan_code = true;
}
else if (character == WD_KEY_R_END) { // end
key_info.key_code = VK_END;
key_info.scan_code = VK_END;
key_info.is_extended_key = true;
key_info.key_code = VK_NUMPAD1;
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);
key_info.is_force_scan_code = true;
}
else if (character == WD_KEY_R_HOME) { // home
key_info.key_code = VK_HOME;
key_info.scan_code = VK_HOME;
key_info.is_extended_key = true;
key_info.key_code = VK_NUMPAD7;
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);
key_info.is_force_scan_code = true;
}
else if (character == WD_KEY_R_LEFT) { // left arrow
key_info.key_code = VK_LEFT;
key_info.scan_code = VK_LEFT;
key_info.is_extended_key = true;
key_info.key_code = VK_NUMPAD4;
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);
key_info.is_force_scan_code = true;
}
else if (character == WD_KEY_R_UP) { // up arrow
key_info.key_code = VK_UP;
key_info.scan_code = VK_UP;
key_info.is_extended_key = true;
key_info.key_code = VK_NUMPAD8;
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);
key_info.is_force_scan_code = true;
}
else if (character == WD_KEY_R_RIGHT) { // right arrow
key_info.key_code = VK_RIGHT;
key_info.scan_code = VK_RIGHT;
key_info.is_extended_key = true;
key_info.key_code = VK_NUMPAD6;
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);
key_info.is_force_scan_code = true;
}
else if (character == WD_KEY_R_DOWN) { // down arrow
key_info.key_code = VK_DOWN;
key_info.scan_code = VK_DOWN;
key_info.is_extended_key = true;
key_info.key_code = VK_NUMPAD2;
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);
key_info.is_force_scan_code = true;
}
else if (character == WD_KEY_R_INSERT) { // insert
key_info.key_code = VK_INSERT;
key_info.scan_code = VK_INSERT;
key_info.is_extended_key = true;
key_info.key_code = VK_NUMPAD0;
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);
key_info.is_force_scan_code = true;
}
else if (character == WD_KEY_R_DELETE) { // delete
key_info.key_code = VK_DELETE;
key_info.scan_code = VK_DELETE;
key_info.is_extended_key = true;
key_info.key_code = VK_DECIMAL;
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);
key_info.is_force_scan_code = true;
}
else if (character == WD_KEY_F1) { // F1
key_info.key_code = VK_F1;
Expand Down
1 change: 1 addition & 0 deletions cpp/iedriver/InputManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct KeyInfo {
bool is_extended_key;
bool is_webdriver_key;
bool is_ignored_key;
bool is_force_scan_code;
wchar_t character;
};

Expand Down
4 changes: 4 additions & 0 deletions cpp/iedriverserver/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ available via the project downloads page. Changes in "revision" field indicate
private releases checked into the prebuilts directory of the source tree, but
not made generally available on the downloads page.

v3.141.5.6
==========
* Fixed proper keyboard event values for extended keys.

v3.141.5.5
==========
* Added hack for handling cases where document.designMode is on.
Expand Down
8 changes: 4 additions & 4 deletions cpp/iedriverserver/IEDriverServer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,141,5,5
PRODUCTVERSION 3,141,5,5
FILEVERSION 3,141,5,6
PRODUCTVERSION 3,141,5,6
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -68,12 +68,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Software Freedom Conservancy"
VALUE "FileDescription", "Command line server for the IE driver"
VALUE "FileVersion", "3.141.5.5"
VALUE "FileVersion", "3.141.5.6"
VALUE "InternalName", "IEDriverServer.exe"
VALUE "LegalCopyright", "Copyright (C) 2019"
VALUE "OriginalFilename", "IEDriverServer.exe"
VALUE "ProductName", "Selenium WebDriver"
VALUE "ProductVersion", "3.141.5.5"
VALUE "ProductVersion", "3.141.5.6"
END
END
BLOCK "VarFileInfo"
Expand Down
Binary file modified cpp/prebuilt/Win32/Release/IEDriverServer.exe
Binary file not shown.
Binary file modified cpp/prebuilt/x64/Release/IEDriverServer.exe
Binary file not shown.

0 comments on commit b01d2ee

Please sign in to comment.