Files
khadzhibekovpa 292d61bb47
CI / build-and-test (push) Canceled after 0s
feat: initial release of SplitOverlay (KeyOverlay 1.0.0)
Semi-transparent always-on-top Windows overlay that shows the keymap of a
Vial/QMK split keyboard (Silakka54).

- draws all layers from a Vial .vil layout, transparent keys fall through
- detects the active layer from the keyboard via a Raw HID command (firmware/)
- shows characters of the active Windows input language
- can split the two halves into separate, independently movable windows
- highlights pressed keys; tray menu for opacity, size and options
- Inno Setup installer and portable build; GitHub-style CI workflow
2026-10-20 09:43:17 +03:00

130 lines
3.8 KiB
C#

using KeyOverlay.Core;
using Xunit;
namespace KeyOverlay.Core.Tests;
public class ScanCodesTests
{
[Theory]
[InlineData(0x01, false, "KC_ESCAPE")]
[InlineData(0x1E, false, "KC_A")]
[InlineData(0x02, false, "KC_1")]
[InlineData(0x0B, false, "KC_0")]
[InlineData(0x2A, false, "KC_LSHIFT")]
[InlineData(0x1D, false, "KC_LCTRL")]
[InlineData(0x1D, true, "KC_RCTRL")]
[InlineData(0x38, true, "KC_RALT")]
[InlineData(0x4B, true, "KC_LEFT")]
[InlineData(0x3B, false, "KC_F1")]
[InlineData(0x58, false, "KC_F12")]
[InlineData(0x5B, true, "KC_LGUI")]
public void ToKeycode_MapsKnownScanCodes(int scan, bool ext, string expected) =>
Assert.Equal(expected, ScanCodes.ToKeycode(scan, ext));
[Fact]
public void ToKeycode_ReturnsNullForUnknown() =>
Assert.Null(ScanCodes.ToKeycode(0x7F, false));
}
public class PressedKeysTests
{
[Fact]
public void Apply_TracksDownAndUp()
{
var p = new PressedKeys();
p.Apply(0x1E, false, true);
Assert.True(p.IsDown("KC_A"));
p.Apply(0x1E, false, false);
Assert.False(p.IsDown("KC_A"));
}
[Fact]
public void ShiftDown_TrueForEitherShift()
{
var p = new PressedKeys();
p.Apply(0x36, false, true);
Assert.True(p.ShiftDown);
}
[Fact]
public void CtrlAndLeftAlt_DetectsChord()
{
var p = new PressedKeys();
Assert.False(p.CtrlAndLeftAltDown);
p.Apply(0x1D, false, true);
p.Apply(0x38, false, true);
Assert.True(p.CtrlAndLeftAltDown);
}
}
public class BoardGeometryTests
{
[Fact]
public void RightHalf_IsMirroredSoOuterColumnIsRightmost()
{
var outer = BoardGeometry.Position(new KeyId(Side.Right, 0, 0));
var inner = BoardGeometry.Position(new KeyId(Side.Right, 0, 5));
Assert.True(outer.X > inner.X);
}
[Fact]
public void RightHalf_IsToTheRightOfLeftHalf()
{
var leftInner = BoardGeometry.Position(new KeyId(Side.Left, 0, 5));
var rightInner = BoardGeometry.Position(new KeyId(Side.Right, 0, 5));
Assert.True(rightInner.X > leftInner.X + 1);
}
[Fact]
public void SingleHalf_WidthIsSixColumns() =>
Assert.Equal(6, BoardGeometry.WidthOf(Side.Right));
[Fact]
public void SingleHalf_BothWidthMatchesFullBoard() =>
Assert.Equal(BoardGeometry.Width, BoardGeometry.WidthOf(null));
[Theory]
[InlineData(Side.Left)]
[InlineData(Side.Right)]
public void SingleHalf_KeysStartAtOriginAndFitWidth(Side side)
{
for (var col = 0; col < 6; col++)
{
var p = BoardGeometry.Position(new KeyId(side, 0, col), side);
Assert.InRange(p.X, 0, BoardGeometry.WidthOf(side) - 1);
}
}
[Fact]
public void SingleHalf_RightOuterColumnIsStillRightmost()
{
var outer = BoardGeometry.Position(new KeyId(Side.Right, 0, 0), Side.Right);
var inner = BoardGeometry.Position(new KeyId(Side.Right, 0, 5), Side.Right);
Assert.True(outer.X > inner.X);
}
[Fact]
public void SingleHalf_KeepsSameRowPositionAsFullBoard()
{
var key = new KeyId(Side.Right, 2, 1);
Assert.Equal(BoardGeometry.Position(key).Y, BoardGeometry.Position(key, Side.Right).Y);
}
[Fact]
public void AllKeys_FitInsideBoardBounds()
{
foreach (var side in new[] { Side.Left, Side.Right })
{
for (var row = 0; row < 5; row++)
{
for (var col = 0; col < 6; col++)
{
var p = BoardGeometry.Position(new KeyId(side, row, col));
Assert.InRange(p.X, 0, BoardGeometry.Width - 1);
Assert.InRange(p.Y, 0, BoardGeometry.Height - 1);
}
}
}
}
}