Cleans up key handling in drivers (was "fixes VkeyPacketSimulator is broken") (#3078)

* Fixes #3054. VkeyPacketSimulator scenario is broken.

* Fix some key handle and unit tests.

* Remove unnecessary conditional.

* Improves key handling.

* Also allow map capslock to shift with accented characters.

* Change to MemberData.

* Remove unnecessary using.

* Fix merge errors.

* Fixes #3095. WindowsDriver should return the mask keys to IsShift, IsAlt and IsCtrl return the right value.

* Modifiers keys are valid to be handled on key down and key up.

* Map KeyCode.Enter to ConsoleKey.Enter and vice versa.

* Updated ScanCodeMapping table with readable constants

* Documented bugs

* Implemented mapping using MapVirtualKeyEx

* Implemented mapping using MapVirtualKeyEx

* Changed KeyCode special keys to match ConsoleKey values + max unicode codepoint

* Fixed bogus CollectionNavigator impl and tests

* Nuked DeleteChar. renamed InsertChar to Insert

* KeyCode.Enter = ConsoleKey.Enter, not \n

* Code cleanup

* Added diag for keyboard layout name

* Fixed AltGr support (hopefully)

* Simplified code

* Simplified KeyCode by removing ShiftKeys

* Fixed TextView

* Code cleanup

* Fixes cursesdriver (somewhat)

* Code cleanup

* netdriver wip

* Fixed netdriver under WSL

* Turned off debug spew

* Removed old code

---------

Co-authored-by: Tig Kindel <tig@users.noreply.github.com>
Co-authored-by: Tig Kindel <tig@kindel.com>
This commit is contained in:
BDisp
2024-01-04 19:37:01 +00:00
committed by GitHub
parent bc41d9bc09
commit 0484fc8bf9
32 changed files with 7578 additions and 6189 deletions

View File

@@ -383,22 +383,21 @@ public class CollectionNavigatorTests {
Assert.Equal (-1, current = n.GetNextMatchingItem (current, "x", true));
}
[Theory]
[InlineData (KeyCode.A, true)]
[InlineData (KeyCode.Z, true)]
[InlineData (KeyCode.D0, true)]
[InlineData (KeyCode.A | KeyCode.ShiftMask, true)]
[InlineData (KeyCode.Z | KeyCode.ShiftMask, true)]
[InlineData (KeyCode.Space, true)]
[Fact]
public void IsCompatibleKey_Does_Not_Allow_Alt_And_Ctrl_Keys ()
{
// test all Keys
foreach (KeyCode key in Enum.GetValues (typeof (KeyCode))) {
var ke = new Key (key);
_output.WriteLine ($"Testing {key}");
if (key == KeyCode.AltMask || key == KeyCode.CtrlMask || key == KeyCode.SpecialMask) {
Assert.False (CollectionNavigator.IsCompatibleKey (ke));
} else {
Assert.True (CollectionNavigator.IsCompatibleKey (ke));
}
}
// test Capslock, Numlock and Scrolllock
Assert.True (CollectionNavigator.IsCompatibleKey (new (KeyCode.Null)));
}
[InlineData (KeyCode.Z | KeyCode.CtrlMask, false)]
[InlineData (KeyCode.Z | KeyCode.AltMask, false)]
[InlineData (KeyCode.F1, false)]
[InlineData (KeyCode.Delete, false)]
[InlineData (KeyCode.Delete, false)]
[InlineData (KeyCode.Esc, false)]
[InlineData (KeyCode.ShiftMask, false)]
public void IsCompatibleKey_Does_Not_Allow_Alt_And_Ctrl_Keys (KeyCode keyCode, bool compatible) => Assert.Equal (compatible, CollectionNavigatorBase.IsCompatibleKey (keyCode));
}