mirror of
https://codeberg.org/icewind/shortcutd.git
synced 2026-06-03 17:24:08 +02:00
wip shortcut matching
This commit is contained in:
parent
401eba0773
commit
8feb933041
5 changed files with 1002 additions and 4 deletions
324
Cargo.lock
generated
Normal file
324
Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,324 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "0.1.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "derivative"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1eae4d76b7cefedd1b4f8cc24378b2fbd1ac1b66e3bbebe8e2192d3be81cb355"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "evdev"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d7c8445610ccdd8e2c9637eac210eb73ff9594f9578a5d648cf4c700fd58988"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 0.8.2",
|
||||||
|
"fixedbitset",
|
||||||
|
"libc",
|
||||||
|
"nix",
|
||||||
|
"num",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fixedbitset"
|
||||||
|
version = "0.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fuchsia-cprng"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.68"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "main_error"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3516df0fb44d98fe6d6e859d224adfb7b6686447937e5b96308d6061595eed04"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nix"
|
||||||
|
version = "0.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 0.7.0",
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"void",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num"
|
||||||
|
version = "0.1.42"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e"
|
||||||
|
dependencies = [
|
||||||
|
"num-bigint",
|
||||||
|
"num-complex",
|
||||||
|
"num-integer",
|
||||||
|
"num-iter",
|
||||||
|
"num-rational",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-bigint"
|
||||||
|
version = "0.1.44"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e63899ad0da84ce718c14936262a41cee2c79c981fc0a0e7c7beb47d5a07e8c1"
|
||||||
|
dependencies = [
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
"rand",
|
||||||
|
"rustc-serialize",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-complex"
|
||||||
|
version = "0.1.43"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b288631d7878aaf59442cffd36910ea604ecd7745c36054328595114001c9656"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
"rustc-serialize",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-integer"
|
||||||
|
version = "0.1.42"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-iter"
|
||||||
|
version = "0.1.40"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dfb0800a0291891dd9f4fe7bd9c19384f98f7fbe0cd0f39a2c6b88b9868bbc00"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-rational"
|
||||||
|
version = "0.1.42"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ee314c74bd753fc86b4780aa9475da469155f3848473a261d2d18e35245a784e"
|
||||||
|
dependencies = [
|
||||||
|
"num-bigint",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
"rustc-serialize",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num_enum"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ca565a7df06f3d4b485494f25ba05da1435950f4dc263440eda7a6fa9b8e36e4"
|
||||||
|
dependencies = [
|
||||||
|
"derivative",
|
||||||
|
"num_enum_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num_enum_derive"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-crate",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-crate"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e"
|
||||||
|
dependencies = [
|
||||||
|
"toml",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.4.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
|
||||||
|
dependencies = [
|
||||||
|
"fuchsia-cprng",
|
||||||
|
"libc",
|
||||||
|
"rand_core 0.3.1",
|
||||||
|
"rdrand",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||||
|
dependencies = [
|
||||||
|
"rand_core 0.4.2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rdrand"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
||||||
|
dependencies = [
|
||||||
|
"rand_core 0.3.1",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-serialize"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shortcutd"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"evdev",
|
||||||
|
"main_error",
|
||||||
|
"num_enum",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml"
|
||||||
|
version = "0.5.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "void"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
||||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
evdev = "0.10.1"
|
||||||
|
main_error = "0.1.0"
|
||||||
|
num_enum = "0.4.3"
|
||||||
570
src/keyboard/keycodes.rs
Normal file
570
src/keyboard/keycodes.rs
Normal file
|
|
@ -0,0 +1,570 @@
|
||||||
|
use num_enum::TryFromPrimitive;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, TryFromPrimitive, PartialEq, Eq, Hash)]
|
||||||
|
#[repr(u16)]
|
||||||
|
pub enum Key {
|
||||||
|
KeyReserved = 0,
|
||||||
|
KeyEsc = 1,
|
||||||
|
Key1 = 2,
|
||||||
|
Key2 = 3,
|
||||||
|
Key3 = 4,
|
||||||
|
Key4 = 5,
|
||||||
|
Key5 = 6,
|
||||||
|
Key6 = 7,
|
||||||
|
Key7 = 8,
|
||||||
|
Key8 = 9,
|
||||||
|
Key9 = 10,
|
||||||
|
Key0 = 11,
|
||||||
|
KeyMinus = 12,
|
||||||
|
KeyEqual = 13,
|
||||||
|
KeyBackspace = 14,
|
||||||
|
KeyTab = 15,
|
||||||
|
KeyQ = 16,
|
||||||
|
KeyW = 17,
|
||||||
|
KeyE = 18,
|
||||||
|
KeyR = 19,
|
||||||
|
KeyT = 20,
|
||||||
|
KeyY = 21,
|
||||||
|
KeyU = 22,
|
||||||
|
KeyI = 23,
|
||||||
|
KeyO = 24,
|
||||||
|
KeyP = 25,
|
||||||
|
KeyLeftBrace = 26,
|
||||||
|
KeyRightBrace = 27,
|
||||||
|
KeyEnter = 28,
|
||||||
|
KeyLeftCtrl = 29,
|
||||||
|
KeyA = 30,
|
||||||
|
KeyS = 31,
|
||||||
|
KeyD = 32,
|
||||||
|
KeyF = 33,
|
||||||
|
KeyG = 34,
|
||||||
|
KeyH = 35,
|
||||||
|
KeyJ = 36,
|
||||||
|
KeyK = 37,
|
||||||
|
KeyL = 38,
|
||||||
|
KeySemicolon = 39,
|
||||||
|
KeyApostrophe = 40,
|
||||||
|
KeyGrave = 41,
|
||||||
|
KeyLeftshift = 42,
|
||||||
|
KeyBackslash = 43,
|
||||||
|
KeyZ = 44,
|
||||||
|
KeyX = 45,
|
||||||
|
KeyC = 46,
|
||||||
|
KeyV = 47,
|
||||||
|
KeyB = 48,
|
||||||
|
KeyN = 49,
|
||||||
|
KeyM = 50,
|
||||||
|
KeyComma = 51,
|
||||||
|
KeyDot = 52,
|
||||||
|
KeySlash = 53,
|
||||||
|
KeyRightshift = 54,
|
||||||
|
KeyKpAsterisk = 55,
|
||||||
|
KeyLeftAlt = 56,
|
||||||
|
KeySpace = 57,
|
||||||
|
KeyCapsLock = 58,
|
||||||
|
KeyF1 = 59,
|
||||||
|
KeyF2 = 60,
|
||||||
|
KeyF3 = 61,
|
||||||
|
KeyF4 = 62,
|
||||||
|
KeyF5 = 63,
|
||||||
|
KeyF6 = 64,
|
||||||
|
KeyF7 = 65,
|
||||||
|
KeyF8 = 66,
|
||||||
|
KeyF9 = 67,
|
||||||
|
KeyF10 = 68,
|
||||||
|
KeyNumLock = 69,
|
||||||
|
KeyScrollLock = 70,
|
||||||
|
KeyKp7 = 71,
|
||||||
|
KeyKp8 = 72,
|
||||||
|
KeyKp9 = 73,
|
||||||
|
KeyKpMinus = 74,
|
||||||
|
KeyKp4 = 75,
|
||||||
|
KeyKp5 = 76,
|
||||||
|
KeyKp6 = 77,
|
||||||
|
KeyKpPlus = 78,
|
||||||
|
KeyKp1 = 79,
|
||||||
|
KeyKp2 = 80,
|
||||||
|
KeyKp3 = 81,
|
||||||
|
KeyKp0 = 82,
|
||||||
|
KeyKpDot = 83,
|
||||||
|
KeyZenkakuhankaku =85,
|
||||||
|
Key102nd = 86,
|
||||||
|
KeyF11 = 87,
|
||||||
|
KeyF12 = 88,
|
||||||
|
KeyRo = 89,
|
||||||
|
KeyKatakana = 90,
|
||||||
|
KeyHiragana = 91,
|
||||||
|
KeyHenkan = 92,
|
||||||
|
KeyKatakanahiragana =93,
|
||||||
|
KeyMuhenkan = 94,
|
||||||
|
KeyKpJpComma = 95,
|
||||||
|
KeyKpEnter = 96,
|
||||||
|
KeyRightCtrl = 97,
|
||||||
|
KeyKpSlash = 98,
|
||||||
|
KeySysRQ = 99,
|
||||||
|
KeyRightAlt = 100,
|
||||||
|
KeyLinefeed = 101,
|
||||||
|
KeyHome = 102,
|
||||||
|
KeyUp = 103,
|
||||||
|
KeyPageup = 104,
|
||||||
|
KeyLeft = 105,
|
||||||
|
KeyRight = 106,
|
||||||
|
KeyEnd = 107,
|
||||||
|
KeyDown = 108,
|
||||||
|
KeyPagedown = 109,
|
||||||
|
KeyInsert = 110,
|
||||||
|
KeyDelete = 111,
|
||||||
|
KeyMacro = 112,
|
||||||
|
KeyMute = 113,
|
||||||
|
KeyVolumeDown = 114,
|
||||||
|
KeyVolumeUp = 115,
|
||||||
|
KeyPower = 116 /* SC System Power Down */,
|
||||||
|
KeyKpEqual = 117,
|
||||||
|
KeyKpPlusMinus = 118,
|
||||||
|
KeyPause = 119,
|
||||||
|
KeyScale = 120 /* AL Compiz Scale (Expose) */,
|
||||||
|
KeyKpComma = 121,
|
||||||
|
KeyHangeul = 122,
|
||||||
|
KeyHanja = 123,
|
||||||
|
KeyYen = 124,
|
||||||
|
KeyLeftMeta = 125,
|
||||||
|
KeyRightMeta = 126,
|
||||||
|
KeyCompose = 127,
|
||||||
|
KeyStop = 128 /* AC Stop */,
|
||||||
|
KeyAgain = 129,
|
||||||
|
KeyProps = 130 /* AC Properties */,
|
||||||
|
KeyUndo = 131 /* AC Undo */,
|
||||||
|
KeyFront = 132,
|
||||||
|
KeyCopy = 133 /* AC Copy */,
|
||||||
|
KeyOpen = 134 /* AC Open */,
|
||||||
|
KeyPaste = 135 /* AC Paste */,
|
||||||
|
KeyFind = 136 /* AC Search */,
|
||||||
|
KeyCut = 137 /* AC Cut */,
|
||||||
|
KeyHelp = 138 /* AL Integrated Help Center */,
|
||||||
|
KeyMenu = 139 /* Menu (show menu) */,
|
||||||
|
KeyCalc = 140 /* AL Calculator */,
|
||||||
|
KeySetup = 141,
|
||||||
|
KeySleep = 142 /* SC System Sleep */,
|
||||||
|
KeyWakeup = 143 /* System Wake Up */,
|
||||||
|
KeyFile = 144 /* AL Local Machine Browser */,
|
||||||
|
KeySendfile = 145,
|
||||||
|
KeyDeleteFile = 146,
|
||||||
|
KeyXfer = 147,
|
||||||
|
KeyProg1 = 148,
|
||||||
|
KeyProg2 = 149,
|
||||||
|
KeyWww = 150 /* AL Internet Browser */,
|
||||||
|
KeyMsDos = 151,
|
||||||
|
KeyCoffee = 152 /* AL Terminal Lock/Screensaver */,
|
||||||
|
KeyDirection = 153,
|
||||||
|
KeyCycleWindows =154,
|
||||||
|
KeyMail = 155,
|
||||||
|
KeyBookmarks = 156 /* AC Bookmarks */,
|
||||||
|
KeyComputer = 157,
|
||||||
|
KeyBack = 158 /* AC Back */,
|
||||||
|
KeyForward = 159 /* AC Forward */,
|
||||||
|
KeyCloseCd = 160,
|
||||||
|
KeyEjectCd = 161,
|
||||||
|
KeyEjectCloseCd =162,
|
||||||
|
KeyNextSong = 163,
|
||||||
|
KeyPlayPause = 164,
|
||||||
|
KeyPreviousSong =165,
|
||||||
|
KeyStopCd = 166,
|
||||||
|
KeyRecord = 167,
|
||||||
|
KeyRewind = 168,
|
||||||
|
KeyPhone = 169 /* Media Select Telephone */,
|
||||||
|
KeyIso = 170,
|
||||||
|
KeyConfig = 171 /* AL Consumer Control Configuration */,
|
||||||
|
KeyHomepage = 172 /* AC Home */,
|
||||||
|
KeyRefresh = 173 /* AC Refresh */,
|
||||||
|
KeyExit = 174 /* AC Exit */,
|
||||||
|
KeyMove = 175,
|
||||||
|
KeyEdit = 176,
|
||||||
|
KeyScrollUp = 177,
|
||||||
|
KeyScrollDown = 178,
|
||||||
|
KeyKpLeftParen = 179,
|
||||||
|
KeyKpRightParen =180,
|
||||||
|
KeyNew = 181 /* AC New */,
|
||||||
|
KeyRedo = 182 /* AC Redo/Repeat */,
|
||||||
|
KeyF13 = 183,
|
||||||
|
KeyF14 = 184,
|
||||||
|
KeyF15 = 185,
|
||||||
|
KeyF16 = 186,
|
||||||
|
KeyF17 = 187,
|
||||||
|
KeyF18 = 188,
|
||||||
|
KeyF19 = 189,
|
||||||
|
KeyF20 = 190,
|
||||||
|
KeyF21 = 191,
|
||||||
|
KeyF22 = 192,
|
||||||
|
KeyF23 = 193,
|
||||||
|
KeyF24 = 194,
|
||||||
|
KeyPlayCd = 200,
|
||||||
|
KeyPauseCd = 201,
|
||||||
|
KeyProg3 = 202,
|
||||||
|
KeyProg4 = 203,
|
||||||
|
KeyDashboard = 204 /* AL Dashboard */,
|
||||||
|
KeySuspend = 205,
|
||||||
|
KeyClose = 206 /* AC Close */,
|
||||||
|
KeyPlay = 207,
|
||||||
|
KeyFastForward = 208,
|
||||||
|
KeyBassBoost = 209,
|
||||||
|
KeyPrint = 210 /* AC Print */,
|
||||||
|
KeyHp = 211,
|
||||||
|
KeyCamera = 212,
|
||||||
|
KeySound = 213,
|
||||||
|
KeyQuestion = 214,
|
||||||
|
KeyEmail = 215,
|
||||||
|
KeyChat = 216,
|
||||||
|
KeySearch = 217,
|
||||||
|
KeyConnect = 218,
|
||||||
|
KeyFinance = 219,
|
||||||
|
KeySport = 220,
|
||||||
|
KeyShop = 221,
|
||||||
|
KeyAltErase = 222,
|
||||||
|
KeyCancel = 223,
|
||||||
|
KeyBrightnessDown =224,
|
||||||
|
KeyBrightnessUp =225,
|
||||||
|
KeyMedia = 226,
|
||||||
|
KeySwitchVideoMode = 227,
|
||||||
|
KeyKbDillumToggle = 228,
|
||||||
|
KeyKbDillumDown = 229,
|
||||||
|
KeyKbDillumUp = 230,
|
||||||
|
KeySend = 231,
|
||||||
|
KeyReply = 232,
|
||||||
|
KeyForwardMail = 233,
|
||||||
|
KeySave = 234,
|
||||||
|
KeyDocuments = 235,
|
||||||
|
KeyBattery = 236,
|
||||||
|
KeyBluetooth = 237,
|
||||||
|
KeyWlan = 238,
|
||||||
|
KeyUwb = 239,
|
||||||
|
KeyUnknown = 240,
|
||||||
|
KeyVideoNext = 241,
|
||||||
|
KeyVideoPrev = 242,
|
||||||
|
KeyBrightnessCycle =243,
|
||||||
|
KeyBrightnessAuto =244,
|
||||||
|
KeyDisplayOff = 245,
|
||||||
|
KeyWwan = 246,
|
||||||
|
KeyRfKill = 247,
|
||||||
|
KeyMicMute = 248,
|
||||||
|
Btn0 = 0x100,
|
||||||
|
Btn1 = 0x101,
|
||||||
|
Btn2 = 0x102,
|
||||||
|
Btn3 = 0x103,
|
||||||
|
Btn4 = 0x104,
|
||||||
|
Btn5 = 0x105,
|
||||||
|
Btn6 = 0x106,
|
||||||
|
Btn7 = 0x107,
|
||||||
|
Btn8 = 0x108,
|
||||||
|
Btn9 = 0x109,
|
||||||
|
BtnLeft = 0x110,
|
||||||
|
BtnRight = 0x111,
|
||||||
|
BtnMiddle = 0x112,
|
||||||
|
BtnSide = 0x113,
|
||||||
|
BtnExtra = 0x114,
|
||||||
|
BtnForward = 0x115,
|
||||||
|
BtnBack = 0x116,
|
||||||
|
BtnTask = 0x117,
|
||||||
|
BtnTrigger = 0x120,
|
||||||
|
BtnThumb = 0x121,
|
||||||
|
BtnThumb2 = 0x122,
|
||||||
|
BtnTop = 0x123,
|
||||||
|
BtnTop2 = 0x124,
|
||||||
|
BtnPinkie = 0x125,
|
||||||
|
BtnBase = 0x126,
|
||||||
|
BtnBase2 = 0x127,
|
||||||
|
BtnBase3 = 0x128,
|
||||||
|
BtnBase4 = 0x129,
|
||||||
|
BtnBase5 = 0x12a,
|
||||||
|
BtnBase6 = 0x12b,
|
||||||
|
BtnDead = 0x12f,
|
||||||
|
BtnSouth = 0x130,
|
||||||
|
BtnEast = 0x131,
|
||||||
|
BtnC = 0x132,
|
||||||
|
BtnNorth = 0x133,
|
||||||
|
BtnWest = 0x134,
|
||||||
|
BtnZ = 0x135,
|
||||||
|
BtnTl = 0x136,
|
||||||
|
BtnTr = 0x137,
|
||||||
|
BtnTl2 = 0x138,
|
||||||
|
BtnTr2 = 0x139,
|
||||||
|
BtnSelect = 0x13a,
|
||||||
|
BtnStart = 0x13b,
|
||||||
|
BtnMode = 0x13c,
|
||||||
|
BtnThumbL = 0x13d,
|
||||||
|
BtnThumbR = 0x13e,
|
||||||
|
BtnToolPen = 0x140,
|
||||||
|
BtnToolRubber = 0x141,
|
||||||
|
BtnToolBrush = 0x142,
|
||||||
|
BtnToolPencil = 0x143,
|
||||||
|
BtnToolAirbrush =0x144,
|
||||||
|
BtnToolFinger = 0x145,
|
||||||
|
BtnToolMouse = 0x146,
|
||||||
|
BtnToolLens = 0x147,
|
||||||
|
BtnToolQuintTap =0x148 /* Five fingers on trackpad */,
|
||||||
|
BtnTouch = 0x14a,
|
||||||
|
BtnStylus = 0x14b,
|
||||||
|
BtnStylus2 = 0x14c,
|
||||||
|
BtnToolDoubleTap =0x14d,
|
||||||
|
BtnToolTripleTap =0x14e,
|
||||||
|
BtnToolQuadTap =0x14f /* Four fingers on trackpad */,
|
||||||
|
BtnGearDown = 0x150,
|
||||||
|
BtnGearUp = 0x151,
|
||||||
|
KeyOk = 0x160,
|
||||||
|
KeySelect = 0x161,
|
||||||
|
KeyGoto = 0x162,
|
||||||
|
KeyClear = 0x163,
|
||||||
|
KeyPower2 = 0x164,
|
||||||
|
KeyOption = 0x165,
|
||||||
|
KeyInfo = 0x166 /* AL OEM Features/Tips/Tutorial */,
|
||||||
|
KeyTime = 0x167,
|
||||||
|
KeyVendor = 0x168,
|
||||||
|
KeyArchive = 0x169,
|
||||||
|
KeyProgram = 0x16a /* Media Select Program Guide */,
|
||||||
|
KeyChannel = 0x16b,
|
||||||
|
KeyFavorites = 0x16c,
|
||||||
|
KeyEpg = 0x16d,
|
||||||
|
KeyPvr = 0x16e /* Media Select Home */,
|
||||||
|
KeyMhp = 0x16f,
|
||||||
|
KeyLanguage = 0x170,
|
||||||
|
KeyTitle = 0x171,
|
||||||
|
KeySubtitle = 0x172,
|
||||||
|
KeyAngle = 0x173,
|
||||||
|
KeyZoom = 0x174,
|
||||||
|
KeyMode = 0x175,
|
||||||
|
KeyKeyboard = 0x176,
|
||||||
|
KeyScreen = 0x177,
|
||||||
|
KeyPc = 0x178 /* Media Select Computer */,
|
||||||
|
KeyTv = 0x179 /* Media Select TV */,
|
||||||
|
KeyTv2 = 0x17a /* Media Select Cable */,
|
||||||
|
KeyVcr = 0x17b /* Media Select VCR */,
|
||||||
|
KeyVcr2 = 0x17c /* VCR Plus */,
|
||||||
|
KeySat = 0x17d /* Media Select Satellite */,
|
||||||
|
KeySat2 = 0x17e,
|
||||||
|
KeyCd = 0x17f /* Media Select CD */,
|
||||||
|
KeyTape = 0x180 /* Media Select Tape */,
|
||||||
|
KeyRadio = 0x181,
|
||||||
|
KeyTuner = 0x182 /* Media Select Tuner */,
|
||||||
|
KeyPlayer = 0x183,
|
||||||
|
KeyText = 0x184,
|
||||||
|
KeyDvd = 0x185 /* Media Select DVD */,
|
||||||
|
KeyAux = 0x186,
|
||||||
|
KeyMp3 = 0x187,
|
||||||
|
KeyAudio = 0x188 /* AL Audio Browser */,
|
||||||
|
KeyVideo = 0x189 /* AL Movie Browser */,
|
||||||
|
KeyDirectory = 0x18a,
|
||||||
|
KeyList = 0x18b,
|
||||||
|
KeyMemo = 0x18c /* Media Select Messages */,
|
||||||
|
KeyCalendar = 0x18d,
|
||||||
|
KeyRed = 0x18e,
|
||||||
|
KeyGreen = 0x18f,
|
||||||
|
KeyYellow = 0x190,
|
||||||
|
KeyBlue = 0x191,
|
||||||
|
KeyChannelUp = 0x192 /* Channel Increment */,
|
||||||
|
KeyChannelDown = 0x193 /* Channel Decrement */,
|
||||||
|
KeyFirst = 0x194,
|
||||||
|
KeyLast = 0x195 /* Recall Last */,
|
||||||
|
KeyAb = 0x196,
|
||||||
|
KeyNext = 0x197,
|
||||||
|
KeyRestart = 0x198,
|
||||||
|
KeySlow = 0x199,
|
||||||
|
KeyShuffle = 0x19a,
|
||||||
|
KeyBreak = 0x19b,
|
||||||
|
KeyPrevious = 0x19c,
|
||||||
|
KeyDigits = 0x19d,
|
||||||
|
KeyTeen = 0x19e,
|
||||||
|
KeyTwen = 0x19f,
|
||||||
|
KeyVideophone = 0x1a0 /* Media Select Video Phone */,
|
||||||
|
KeyGames = 0x1a1 /* Media Select Games */,
|
||||||
|
KeyZoomIn = 0x1a2 /* AC Zoom In */,
|
||||||
|
KeyZoomOut = 0x1a3 /* AC Zoom Out */,
|
||||||
|
KeyZoomReset = 0x1a4 /* AC Zoom */,
|
||||||
|
KeyWordProcessor =0x1a5 /* AL Word Processor */,
|
||||||
|
KeyEditor = 0x1a6 /* AL Text Editor */,
|
||||||
|
KeySpreadsheet = 0x1a7 /* AL Spreadsheet */,
|
||||||
|
KeyGraphicsEditor =0x1a8 /* AL Graphics Editor */,
|
||||||
|
KeyPresentation =0x1a9 /* AL Presentation App */,
|
||||||
|
KeyDatabase = 0x1aa /* AL Database App */,
|
||||||
|
KeyNews = 0x1ab /* AL Newsreader */,
|
||||||
|
KeyVoiceMail = 0x1ac /* AL Voicemail */,
|
||||||
|
KeyAddressBook = 0x1ad /* AL Contacts/Address Book */,
|
||||||
|
KeyMessenger = 0x1ae /* AL Instant Messaging */,
|
||||||
|
KeyDisplayToggle =0x1af /* Turn display (LCD) on and off */,
|
||||||
|
KeySpellcheck = 0x1b0 /* AL Spell Check */,
|
||||||
|
KeyLogoff = 0x1b1 /* AL Logoff */,
|
||||||
|
KeyDollar = 0x1b2,
|
||||||
|
KeyEuro = 0x1b3,
|
||||||
|
KeyFrameBack = 0x1b4 /* Consumer - transport controls */,
|
||||||
|
KeyFrameForward =0x1b5,
|
||||||
|
KeyContextMenu =0x1b6 /* GenDesc - system context menu */,
|
||||||
|
KeyMediaRepeat =0x1b7 /* Consumer - transport control */,
|
||||||
|
Key10ChannelsUp =0x1b8 /* 10 channels up (10+) */,
|
||||||
|
Key10ChannelsDown =0x1b9 /* 10 channels down (10-) */,
|
||||||
|
KeyImages = 0x1ba /* AL Image Browser */,
|
||||||
|
KeyDelEol = 0x1c0,
|
||||||
|
KeyDelEos = 0x1c1,
|
||||||
|
KeyInsLine = 0x1c2,
|
||||||
|
KeyDelLine = 0x1c3,
|
||||||
|
KeyFn = 0x1d0,
|
||||||
|
KeyFnEsc = 0x1d1,
|
||||||
|
KeyFnF1 = 0x1d2,
|
||||||
|
KeyFnF2 = 0x1d3,
|
||||||
|
KeyFnF3 = 0x1d4,
|
||||||
|
KeyFnF4 = 0x1d5,
|
||||||
|
KeyFnF5 = 0x1d6,
|
||||||
|
KeyFnF6 = 0x1d7,
|
||||||
|
KeyFnF7 = 0x1d8,
|
||||||
|
KeyFnF8 = 0x1d9,
|
||||||
|
KeyFnF9 = 0x1da,
|
||||||
|
KeyFnF10 = 0x1db,
|
||||||
|
KeyFnF11 = 0x1dc,
|
||||||
|
KeyFnF12 = 0x1dd,
|
||||||
|
KeyFn1 = 0x1de,
|
||||||
|
KeyFn2 = 0x1df,
|
||||||
|
KeyFnD = 0x1e0,
|
||||||
|
KeyFnE = 0x1e1,
|
||||||
|
KeyFnF = 0x1e2,
|
||||||
|
KeyFnS = 0x1e3,
|
||||||
|
KeyFnB = 0x1e4,
|
||||||
|
KeyBrlDot1 = 0x1f1,
|
||||||
|
KeyBrlDot2 = 0x1f2,
|
||||||
|
KeyBrlDot3 = 0x1f3,
|
||||||
|
KeyBrlDot4 = 0x1f4,
|
||||||
|
KeyBrlDot5 = 0x1f5,
|
||||||
|
KeyBrlDot6 = 0x1f6,
|
||||||
|
KeyBrlDot7 = 0x1f7,
|
||||||
|
KeyBrlDot8 = 0x1f8,
|
||||||
|
KeyBrlDot9 = 0x1f9,
|
||||||
|
KeyBrlDot10 = 0x1fa,
|
||||||
|
KeyNumeric0 = 0x200 /* used by phones, remote controls, */,
|
||||||
|
KeyNumeric1 = 0x201 /* and other keypads */,
|
||||||
|
KeyNumeric2 = 0x202,
|
||||||
|
KeyNumeric3 = 0x203,
|
||||||
|
KeyNumeric4 = 0x204,
|
||||||
|
KeyNumeric5 = 0x205,
|
||||||
|
KeyNumeric6 = 0x206,
|
||||||
|
KeyNumeric7 = 0x207,
|
||||||
|
KeyNumeric8 = 0x208,
|
||||||
|
KeyNumeric9 = 0x209,
|
||||||
|
KeyNumericStar =0x20a,
|
||||||
|
KeyNumericPound =0x20b,
|
||||||
|
KeyCameraFocus =0x210,
|
||||||
|
KeyWpsButton = 0x211 /* WiFi Protected Setup key */,
|
||||||
|
KeyTouchpadToggle =0x212 /* Request switch touchpad on or off */,
|
||||||
|
KeyTouchpadOn = 0x213,
|
||||||
|
KeyTouchpadOff =0x214,
|
||||||
|
KeyCameraZoomIn =0x215,
|
||||||
|
KeyCameraZoomOut =0x216,
|
||||||
|
KeyCameraUp = 0x217,
|
||||||
|
KeyCameraDown = 0x218,
|
||||||
|
KeyCameraLeft = 0x219,
|
||||||
|
KeyCameraRight =0x21a,
|
||||||
|
KeyAttendantOn =0x21b,
|
||||||
|
KeyAttendantOff =0x21c,
|
||||||
|
KeyAttendantToggle =0x21d /* Attendant call on or off */,
|
||||||
|
KeyLightsToggle =0x21e /* Reading light on or off */,
|
||||||
|
BtnDpadUp = 0x220,
|
||||||
|
BtnDpadDown = 0x221,
|
||||||
|
BtnDpadLeft = 0x222,
|
||||||
|
BtnDpadRight = 0x223,
|
||||||
|
KeyAlsToggle = 0x230 /* Ambient light sensor */,
|
||||||
|
KeyButtonConfig = 0x240 /* AL Button Configuration */,
|
||||||
|
KeyTaskManager = 0x241 /* AL Task/Project Manager */,
|
||||||
|
KeyJournal = 0x242 /* AL Log/Journal/Timecard */,
|
||||||
|
KeyControlPanel = 0x243 /* AL Control Panel */,
|
||||||
|
KeyAppSelect = 0x244 /* AL Select Task/Application */,
|
||||||
|
KeyScreenSaver = 0x245 /* AL Screen Saver */,
|
||||||
|
KeyVoiceCommand = 0x246 /* Listening Voice Command */,
|
||||||
|
KeyBrightnessMin = 0x250 /* Set Brightness to Minimum */,
|
||||||
|
KeyBrightnessMax = 0x251 /* Set Brightness to Maximum */,
|
||||||
|
KeyKbdinputassistPrev = 0x260,
|
||||||
|
KeyKbdinputassistNext = 0x261,
|
||||||
|
KeyKbdinputassistPrevgroup = 0x262,
|
||||||
|
KeyKbdinputassistNextgroup = 0x263,
|
||||||
|
KeyKbdinputassistAccept = 0x264,
|
||||||
|
KeyKbdinputassistCancel = 0x265,
|
||||||
|
BtnTriggerHappy1 = 0x2c0,
|
||||||
|
BtnTriggerHappy2 = 0x2c1,
|
||||||
|
BtnTriggerHappy3 = 0x2c2,
|
||||||
|
BtnTriggerHappy4 = 0x2c3,
|
||||||
|
BtnTriggerHappy5 = 0x2c4,
|
||||||
|
BtnTriggerHappy6 = 0x2c5,
|
||||||
|
BtnTriggerHappy7 = 0x2c6,
|
||||||
|
BtnTriggerHappy8 = 0x2c7,
|
||||||
|
BtnTriggerHappy9 = 0x2c8,
|
||||||
|
BtnTriggerHappy10 = 0x2c9,
|
||||||
|
BtnTriggerHappy11 = 0x2ca,
|
||||||
|
BtnTriggerHappy12 = 0x2cb,
|
||||||
|
BtnTriggerHappy13 = 0x2cc,
|
||||||
|
BtnTriggerHappy14 = 0x2cd,
|
||||||
|
BtnTriggerHappy15 = 0x2ce,
|
||||||
|
BtnTriggerHappy16 = 0x2cf,
|
||||||
|
BtnTriggerHappy17 = 0x2d0,
|
||||||
|
BtnTriggerHappy18 = 0x2d1,
|
||||||
|
BtnTriggerHappy19 = 0x2d2,
|
||||||
|
BtnTriggerHappy20 = 0x2d3,
|
||||||
|
BtnTriggerHappy21 = 0x2d4,
|
||||||
|
BtnTriggerHappy22 = 0x2d5,
|
||||||
|
BtnTriggerHappy23 = 0x2d6,
|
||||||
|
BtnTriggerHappy24 = 0x2d7,
|
||||||
|
BtnTriggerHappy25 = 0x2d8,
|
||||||
|
BtnTriggerHappy26 = 0x2d9,
|
||||||
|
BtnTriggerHappy27 = 0x2da,
|
||||||
|
BtnTriggerHappy28 = 0x2db,
|
||||||
|
BtnTriggerHappy29 = 0x2dc,
|
||||||
|
BtnTriggerHappy30 = 0x2dd,
|
||||||
|
BtnTriggerHappy31 = 0x2de,
|
||||||
|
BtnTriggerHappy32 = 0x2df,
|
||||||
|
BtnTriggerHappy33 = 0x2e0,
|
||||||
|
BtnTriggerHappy34 = 0x2e1,
|
||||||
|
BtnTriggerHappy35 = 0x2e2,
|
||||||
|
BtnTriggerHappy36 = 0x2e3,
|
||||||
|
BtnTriggerHappy37 = 0x2e4,
|
||||||
|
BtnTriggerHappy38 = 0x2e5,
|
||||||
|
BtnTriggerHappy39 = 0x2e6,
|
||||||
|
BtnTriggerHappy40 = 0x2e7,
|
||||||
|
KeyMax = 0x2ff,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Key {
|
||||||
|
pub fn is_ascii_alpha_numeric(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
Key::Key0 => true,
|
||||||
|
Key::Key1 => true,
|
||||||
|
Key::Key2 => true,
|
||||||
|
Key::Key3 => true,
|
||||||
|
Key::Key4 => true,
|
||||||
|
Key::Key5 => true,
|
||||||
|
Key::Key6 => true,
|
||||||
|
Key::Key7 => true,
|
||||||
|
Key::Key8 => true,
|
||||||
|
Key::Key9 => true,
|
||||||
|
Key::KeyA => true,
|
||||||
|
Key::KeyB => true,
|
||||||
|
Key::KeyC => true,
|
||||||
|
Key::KeyD => true,
|
||||||
|
Key::KeyE => true,
|
||||||
|
Key::KeyF => true,
|
||||||
|
Key::KeyG => true,
|
||||||
|
Key::KeyH => true,
|
||||||
|
Key::KeyI => true,
|
||||||
|
Key::KeyJ => true,
|
||||||
|
Key::KeyK => true,
|
||||||
|
Key::KeyL => true,
|
||||||
|
Key::KeyM => true,
|
||||||
|
Key::KeyN => true,
|
||||||
|
Key::KeyO => true,
|
||||||
|
Key::KeyP => true,
|
||||||
|
Key::KeyQ => true,
|
||||||
|
Key::KeyR => true,
|
||||||
|
Key::KeyS => true,
|
||||||
|
Key::KeyT => true,
|
||||||
|
Key::KeyU => true,
|
||||||
|
Key::KeyV => true,
|
||||||
|
Key::KeyW => true,
|
||||||
|
Key::KeyX => true,
|
||||||
|
Key::KeyY => true,
|
||||||
|
Key::KeyZ => true,
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
59
src/keyboard/mod.rs
Normal file
59
src/keyboard/mod.rs
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
mod keycodes;
|
||||||
|
|
||||||
|
pub use keycodes::Key;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
pub enum Modifier {
|
||||||
|
AnyAlt,
|
||||||
|
LeftAlt,
|
||||||
|
RightAlt,
|
||||||
|
AnyCtrl,
|
||||||
|
LeftCtrl,
|
||||||
|
RightCtrl,
|
||||||
|
AnyShift,
|
||||||
|
LeftShift,
|
||||||
|
RightShift,
|
||||||
|
AnyMeta,
|
||||||
|
LeftMeta,
|
||||||
|
RightMeta,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Modifier {
|
||||||
|
pub fn is_modifier(&self, key: Key) -> bool {
|
||||||
|
match self {
|
||||||
|
Modifier::AnyAlt => key == Key::KeyLeftAlt || key == Key::KeyRightAlt,
|
||||||
|
Modifier::LeftAlt => key == Key::KeyLeftAlt,
|
||||||
|
Modifier::RightAlt => key == Key::KeyRightAlt,
|
||||||
|
Modifier::AnyCtrl => key == Key::KeyLeftCtrl || key == Key::KeyRightCtrl,
|
||||||
|
Modifier::LeftCtrl => key == Key::KeyLeftCtrl,
|
||||||
|
Modifier::RightCtrl => key == Key::KeyRightCtrl,
|
||||||
|
Modifier::AnyMeta => key == Key::KeyLeftMeta || key == Key::KeyRightMeta,
|
||||||
|
Modifier::LeftMeta => key == Key::KeyLeftMeta,
|
||||||
|
Modifier::RightMeta => key == Key::KeyRightMeta,
|
||||||
|
Modifier::AnyShift => key == Key::KeyLeftshift || key == Key::KeyRightshift,
|
||||||
|
Modifier::LeftShift => key == Key::KeyLeftshift,
|
||||||
|
Modifier::RightShift => key == Key::KeyRightshift,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub struct Shortcut {
|
||||||
|
pub modifiers: Vec<Modifier>,
|
||||||
|
pub key: Key,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Shortcut {
|
||||||
|
pub fn is_triggered(&self, active_keys: &HashSet<Key>) -> bool {
|
||||||
|
for modifier in &self.modifiers {
|
||||||
|
if active_keys.iter().any(|key| modifier.is_modifier(*key)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
active_keys.contains(&self.key)
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/main.rs
48
src/main.rs
|
|
@ -1,3 +1,47 @@
|
||||||
fn main() {
|
use evdev::Device;
|
||||||
println!("Hello, world!");
|
use main_error::MainError;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use crate::keyboard::{Key, Shortcut, Modifier};
|
||||||
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
|
mod keyboard;
|
||||||
|
|
||||||
|
fn main() -> Result<(), MainError> {
|
||||||
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
let mut device = if args.len() > 1 {
|
||||||
|
Device::open(&args[1])?
|
||||||
|
} else {
|
||||||
|
eprintln!("Usage {} </dev/input/...>", args[0]);
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut keys = HashSet::new();
|
||||||
|
let shortcut = Shortcut {
|
||||||
|
modifiers: vec![Modifier::AnyCtrl, Modifier::AnyCtrl],
|
||||||
|
key: Key::KeyP
|
||||||
|
};
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let mut got_event = false;
|
||||||
|
|
||||||
|
for ev in device.events()? {
|
||||||
|
got_event = true;
|
||||||
|
|
||||||
|
if let Ok(key) = Key::try_from(ev.code) {
|
||||||
|
match ev.value {
|
||||||
|
1 => keys.insert(key),
|
||||||
|
0 => keys.remove(&key),
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if got_event {
|
||||||
|
if shortcut.is_triggered(&keys) {
|
||||||
|
println!("triggered");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue