Compare commits

...

2 Commits

Author SHA1 Message Date
0366675bb3 Add bitmasks to Modifier enum 2023-03-19 00:48:43 +01:00
c3e8a23344 Expand Keys enum to all supported keycodes. 2023-03-19 00:48:17 +01:00
2 changed files with 227 additions and 21 deletions

View File

@ -3,16 +3,23 @@ use serde::{Deserialize, Serialize};
use crate::keys::Key;
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum Modifier {
LShift,
LCtrl,
LAlt,
LMod,
RShift,
RCtrl,
RAlt,
RMod,
LCtrl = 0x01,
LShift = 0x02,
LAlt = 0x04,
LMod = 0x08,
RCtrl = 0x10,
RShift = 0x20,
RAlt = 0x40,
RMod = 0x80,
}
impl From<Modifier> for u8 {
fn from(modifier: Modifier) -> Self {
modifier as u8
}
}
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]

View File

@ -31,33 +31,232 @@ pub enum Key {
Y = 0x1C,
Z = 0x1D,
/// Keyboard 1 and !
D1 = 0x1E,
/// Keyboard 2 and @
D2 = 0x1F,
/// Keyboard 3 and #
D3 = 0x20,
/// Keyboard 4 and $
D4 = 0x21,
/// Keyboard 5 and %
D5 = 0x22,
/// Keyboard 6 and ∧
D6 = 0x23,
/// Keyboard 7 and &
D7 = 0x24,
/// Keyboard 8 and *
D8 = 0x25,
/// Keyboard 9 and (
D9 = 0x26,
/// Keyboard 0 and )
D0 = 0x27,
Colon = 0x33,
Apostrophe = 0x34,
Comma = 0x36,
Period = 0x37,
Space = 0x2C,
Return = 0x28,
Escape = 0x29,
Delete = 0x2A,
Tab = 0x2B,
LCtrl = 0xE0,
RCtrl = 0xE4,
/// Keyboard Spacebar
Space = 0x2C,
/// Keyboard - and (underscore)
Dash = 0x2D,
/// Keyboard = and +2
Equal = 0x2E,
/// Keyboard [ and {
LBracket = 0x2F,
/// Keyboard ] and }
RBracket = 0x30,
/// Keyboard \and |
BackslashPipe = 0x31,
/// Keyboard Non-US # and ̃
Pound = 0x32,
/// Keyboard ; and :
Colon = 0x33,
/// Keyboard and “
Apostrophe = 0x34,
/// Keyboard Grave Accent and Tilde
Accent = 0x35,
/// Keyboard , and <
Comma = 0x36,
/// Keyboard . and >
Period = 0x37,
/// Keyboard / and ?
Slash = 0x38,
CapsLock = 0x39,
LShift = 0xE1,
RShift = 0xE5,
F1 = 0x3A,
F2 = 0x3B,
F3 = 0x3C,
F4 = 0x3D,
F5 = 0x3E,
F6 = 0x3F,
F7 = 0x40,
F8 = 0x41,
F9 = 0x42,
F10 = 0x43,
F11 = 0x44,
F12 = 0x45,
LAlt = 0xE2,
RAlt = 0xE6,
/// Keyboard PrintScreen
PrintScreen = 0x46,
/// Keyboard Scroll Lock
ScrollLock = 0x47,
/// Keyboard Pause
Pause = 0x48,
/// Keyboard Insert
Insert = 0x49,
/// Keyboard Home
Home = 0x4A,
/// Keyboard PageUp
PageUp = 0x4B,
/// Keyboard Delete Forward
DeleteForward = 0x4C,
/// KeyboardEnd7
End = 0x4D,
/// Keyboard PageDown7
PageDown7 = 0x4E,
/// Keyboard RightArrow7
RightArrow7 = 0x4F,
/// Keyboard LeftArrow7
LeftArrow7 = 0x50,
/// Keyboard DownArrow7
DownArrow7 = 0x51,
/// Keyboard UpArrow7
UpArrow7 = 0x52,
/// Keypad Num Lock and Clear6
KeypadNumLock = 0x53,
/// Keypad /
KeypadSlash = 0x54,
/// Keypad *
KeypadAsterisk = 0x55,
/// Keypad -
KeypadMinus = 0x56,
/// Keypad +
KeypadPlus = 0x57,
/// KeypadEnter
KeypadEnter = 0x58,
/// Keypad 1 and End
Keypad1 = 0x59,
/// Keypad 2 and Down Arrow
Keypad2 = 0x5A,
/// Keypad 3 and PageDn
Keypad3 = 0x5B,
/// Keypad 4 and Left Arrow
Keypad4 = 0x5C,
/// Keypad 5
Keypad5 = 0x5D,
/// Keypad 6 and Right Arrow
Keypad6 = 0x5E,
/// Keypad 7 and Home
Keypad7 = 0x5F,
/// Keypad 8 and Up Arrow
Keypad8 = 0x60,
/// Keypad 9 and PageUp
Keypad9 = 0x61,
/// Keypad 0 and Insert
Keypad0 = 0x62,
/// Keypad . and Delete
KbPeriod = 0x63,
/// Keyboard Non-US \ and |
NonUsBackslashPipe = 0x64,
Application = 0x65,
Power = 0x66,
/// Keypad =
KpEqual = 0x67,
F13 = 0x68,
F14 = 0x69,
F15 = 0x6A,
F16 = 0x6B,
F17 = 0x6C,
F18 = 0x6D,
F19 = 0x6E,
F20 = 0x6F,
F21 = 0x70,
F22 = 0x71,
F23 = 0x72,
F24 = 0x73,
Execute = 0x74,
Help = 0x75,
Menu = 0x76,
Select = 0x77,
Stop = 0x78,
Again = 0x79,
Undo = 0x7A,
Cut = 0x7B,
Copy = 0x7C,
Paste = 0x7D,
Find = 0x7E,
Mute = 0x7F,
VolumeUp = 0x80,
VolumeDown = 0x81,
/// Keyboard Locking Caps Lock
LockingCapsLock = 0x82,
/// Keyboard Locking Num Lock
LockingNumLock = 0x83,
/// Keyboard Locking Scroll Lock
LockingScrollLock = 0x84,
/// Keypad ,
KpComma = 0x85,
/// Keypad Equal Sign
KpEqualSIgn = 0x86,
International1 = 0x87,
International2 = 0x88,
International3 = 0x89,
International4 = 0x8A,
International5 = 0x8B,
International6 = 0x8C,
International7 = 0x8D,
International8 = 0x8E,
International9 = 0x8F,
Lang1 = 0x90,
Lang2 = 0x91,
Lang3 = 0x92,
Lang4 = 0x93,
Lang5 = 0x94,
Lang6 = 0x95,
Lang7 = 0x96,
Lang8 = 0x97,
Lang9 = 0x98,
/// Keyboard Alternative Erase
AltErase = 0x99,
/// Keyboard SysReq/Attention
SysReq = 0x9A,
Cancel = 0x9B,
Clear = 0x9C,
Prior = 0x9D,
/// Keyboard Return
Return2 = 0x9E,
/// Keyboard Separator
Separator = 0x9F,
/// Keyboard Out
Out = 0xA0,
/// Keyboard Oper
Oper = 0xA1,
/// Keyboard Clear/Again
ClearAgain = 0xA2,
/// Keyboard CrSel/Props
CrSel = 0xA3,
/// Keyboard ExSel
ExSel = 0xA4,
//
// NOTE: the usb keyboard/keypad page allegedly har characters in the rage above A4,
// like the ones below, but they don't seem to work
///// Keypad {
//LCurly = 0xB8,
///// Keypad }
//RCurly = 0xB9,
//
// NOTE: Not sure if these are required
//LCtrl = 0xE0,
//LShift = 0xE1,
//LAlt = 0xE2,
//RCtrl = 0xE4,
//RShift = 0xE5,
//RAlt = 0xE6,
}
impl From<Key> for u8 {