terminal/src/cascadia/TerminalControl/KeyChord.h
Leonard Hecker 70d44c84c8
Make ActionMap compatible with ScanCode-only KeyChords (#10945)
This commit partially reverts d465a47 and introduces an alternative approach by adding Hash and Equals methods to the KeyChords class. Those methods will now favor any existing Vkeys over ScanCodes.

## PR Checklist
* [x] Closes #10933
* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed

* Added a new test, which is ✔️
* Various standard commands still work ✔️
* Hash() returns the same value for all KeyChords that are Equals() ✔️
2021-08-20 00:21:33 +00:00

39 lines
1.2 KiB
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "KeyChord.g.h"
namespace winrt::Microsoft::Terminal::Control::implementation
{
struct KeyChord : KeyChordT<KeyChord>
{
KeyChord() noexcept = default;
KeyChord(const winrt::Windows::System::VirtualKeyModifiers modifiers, int32_t vkey, int32_t scanCode) noexcept;
KeyChord(bool ctrl, bool alt, bool shift, bool win, int32_t vkey, int32_t scanCode) noexcept;
uint64_t Hash() const noexcept;
bool Equals(const Control::KeyChord& other) const noexcept;
winrt::Windows::System::VirtualKeyModifiers Modifiers() const noexcept;
void Modifiers(const winrt::Windows::System::VirtualKeyModifiers value) noexcept;
int32_t Vkey() const noexcept;
void Vkey(int32_t value) noexcept;
int32_t ScanCode() const noexcept;
void ScanCode(int32_t value) noexcept;
private:
winrt::Windows::System::VirtualKeyModifiers _modifiers{};
int32_t _vkey{};
int32_t _scanCode{};
};
}
namespace winrt::Microsoft::Terminal::Control::factory_implementation
{
struct KeyChord : KeyChordT<KeyChord, implementation::KeyChord>
{
};
}