Skip to content

Commit

Permalink
Merge branch 'dev/build-features' into user/lamotile/refactoring_plus…
Browse files Browse the repository at this point in the history
…_tests
  • Loading branch information
Lavius Motileng authored Apr 17, 2020
2 parents da62489 + 2cfcad6 commit 9ac0d53
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Page
<Page
x:Class="Microsoft.PowerToys.Settings.UI.Views.GeneralPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand Down
16 changes: 16 additions & 0 deletions src/modules/keyboardmanager/common/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,19 @@ IInspectable getSiblingElement(IInspectable const& element)
parentElement.Children().IndexOf(frameworkElement, index);
return parentElement.Children().GetAt(index + 1);
}

// Function to return if the key is an extended key which requires the use of the extended key flag
bool isExtendedKey(DWORD key)
{
switch (key)
{
case VK_RCONTROL:
case VK_RMENU:
case VK_NUMLOCK:
case VK_SNAPSHOT:
case VK_CANCEL:
return true;
default:
return false;
}
}
3 changes: 3 additions & 0 deletions src/modules/keyboardmanager/common/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ std::vector<T> convertWStringVectorToIntegerVector(const std::vector<std::wstrin

return typeVector;
}

// Function to return if the key is an extended key which requires the use of the extended key flag
bool isExtendedKey(DWORD key);
4 changes: 2 additions & 2 deletions src/modules/keyboardmanager/common/Shortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ bool Shortcut::CheckModifiersKeyboardState() const
// Function to check if any keys are pressed down except those in the shortcut
bool Shortcut::IsKeyboardStateClearExceptShortcut() const
{
// Iterate through all the virtual key codes
for (int keyVal = 0; keyVal < 0x100; keyVal++)
// Iterate through all the virtual key codes - 0xFF is set to key down because of the Num Lock
for (int keyVal = 0; keyVal < 0xFF; keyVal++)
{
// Skip mouse buttons. Keeping this could cause a remapping to fail if a mouse button is also pressed at the same time
if (keyVal == VK_LBUTTON || keyVal == VK_RBUTTON || keyVal == VK_MBUTTON || keyVal == VK_XBUTTON1 || keyVal == VK_XBUTTON2)
Expand Down
6 changes: 5 additions & 1 deletion src/modules/keyboardmanager/dll/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class KeyboardManager : public PowertoyModuleIface
PowerToysSettings::CustomActionObject::from_json_string(action);
HINSTANCE hInstance = reinterpret_cast<HINSTANCE>(&__ImageBase);

if (action_object.get_name() == L"RemapKeyboard")
if (action_object.get_name() == L"RemapKeyboard")
{
if (!CheckEditKeyboardWindowActive())
{
Expand Down Expand Up @@ -325,6 +325,10 @@ class KeyboardManager : public PowertoyModuleIface
keyEventArray[index].type = inputType;
keyEventArray[index].ki.wVk = keyCode;
keyEventArray[index].ki.dwFlags = flags;
if (isExtendedKey(keyCode))
{
keyEventArray[index].ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
}
keyEventArray[index].ki.dwExtraInfo = extraInfo;
}

Expand Down

0 comments on commit 9ac0d53

Please sign in to comment.