mirror of
https://codeberg.org/icewind/evdev-shortcut.git
synced 2026-06-03 10:04:11 +02:00
initial import
This commit is contained in:
commit
0f6f3fdfe5
6 changed files with 1287 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/target
|
||||||
485
Cargo.lock
generated
Normal file
485
Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,485 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "0.7.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "err-derive"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "22deed3a8124cff5fa835713fa105621e43bbdc46690c3a6b68328a012d350d4"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-error",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rustversion",
|
||||||
|
"syn",
|
||||||
|
"synstructure",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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 = "evdev-shortcut"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"err-derive",
|
||||||
|
"evdev",
|
||||||
|
"num_enum",
|
||||||
|
"parse-display",
|
||||||
|
"test-case",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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 = "lazy_static"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.69"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
||||||
|
|
||||||
|
[[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 = "parse-display"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "718b422bc6b056b6374f7ffc3b2d9b55180a4af59a089835df1963994676d8b6"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"parse-display-derive",
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parse-display-derive"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7cf2deb364a60cc0f633c1ffe619b42463993c91352ae367010b8420e442655"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"regex",
|
||||||
|
"regex-syntax",
|
||||||
|
"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-macro-error"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-error-attr",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-error-attr"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"syn-mid",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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 = "regex"
|
||||||
|
version = "1.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
"thread_local",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.6.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-serialize"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b3bba175698996010c4f6dce5e7f173b6eb781fce25d2cfc45e27091ce0b79f6"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399"
|
||||||
|
|
||||||
|
[[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 = "syn-mid"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "synstructure"
|
||||||
|
version = "0.12.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "test-case"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "199464148b42bcf3da8b2a56f6ee87ca68f47402496d1268849291ec9fb463c8"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thread_local"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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 = "version_check"
|
||||||
|
version = "0.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
|
||||||
|
|
||||||
|
[[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"
|
||||||
18
Cargo.toml
Normal file
18
Cargo.toml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[package]
|
||||||
|
name = "evdev-shortcut"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
evdev = { version = "0.10.1", optional = true }
|
||||||
|
num_enum = "0.4.3"
|
||||||
|
parse-display = "0.1.1"
|
||||||
|
err-derive = "0.2.4"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
test-case = "1.0.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
listener = ["evdev"]
|
||||||
|
default = ["listener"]
|
||||||
527
src/keycodes.rs
Normal file
527
src/keycodes.rs
Normal file
|
|
@ -0,0 +1,527 @@
|
||||||
|
use num_enum::TryFromPrimitive;
|
||||||
|
use parse_display::{Display, FromStr};
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, TryFromPrimitive, PartialEq, Eq, Hash, Display, FromStr)]
|
||||||
|
#[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,
|
||||||
|
}
|
||||||
182
src/lib.rs
Normal file
182
src/lib.rs
Normal file
|
|
@ -0,0 +1,182 @@
|
||||||
|
pub use keycodes::Key;
|
||||||
|
use parse_display::{Display, FromStr, ParseError};
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use std::fmt::{self, Display};
|
||||||
|
use std::str::FromStr;
|
||||||
|
use err_derive::Error;
|
||||||
|
|
||||||
|
mod keycodes;
|
||||||
|
|
||||||
|
#[cfg(feature = "foo")]
|
||||||
|
mod listener;
|
||||||
|
#[cfg(feature = "foo")]
|
||||||
|
pub use listener::ShortcutListener;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Error)]
|
||||||
|
#[error(display = "Failed to open device")]
|
||||||
|
pub struct DeviceOpenError;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Display, FromStr)]
|
||||||
|
pub enum Modifier {
|
||||||
|
Alt,
|
||||||
|
LeftAlt,
|
||||||
|
RightAlt,
|
||||||
|
Ctrl,
|
||||||
|
LeftCtrl,
|
||||||
|
RightCtrl,
|
||||||
|
Shift,
|
||||||
|
LeftShift,
|
||||||
|
RightShift,
|
||||||
|
Meta,
|
||||||
|
LeftMeta,
|
||||||
|
RightMeta,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Modifier {
|
||||||
|
pub fn as_mask(&self) -> u8 {
|
||||||
|
match self {
|
||||||
|
Modifier::Alt => 0b00000011,
|
||||||
|
Modifier::LeftAlt => 0b00000001,
|
||||||
|
Modifier::RightAlt => 0b00000010,
|
||||||
|
Modifier::Ctrl => 0b00001100,
|
||||||
|
Modifier::LeftCtrl => 0b00000100,
|
||||||
|
Modifier::RightCtrl => 0b00001000,
|
||||||
|
Modifier::Meta => 0b00110000,
|
||||||
|
Modifier::LeftMeta => 0b00010000,
|
||||||
|
Modifier::RightMeta => 0b00100000,
|
||||||
|
Modifier::Shift => 0b11000000,
|
||||||
|
Modifier::LeftShift => 0b01000000,
|
||||||
|
Modifier::RightShift => 0b10000000,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mask_from_key(key: Key) -> u8 {
|
||||||
|
match key {
|
||||||
|
Key::KeyLeftAlt => 0b00000001,
|
||||||
|
Key::KeyRightAlt => 0b00000010,
|
||||||
|
Key::KeyLeftCtrl => 0b00000100,
|
||||||
|
Key::KeyRightCtrl => 0b00001000,
|
||||||
|
Key::KeyLeftMeta => 0b00010000,
|
||||||
|
Key::KeyRightMeta => 0b00100000,
|
||||||
|
Key::KeyLeftShift => 0b01000000,
|
||||||
|
Key::KeyRightShift => 0b10000000,
|
||||||
|
_ => 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
||||||
|
pub struct ModifierList(Vec<Modifier>);
|
||||||
|
|
||||||
|
impl ModifierList {
|
||||||
|
pub fn as_mask(&self) -> u8 {
|
||||||
|
self.0
|
||||||
|
.iter()
|
||||||
|
.fold(0, |mask, modifier| mask | modifier.as_mask())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for ModifierList {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
for modifier in self.0.iter() {
|
||||||
|
write!(f, "<{}>", modifier)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for ModifierList {
|
||||||
|
type Err = ParseError;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
Ok(ModifierList(
|
||||||
|
s.split('>')
|
||||||
|
.filter(|part| !part.is_empty())
|
||||||
|
.map(|part| {
|
||||||
|
if !part.starts_with('<') {
|
||||||
|
Err(ParseError::with_message("Invalid modifier"))
|
||||||
|
} else {
|
||||||
|
Ok(part[1..].parse::<Modifier>()?)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<Modifier>, ParseError>>()?,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Hash, PartialEq, Eq, Display, FromStr)]
|
||||||
|
#[display("{modifiers}-{key}")]
|
||||||
|
pub struct Shortcut {
|
||||||
|
modifiers: ModifierList,
|
||||||
|
key: Key,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::keyboard::{Key, Modifier, Shortcut};
|
||||||
|
use test_case::test_case;
|
||||||
|
|
||||||
|
#[test_case("<Ctrl>-KeyP", Shortcut::new(vec ! [Modifier::Ctrl], Key::KeyP))]
|
||||||
|
#[test_case("<LeftCtrl><LeftAlt>-KeyLeft", Shortcut::new(vec ! [Modifier::LeftCtrl, Modifier::LeftAlt], Key::KeyLeft))]
|
||||||
|
fn shortcut_parse_display_test(s: &str, shortcut: Shortcut) {
|
||||||
|
assert_eq!(s, format!("{}", shortcut));
|
||||||
|
|
||||||
|
assert_eq!(shortcut, s.parse().unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Shortcut {
|
||||||
|
pub fn new(modifiers: Vec<Modifier>, key: Key) -> Self {
|
||||||
|
Shortcut {
|
||||||
|
modifiers: ModifierList(modifiers),
|
||||||
|
key,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn identifier(&self) -> String {
|
||||||
|
self.to_string()
|
||||||
|
.replace('<', "")
|
||||||
|
.replace('>', "")
|
||||||
|
.replace('-', "_")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Shortcut {
|
||||||
|
pub fn is_triggered(&self, active_keys: &HashSet<Key>) -> bool {
|
||||||
|
let desired_mask = self.modifiers.as_mask();
|
||||||
|
let pressed_mask = active_keys
|
||||||
|
.iter()
|
||||||
|
.fold(0, |mask, key| mask | Modifier::mask_from_key(*key));
|
||||||
|
|
||||||
|
let desired_presses = desired_mask & pressed_mask;
|
||||||
|
let modifiers_match = (desired_presses == pressed_mask)
|
||||||
|
&& (desired_presses.count_ones() == self.modifiers.0.len() as u32);
|
||||||
|
|
||||||
|
modifiers_match && active_keys.contains(&self.key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod triggered_tests {
|
||||||
|
use crate::keyboard::{Key, Shortcut};
|
||||||
|
use test_case::test_case;
|
||||||
|
|
||||||
|
#[test_case("<Ctrl>-KeyP", & [] => false)]
|
||||||
|
#[test_case("<Ctrl>-KeyP", & [Key::KeyLeftCtrl, Key::KeyP] => true)]
|
||||||
|
#[test_case("<Ctrl>-KeyP", & [Key::KeyRightCtrl, Key::KeyP] => true)]
|
||||||
|
#[test_case("<LeftCtrl>-KeyP", & [Key::KeyLeftCtrl, Key::KeyP] => true)]
|
||||||
|
#[test_case("<LeftCtrl>-KeyP", & [Key::KeyRightCtrl, Key::KeyP] => false)]
|
||||||
|
#[test_case("<Ctrl>-KeyP", & [Key::KeyLeftCtrl, Key::KeyLeftAlt, Key::KeyP] => false)]
|
||||||
|
#[test_case("<LeftCtrl><LeftAlt>-KeyLeft", & [] => false)]
|
||||||
|
#[test_case("<LeftCtrl><LeftAlt>-KeyLeft", & [Key::KeyLeft] => false)]
|
||||||
|
#[test_case("<LeftCtrl><LeftAlt>-KeyLeft", & [Key::KeyLeftCtrl, Key::KeyLeft] => false)]
|
||||||
|
#[test_case("<LeftCtrl><LeftAlt>-KeyLeft", & [Key::KeyLeftCtrl, Key::KeyLeftAlt] => false)]
|
||||||
|
#[test_case("<LeftCtrl><LeftAlt>-KeyLeft", & [Key::KeyLeftCtrl, Key::KeyLeftAlt, Key::KeyRight] => false)]
|
||||||
|
#[test_case("<LeftCtrl><LeftAlt>-KeyLeft", & [Key::KeyLeftCtrl, Key::KeyLeftAlt, Key::KeyLeft] => true)]
|
||||||
|
#[test_case("<LeftCtrl><LeftAlt>-KeyLeft", & [Key::KeyLeftCtrl, Key::KeyRightAlt, Key::KeyLeft] => false)]
|
||||||
|
#[test_case("<Ctrl><Alt>-KeyLeft", & [Key::KeyLeftCtrl, Key::KeyRightAlt, Key::KeyLeft] => true)]
|
||||||
|
fn shortcut_triggered(s: &str, keys: &[Key]) -> bool {
|
||||||
|
let shortcut: Shortcut = s.parse().unwrap();
|
||||||
|
shortcut.is_triggered(&keys.into_iter().copied().collect())
|
||||||
|
}
|
||||||
|
}
|
||||||
74
src/listener.rs
Normal file
74
src/listener.rs
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
use evdev::Device;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use std::convert::TryFrom;
|
||||||
|
use std::sync::mpsc::{channel, Receiver};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::time::Duration;
|
||||||
|
use crate::{Shortcut, DeviceOpenError, Key};
|
||||||
|
|
||||||
|
pub struct ShortcutListener {
|
||||||
|
shortcuts: Arc<Mutex<HashSet<Shortcut>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ShortcutListener {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
ShortcutListener {
|
||||||
|
shortcuts: Arc::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn listen(&self, devices: &[&str]) -> Result<Receiver<Shortcut>, DeviceOpenError> {
|
||||||
|
let mut devices = devices
|
||||||
|
.iter()
|
||||||
|
.map(|path| Ok(Device::open(path).map_err(|_| DeviceOpenError)?))
|
||||||
|
.collect::<Result<Vec<Device>, DeviceOpenError>>()?;
|
||||||
|
|
||||||
|
let (tx, rx) = channel();
|
||||||
|
|
||||||
|
let shortcuts = self.shortcuts.clone();
|
||||||
|
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
let mut active_keys = HashSet::new();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let mut got_event = false;
|
||||||
|
|
||||||
|
let events = devices
|
||||||
|
.iter_mut()
|
||||||
|
.flat_map(|device| device.events().unwrap());
|
||||||
|
|
||||||
|
for ev in events {
|
||||||
|
got_event = true;
|
||||||
|
|
||||||
|
if let Ok(key) = Key::try_from(ev.code) {
|
||||||
|
match ev.value {
|
||||||
|
1 => active_keys.insert(key),
|
||||||
|
0 => active_keys.remove(&key),
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if got_event {
|
||||||
|
for shortcut in shortcuts.lock().unwrap().iter() {
|
||||||
|
if shortcut.is_triggered(&active_keys) {
|
||||||
|
tx.send(shortcut.clone()).unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::thread::sleep(Duration::from_millis(10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(rx)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add(&self, shortcut: Shortcut) {
|
||||||
|
self.shortcuts.lock().unwrap().insert(shortcut);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn remove(&self, shortcut: Shortcut) {
|
||||||
|
self.shortcuts.lock().unwrap().remove(&shortcut);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue