Skip to content

Commit

Permalink
Fix build for VS 16.10 (#11557)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykhailopylyp authored Jun 1, 2021
1 parent 8e24e07 commit 3b32116
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 144 deletions.
4 changes: 2 additions & 2 deletions src/common/interop/shared_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace CommonSharedConstants
const uintptr_t KEYBOARDMANAGER_INJECTED_FLAG = 0x1;

// Fake key code to represent VK_WIN.
inline const int VK_WIN_BOTH = 0x104;
inline const DWORD VK_WIN_BOTH = 0x104;

const wchar_t APPDATA_PATH[] = L"Microsoft\\PowerToys";

Expand All @@ -27,5 +27,5 @@ namespace CommonSharedConstants
const wchar_t SHORTCUT_GUIDE_EXIT_EVENT[] = L"Local\\ShortcutGuide-ExitEvent-35697cdd-a3d2-47d6-a246-34efcc73eac0";

// Max DWORD for key code to disable keys.
const int VK_DISABLED = 0x100;
const DWORD VK_DISABLED = 0x100;
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ namespace BufferValidationHelpers
// If there is no error, set the buffer
if (errorType == ShortcutErrorType::NoError)
{
remapBuffer[rowIndex].first[colIndex] = selectedKeyCode;
remapBuffer[rowIndex].first[colIndex] = (DWORD)selectedKeyCode;
}
else
{
remapBuffer[rowIndex].first[colIndex] = NULL;
remapBuffer[rowIndex].first[colIndex] = (DWORD)0;
}
}
else
{
// Reset to null if the key is not found
remapBuffer[rowIndex].first[colIndex] = NULL;
remapBuffer[rowIndex].first[colIndex] = (DWORD)0;
}

return errorType;
Expand Down Expand Up @@ -214,7 +214,7 @@ namespace BufferValidationHelpers
KeyShortcutUnion tempShortcut;
if (isHybridControl && KeyDropDownControl::GetNumberOfSelectedKeys(selectedCodes) == 1)
{
tempShortcut = *std::find_if(selectedCodes.begin(), selectedCodes.end(), [](int32_t a) { return a != -1 && a != 0; });
tempShortcut = (DWORD)*std::find_if(selectedCodes.begin(), selectedCodes.end(), [](int32_t a) { return a != -1 && a != 0; });
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void KeyDropDownControl::SetSelectionHandler(StackPanel& table, StackPanel row,
// If exactly one key is selected consider it to be a key remap
if (GetNumberOfSelectedKeys(selectedKeyCodes) == 1)
{
shortcutRemapBuffer[validationResult.second].first[colIndex] = selectedKeyCodes[0];
shortcutRemapBuffer[validationResult.second].first[colIndex] = (DWORD)selectedKeyCodes[0];
}
else
{
Expand Down Expand Up @@ -357,7 +357,7 @@ void KeyDropDownControl::ValidateShortcutFromDropDownList(StackPanel table, Stac
KeyShortcutUnion currentShortcut;
if (GetNumberOfSelectedKeys(selectedKeyCodes) == 1 && isHybridControl)
{
currentShortcut = selectedKeyCodes[0];
currentShortcut = (DWORD)selectedKeyCodes[0];
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
// If exactly one key is selected consider it to be a key remap
if (selectedKeyCodes.size() == 1)
{
shortcutRemapBuffer[rowIndex].first[1] = selectedKeyCodes[0];
shortcutRemapBuffer[rowIndex].first[1] = (DWORD)selectedKeyCodes[0];
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
else
{
// Initialize both keys to NULL
singleKeyRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ NULL, NULL }, L""));
singleKeyRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ (DWORD)0, (DWORD)0 }, L""));
}

// Delete row button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SingleKeyRemapControl
SingleKeyRemapControl(StackPanel table, StackPanel row, const int colIndex);

// Function to add a new row to the remap keys table. If the originalKey and newKey args are provided, then the displayed remap keys are set to those values.
static void AddNewControlKeyRemapRow(StackPanel& parent, std::vector<std::vector<std::unique_ptr<SingleKeyRemapControl>>>& keyboardRemapControlObjects, const DWORD originalKey = NULL, const KeyShortcutUnion newKey = NULL);
static void AddNewControlKeyRemapRow(StackPanel& parent, std::vector<std::vector<std::unique_ptr<SingleKeyRemapControl>>>& keyboardRemapControlObjects, const DWORD originalKey = 0, const KeyShortcutUnion newKey = (DWORD)0);

// Function to return the stack panel element of the SingleKeyRemapControl. This is the externally visible UI element which can be used to add it to other layouts
winrt::Windows::UI::Xaml::Controls::StackPanel getSingleKeyRemapControl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ namespace RemappingUITests
RemapBuffer remapBuffer;

// Add 2 empty rows
remapBuffer.push_back(std::make_pair(RemapBufferItem({ NULL, NULL }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ NULL, NULL }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0, (DWORD)0 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0, (DWORD)0 }), std::wstring()));

// Validate and update the element when -1 i.e. null selection is made on an empty row.
ValidateAndUpdateKeyBufferElementArgs args = { 0, 0, -1 };
Expand All @@ -75,7 +75,7 @@ namespace RemappingUITests
RemapBuffer remapBuffer;

// Add an empty row
remapBuffer.push_back(std::make_pair(RemapBufferItem({ NULL, NULL }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0, (DWORD)0 }), std::wstring()));

// Validate and update the element when selecting B on an empty row
ValidateAndUpdateKeyBufferElementArgs args = { 0, 0, 0x42 };
Expand All @@ -93,7 +93,7 @@ namespace RemappingUITests
RemapBuffer remapBuffer;

// Add a row with A as the target
remapBuffer.push_back(std::make_pair(RemapBufferItem({ NULL, 0x41 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0, (DWORD)0x41 }), std::wstring()));

// Validate and update the element when selecting B on a row
ValidateAndUpdateKeyBufferElementArgs args = { 0, 0, 0x42 };
Expand All @@ -111,7 +111,7 @@ namespace RemappingUITests
RemapBuffer remapBuffer;

// Add a row with Ctrl+A as the target
remapBuffer.push_back(std::make_pair(RemapBufferItem({ NULL, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) }), std::wstring()));

// Validate and update the element when selecting B on a row
ValidateAndUpdateKeyBufferElementArgs args = { 0, 0, 0x42 };
Expand All @@ -129,7 +129,7 @@ namespace RemappingUITests
RemapBuffer remapBuffer;

// Add a row with A as the target
remapBuffer.push_back(std::make_pair(RemapBufferItem({ NULL, 0x41 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0, (DWORD)0x41 }), std::wstring()));

// Validate and update the element when selecting A on a row
ValidateAndUpdateKeyBufferElementArgs args = { 0, 0, 0x41 };
Expand All @@ -147,8 +147,8 @@ namespace RemappingUITests
RemapBuffer remapBuffer;

// Add a row from A->B and a row with C as target
remapBuffer.push_back(std::make_pair(RemapBufferItem({ 0x41, 0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ NULL, 0x43 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0, (DWORD)0x43 }), std::wstring()));

// Validate and update the element when selecting A on second row
ValidateAndUpdateKeyBufferElementArgs args = { 1, 0, 0x41 };
Expand All @@ -166,8 +166,8 @@ namespace RemappingUITests
RemapBuffer remapBuffer;

// Add a row from A->B and a row with Ctrl+A as target
remapBuffer.push_back(std::make_pair(RemapBufferItem({ 0x41, 0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ NULL, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0x41, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) }), std::wstring()));

// Validate and update the element when selecting A on second row
ValidateAndUpdateKeyBufferElementArgs args = { 1, 0, 0x41 };
Expand All @@ -185,8 +185,8 @@ namespace RemappingUITests
RemapBuffer remapBuffer;

// Add a row from Ctrl->B and a row with C as target
remapBuffer.push_back(std::make_pair(RemapBufferItem({ VK_CONTROL, 0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ NULL, 0x43 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)VK_CONTROL, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0, (DWORD)0x43 }), std::wstring()));

// Validate and update the element when selecting LCtrl on second row
ValidateAndUpdateKeyBufferElementArgs args = { 1, 0, VK_LCONTROL };
Expand All @@ -204,8 +204,8 @@ namespace RemappingUITests
RemapBuffer remapBuffer;

// Add a row from Ctrl->B and a row with Ctrl+A as target
remapBuffer.push_back(std::make_pair(RemapBufferItem({ VK_CONTROL, 0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ NULL, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)VK_CONTROL, (DWORD)0x42 }), std::wstring()));
remapBuffer.push_back(std::make_pair(RemapBufferItem({ (DWORD)0, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) }), std::wstring()));

// Validate and update the element when selecting LCtrl on second row
ValidateAndUpdateKeyBufferElementArgs args = { 1, 0, VK_LCONTROL };
Expand All @@ -226,9 +226,9 @@ namespace RemappingUITests
// Case 2: Validate the element when making null-selection (-1 index) on second column of empty shortcut to shortcut row
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ -1 }, std::wstring(), false, std::make_pair(RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring()) });
// Case 3: Validate the element when making null-selection (-1 index) on first column of empty shortcut to key row
testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ -1 }, std::wstring(), false, std::make_pair(RemapBufferItem{ Shortcut(), NULL }, std::wstring()) });
testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ -1 }, std::wstring(), false, std::make_pair(RemapBufferItem{ Shortcut(), (DWORD)0 }, std::wstring()) });
// Case 4: Validate the element when making null-selection (-1 index) on second column of empty shortcut to key row
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ -1 }, std::wstring(), true, std::make_pair(RemapBufferItem{ Shortcut(), NULL }, std::wstring()) });
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ -1 }, std::wstring(), true, std::make_pair(RemapBufferItem{ Shortcut(), (DWORD)0 }, std::wstring()) });
// Case 5: Validate the element when making null-selection (-1 index) on first dropdown of first column of valid shortcut to shortcut row
testCases.push_back({ 0, 0, 0, std::vector<int32_t>({ -1, 0x43 }), std::wstring(), false, std::make_pair(RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring()) });
// Case 6: Validate the element when making null-selection (-1 index) on first dropdown of second column of valid shortcut to shortcut row
Expand Down Expand Up @@ -283,7 +283,7 @@ namespace RemappingUITests
// Case 2: Validate the element when selecting A (0x41) on first dropdown of second column of empty shortcut to shortcut row
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), false, std::make_pair(RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring()) });
// Case 3: Validate the element when selecting A (0x41) on first dropdown of first column of empty shortcut to key row
testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), false, std::make_pair(RemapBufferItem{ Shortcut(), NULL }, std::wstring()) });
testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), false, std::make_pair(RemapBufferItem{ Shortcut(), (DWORD)0 }, std::wstring()) });
// Case 4: Validate the element when selecting A (0x41) on first dropdown of first column of valid shortcut to shortcut row
testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0x41, 0x43 }, std::wstring(), false, std::make_pair(RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring()) });

Expand All @@ -308,7 +308,7 @@ namespace RemappingUITests
// Case 1: Validate the element when selecting A (0x41) on first dropdown of second column of empty shortcut to shortcut row
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring()) });
// Case 2: Validate the element when selecting A (0x41) on first dropdown of second column of empty shortcut to key row
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ Shortcut(), NULL }, std::wstring()) });
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ Shortcut(), (DWORD)0 }, std::wstring()) });

RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) {
// Arrange
Expand Down Expand Up @@ -472,7 +472,7 @@ namespace RemappingUITests
// Case 6: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column of 1 dropdown hybrid shortcut to shortcut row
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_SHIFT }, std::wstring(), true, std::make_pair(RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring()) });
// Case 7: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column of 1 dropdown hybrid shortcut to key row with an action key selected
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_SHIFT }, std::wstring(), true, std::make_pair(RemapBufferItem{ Shortcut(), 0x44 }, std::wstring()) });
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_SHIFT }, std::wstring(), true, std::make_pair(RemapBufferItem{ Shortcut(), (DWORD)0x44 }, std::wstring()) });

RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) {
// Arrange
Expand Down Expand Up @@ -963,21 +963,21 @@ namespace RemappingUITests
{
std::vector<ValidateShortcutBufferElementArgs> testCases;
// Case 1: Validate the element when selecting A (0x41) on first dropdown of empty hybrid second column
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41, -1, -1 }, std::wstring(), true, std::make_pair(RemapBufferItem{ 0x41, NULL }, std::wstring()) });
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41, -1, -1 }, std::wstring(), true, std::make_pair(RemapBufferItem{ (DWORD)0x41, (DWORD)0 }, std::wstring()) });
// Case 2: Validate the element when selecting A (0x41) on second dropdown of empty hybrid second column
testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, 0x41, -1 }, std::wstring(), true, std::make_pair(RemapBufferItem{ 0x41, NULL }, std::wstring()) });
testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, 0x41, -1 }, std::wstring(), true, std::make_pair(RemapBufferItem{ (DWORD)0x41, (DWORD)0 }, std::wstring()) });
// Case 3: Validate the element when selecting A (0x41) on third dropdown of empty hybrid second column
testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ -1, -1, 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ 0x41, NULL }, std::wstring()) });
testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ -1, -1, 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ (DWORD)0x41, (DWORD)0 }, std::wstring()) });
// Case 4: Validate the element when selecting A (0x41) on first dropdown of hybrid second column with key
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ 0x41, 0x43 }, std::wstring()) });
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ (DWORD)0x41, (DWORD)0x43 }, std::wstring()) });
// Case 5: Validate the element when selecting Null (-1) on first dropdown of hybrid second column with shortcut
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ -1, 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ 0x41, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring()) });
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ -1, 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ (DWORD)0x41, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring()) });
// Case 6: Validate the element when selecting None (0) on first dropdown of hybrid second column with shortcut
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ 0x41, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring()) });
testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, 0x41 }, std::wstring(), true, std::make_pair(RemapBufferItem{ (DWORD)0x41, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring()) });
// Case 7: Validate the element when selecting Null (-1) on second dropdown of hybrid second column with shortcut
testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, VK_CONTROL }, std::wstring(), true, std::make_pair(RemapBufferItem{ VK_CONTROL, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring()) });
testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, VK_CONTROL }, std::wstring(), true, std::make_pair(RemapBufferItem{ (DWORD)VK_CONTROL, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring()) });
// Case 8: Validate the element when selecting None (0) on second dropdown of hybrid second column with shortcut
testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ 0, VK_CONTROL }, std::wstring(), true, std::make_pair(RemapBufferItem{ VK_CONTROL, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring()) });
testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ 0, VK_CONTROL }, std::wstring(), true, std::make_pair(RemapBufferItem{ (DWORD)VK_CONTROL, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring()) });

RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) {
// Arrange
Expand Down
Loading

0 comments on commit 3b32116

Please sign in to comment.