214 lines
5.0 KiB
C#
214 lines
5.0 KiB
C#
namespace Dashboard.Events
|
|
{
|
|
[Flags]
|
|
public enum ModifierKeys
|
|
{
|
|
None = 0,
|
|
LeftBitPos = 8,
|
|
RightBitPos = 16,
|
|
|
|
Shift = (1 << 0),
|
|
Control = (1 << 1),
|
|
Alt = (1 << 2),
|
|
Meta = (1 << 3),
|
|
|
|
NumLock = (1 << 4),
|
|
CapsLock = (1 << 5),
|
|
ScrollLock = (1 << 6),
|
|
|
|
LeftShift = (Shift << LeftBitPos),
|
|
LeftControl = (Control << LeftBitPos),
|
|
LeftAlt = (Alt << LeftBitPos),
|
|
LeftMeta = (Meta << LeftBitPos),
|
|
|
|
RightShift = (Shift << RightBitPos),
|
|
RightControl = (Control << RightBitPos),
|
|
RightAlt = (Alt << RightBitPos),
|
|
RightMeta = (Meta << RightBitPos),
|
|
}
|
|
|
|
public enum KeyCode
|
|
{
|
|
// TODO:
|
|
}
|
|
|
|
public enum ScanCode
|
|
{
|
|
// This scan code table is based on the Win32 scan code table.
|
|
// See https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input
|
|
Error = 0xFF,
|
|
SystemPowerDown = 0xE05E,
|
|
SystemSleep = 0xE05F,
|
|
SystemWakeUp = 0xE063,
|
|
|
|
A = 0x1E,
|
|
B = 0x30,
|
|
C = 0x2E,
|
|
D = 0x20,
|
|
E = 0x12,
|
|
F = 0x21,
|
|
G = 0x22,
|
|
H = 0x23,
|
|
I = 0x17,
|
|
J = 0x24,
|
|
K = 0x25,
|
|
L = 0x26,
|
|
M = 0x32,
|
|
N = 0x31,
|
|
O = 0x18,
|
|
P = 0x19,
|
|
Q = 0x10,
|
|
R = 0x13,
|
|
S = 0x1F,
|
|
T = 0x14,
|
|
U = 0x16,
|
|
V = 0x2F,
|
|
W = 0x11,
|
|
X = 0x2D,
|
|
Y = 0x15,
|
|
Z = 0x2C,
|
|
|
|
D1 = 0x02,
|
|
D2 = 0x03,
|
|
D3 = 0x04,
|
|
D4 = 0x05,
|
|
D5 = 0x06,
|
|
D6 = 0x07,
|
|
D7 = 0x08,
|
|
D8 = 0x09,
|
|
D9 = 0x0A,
|
|
D0 = 0x0B,
|
|
|
|
Return = 0x1C,
|
|
Esc = 0x01,
|
|
Delete = 0x0E,
|
|
Tab = 0x0F,
|
|
Space = 0x39,
|
|
Dash = 0x0C,
|
|
Equals = 0x0D,
|
|
LBracket = 0x1A,
|
|
RBracket = 0x1B,
|
|
Backslash = 0x2B,
|
|
Semicolon = 0x27,
|
|
Apostrophe = 0x28,
|
|
Grave = 0x29,
|
|
Comma = 0x33,
|
|
Period = 0x34,
|
|
ForwardSlash = 0x35,
|
|
CapsLock = 0x3A,
|
|
F1 = 0x3B,
|
|
F2 = 0x3C,
|
|
F3 = 0x3D,
|
|
F4 = 0x3E,
|
|
F5 = 0x3F,
|
|
F6 = 0x40,
|
|
F7 = 0x41,
|
|
F8 = 0x42,
|
|
F9 = 0x43,
|
|
F10 = 0x44,
|
|
F11 = 0x45,
|
|
F12 = 0x46,
|
|
PrintScr = 0xE037,
|
|
ScrollLock = 0x46,
|
|
Pause = 0xE046,
|
|
Insert = 0xE052,
|
|
Home = 0xE047,
|
|
PageUp = 0xE049,
|
|
Backspace = 0xE053,
|
|
End = 0xE04F,
|
|
PageDown = 0xE051,
|
|
RightArrow = 0xE04D,
|
|
LeftArrow = 0xE04B,
|
|
DownArrow = 0xE050,
|
|
UpArrow = 0xE048,
|
|
NumLock = 0xE045,
|
|
NumDiv = 0xE035,
|
|
NumMul = 0x37,
|
|
NumSub = 0x4A,
|
|
NumAdd = 0x4E,
|
|
NumEnter = 0xE01C,
|
|
Num1 = 0x4F,
|
|
Num2 = 0x50,
|
|
Num3 = 0x51,
|
|
Num4 = 0x4B,
|
|
Num5 = 0x4C,
|
|
Num6 = 0x4D,
|
|
Num7 = 0x47,
|
|
Num8 = 0x48,
|
|
Num9 = 0x49,
|
|
Num0 = 0x52,
|
|
NumDecimal = 0x53,
|
|
NumBackslash = 0x56,
|
|
NumEquals = 0x59,
|
|
Application = 0xE05D,
|
|
F13 = 0x64,
|
|
F14 = 0x65,
|
|
F15 = 0x66,
|
|
F16 = 0x67,
|
|
F17 = 0x68,
|
|
F18 = 0x69,
|
|
F19 = 0x6A,
|
|
F20 = 0x6B,
|
|
F21 = 0x6C,
|
|
F22 = 0x6D,
|
|
F23 = 0x6E,
|
|
F24 = 0x76,
|
|
NumComma = 0x7E,
|
|
International1 = 0x73,
|
|
International2 = 0x70,
|
|
International3 = 0x7D,
|
|
International4 = 0x79,
|
|
International5 = 0x7B,
|
|
International6 = 0x5C,
|
|
Lang1 = 0x72,
|
|
Lang2 = 0x71,
|
|
Lang3 = 0x78,
|
|
Lang4 = 0x77,
|
|
LCtrl = 0x1D,
|
|
LShift = 0x2A,
|
|
LWin = 0xE05B,
|
|
LAlt = 0x38,
|
|
RAlt = 0xE038,
|
|
RWin = 0xE05C,
|
|
RCtrl = 0xE01D,
|
|
RShift = 0x36,
|
|
NextTrack = 0xE019,
|
|
PrevTrack = 0xE010,
|
|
Stop = 0xE024,
|
|
PlayPause = 0xE022,
|
|
VolUp = 0xE030,
|
|
VolDown = 0xE029,
|
|
Configuration = 0xE06D,
|
|
Email = 0xE06C,
|
|
Calculator = 0xE021,
|
|
Browser = 0xE06B,
|
|
Search = 0xE065,
|
|
HomePage = 0xE032,
|
|
Back = 0xE06A,
|
|
Forward = 0xE69,
|
|
Halt = 0xE068,
|
|
Refresh = 0xE67,
|
|
Bookmarks = 0xE066,
|
|
}
|
|
|
|
public class KeyboardButtonEventArgs(KeyCode keyCode, ScanCode scanCode, ModifierKeys modifierKeys, bool up)
|
|
: UiEventArgs(up ? UiEventType.KeyUp : UiEventType.KeyDown)
|
|
{
|
|
public KeyCode KeyCode { get; } = keyCode;
|
|
public ScanCode ScanCode { get; } = scanCode;
|
|
public ModifierKeys ModifierKeys { get; } = modifierKeys;
|
|
}
|
|
|
|
public class TextInputEventArgs(string text) : UiEventArgs(UiEventType.TextEdit)
|
|
{
|
|
public string Text { get; } = text;
|
|
}
|
|
|
|
public class TextEditEventArgs(string candidate, int cursor, int length) : UiEventArgs(UiEventType.TextEdit)
|
|
{
|
|
public string Candidate { get; } = candidate;
|
|
public int Cursor { get; } = cursor;
|
|
public int Length { get; } = length;
|
|
}
|
|
}
|