mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 06:29:44 +08:00
Fix remapping issues to Home/PgUp and other keys which are also present on NumPad (#4398)
* Added extended key flag to more keys * Add test for extended key flag * Move shlwapi.lib reference * Added shcore ref * Fixed pipeline incompatibility * Fixed lib declaration in common * Fixed formatting * Remove unused statements * removed another statement
This commit is contained in:
parent
8e758507b1
commit
f1b6e6570c
@ -82,7 +82,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>Shlwapi.lib;</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>shlwapi.lib;shcore.lib</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(CIBuild)'!='true'">
|
||||
@ -111,7 +111,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>Shlwapi.lib;</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>shlwapi.lib;shcore.lib</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
@ -75,6 +75,17 @@ namespace KeyboardManagerHelper
|
||||
case VK_NUMLOCK:
|
||||
case VK_SNAPSHOT:
|
||||
case VK_CANCEL:
|
||||
// If the extended flag is not set for the following keys, their NumPad versions are sent. This causes weird behavior when NumLock is on (more information at https://github.com/microsoft/PowerToys/issues/3478)
|
||||
case VK_INSERT:
|
||||
case VK_HOME:
|
||||
case VK_PRIOR:
|
||||
case VK_DELETE:
|
||||
case VK_END:
|
||||
case VK_NEXT:
|
||||
case VK_LEFT:
|
||||
case VK_DOWN:
|
||||
case VK_RIGHT:
|
||||
case VK_UP:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -100,6 +100,12 @@
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">shlwapi.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
<Lib>
|
||||
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">shlwapi.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Helpers.cpp" />
|
||||
|
@ -103,12 +103,6 @@
|
||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4002</DisableSpecificWarnings>
|
||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4002</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">shcore.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<Link>
|
||||
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">shcore.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(CIBuild)'!='true'">
|
||||
<ClCompile>
|
||||
|
@ -5,4 +5,4 @@
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <shlwapi.h>
|
||||
#include <stdexcept>
|
||||
#include <unordered_set>
|
||||
#include <unordered_set>
|
||||
|
@ -45,6 +45,34 @@ namespace KeyboardManagerRemapLogicTests
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CLASS (SetKeyEventTests)
|
||||
{
|
||||
public:
|
||||
TEST_METHOD_INITIALIZE(InitializeTestEnv)
|
||||
{
|
||||
// Reset test environment
|
||||
TestHelpers::ResetTestEnv(mockedInputHandler, testState);
|
||||
}
|
||||
|
||||
// Test if SetKeyEvent sets the extended key flag for all the extended keys
|
||||
TEST_METHOD (SetKeyEvent_ShouldUseExtendedKeyFlag_WhenArgumentIsExtendedKey)
|
||||
{
|
||||
const int nInputs = 15;
|
||||
INPUT input[nInputs] = {};
|
||||
|
||||
// List of extended keys
|
||||
WORD keyCodes[nInputs] = { VK_RCONTROL, VK_RMENU, VK_NUMLOCK, VK_SNAPSHOT, VK_CANCEL, VK_INSERT, VK_HOME, VK_PRIOR, VK_DELETE, VK_END, VK_NEXT, VK_LEFT, VK_DOWN, VK_RIGHT, VK_UP };
|
||||
|
||||
for (int i = 0; i < nInputs; i++)
|
||||
{
|
||||
// Set key events for all the extended keys
|
||||
KeyboardManagerHelper::SetKeyEvent(input, i, INPUT_KEYBOARD, keyCodes[i], 0, 0);
|
||||
// Extended key flag should be set
|
||||
Assert::AreEqual(true, bool(input[i].ki.dwFlags & KEYEVENTF_EXTENDEDKEY));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CLASS (SingleKeyRemappingTests)
|
||||
{
|
||||
public:
|
||||
|
@ -1 +1,2 @@
|
||||
#pragma once
|
||||
#pragma comment(lib, "shlwapi.lib")
|
||||
|
Loading…
Reference in New Issue
Block a user