mirror of
https://github.com/htrefil/rkvm.git
synced 2025-01-30 20:34:13 +01:00
Restructure code to support multiple platforms
This commit is contained in:
parent
a0a96f65db
commit
38c6f02701
20 changed files with 1619 additions and 1394 deletions
149
Cargo.lock
generated
149
Cargo.lock
generated
|
@ -2,9 +2,9 @@
|
|||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.13"
|
||||
version = "0.7.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
|
||||
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
@ -20,15 +20,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.33"
|
||||
version = "1.0.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c"
|
||||
|
||||
[[package]]
|
||||
name = "arc-swap"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034"
|
||||
checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
|
@ -65,7 +59,7 @@ checksum = "75b13ce559e6433d360c26305643803cb52cfbabbc2b9c47ce04a58493dfb443"
|
|||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"cfg-if",
|
||||
"cfg-if 0.1.10",
|
||||
"clang-sys",
|
||||
"clap",
|
||||
"env_logger 0.7.1",
|
||||
|
@ -101,9 +95,9 @@ checksum = "e0dcbc35f504eb6fc275a6d20e4ebcda18cf50d40ba6fabff8c711fa16cb3b16"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.60"
|
||||
version = "1.0.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c"
|
||||
checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40"
|
||||
|
||||
[[package]]
|
||||
name = "certificate-gen"
|
||||
|
@ -130,10 +124,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9da1484c6a890e374ca5086062d4847e0a2c1e5eba9afa5d48c09e8eb39b2519"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa785e9017cb8e8c8045e3f096b7d1ebc4d7337cceccdca8d678a27f788ac133"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
|
@ -173,9 +173,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.7.0"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
|
||||
checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
|
@ -183,9 +183,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.7.0"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
|
||||
checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
|
@ -230,9 +230,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
|||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95314d38584ffbfda215621d723e0a3906f032e03ae5551e650058dac83d4797"
|
||||
checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
|
@ -245,9 +245,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0448174b01148032eed37ac4aed28963aaaa8cfa93569a08e5b479bbc6c2c151"
|
||||
checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
|
@ -255,15 +255,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18eaa56102984bed2c88ea39026cff3ce3b4c7f508ca970cedf2450ea10d4e46"
|
||||
checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5f8e0c9258abaea85e78ebdda17ef9666d390e987f006be6080dfe354b708cb"
|
||||
checksum = "4caa2b2b68b880003057c1dd49f1ed937e38f22fcf6c212188a121f08cf40a65"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
|
@ -272,15 +272,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e1798854a4727ff944a7b12aa999f58ce7aa81db80d2dfaaf2ba06f065ddd2b"
|
||||
checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e36fccf3fc58563b4a14d265027c627c3b665d7fed489427e88e7cc929559efe"
|
||||
checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556"
|
||||
dependencies = [
|
||||
"proc-macro-hack",
|
||||
"proc-macro2",
|
||||
|
@ -290,24 +290,24 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e3ca3f17d6e8804ae5d3df7a7d35b2b3a6fe89dac84b31872720fc3060a0b11"
|
||||
checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96d502af37186c4fef99453df03e374683f8a1eec9dcc1e66b3b82dc8278ce3c"
|
||||
checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abcb44342f62e6f3e8ac427b8aa815f724fd705dfad060b18ac7866c15bb8e34"
|
||||
checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
|
@ -329,7 +329,7 @@ version = "0.1.15"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 0.1.10",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
@ -351,9 +351,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.15"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
|
||||
checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
@ -400,12 +400,12 @@ name = "input"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
"futures",
|
||||
"inotify",
|
||||
"libc",
|
||||
"serde",
|
||||
"tokio",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -422,17 +422,17 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.77"
|
||||
version = "0.2.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235"
|
||||
checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.6.3"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2443d8f0478b16759158b2f66d525991a05491138bc05814ef52a250148ef4f9"
|
||||
checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -442,14 +442,14 @@ version = "0.4.11"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 0.1.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.3.3"
|
||||
version = "2.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
||||
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
|
@ -476,9 +476,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "native-tls"
|
||||
version = "0.2.4"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d"
|
||||
checksum = "6fcc7939b5edc4e4f86b1b4a04bb1498afaaf871b1a6691838ed06fcb48d3a3f"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"libc",
|
||||
|
@ -533,9 +533,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.4.1"
|
||||
version = "1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad"
|
||||
checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
|
@ -544,7 +544,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"cfg-if 0.1.10",
|
||||
"foreign-types",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
|
@ -598,9 +598,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.1.7"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715"
|
||||
checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b"
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
|
@ -616,9 +616,9 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
|
|||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.9"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
|
@ -729,9 +729,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
|||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.3.9"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
|
||||
checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
|
@ -741,9 +741,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.18"
|
||||
version = "0.6.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
|
||||
checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
|
||||
|
||||
[[package]]
|
||||
name = "remove_dir_all"
|
||||
|
@ -772,9 +772,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "0.4.4"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535"
|
||||
checksum = "c1759c2e3c8580017a484a7ac56d3abc5a6c1feadf88db2f3633f12ae4268c69"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"core-foundation",
|
||||
|
@ -785,9 +785,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "security-framework-sys"
|
||||
version = "0.4.3"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405"
|
||||
checksum = "f99b9d5e26d2a71633cc4f2ebae7cc9f874044e0c351a27e17892d76dce5678b"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
|
@ -837,11 +837,10 @@ checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
|
|||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.2.1"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035"
|
||||
checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
@ -853,11 +852,11 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
|||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.3.15"
|
||||
version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44"
|
||||
checksum = "7fd8b795c389288baa5f355489c65e71fd48a02104600d15c4cfbc561e9e429d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 0.1.10",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"winapi",
|
||||
|
@ -895,9 +894,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.46"
|
||||
version = "1.0.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ad5de3220ea04da322618ded2c42233d02baca219d6f160a3e9c87cda16c942"
|
||||
checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -910,7 +909,7 @@ version = "3.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 0.1.10",
|
||||
"libc",
|
||||
"rand",
|
||||
"redox_syscall",
|
||||
|
|
|
@ -7,12 +7,16 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.117", features = ["derive"] }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
inotify = "0.9.1"
|
||||
tokio = { version = "0.3.3", features = ["fs", "io-util", "net", "sync", "rt", "time"] }
|
||||
libc = "0.2.77"
|
||||
serde = { version = "1.0.117", features = ["derive"] }
|
||||
inotify = "0.9.1"
|
||||
futures = "0.3.7"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = { version = "0.3.9", features = ["winuser"] }
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.55.1"
|
||||
cc = "1.0.60"
|
||||
|
|
|
@ -3,6 +3,12 @@ use std::env;
|
|||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
match env::var("CARGO_CFG_TARGET_OS").unwrap().as_str() {
|
||||
"windows" => return,
|
||||
"linux" => {}
|
||||
_ => panic!("Unsupported target OS"),
|
||||
}
|
||||
|
||||
println!("cargo:rerun-if-changed=glue/glue.h");
|
||||
println!("cargo:rustc-link-lib=evdev");
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ mod key;
|
|||
pub use button::Button;
|
||||
pub use key::Key;
|
||||
|
||||
use crate::glue::{self, input_event, timeval};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
||||
|
@ -14,65 +13,6 @@ pub enum Event {
|
|||
Key { direction: Direction, kind: KeyKind },
|
||||
}
|
||||
|
||||
impl Event {
|
||||
pub(crate) fn to_raw(&self) -> input_event {
|
||||
let (type_, code, value) = match *self {
|
||||
Event::MouseScroll { delta } => (glue::EV_REL as _, glue::REL_WHEEL as _, delta),
|
||||
Event::MouseMove {
|
||||
axis: Axis::X,
|
||||
delta,
|
||||
} => (glue::EV_REL as _, glue::REL_X as _, delta),
|
||||
Event::MouseMove {
|
||||
axis: Axis::Y,
|
||||
delta,
|
||||
} => (glue::EV_REL as _, glue::REL_Y as _, delta),
|
||||
Event::Key {
|
||||
direction: Direction::Up,
|
||||
kind,
|
||||
} => (glue::EV_KEY as _, kind.to_raw(), 0),
|
||||
Event::Key {
|
||||
direction: Direction::Down,
|
||||
kind,
|
||||
} => (glue::EV_KEY as _, kind.to_raw(), 1),
|
||||
};
|
||||
|
||||
input_event {
|
||||
type_,
|
||||
code,
|
||||
value,
|
||||
time: timeval {
|
||||
tv_sec: 0,
|
||||
tv_usec: 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn from_raw(raw: input_event) -> Option<Self> {
|
||||
let event = match (raw.type_ as _, raw.code as _, raw.value) {
|
||||
(glue::EV_REL, glue::REL_WHEEL, value) => Event::MouseScroll { delta: value },
|
||||
(glue::EV_REL, glue::REL_X, value) => Event::MouseMove {
|
||||
axis: Axis::X,
|
||||
delta: value,
|
||||
},
|
||||
(glue::EV_REL, glue::REL_Y, value) => Event::MouseMove {
|
||||
axis: Axis::Y,
|
||||
delta: value,
|
||||
},
|
||||
(glue::EV_KEY, code, 0) => Event::Key {
|
||||
direction: Direction::Up,
|
||||
kind: KeyKind::from_raw(code as _)?,
|
||||
},
|
||||
(glue::EV_KEY, code, 1) => Event::Key {
|
||||
direction: Direction::Down,
|
||||
kind: KeyKind::from_raw(code as _)?,
|
||||
},
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(event)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
||||
pub enum Axis {
|
||||
X,
|
||||
|
@ -92,7 +32,7 @@ pub enum KeyKind {
|
|||
}
|
||||
|
||||
impl KeyKind {
|
||||
pub(crate) fn to_raw(&self) -> u16 {
|
||||
pub(crate) fn to_raw(&self) -> Option<u16> {
|
||||
match self {
|
||||
KeyKind::Key(key) => key.to_raw(),
|
||||
KeyKind::Button(button) => button.to_raw(),
|
||||
|
|
|
@ -124,263 +124,6 @@ pub enum Button {
|
|||
Z,
|
||||
}
|
||||
|
||||
impl Button {
|
||||
pub(crate) fn to_raw(&self) -> u16 {
|
||||
use Button::*;
|
||||
|
||||
match *self {
|
||||
A => 0x0130,
|
||||
B => 0x0131,
|
||||
Back => 0x0116,
|
||||
Base => 0x0126,
|
||||
Base2 => 0x0127,
|
||||
Base3 => 0x0128,
|
||||
Base4 => 0x0129,
|
||||
Base5 => 0x012A,
|
||||
Base6 => 0x012B,
|
||||
C => 0x0132,
|
||||
Dead => 0x012F,
|
||||
Digi => 0x0140,
|
||||
DpadDown => 0x0221,
|
||||
DpadLeft => 0x0222,
|
||||
DpadRight => 0x0223,
|
||||
DpadUp => 0x0220,
|
||||
East => 0x0131,
|
||||
Extra => 0x0114,
|
||||
Forward => 0x0115,
|
||||
Gamepad => 0x0130,
|
||||
GearDown => 0x0150,
|
||||
GearUp => 0x0151,
|
||||
Joystick => 0x0120,
|
||||
Left => 0x0110,
|
||||
Middle => 0x0112,
|
||||
Misc => 0x0100,
|
||||
Mode => 0x013C,
|
||||
Mouse => 0x0110,
|
||||
N0 => 0x0100,
|
||||
N1 => 0x0101,
|
||||
N2 => 0x0102,
|
||||
N3 => 0x0103,
|
||||
N4 => 0x0104,
|
||||
N5 => 0x0105,
|
||||
N6 => 0x0106,
|
||||
N7 => 0x0107,
|
||||
N8 => 0x0108,
|
||||
N9 => 0x0109,
|
||||
North => 0x0133,
|
||||
Pinkie => 0x0125,
|
||||
Right => 0x0111,
|
||||
Select => 0x013A,
|
||||
Side => 0x0113,
|
||||
South => 0x0130,
|
||||
Start => 0x013B,
|
||||
Stylus => 0x014B,
|
||||
Stylus2 => 0x014C,
|
||||
Stylus3 => 0x0149,
|
||||
Task => 0x0117,
|
||||
Thumb => 0x0121,
|
||||
Thumb2 => 0x0122,
|
||||
Thumbl => 0x013D,
|
||||
Thumbr => 0x013E,
|
||||
Tl => 0x0136,
|
||||
Tl2 => 0x0138,
|
||||
ToolAirbrush => 0x0144,
|
||||
ToolBrush => 0x0142,
|
||||
ToolDoubletap => 0x014D,
|
||||
ToolFinger => 0x0145,
|
||||
ToolLens => 0x0147,
|
||||
ToolMouse => 0x0146,
|
||||
ToolPen => 0x0140,
|
||||
ToolPencil => 0x0143,
|
||||
ToolQuadtap => 0x014F,
|
||||
ToolQuinttap => 0x0148,
|
||||
ToolRubber => 0x0141,
|
||||
ToolTripletap => 0x014E,
|
||||
Top => 0x0123,
|
||||
Top2 => 0x0124,
|
||||
Touch => 0x014A,
|
||||
Tr => 0x0137,
|
||||
Tr2 => 0x0139,
|
||||
Trigger => 0x0120,
|
||||
TriggerHappy => 0x02C0,
|
||||
TriggerHappy1 => 0x02C0,
|
||||
TriggerHappy10 => 0x02C9,
|
||||
TriggerHappy11 => 0x02CA,
|
||||
TriggerHappy12 => 0x02CB,
|
||||
TriggerHappy13 => 0x02CC,
|
||||
TriggerHappy14 => 0x02CD,
|
||||
TriggerHappy15 => 0x02CE,
|
||||
TriggerHappy16 => 0x02CF,
|
||||
TriggerHappy17 => 0x02D0,
|
||||
TriggerHappy18 => 0x02D1,
|
||||
TriggerHappy19 => 0x02D2,
|
||||
TriggerHappy2 => 0x02C1,
|
||||
TriggerHappy20 => 0x02D3,
|
||||
TriggerHappy21 => 0x02D4,
|
||||
TriggerHappy22 => 0x02D5,
|
||||
TriggerHappy23 => 0x02D6,
|
||||
TriggerHappy24 => 0x02D7,
|
||||
TriggerHappy25 => 0x02D8,
|
||||
TriggerHappy26 => 0x02D9,
|
||||
TriggerHappy27 => 0x02DA,
|
||||
TriggerHappy28 => 0x02DB,
|
||||
TriggerHappy29 => 0x02DC,
|
||||
TriggerHappy3 => 0x02C2,
|
||||
TriggerHappy30 => 0x02DD,
|
||||
TriggerHappy31 => 0x02DE,
|
||||
TriggerHappy32 => 0x02DF,
|
||||
TriggerHappy33 => 0x02E0,
|
||||
TriggerHappy34 => 0x02E1,
|
||||
TriggerHappy35 => 0x02E2,
|
||||
TriggerHappy36 => 0x02E3,
|
||||
TriggerHappy37 => 0x02E4,
|
||||
TriggerHappy38 => 0x02E5,
|
||||
TriggerHappy39 => 0x02E6,
|
||||
TriggerHappy4 => 0x02C3,
|
||||
TriggerHappy40 => 0x02E7,
|
||||
TriggerHappy5 => 0x02C4,
|
||||
TriggerHappy6 => 0x02C5,
|
||||
TriggerHappy7 => 0x02C6,
|
||||
TriggerHappy8 => 0x02C7,
|
||||
TriggerHappy9 => 0x02C8,
|
||||
West => 0x0134,
|
||||
Wheel => 0x0150,
|
||||
X => 0x0130,
|
||||
Y => 0x0150,
|
||||
Z => 0x0135,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn from_raw(code: u16) -> Option<Self> {
|
||||
use Button::*;
|
||||
|
||||
// This is generated from linux headers, some patterns are unreachable, and we don't care.
|
||||
#[allow(unreachable_patterns, clippy::match_overlapping_arm)]
|
||||
let button = match code {
|
||||
0x0130 => A,
|
||||
0x0131 => B,
|
||||
0x0116 => Back,
|
||||
0x0126 => Base,
|
||||
0x0127 => Base2,
|
||||
0x0128 => Base3,
|
||||
0x0129 => Base4,
|
||||
0x012A => Base5,
|
||||
0x012B => Base6,
|
||||
0x0132 => C,
|
||||
0x012F => Dead,
|
||||
0x0140 => Digi,
|
||||
0x0221 => DpadDown,
|
||||
0x0222 => DpadLeft,
|
||||
0x0223 => DpadRight,
|
||||
0x0220 => DpadUp,
|
||||
0x0131 => East,
|
||||
0x0114 => Extra,
|
||||
0x0115 => Forward,
|
||||
0x0130 => Gamepad,
|
||||
0x0150 => GearDown,
|
||||
0x0151 => GearUp,
|
||||
0x0120 => Joystick,
|
||||
0x0110 => Left,
|
||||
0x0112 => Middle,
|
||||
0x0100 => Misc,
|
||||
0x013C => Mode,
|
||||
0x0110 => Mouse,
|
||||
0x0100 => N0,
|
||||
0x0101 => N1,
|
||||
0x0102 => N2,
|
||||
0x0103 => N3,
|
||||
0x0104 => N4,
|
||||
0x0105 => N5,
|
||||
0x0106 => N6,
|
||||
0x0107 => N7,
|
||||
0x0108 => N8,
|
||||
0x0109 => N9,
|
||||
0x0133 => North,
|
||||
0x0125 => Pinkie,
|
||||
0x0111 => Right,
|
||||
0x013A => Select,
|
||||
0x0113 => Side,
|
||||
0x0130 => South,
|
||||
0x013B => Start,
|
||||
0x014B => Stylus,
|
||||
0x014C => Stylus2,
|
||||
0x0149 => Stylus3,
|
||||
0x0117 => Task,
|
||||
0x0121 => Thumb,
|
||||
0x0122 => Thumb2,
|
||||
0x013D => Thumbl,
|
||||
0x013E => Thumbr,
|
||||
0x0136 => Tl,
|
||||
0x0138 => Tl2,
|
||||
0x0144 => ToolAirbrush,
|
||||
0x0142 => ToolBrush,
|
||||
0x014D => ToolDoubletap,
|
||||
0x0145 => ToolFinger,
|
||||
0x0147 => ToolLens,
|
||||
0x0146 => ToolMouse,
|
||||
0x0140 => ToolPen,
|
||||
0x0143 => ToolPencil,
|
||||
0x014F => ToolQuadtap,
|
||||
0x0148 => ToolQuinttap,
|
||||
0x0141 => ToolRubber,
|
||||
0x014E => ToolTripletap,
|
||||
0x0123 => Top,
|
||||
0x0124 => Top2,
|
||||
0x014A => Touch,
|
||||
0x0137 => Tr,
|
||||
0x0139 => Tr2,
|
||||
0x0120 => Trigger,
|
||||
0x02C0 => TriggerHappy,
|
||||
0x02C0 => TriggerHappy1,
|
||||
0x02C9 => TriggerHappy10,
|
||||
0x02CA => TriggerHappy11,
|
||||
0x02CB => TriggerHappy12,
|
||||
0x02CC => TriggerHappy13,
|
||||
0x02CD => TriggerHappy14,
|
||||
0x02CE => TriggerHappy15,
|
||||
0x02CF => TriggerHappy16,
|
||||
0x02D0 => TriggerHappy17,
|
||||
0x02D1 => TriggerHappy18,
|
||||
0x02D2 => TriggerHappy19,
|
||||
0x02C1 => TriggerHappy2,
|
||||
0x02D3 => TriggerHappy20,
|
||||
0x02D4 => TriggerHappy21,
|
||||
0x02D5 => TriggerHappy22,
|
||||
0x02D6 => TriggerHappy23,
|
||||
0x02D7 => TriggerHappy24,
|
||||
0x02D8 => TriggerHappy25,
|
||||
0x02D9 => TriggerHappy26,
|
||||
0x02DA => TriggerHappy27,
|
||||
0x02DB => TriggerHappy28,
|
||||
0x02DC => TriggerHappy29,
|
||||
0x02C2 => TriggerHappy3,
|
||||
0x02DD => TriggerHappy30,
|
||||
0x02DE => TriggerHappy31,
|
||||
0x02DF => TriggerHappy32,
|
||||
0x02E0 => TriggerHappy33,
|
||||
0x02E1 => TriggerHappy34,
|
||||
0x02E2 => TriggerHappy35,
|
||||
0x02E3 => TriggerHappy36,
|
||||
0x02E4 => TriggerHappy37,
|
||||
0x02E5 => TriggerHappy38,
|
||||
0x02E6 => TriggerHappy39,
|
||||
0x02C3 => TriggerHappy4,
|
||||
0x02E7 => TriggerHappy40,
|
||||
0x02C4 => TriggerHappy5,
|
||||
0x02C5 => TriggerHappy6,
|
||||
0x02C6 => TriggerHappy7,
|
||||
0x02C7 => TriggerHappy8,
|
||||
0x02C8 => TriggerHappy9,
|
||||
0x0134 => West,
|
||||
0x0150 => Wheel,
|
||||
0x0135 => Z,
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(button)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Button {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.to_raw() == other.to_raw()
|
||||
|
|
|
@ -493,996 +493,6 @@ pub enum Key {
|
|||
ZoomReset,
|
||||
}
|
||||
|
||||
impl Key {
|
||||
pub(crate) fn to_raw(&self) -> u16 {
|
||||
use Key::*;
|
||||
|
||||
match *self {
|
||||
A => 0x001E,
|
||||
Ab => 0x0196,
|
||||
AddressBook => 0x01AD,
|
||||
Again => 0x0081,
|
||||
AlsToggle => 0x0230,
|
||||
AltErase => 0x00DE,
|
||||
Angle => 0x0173,
|
||||
Apostrophe => 0x0028,
|
||||
Appselect => 0x0244,
|
||||
Archive => 0x0169,
|
||||
AspectRatio => 0x0177,
|
||||
Assistant => 0x0247,
|
||||
AttendantOff => 0x021C,
|
||||
AttendantOn => 0x021B,
|
||||
AttendantToggle => 0x021D,
|
||||
Audio => 0x0188,
|
||||
AudioDesc => 0x026E,
|
||||
Aux => 0x0186,
|
||||
B => 0x0030,
|
||||
Back => 0x009E,
|
||||
Backslash => 0x002B,
|
||||
Backspace => 0x000E,
|
||||
BassBoost => 0x00D1,
|
||||
Battery => 0x00EC,
|
||||
Blue => 0x0191,
|
||||
Bluetooth => 0x00ED,
|
||||
Bookmarks => 0x009C,
|
||||
Break => 0x019B,
|
||||
BrightnessAuto => 0x00F4,
|
||||
BrightnessCycle => 0x00F3,
|
||||
BrightnessMax => 0x0251,
|
||||
BrightnessMin => 0x0250,
|
||||
BrightnessToggle => 0x01AF,
|
||||
BrightnessZero => 0x00F4,
|
||||
BrightnessDown => 0x00E0,
|
||||
BrightnessUp => 0x00E1,
|
||||
BrlDot1 => 0x01F1,
|
||||
BrlDot10 => 0x01FA,
|
||||
BrlDot2 => 0x01F2,
|
||||
BrlDot3 => 0x01F3,
|
||||
BrlDot4 => 0x01F4,
|
||||
BrlDot5 => 0x01F5,
|
||||
BrlDot6 => 0x01F6,
|
||||
BrlDot7 => 0x01F7,
|
||||
BrlDot8 => 0x01F8,
|
||||
BrlDot9 => 0x01F9,
|
||||
ButtonConfig => 0x0240,
|
||||
C => 0x002E,
|
||||
Calc => 0x008C,
|
||||
Calendar => 0x018D,
|
||||
Camera => 0x00D4,
|
||||
CameraDown => 0x0218,
|
||||
CameraFocus => 0x0210,
|
||||
CameraLeft => 0x0219,
|
||||
CameraRight => 0x021A,
|
||||
CameraUp => 0x0217,
|
||||
CameraZoomIn => 0x0215,
|
||||
CameraZoomOut => 0x0216,
|
||||
Cancel => 0x00DF,
|
||||
CapsLock => 0x003A,
|
||||
Cd => 0x017F,
|
||||
Channel => 0x016B,
|
||||
ChannelDown => 0x0193,
|
||||
ChannelUp => 0x0192,
|
||||
Chat => 0x00D8,
|
||||
Clear => 0x0163,
|
||||
Close => 0x00CE,
|
||||
CloseCd => 0x00A0,
|
||||
Coffee => 0x0098,
|
||||
Comma => 0x0033,
|
||||
Compose => 0x007F,
|
||||
Computer => 0x009D,
|
||||
Config => 0x00AB,
|
||||
Connect => 0x00DA,
|
||||
ContextMenu => 0x01B6,
|
||||
Controlpanel => 0x0243,
|
||||
Copy => 0x0085,
|
||||
Cut => 0x0089,
|
||||
CycleWindows => 0x009A,
|
||||
D => 0x0020,
|
||||
Dashboard => 0x00CC,
|
||||
Data => 0x0277,
|
||||
Database => 0x01AA,
|
||||
DelEol => 0x01C0,
|
||||
DelEos => 0x01C1,
|
||||
DelLine => 0x01C3,
|
||||
Delete => 0x006F,
|
||||
DeleteFile => 0x0092,
|
||||
Digits => 0x019D,
|
||||
Direction => 0x0099,
|
||||
Directory => 0x018A,
|
||||
DisplayOff => 0x00F5,
|
||||
DisplayToggle => 0x01AF,
|
||||
Documents => 0x00EB,
|
||||
Dollar => 0x01B2,
|
||||
Dot => 0x0034,
|
||||
Down => 0x006C,
|
||||
Dvd => 0x0185,
|
||||
E => 0x0012,
|
||||
Edit => 0x00B0,
|
||||
Editor => 0x01A6,
|
||||
EjectCd => 0x00A1,
|
||||
EjectCloseCd => 0x00A2,
|
||||
Email => 0x00D7,
|
||||
End => 0x006B,
|
||||
Enter => 0x001C,
|
||||
Epg => 0x016D,
|
||||
Equal => 0x000D,
|
||||
Esc => 0x0001,
|
||||
Euro => 0x01B3,
|
||||
Exit => 0x00AE,
|
||||
F => 0x0021,
|
||||
F1 => 0x003B,
|
||||
F10 => 0x0044,
|
||||
F11 => 0x0057,
|
||||
F12 => 0x0058,
|
||||
F13 => 0x00B7,
|
||||
F14 => 0x00B8,
|
||||
F15 => 0x00B9,
|
||||
F16 => 0x00BA,
|
||||
F17 => 0x00BB,
|
||||
F18 => 0x00BC,
|
||||
F19 => 0x00BD,
|
||||
F2 => 0x003C,
|
||||
F20 => 0x00BE,
|
||||
F21 => 0x00BF,
|
||||
F22 => 0x00C0,
|
||||
F23 => 0x00C1,
|
||||
F24 => 0x00C2,
|
||||
F3 => 0x003D,
|
||||
F4 => 0x003E,
|
||||
F5 => 0x003F,
|
||||
F6 => 0x0040,
|
||||
F7 => 0x0041,
|
||||
F8 => 0x0042,
|
||||
F9 => 0x0043,
|
||||
FastForward => 0x00D0,
|
||||
FastReverse => 0x0275,
|
||||
Favorites => 0x016C,
|
||||
File => 0x0090,
|
||||
Finance => 0x00DB,
|
||||
Find => 0x0088,
|
||||
First => 0x0194,
|
||||
Fn => 0x01D0,
|
||||
Fn1 => 0x01DE,
|
||||
Fn2 => 0x01DF,
|
||||
FnB => 0x01E4,
|
||||
FnD => 0x01E0,
|
||||
FnE => 0x01E1,
|
||||
FnEsc => 0x01D1,
|
||||
FnF => 0x01E2,
|
||||
FnF1 => 0x01D2,
|
||||
FnF10 => 0x01DB,
|
||||
FnF11 => 0x01DC,
|
||||
FnF12 => 0x01DD,
|
||||
FnF2 => 0x01D3,
|
||||
FnF3 => 0x01D4,
|
||||
FnF4 => 0x01D5,
|
||||
FnF5 => 0x01D6,
|
||||
FnF6 => 0x01D7,
|
||||
FnF7 => 0x01D8,
|
||||
FnF8 => 0x01D9,
|
||||
FnF9 => 0x01DA,
|
||||
FnS => 0x01E3,
|
||||
Forward => 0x009F,
|
||||
ForwardMail => 0x00E9,
|
||||
Frameback => 0x01B4,
|
||||
FrameForward => 0x01B5,
|
||||
Front => 0x0084,
|
||||
FullScreen => 0x0174,
|
||||
G => 0x0022,
|
||||
Games => 0x01A1,
|
||||
Goto => 0x0162,
|
||||
GraphicsEditor => 0x01A8,
|
||||
Grave => 0x0029,
|
||||
Green => 0x018F,
|
||||
H => 0x0023,
|
||||
Hangeul => 0x007A,
|
||||
Hanja => 0x007B,
|
||||
Help => 0x008A,
|
||||
Henkan => 0x005C,
|
||||
Hiragana => 0x005B,
|
||||
Home => 0x0066,
|
||||
Homepage => 0x00AC,
|
||||
Hp => 0x00D3,
|
||||
I => 0x0017,
|
||||
Images => 0x01BA,
|
||||
Info => 0x0166,
|
||||
InsLine => 0x01C2,
|
||||
Insert => 0x006E,
|
||||
Iso => 0x00AA,
|
||||
J => 0x0024,
|
||||
Journal => 0x0242,
|
||||
K => 0x0025,
|
||||
Katakana => 0x005A,
|
||||
KatakanaHiragana => 0x005D,
|
||||
KbdLayoutNext => 0x0248,
|
||||
KbdLcdMenu1 => 0x02B8,
|
||||
KbdLcdMenu2 => 0x02B9,
|
||||
KbdLcdMenu3 => 0x02BA,
|
||||
KbdLcdMenu4 => 0x02BB,
|
||||
KbdLcdMenu5 => 0x02BC,
|
||||
KbdIllumDown => 0x00E5,
|
||||
KbdIllumToggle => 0x00E4,
|
||||
KbdIllumUp => 0x00E6,
|
||||
KbdInputAssistAccept => 0x0264,
|
||||
KbdInputAssistCancel => 0x0265,
|
||||
KbdInputAssistNext => 0x0261,
|
||||
KbdInputAssistNextgroup => 0x0263,
|
||||
KbdInputAssistPrev => 0x0260,
|
||||
KbdInputAssistPrevgroup => 0x0262,
|
||||
Keyboard => 0x0176,
|
||||
Kp0 => 0x0052,
|
||||
Kp1 => 0x004F,
|
||||
Kp2 => 0x0050,
|
||||
Kp3 => 0x0051,
|
||||
Kp4 => 0x004B,
|
||||
Kp5 => 0x004C,
|
||||
Kp6 => 0x004D,
|
||||
Kp7 => 0x0047,
|
||||
Kp8 => 0x0048,
|
||||
Kp9 => 0x0049,
|
||||
KpAsterisk => 0x0037,
|
||||
KpComma => 0x0079,
|
||||
KpDott => 0x0053,
|
||||
KpEnter => 0x0060,
|
||||
KpEqual => 0x0075,
|
||||
KpJpComma => 0x005F,
|
||||
KpLeftParen => 0x00B3,
|
||||
KpMinus => 0x004A,
|
||||
KpPlus => 0x004E,
|
||||
KpPlusMinus => 0x0076,
|
||||
KpRightParen => 0x00B4,
|
||||
KpSlash => 0x0062,
|
||||
L => 0x0026,
|
||||
Language => 0x0170,
|
||||
Last => 0x0195,
|
||||
Left => 0x0069,
|
||||
LeftDown => 0x0269,
|
||||
LeftUp => 0x0268,
|
||||
LeftAlt => 0x0038,
|
||||
LeftBrace => 0x001A,
|
||||
LeftCtrl => 0x001D,
|
||||
LeftMeta => 0x007D,
|
||||
LeftShift => 0x002A,
|
||||
LightsToggle => 0x021E,
|
||||
LineFeed => 0x0065,
|
||||
List => 0x018B,
|
||||
LogOff => 0x01B1,
|
||||
M => 0x0032,
|
||||
Macro => 0x0070,
|
||||
Macro1 => 0x0290,
|
||||
Macro10 => 0x0299,
|
||||
Macro11 => 0x029A,
|
||||
Macro12 => 0x029B,
|
||||
Macro13 => 0x029C,
|
||||
Macro14 => 0x029D,
|
||||
Macro15 => 0x029E,
|
||||
Macro16 => 0x029F,
|
||||
Macro17 => 0x02A0,
|
||||
Macro18 => 0x02A1,
|
||||
Macro19 => 0x02A2,
|
||||
Macro2 => 0x0291,
|
||||
Macro20 => 0x02A3,
|
||||
Macro21 => 0x02A4,
|
||||
Macro22 => 0x02A5,
|
||||
Macro23 => 0x02A6,
|
||||
Macro24 => 0x02A7,
|
||||
Macro25 => 0x02A8,
|
||||
Macro26 => 0x02A9,
|
||||
Macro27 => 0x02AA,
|
||||
Macro28 => 0x02AB,
|
||||
Macro29 => 0x02AC,
|
||||
Macro3 => 0x0292,
|
||||
Macro30 => 0x02AD,
|
||||
Macro4 => 0x0293,
|
||||
Macro5 => 0x0294,
|
||||
Macro6 => 0x0295,
|
||||
Macro7 => 0x0296,
|
||||
Macro8 => 0x0297,
|
||||
Macro9 => 0x0298,
|
||||
MacroPreset1 => 0x02B3,
|
||||
MacroPreset2 => 0x02B4,
|
||||
MacroPreset3 => 0x02B5,
|
||||
MacroPresetCycle => 0x02B2,
|
||||
MacroRecordStart => 0x02B0,
|
||||
MacroRecordStop => 0x02B1,
|
||||
Mail => 0x009B,
|
||||
Media => 0x00E2,
|
||||
MediaRepeat => 0x01B7,
|
||||
MediaTopMenu => 0x026B,
|
||||
Memo => 0x018C,
|
||||
Menu => 0x008B,
|
||||
Messenger => 0x01AE,
|
||||
Mhp => 0x016F,
|
||||
MicMute => 0x00F8,
|
||||
Minus => 0x000C,
|
||||
Mode => 0x0175,
|
||||
Move => 0x00AF,
|
||||
Mp3 => 0x0187,
|
||||
MsDos => 0x0097,
|
||||
Muhenkan => 0x005E,
|
||||
Mute => 0x0071,
|
||||
N => 0x0031,
|
||||
N0 => 0x000B,
|
||||
N1 => 0x0002,
|
||||
N102nd => 0x0056,
|
||||
N10ChannelsDown => 0x01B9,
|
||||
N10ChannelsUp => 0x01B8,
|
||||
N2 => 0x0003,
|
||||
N3 => 0x0004,
|
||||
N3dMode => 0x026F,
|
||||
N4 => 0x0005,
|
||||
N5 => 0x0006,
|
||||
N6 => 0x0007,
|
||||
N7 => 0x0008,
|
||||
N8 => 0x0009,
|
||||
N9 => 0x000A,
|
||||
New => 0x00B5,
|
||||
News => 0x01AB,
|
||||
Next => 0x0197,
|
||||
NextFavorite => 0x0270,
|
||||
Nextsong => 0x00A3,
|
||||
Numeric0 => 0x0200,
|
||||
Numeric1 => 0x0201,
|
||||
Numeric11 => 0x026C,
|
||||
Numeric12 => 0x026D,
|
||||
Numeric2 => 0x0202,
|
||||
Numeric3 => 0x0203,
|
||||
Numeric4 => 0x0204,
|
||||
Numeric5 => 0x0205,
|
||||
Numeric6 => 0x0206,
|
||||
Numeric7 => 0x0207,
|
||||
Numeric8 => 0x0208,
|
||||
Numeric9 => 0x0209,
|
||||
NumericA => 0x020C,
|
||||
NumericB => 0x020D,
|
||||
NumericC => 0x020E,
|
||||
NumericD => 0x020F,
|
||||
NumericPound => 0x020B,
|
||||
NumericStar => 0x020A,
|
||||
NumLock => 0x0045,
|
||||
O => 0x0018,
|
||||
Ok => 0x0160,
|
||||
OnscreenKeyboard => 0x0278,
|
||||
Open => 0x0086,
|
||||
Option => 0x0165,
|
||||
P => 0x0019,
|
||||
Pagedown => 0x006D,
|
||||
Pageup => 0x0068,
|
||||
Paste => 0x0087,
|
||||
Pause => 0x0077,
|
||||
PauseRecord => 0x0272,
|
||||
PauseCd => 0x00C9,
|
||||
Pc => 0x0178,
|
||||
Phone => 0x00A9,
|
||||
Play => 0x00CF,
|
||||
PlayCd => 0x00C8,
|
||||
Player => 0x0183,
|
||||
PlayPause => 0x00A4,
|
||||
Power => 0x0074,
|
||||
Power2 => 0x0164,
|
||||
Presentation => 0x01A9,
|
||||
Previous => 0x019C,
|
||||
PreviousSong => 0x00A5,
|
||||
Print => 0x00D2,
|
||||
PrivacyScreenToggle => 0x0279,
|
||||
Prog1 => 0x0094,
|
||||
Prog2 => 0x0095,
|
||||
Prog3 => 0x00CA,
|
||||
Prog4 => 0x00CB,
|
||||
Program => 0x016A,
|
||||
Props => 0x0082,
|
||||
Pvr => 0x016E,
|
||||
Q => 0x0010,
|
||||
Question => 0x00D6,
|
||||
R => 0x0013,
|
||||
Radio => 0x0181,
|
||||
Record => 0x00A7,
|
||||
Red => 0x018E,
|
||||
Redo => 0x00B6,
|
||||
Refresh => 0x00AD,
|
||||
Reply => 0x00E8,
|
||||
Reserved => 0x0000,
|
||||
Restart => 0x0198,
|
||||
Rewind => 0x00A8,
|
||||
RfKill => 0x00F7,
|
||||
Right => 0x006A,
|
||||
RightDown => 0x0267,
|
||||
RightUp => 0x0266,
|
||||
RightAlt => 0x0064,
|
||||
RightBrace => 0x001B,
|
||||
RightCtrl => 0x0061,
|
||||
RightMeta => 0x007E,
|
||||
RightShift => 0x0036,
|
||||
Ro => 0x0059,
|
||||
RootMenu => 0x026A,
|
||||
RotateDisplay => 0x0099,
|
||||
RotateLockToggle => 0x0231,
|
||||
S => 0x001F,
|
||||
Sat => 0x017D,
|
||||
Sat2 => 0x017E,
|
||||
Save => 0x00EA,
|
||||
Scale => 0x0078,
|
||||
Screen => 0x0177,
|
||||
Screenlock => 0x0098,
|
||||
Screensaver => 0x0245,
|
||||
ScrollDown => 0x00B2,
|
||||
ScrollLock => 0x0046,
|
||||
ScrollUp => 0x00B1,
|
||||
Search => 0x00D9,
|
||||
Select => 0x0161,
|
||||
SelectiveScreenshot => 0x027A,
|
||||
Semicolon => 0x0027,
|
||||
Send => 0x00E7,
|
||||
SendFile => 0x0091,
|
||||
Setup => 0x008D,
|
||||
Shop => 0x00DD,
|
||||
Shuffle => 0x019A,
|
||||
Slash => 0x0035,
|
||||
Sleep => 0x008E,
|
||||
Slow => 0x0199,
|
||||
SlowReverse => 0x0276,
|
||||
Sound => 0x00D5,
|
||||
Space => 0x0039,
|
||||
Spellcheck => 0x01B0,
|
||||
Sport => 0x00DC,
|
||||
Spreadsheet => 0x01A7,
|
||||
Stop => 0x0080,
|
||||
StopRecord => 0x0271,
|
||||
StopCd => 0x00A6,
|
||||
Subtitle => 0x0172,
|
||||
Suspend => 0x00CD,
|
||||
SwitchVideoMode => 0x00E3,
|
||||
SysRq => 0x0063,
|
||||
T => 0x0014,
|
||||
Tab => 0x000F,
|
||||
Tape => 0x0180,
|
||||
TaskManager => 0x0241,
|
||||
Teen => 0x019E,
|
||||
Text => 0x0184,
|
||||
Time => 0x0167,
|
||||
Title => 0x0171,
|
||||
TouchpadOff => 0x0214,
|
||||
TouchpadOn => 0x0213,
|
||||
TouchpadToggle => 0x0212,
|
||||
Tuner => 0x0182,
|
||||
Tv => 0x0179,
|
||||
Tv2 => 0x017A,
|
||||
Twen => 0x019F,
|
||||
U => 0x0016,
|
||||
Undo => 0x0083,
|
||||
Unknown => 0x00F0,
|
||||
Unmute => 0x0274,
|
||||
Up => 0x0067,
|
||||
Uwb => 0x00EF,
|
||||
V => 0x002F,
|
||||
Vcr => 0x017B,
|
||||
Vcr2 => 0x017C,
|
||||
Vendor => 0x0168,
|
||||
Video => 0x0189,
|
||||
VideoNext => 0x00F1,
|
||||
VideoPrev => 0x00F2,
|
||||
VideoPhone => 0x01A0,
|
||||
Vod => 0x0273,
|
||||
VoiceCommand => 0x0246,
|
||||
VoiceMail => 0x01AC,
|
||||
VolumeDown => 0x0072,
|
||||
VolumeUp => 0x0073,
|
||||
W => 0x0011,
|
||||
WakeUp => 0x008F,
|
||||
Wimax => 0x00F6,
|
||||
Wlan => 0x00EE,
|
||||
WordProcessor => 0x01A5,
|
||||
WpsButton => 0x0211,
|
||||
Wwan => 0x00F6,
|
||||
Www => 0x0096,
|
||||
X => 0x002D,
|
||||
Xfer => 0x0093,
|
||||
Y => 0x0015,
|
||||
Yellow => 0x0190,
|
||||
Yen => 0x007C,
|
||||
Z => 0x002C,
|
||||
ZenkakuHankaku => 0x0055,
|
||||
Zoom => 0x0174,
|
||||
ZoomIn => 0x01A2,
|
||||
ZoomOut => 0x01A3,
|
||||
ZoomReset => 0x01A4,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn from_raw(code: u16) -> Option<Self> {
|
||||
use Key::*;
|
||||
|
||||
// This is generated from linux headers, some patterns are unreachable, and we don't care.
|
||||
#[allow(unreachable_patterns)]
|
||||
let key = match code {
|
||||
0x001E => A,
|
||||
0x0196 => Ab,
|
||||
0x01AD => AddressBook,
|
||||
0x0081 => Again,
|
||||
0x0230 => AlsToggle,
|
||||
0x00DE => AltErase,
|
||||
0x0173 => Angle,
|
||||
0x0028 => Apostrophe,
|
||||
0x0244 => Appselect,
|
||||
0x0169 => Archive,
|
||||
0x0177 => AspectRatio,
|
||||
0x0247 => Assistant,
|
||||
0x021C => AttendantOff,
|
||||
0x021B => AttendantOn,
|
||||
0x021D => AttendantToggle,
|
||||
0x0188 => Audio,
|
||||
0x026E => AudioDesc,
|
||||
0x0186 => Aux,
|
||||
0x0030 => B,
|
||||
0x009E => Back,
|
||||
0x002B => Backslash,
|
||||
0x000E => Backspace,
|
||||
0x00D1 => BassBoost,
|
||||
0x00EC => Battery,
|
||||
0x0191 => Blue,
|
||||
0x00ED => Bluetooth,
|
||||
0x009C => Bookmarks,
|
||||
0x019B => Break,
|
||||
0x00F4 => BrightnessAuto,
|
||||
0x00F3 => BrightnessCycle,
|
||||
0x0251 => BrightnessMax,
|
||||
0x0250 => BrightnessMin,
|
||||
0x00E0 => BrightnessDown,
|
||||
0x00E1 => BrightnessUp,
|
||||
0x01F1 => BrlDot1,
|
||||
0x01FA => BrlDot10,
|
||||
0x01F2 => BrlDot2,
|
||||
0x01F3 => BrlDot3,
|
||||
0x01F4 => BrlDot4,
|
||||
0x01F5 => BrlDot5,
|
||||
0x01F6 => BrlDot6,
|
||||
0x01F7 => BrlDot7,
|
||||
0x01F8 => BrlDot8,
|
||||
0x01F9 => BrlDot9,
|
||||
0x0240 => ButtonConfig,
|
||||
0x002E => C,
|
||||
0x008C => Calc,
|
||||
0x018D => Calendar,
|
||||
0x00D4 => Camera,
|
||||
0x0218 => CameraDown,
|
||||
0x0210 => CameraFocus,
|
||||
0x0219 => CameraLeft,
|
||||
0x021A => CameraRight,
|
||||
0x0217 => CameraUp,
|
||||
0x0215 => CameraZoomIn,
|
||||
0x0216 => CameraZoomOut,
|
||||
0x00DF => Cancel,
|
||||
0x003A => CapsLock,
|
||||
0x017F => Cd,
|
||||
0x016B => Channel,
|
||||
0x0193 => ChannelDown,
|
||||
0x0192 => ChannelUp,
|
||||
0x00D8 => Chat,
|
||||
0x0163 => Clear,
|
||||
0x00CE => Close,
|
||||
0x00A0 => CloseCd,
|
||||
0x0098 => Coffee,
|
||||
0x0033 => Comma,
|
||||
0x007F => Compose,
|
||||
0x009D => Computer,
|
||||
0x00AB => Config,
|
||||
0x00DA => Connect,
|
||||
0x01B6 => ContextMenu,
|
||||
0x0243 => Controlpanel,
|
||||
0x0085 => Copy,
|
||||
0x0089 => Cut,
|
||||
0x009A => CycleWindows,
|
||||
0x0020 => D,
|
||||
0x00CC => Dashboard,
|
||||
0x0277 => Data,
|
||||
0x01AA => Database,
|
||||
0x01C0 => DelEol,
|
||||
0x01C1 => DelEos,
|
||||
0x01C3 => DelLine,
|
||||
0x006F => Delete,
|
||||
0x0092 => DeleteFile,
|
||||
0x019D => Digits,
|
||||
0x018A => Directory,
|
||||
0x00F5 => DisplayOff,
|
||||
0x01AF => DisplayToggle,
|
||||
0x00EB => Documents,
|
||||
0x01B2 => Dollar,
|
||||
0x0034 => Dot,
|
||||
0x006C => Down,
|
||||
0x0185 => Dvd,
|
||||
0x0012 => E,
|
||||
0x00B0 => Edit,
|
||||
0x01A6 => Editor,
|
||||
0x00A1 => EjectCd,
|
||||
0x00A2 => EjectCloseCd,
|
||||
0x00D7 => Email,
|
||||
0x006B => End,
|
||||
0x001C => Enter,
|
||||
0x016D => Epg,
|
||||
0x000D => Equal,
|
||||
0x0001 => Esc,
|
||||
0x01B3 => Euro,
|
||||
0x00AE => Exit,
|
||||
0x0021 => F,
|
||||
0x003B => F1,
|
||||
0x0044 => F10,
|
||||
0x0057 => F11,
|
||||
0x0058 => F12,
|
||||
0x00B7 => F13,
|
||||
0x00B8 => F14,
|
||||
0x00B9 => F15,
|
||||
0x00BA => F16,
|
||||
0x00BB => F17,
|
||||
0x00BC => F18,
|
||||
0x00BD => F19,
|
||||
0x003C => F2,
|
||||
0x00BE => F20,
|
||||
0x00BF => F21,
|
||||
0x00C0 => F22,
|
||||
0x00C1 => F23,
|
||||
0x00C2 => F24,
|
||||
0x003D => F3,
|
||||
0x003E => F4,
|
||||
0x003F => F5,
|
||||
0x0040 => F6,
|
||||
0x0041 => F7,
|
||||
0x0042 => F8,
|
||||
0x0043 => F9,
|
||||
0x00D0 => FastForward,
|
||||
0x0275 => FastReverse,
|
||||
0x016C => Favorites,
|
||||
0x0090 => File,
|
||||
0x00DB => Finance,
|
||||
0x0088 => Find,
|
||||
0x0194 => First,
|
||||
0x01D0 => Fn,
|
||||
0x01DE => Fn1,
|
||||
0x01DF => Fn2,
|
||||
0x01E4 => FnB,
|
||||
0x01E0 => FnD,
|
||||
0x01E1 => FnE,
|
||||
0x01D1 => FnEsc,
|
||||
0x01E2 => FnF,
|
||||
0x01D2 => FnF1,
|
||||
0x01DB => FnF10,
|
||||
0x01DC => FnF11,
|
||||
0x01DD => FnF12,
|
||||
0x01D3 => FnF2,
|
||||
0x01D4 => FnF3,
|
||||
0x01D5 => FnF4,
|
||||
0x01D6 => FnF5,
|
||||
0x01D7 => FnF6,
|
||||
0x01D8 => FnF7,
|
||||
0x01D9 => FnF8,
|
||||
0x01DA => FnF9,
|
||||
0x01E3 => FnS,
|
||||
0x009F => Forward,
|
||||
0x00E9 => ForwardMail,
|
||||
0x01B4 => Frameback,
|
||||
0x01B5 => FrameForward,
|
||||
0x0084 => Front,
|
||||
0x0174 => FullScreen,
|
||||
0x0022 => G,
|
||||
0x01A1 => Games,
|
||||
0x0162 => Goto,
|
||||
0x01A8 => GraphicsEditor,
|
||||
0x0029 => Grave,
|
||||
0x018F => Green,
|
||||
0x0023 => H,
|
||||
0x007A => Hangeul,
|
||||
0x007B => Hanja,
|
||||
0x008A => Help,
|
||||
0x005C => Henkan,
|
||||
0x005B => Hiragana,
|
||||
0x0066 => Home,
|
||||
0x00AC => Homepage,
|
||||
0x00D3 => Hp,
|
||||
0x0017 => I,
|
||||
0x01BA => Images,
|
||||
0x0166 => Info,
|
||||
0x01C2 => InsLine,
|
||||
0x006E => Insert,
|
||||
0x00AA => Iso,
|
||||
0x0024 => J,
|
||||
0x0242 => Journal,
|
||||
0x0025 => K,
|
||||
0x005A => Katakana,
|
||||
0x005D => KatakanaHiragana,
|
||||
0x0248 => KbdLayoutNext,
|
||||
0x02B8 => KbdLcdMenu1,
|
||||
0x02B9 => KbdLcdMenu2,
|
||||
0x02BA => KbdLcdMenu3,
|
||||
0x02BB => KbdLcdMenu4,
|
||||
0x02BC => KbdLcdMenu5,
|
||||
0x00E5 => KbdIllumDown,
|
||||
0x00E4 => KbdIllumToggle,
|
||||
0x00E6 => KbdIllumUp,
|
||||
0x0264 => KbdInputAssistAccept,
|
||||
0x0265 => KbdInputAssistCancel,
|
||||
0x0261 => KbdInputAssistNext,
|
||||
0x0263 => KbdInputAssistNextgroup,
|
||||
0x0260 => KbdInputAssistPrev,
|
||||
0x0262 => KbdInputAssistPrevgroup,
|
||||
0x0176 => Keyboard,
|
||||
0x0052 => Kp0,
|
||||
0x004F => Kp1,
|
||||
0x0050 => Kp2,
|
||||
0x0051 => Kp3,
|
||||
0x004B => Kp4,
|
||||
0x004C => Kp5,
|
||||
0x004D => Kp6,
|
||||
0x0047 => Kp7,
|
||||
0x0048 => Kp8,
|
||||
0x0049 => Kp9,
|
||||
0x0037 => KpAsterisk,
|
||||
0x0079 => KpComma,
|
||||
0x0053 => KpDott,
|
||||
0x0060 => KpEnter,
|
||||
0x0075 => KpEqual,
|
||||
0x005F => KpJpComma,
|
||||
0x00B3 => KpLeftParen,
|
||||
0x004A => KpMinus,
|
||||
0x004E => KpPlus,
|
||||
0x0076 => KpPlusMinus,
|
||||
0x00B4 => KpRightParen,
|
||||
0x0062 => KpSlash,
|
||||
0x0026 => L,
|
||||
0x0170 => Language,
|
||||
0x0195 => Last,
|
||||
0x0069 => Left,
|
||||
0x0269 => LeftDown,
|
||||
0x0268 => LeftUp,
|
||||
0x0038 => LeftAlt,
|
||||
0x001A => LeftBrace,
|
||||
0x001D => LeftCtrl,
|
||||
0x007D => LeftMeta,
|
||||
0x002A => LeftShift,
|
||||
0x021E => LightsToggle,
|
||||
0x0065 => LineFeed,
|
||||
0x018B => List,
|
||||
0x01B1 => LogOff,
|
||||
0x0032 => M,
|
||||
0x0070 => Macro,
|
||||
0x0290 => Macro1,
|
||||
0x0299 => Macro10,
|
||||
0x029A => Macro11,
|
||||
0x029B => Macro12,
|
||||
0x029C => Macro13,
|
||||
0x029D => Macro14,
|
||||
0x029E => Macro15,
|
||||
0x029F => Macro16,
|
||||
0x02A0 => Macro17,
|
||||
0x02A1 => Macro18,
|
||||
0x02A2 => Macro19,
|
||||
0x0291 => Macro2,
|
||||
0x02A3 => Macro20,
|
||||
0x02A4 => Macro21,
|
||||
0x02A5 => Macro22,
|
||||
0x02A6 => Macro23,
|
||||
0x02A7 => Macro24,
|
||||
0x02A8 => Macro25,
|
||||
0x02A9 => Macro26,
|
||||
0x02AA => Macro27,
|
||||
0x02AB => Macro28,
|
||||
0x02AC => Macro29,
|
||||
0x0292 => Macro3,
|
||||
0x02AD => Macro30,
|
||||
0x0293 => Macro4,
|
||||
0x0294 => Macro5,
|
||||
0x0295 => Macro6,
|
||||
0x0296 => Macro7,
|
||||
0x0297 => Macro8,
|
||||
0x0298 => Macro9,
|
||||
0x02B3 => MacroPreset1,
|
||||
0x02B4 => MacroPreset2,
|
||||
0x02B5 => MacroPreset3,
|
||||
0x02B2 => MacroPresetCycle,
|
||||
0x02B0 => MacroRecordStart,
|
||||
0x02B1 => MacroRecordStop,
|
||||
0x009B => Mail,
|
||||
0x00E2 => Media,
|
||||
0x01B7 => MediaRepeat,
|
||||
0x026B => MediaTopMenu,
|
||||
0x018C => Memo,
|
||||
0x008B => Menu,
|
||||
0x01AE => Messenger,
|
||||
0x016F => Mhp,
|
||||
0x00F8 => MicMute,
|
||||
0x000C => Minus,
|
||||
0x0175 => Mode,
|
||||
0x00AF => Move,
|
||||
0x0187 => Mp3,
|
||||
0x0097 => MsDos,
|
||||
0x005E => Muhenkan,
|
||||
0x0071 => Mute,
|
||||
0x0031 => N,
|
||||
0x000B => N0,
|
||||
0x0002 => N1,
|
||||
0x0056 => N102nd,
|
||||
0x01B9 => N10ChannelsDown,
|
||||
0x01B8 => N10ChannelsUp,
|
||||
0x0003 => N2,
|
||||
0x0004 => N3,
|
||||
0x026F => N3dMode,
|
||||
0x0005 => N4,
|
||||
0x0006 => N5,
|
||||
0x0007 => N6,
|
||||
0x0008 => N7,
|
||||
0x0009 => N8,
|
||||
0x000A => N9,
|
||||
0x00B5 => New,
|
||||
0x01AB => News,
|
||||
0x0197 => Next,
|
||||
0x0270 => NextFavorite,
|
||||
0x00A3 => Nextsong,
|
||||
0x0200 => Numeric0,
|
||||
0x0201 => Numeric1,
|
||||
0x026C => Numeric11,
|
||||
0x026D => Numeric12,
|
||||
0x0202 => Numeric2,
|
||||
0x0203 => Numeric3,
|
||||
0x0204 => Numeric4,
|
||||
0x0205 => Numeric5,
|
||||
0x0206 => Numeric6,
|
||||
0x0207 => Numeric7,
|
||||
0x0208 => Numeric8,
|
||||
0x0209 => Numeric9,
|
||||
0x020C => NumericA,
|
||||
0x020D => NumericB,
|
||||
0x020E => NumericC,
|
||||
0x020F => NumericD,
|
||||
0x020B => NumericPound,
|
||||
0x020A => NumericStar,
|
||||
0x0045 => NumLock,
|
||||
0x0018 => O,
|
||||
0x0160 => Ok,
|
||||
0x0278 => OnscreenKeyboard,
|
||||
0x0086 => Open,
|
||||
0x0165 => Option,
|
||||
0x0019 => P,
|
||||
0x006D => Pagedown,
|
||||
0x0068 => Pageup,
|
||||
0x0087 => Paste,
|
||||
0x0077 => Pause,
|
||||
0x0272 => PauseRecord,
|
||||
0x00C9 => PauseCd,
|
||||
0x0178 => Pc,
|
||||
0x00A9 => Phone,
|
||||
0x00CF => Play,
|
||||
0x00C8 => PlayCd,
|
||||
0x0183 => Player,
|
||||
0x00A4 => PlayPause,
|
||||
0x0074 => Power,
|
||||
0x0164 => Power2,
|
||||
0x01A9 => Presentation,
|
||||
0x019C => Previous,
|
||||
0x00A5 => PreviousSong,
|
||||
0x00D2 => Print,
|
||||
0x0279 => PrivacyScreenToggle,
|
||||
0x0094 => Prog1,
|
||||
0x0095 => Prog2,
|
||||
0x00CA => Prog3,
|
||||
0x00CB => Prog4,
|
||||
0x016A => Program,
|
||||
0x0082 => Props,
|
||||
0x016E => Pvr,
|
||||
0x0010 => Q,
|
||||
0x00D6 => Question,
|
||||
0x0013 => R,
|
||||
0x0181 => Radio,
|
||||
0x00A7 => Record,
|
||||
0x018E => Red,
|
||||
0x00B6 => Redo,
|
||||
0x00AD => Refresh,
|
||||
0x00E8 => Reply,
|
||||
0x0000 => Reserved,
|
||||
0x0198 => Restart,
|
||||
0x00A8 => Rewind,
|
||||
0x00F7 => RfKill,
|
||||
0x006A => Right,
|
||||
0x0267 => RightDown,
|
||||
0x0266 => RightUp,
|
||||
0x0064 => RightAlt,
|
||||
0x001B => RightBrace,
|
||||
0x0061 => RightCtrl,
|
||||
0x007E => RightMeta,
|
||||
0x0036 => RightShift,
|
||||
0x0059 => Ro,
|
||||
0x026A => RootMenu,
|
||||
0x0099 => RotateDisplay,
|
||||
0x0231 => RotateLockToggle,
|
||||
0x001F => S,
|
||||
0x017D => Sat,
|
||||
0x017E => Sat2,
|
||||
0x00EA => Save,
|
||||
0x0078 => Scale,
|
||||
0x0245 => Screensaver,
|
||||
0x00B2 => ScrollDown,
|
||||
0x0046 => ScrollLock,
|
||||
0x00B1 => ScrollUp,
|
||||
0x00D9 => Search,
|
||||
0x0161 => Select,
|
||||
0x027A => SelectiveScreenshot,
|
||||
0x0027 => Semicolon,
|
||||
0x00E7 => Send,
|
||||
0x0091 => SendFile,
|
||||
0x008D => Setup,
|
||||
0x00DD => Shop,
|
||||
0x019A => Shuffle,
|
||||
0x0035 => Slash,
|
||||
0x008E => Sleep,
|
||||
0x0199 => Slow,
|
||||
0x0276 => SlowReverse,
|
||||
0x00D5 => Sound,
|
||||
0x0039 => Space,
|
||||
0x01B0 => Spellcheck,
|
||||
0x00DC => Sport,
|
||||
0x01A7 => Spreadsheet,
|
||||
0x0080 => Stop,
|
||||
0x0271 => StopRecord,
|
||||
0x00A6 => StopCd,
|
||||
0x0172 => Subtitle,
|
||||
0x00CD => Suspend,
|
||||
0x00E3 => SwitchVideoMode,
|
||||
0x0063 => SysRq,
|
||||
0x0014 => T,
|
||||
0x000F => Tab,
|
||||
0x0180 => Tape,
|
||||
0x0241 => TaskManager,
|
||||
0x019E => Teen,
|
||||
0x0184 => Text,
|
||||
0x0167 => Time,
|
||||
0x0171 => Title,
|
||||
0x0214 => TouchpadOff,
|
||||
0x0213 => TouchpadOn,
|
||||
0x0212 => TouchpadToggle,
|
||||
0x0182 => Tuner,
|
||||
0x0179 => Tv,
|
||||
0x017A => Tv2,
|
||||
0x019F => Twen,
|
||||
0x0016 => U,
|
||||
0x0083 => Undo,
|
||||
0x00F0 => Unknown,
|
||||
0x0274 => Unmute,
|
||||
0x0067 => Up,
|
||||
0x00EF => Uwb,
|
||||
0x002F => V,
|
||||
0x017B => Vcr,
|
||||
0x017C => Vcr2,
|
||||
0x0168 => Vendor,
|
||||
0x0189 => Video,
|
||||
0x00F1 => VideoNext,
|
||||
0x00F2 => VideoPrev,
|
||||
0x01A0 => VideoPhone,
|
||||
0x0273 => Vod,
|
||||
0x0246 => VoiceCommand,
|
||||
0x01AC => VoiceMail,
|
||||
0x0072 => VolumeDown,
|
||||
0x0073 => VolumeUp,
|
||||
0x0011 => W,
|
||||
0x008F => WakeUp,
|
||||
0x00EE => Wlan,
|
||||
0x01A5 => WordProcessor,
|
||||
0x0211 => WpsButton,
|
||||
0x00F6 => Wwan,
|
||||
0x0096 => Www,
|
||||
0x002D => X,
|
||||
0x0093 => Xfer,
|
||||
0x0015 => Y,
|
||||
0x0190 => Yellow,
|
||||
0x007C => Yen,
|
||||
0x002C => Z,
|
||||
0x0055 => ZenkakuHankaku,
|
||||
0x01A2 => ZoomIn,
|
||||
0x01A3 => ZoomOut,
|
||||
0x01A4 => ZoomReset,
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(key)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Key {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.to_raw() == other.to_raw()
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
#[cfg(target_os = "linux")]
|
||||
mod device_id;
|
||||
|
||||
mod event;
|
||||
mod event_manager;
|
||||
mod event_reader;
|
||||
mod event_writer;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod glue;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod linux;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
mod windows;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub use linux::{EventManager, EventWriter};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub use windows::{EventManager, EventWriter};
|
||||
|
||||
pub use event::{Axis, Button, Direction, Event, Key, KeyKind};
|
||||
pub use event_manager::EventManager;
|
||||
pub use event_writer::EventWriter;
|
||||
|
|
7
input/src/linux.rs
Normal file
7
input/src/linux.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
mod event;
|
||||
mod event_manager;
|
||||
mod event_reader;
|
||||
mod event_writer;
|
||||
|
||||
pub use event_manager::EventManager;
|
||||
pub use event_writer::EventWriter;
|
64
input/src/linux/event.rs
Normal file
64
input/src/linux/event.rs
Normal file
|
@ -0,0 +1,64 @@
|
|||
mod button;
|
||||
mod key;
|
||||
|
||||
use crate::event::{Axis, Direction, Event, KeyKind};
|
||||
use crate::glue::{self, input_event, timeval};
|
||||
|
||||
impl Event {
|
||||
pub(crate) fn to_raw(&self) -> Option<input_event> {
|
||||
let (type_, code, value) = match *self {
|
||||
Event::MouseScroll { delta } => (glue::EV_REL as _, glue::REL_WHEEL as _, delta),
|
||||
Event::MouseMove {
|
||||
axis: Axis::X,
|
||||
delta,
|
||||
} => (glue::EV_REL as _, glue::REL_X as _, delta),
|
||||
Event::MouseMove {
|
||||
axis: Axis::Y,
|
||||
delta,
|
||||
} => (glue::EV_REL as _, glue::REL_Y as _, delta),
|
||||
Event::Key {
|
||||
direction: Direction::Up,
|
||||
kind,
|
||||
} => (glue::EV_KEY as _, kind.to_raw()?, 0),
|
||||
Event::Key {
|
||||
direction: Direction::Down,
|
||||
kind,
|
||||
} => (glue::EV_KEY as _, kind.to_raw()?, 1),
|
||||
};
|
||||
|
||||
Some(input_event {
|
||||
type_,
|
||||
code,
|
||||
value,
|
||||
time: timeval {
|
||||
tv_sec: 0,
|
||||
tv_usec: 0,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn from_raw(raw: input_event) -> Option<Self> {
|
||||
let event = match (raw.type_ as _, raw.code as _, raw.value) {
|
||||
(glue::EV_REL, glue::REL_WHEEL, value) => Event::MouseScroll { delta: value },
|
||||
(glue::EV_REL, glue::REL_X, value) => Event::MouseMove {
|
||||
axis: Axis::X,
|
||||
delta: value,
|
||||
},
|
||||
(glue::EV_REL, glue::REL_Y, value) => Event::MouseMove {
|
||||
axis: Axis::Y,
|
||||
delta: value,
|
||||
},
|
||||
(glue::EV_KEY, code, 0) => Event::Key {
|
||||
direction: Direction::Up,
|
||||
kind: KeyKind::from_raw(code as _)?,
|
||||
},
|
||||
(glue::EV_KEY, code, 1) => Event::Key {
|
||||
direction: Direction::Down,
|
||||
kind: KeyKind::from_raw(code as _)?,
|
||||
},
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(event)
|
||||
}
|
||||
}
|
260
input/src/linux/event/button.rs
Normal file
260
input/src/linux/event/button.rs
Normal file
|
@ -0,0 +1,260 @@
|
|||
use crate::event::Button;
|
||||
|
||||
impl Button {
|
||||
pub(crate) fn to_raw(&self) -> Option<u16> {
|
||||
use Button::*;
|
||||
|
||||
let code = match *self {
|
||||
A => 0x0130,
|
||||
B => 0x0131,
|
||||
Back => 0x0116,
|
||||
Base => 0x0126,
|
||||
Base2 => 0x0127,
|
||||
Base3 => 0x0128,
|
||||
Base4 => 0x0129,
|
||||
Base5 => 0x012A,
|
||||
Base6 => 0x012B,
|
||||
C => 0x0132,
|
||||
Dead => 0x012F,
|
||||
Digi => 0x0140,
|
||||
DpadDown => 0x0221,
|
||||
DpadLeft => 0x0222,
|
||||
DpadRight => 0x0223,
|
||||
DpadUp => 0x0220,
|
||||
East => 0x0131,
|
||||
Extra => 0x0114,
|
||||
Forward => 0x0115,
|
||||
Gamepad => 0x0130,
|
||||
GearDown => 0x0150,
|
||||
GearUp => 0x0151,
|
||||
Joystick => 0x0120,
|
||||
Left => 0x0110,
|
||||
Middle => 0x0112,
|
||||
Misc => 0x0100,
|
||||
Mode => 0x013C,
|
||||
Mouse => 0x0110,
|
||||
N0 => 0x0100,
|
||||
N1 => 0x0101,
|
||||
N2 => 0x0102,
|
||||
N3 => 0x0103,
|
||||
N4 => 0x0104,
|
||||
N5 => 0x0105,
|
||||
N6 => 0x0106,
|
||||
N7 => 0x0107,
|
||||
N8 => 0x0108,
|
||||
N9 => 0x0109,
|
||||
North => 0x0133,
|
||||
Pinkie => 0x0125,
|
||||
Right => 0x0111,
|
||||
Select => 0x013A,
|
||||
Side => 0x0113,
|
||||
South => 0x0130,
|
||||
Start => 0x013B,
|
||||
Stylus => 0x014B,
|
||||
Stylus2 => 0x014C,
|
||||
Stylus3 => 0x0149,
|
||||
Task => 0x0117,
|
||||
Thumb => 0x0121,
|
||||
Thumb2 => 0x0122,
|
||||
Thumbl => 0x013D,
|
||||
Thumbr => 0x013E,
|
||||
Tl => 0x0136,
|
||||
Tl2 => 0x0138,
|
||||
ToolAirbrush => 0x0144,
|
||||
ToolBrush => 0x0142,
|
||||
ToolDoubletap => 0x014D,
|
||||
ToolFinger => 0x0145,
|
||||
ToolLens => 0x0147,
|
||||
ToolMouse => 0x0146,
|
||||
ToolPen => 0x0140,
|
||||
ToolPencil => 0x0143,
|
||||
ToolQuadtap => 0x014F,
|
||||
ToolQuinttap => 0x0148,
|
||||
ToolRubber => 0x0141,
|
||||
ToolTripletap => 0x014E,
|
||||
Top => 0x0123,
|
||||
Top2 => 0x0124,
|
||||
Touch => 0x014A,
|
||||
Tr => 0x0137,
|
||||
Tr2 => 0x0139,
|
||||
Trigger => 0x0120,
|
||||
TriggerHappy => 0x02C0,
|
||||
TriggerHappy1 => 0x02C0,
|
||||
TriggerHappy10 => 0x02C9,
|
||||
TriggerHappy11 => 0x02CA,
|
||||
TriggerHappy12 => 0x02CB,
|
||||
TriggerHappy13 => 0x02CC,
|
||||
TriggerHappy14 => 0x02CD,
|
||||
TriggerHappy15 => 0x02CE,
|
||||
TriggerHappy16 => 0x02CF,
|
||||
TriggerHappy17 => 0x02D0,
|
||||
TriggerHappy18 => 0x02D1,
|
||||
TriggerHappy19 => 0x02D2,
|
||||
TriggerHappy2 => 0x02C1,
|
||||
TriggerHappy20 => 0x02D3,
|
||||
TriggerHappy21 => 0x02D4,
|
||||
TriggerHappy22 => 0x02D5,
|
||||
TriggerHappy23 => 0x02D6,
|
||||
TriggerHappy24 => 0x02D7,
|
||||
TriggerHappy25 => 0x02D8,
|
||||
TriggerHappy26 => 0x02D9,
|
||||
TriggerHappy27 => 0x02DA,
|
||||
TriggerHappy28 => 0x02DB,
|
||||
TriggerHappy29 => 0x02DC,
|
||||
TriggerHappy3 => 0x02C2,
|
||||
TriggerHappy30 => 0x02DD,
|
||||
TriggerHappy31 => 0x02DE,
|
||||
TriggerHappy32 => 0x02DF,
|
||||
TriggerHappy33 => 0x02E0,
|
||||
TriggerHappy34 => 0x02E1,
|
||||
TriggerHappy35 => 0x02E2,
|
||||
TriggerHappy36 => 0x02E3,
|
||||
TriggerHappy37 => 0x02E4,
|
||||
TriggerHappy38 => 0x02E5,
|
||||
TriggerHappy39 => 0x02E6,
|
||||
TriggerHappy4 => 0x02C3,
|
||||
TriggerHappy40 => 0x02E7,
|
||||
TriggerHappy5 => 0x02C4,
|
||||
TriggerHappy6 => 0x02C5,
|
||||
TriggerHappy7 => 0x02C6,
|
||||
TriggerHappy8 => 0x02C7,
|
||||
TriggerHappy9 => 0x02C8,
|
||||
West => 0x0134,
|
||||
Wheel => 0x0150,
|
||||
X => 0x0130,
|
||||
Y => 0x0150,
|
||||
Z => 0x0135,
|
||||
};
|
||||
|
||||
Some(code)
|
||||
}
|
||||
|
||||
pub(crate) fn from_raw(code: u16) -> Option<Self> {
|
||||
use Button::*;
|
||||
|
||||
// This is generated from linux headers, some patterns are unreachable, and we don't care.
|
||||
#[allow(unreachable_patterns, clippy::match_overlapping_arm)]
|
||||
let button = match code {
|
||||
0x0130 => A,
|
||||
0x0131 => B,
|
||||
0x0116 => Back,
|
||||
0x0126 => Base,
|
||||
0x0127 => Base2,
|
||||
0x0128 => Base3,
|
||||
0x0129 => Base4,
|
||||
0x012A => Base5,
|
||||
0x012B => Base6,
|
||||
0x0132 => C,
|
||||
0x012F => Dead,
|
||||
0x0140 => Digi,
|
||||
0x0221 => DpadDown,
|
||||
0x0222 => DpadLeft,
|
||||
0x0223 => DpadRight,
|
||||
0x0220 => DpadUp,
|
||||
0x0131 => East,
|
||||
0x0114 => Extra,
|
||||
0x0115 => Forward,
|
||||
0x0130 => Gamepad,
|
||||
0x0150 => GearDown,
|
||||
0x0151 => GearUp,
|
||||
0x0120 => Joystick,
|
||||
0x0110 => Left,
|
||||
0x0112 => Middle,
|
||||
0x0100 => Misc,
|
||||
0x013C => Mode,
|
||||
0x0110 => Mouse,
|
||||
0x0100 => N0,
|
||||
0x0101 => N1,
|
||||
0x0102 => N2,
|
||||
0x0103 => N3,
|
||||
0x0104 => N4,
|
||||
0x0105 => N5,
|
||||
0x0106 => N6,
|
||||
0x0107 => N7,
|
||||
0x0108 => N8,
|
||||
0x0109 => N9,
|
||||
0x0133 => North,
|
||||
0x0125 => Pinkie,
|
||||
0x0111 => Right,
|
||||
0x013A => Select,
|
||||
0x0113 => Side,
|
||||
0x0130 => South,
|
||||
0x013B => Start,
|
||||
0x014B => Stylus,
|
||||
0x014C => Stylus2,
|
||||
0x0149 => Stylus3,
|
||||
0x0117 => Task,
|
||||
0x0121 => Thumb,
|
||||
0x0122 => Thumb2,
|
||||
0x013D => Thumbl,
|
||||
0x013E => Thumbr,
|
||||
0x0136 => Tl,
|
||||
0x0138 => Tl2,
|
||||
0x0144 => ToolAirbrush,
|
||||
0x0142 => ToolBrush,
|
||||
0x014D => ToolDoubletap,
|
||||
0x0145 => ToolFinger,
|
||||
0x0147 => ToolLens,
|
||||
0x0146 => ToolMouse,
|
||||
0x0140 => ToolPen,
|
||||
0x0143 => ToolPencil,
|
||||
0x014F => ToolQuadtap,
|
||||
0x0148 => ToolQuinttap,
|
||||
0x0141 => ToolRubber,
|
||||
0x014E => ToolTripletap,
|
||||
0x0123 => Top,
|
||||
0x0124 => Top2,
|
||||
0x014A => Touch,
|
||||
0x0137 => Tr,
|
||||
0x0139 => Tr2,
|
||||
0x0120 => Trigger,
|
||||
0x02C0 => TriggerHappy,
|
||||
0x02C0 => TriggerHappy1,
|
||||
0x02C9 => TriggerHappy10,
|
||||
0x02CA => TriggerHappy11,
|
||||
0x02CB => TriggerHappy12,
|
||||
0x02CC => TriggerHappy13,
|
||||
0x02CD => TriggerHappy14,
|
||||
0x02CE => TriggerHappy15,
|
||||
0x02CF => TriggerHappy16,
|
||||
0x02D0 => TriggerHappy17,
|
||||
0x02D1 => TriggerHappy18,
|
||||
0x02D2 => TriggerHappy19,
|
||||
0x02C1 => TriggerHappy2,
|
||||
0x02D3 => TriggerHappy20,
|
||||
0x02D4 => TriggerHappy21,
|
||||
0x02D5 => TriggerHappy22,
|
||||
0x02D6 => TriggerHappy23,
|
||||
0x02D7 => TriggerHappy24,
|
||||
0x02D8 => TriggerHappy25,
|
||||
0x02D9 => TriggerHappy26,
|
||||
0x02DA => TriggerHappy27,
|
||||
0x02DB => TriggerHappy28,
|
||||
0x02DC => TriggerHappy29,
|
||||
0x02C2 => TriggerHappy3,
|
||||
0x02DD => TriggerHappy30,
|
||||
0x02DE => TriggerHappy31,
|
||||
0x02DF => TriggerHappy32,
|
||||
0x02E0 => TriggerHappy33,
|
||||
0x02E1 => TriggerHappy34,
|
||||
0x02E2 => TriggerHappy35,
|
||||
0x02E3 => TriggerHappy36,
|
||||
0x02E4 => TriggerHappy37,
|
||||
0x02E5 => TriggerHappy38,
|
||||
0x02E6 => TriggerHappy39,
|
||||
0x02C3 => TriggerHappy4,
|
||||
0x02E7 => TriggerHappy40,
|
||||
0x02C4 => TriggerHappy5,
|
||||
0x02C5 => TriggerHappy6,
|
||||
0x02C6 => TriggerHappy7,
|
||||
0x02C7 => TriggerHappy8,
|
||||
0x02C8 => TriggerHappy9,
|
||||
0x0134 => West,
|
||||
0x0150 => Wheel,
|
||||
0x0135 => Z,
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(button)
|
||||
}
|
||||
}
|
993
input/src/linux/event/key.rs
Normal file
993
input/src/linux/event/key.rs
Normal file
|
@ -0,0 +1,993 @@
|
|||
use crate::event::Key;
|
||||
|
||||
impl Key {
|
||||
pub(crate) fn to_raw(&self) -> Option<u16> {
|
||||
use Key::*;
|
||||
|
||||
let code = match *self {
|
||||
A => 0x001E,
|
||||
Ab => 0x0196,
|
||||
AddressBook => 0x01AD,
|
||||
Again => 0x0081,
|
||||
AlsToggle => 0x0230,
|
||||
AltErase => 0x00DE,
|
||||
Angle => 0x0173,
|
||||
Apostrophe => 0x0028,
|
||||
Appselect => 0x0244,
|
||||
Archive => 0x0169,
|
||||
AspectRatio => 0x0177,
|
||||
Assistant => 0x0247,
|
||||
AttendantOff => 0x021C,
|
||||
AttendantOn => 0x021B,
|
||||
AttendantToggle => 0x021D,
|
||||
Audio => 0x0188,
|
||||
AudioDesc => 0x026E,
|
||||
Aux => 0x0186,
|
||||
B => 0x0030,
|
||||
Back => 0x009E,
|
||||
Backslash => 0x002B,
|
||||
Backspace => 0x000E,
|
||||
BassBoost => 0x00D1,
|
||||
Battery => 0x00EC,
|
||||
Blue => 0x0191,
|
||||
Bluetooth => 0x00ED,
|
||||
Bookmarks => 0x009C,
|
||||
Break => 0x019B,
|
||||
BrightnessAuto => 0x00F4,
|
||||
BrightnessCycle => 0x00F3,
|
||||
BrightnessMax => 0x0251,
|
||||
BrightnessMin => 0x0250,
|
||||
BrightnessToggle => 0x01AF,
|
||||
BrightnessZero => 0x00F4,
|
||||
BrightnessDown => 0x00E0,
|
||||
BrightnessUp => 0x00E1,
|
||||
BrlDot1 => 0x01F1,
|
||||
BrlDot10 => 0x01FA,
|
||||
BrlDot2 => 0x01F2,
|
||||
BrlDot3 => 0x01F3,
|
||||
BrlDot4 => 0x01F4,
|
||||
BrlDot5 => 0x01F5,
|
||||
BrlDot6 => 0x01F6,
|
||||
BrlDot7 => 0x01F7,
|
||||
BrlDot8 => 0x01F8,
|
||||
BrlDot9 => 0x01F9,
|
||||
ButtonConfig => 0x0240,
|
||||
C => 0x002E,
|
||||
Calc => 0x008C,
|
||||
Calendar => 0x018D,
|
||||
Camera => 0x00D4,
|
||||
CameraDown => 0x0218,
|
||||
CameraFocus => 0x0210,
|
||||
CameraLeft => 0x0219,
|
||||
CameraRight => 0x021A,
|
||||
CameraUp => 0x0217,
|
||||
CameraZoomIn => 0x0215,
|
||||
CameraZoomOut => 0x0216,
|
||||
Cancel => 0x00DF,
|
||||
CapsLock => 0x003A,
|
||||
Cd => 0x017F,
|
||||
Channel => 0x016B,
|
||||
ChannelDown => 0x0193,
|
||||
ChannelUp => 0x0192,
|
||||
Chat => 0x00D8,
|
||||
Clear => 0x0163,
|
||||
Close => 0x00CE,
|
||||
CloseCd => 0x00A0,
|
||||
Coffee => 0x0098,
|
||||
Comma => 0x0033,
|
||||
Compose => 0x007F,
|
||||
Computer => 0x009D,
|
||||
Config => 0x00AB,
|
||||
Connect => 0x00DA,
|
||||
ContextMenu => 0x01B6,
|
||||
Controlpanel => 0x0243,
|
||||
Copy => 0x0085,
|
||||
Cut => 0x0089,
|
||||
CycleWindows => 0x009A,
|
||||
D => 0x0020,
|
||||
Dashboard => 0x00CC,
|
||||
Data => 0x0277,
|
||||
Database => 0x01AA,
|
||||
DelEol => 0x01C0,
|
||||
DelEos => 0x01C1,
|
||||
DelLine => 0x01C3,
|
||||
Delete => 0x006F,
|
||||
DeleteFile => 0x0092,
|
||||
Digits => 0x019D,
|
||||
Direction => 0x0099,
|
||||
Directory => 0x018A,
|
||||
DisplayOff => 0x00F5,
|
||||
DisplayToggle => 0x01AF,
|
||||
Documents => 0x00EB,
|
||||
Dollar => 0x01B2,
|
||||
Dot => 0x0034,
|
||||
Down => 0x006C,
|
||||
Dvd => 0x0185,
|
||||
E => 0x0012,
|
||||
Edit => 0x00B0,
|
||||
Editor => 0x01A6,
|
||||
EjectCd => 0x00A1,
|
||||
EjectCloseCd => 0x00A2,
|
||||
Email => 0x00D7,
|
||||
End => 0x006B,
|
||||
Enter => 0x001C,
|
||||
Epg => 0x016D,
|
||||
Equal => 0x000D,
|
||||
Esc => 0x0001,
|
||||
Euro => 0x01B3,
|
||||
Exit => 0x00AE,
|
||||
F => 0x0021,
|
||||
F1 => 0x003B,
|
||||
F10 => 0x0044,
|
||||
F11 => 0x0057,
|
||||
F12 => 0x0058,
|
||||
F13 => 0x00B7,
|
||||
F14 => 0x00B8,
|
||||
F15 => 0x00B9,
|
||||
F16 => 0x00BA,
|
||||
F17 => 0x00BB,
|
||||
F18 => 0x00BC,
|
||||
F19 => 0x00BD,
|
||||
F2 => 0x003C,
|
||||
F20 => 0x00BE,
|
||||
F21 => 0x00BF,
|
||||
F22 => 0x00C0,
|
||||
F23 => 0x00C1,
|
||||
F24 => 0x00C2,
|
||||
F3 => 0x003D,
|
||||
F4 => 0x003E,
|
||||
F5 => 0x003F,
|
||||
F6 => 0x0040,
|
||||
F7 => 0x0041,
|
||||
F8 => 0x0042,
|
||||
F9 => 0x0043,
|
||||
FastForward => 0x00D0,
|
||||
FastReverse => 0x0275,
|
||||
Favorites => 0x016C,
|
||||
File => 0x0090,
|
||||
Finance => 0x00DB,
|
||||
Find => 0x0088,
|
||||
First => 0x0194,
|
||||
Fn => 0x01D0,
|
||||
Fn1 => 0x01DE,
|
||||
Fn2 => 0x01DF,
|
||||
FnB => 0x01E4,
|
||||
FnD => 0x01E0,
|
||||
FnE => 0x01E1,
|
||||
FnEsc => 0x01D1,
|
||||
FnF => 0x01E2,
|
||||
FnF1 => 0x01D2,
|
||||
FnF10 => 0x01DB,
|
||||
FnF11 => 0x01DC,
|
||||
FnF12 => 0x01DD,
|
||||
FnF2 => 0x01D3,
|
||||
FnF3 => 0x01D4,
|
||||
FnF4 => 0x01D5,
|
||||
FnF5 => 0x01D6,
|
||||
FnF6 => 0x01D7,
|
||||
FnF7 => 0x01D8,
|
||||
FnF8 => 0x01D9,
|
||||
FnF9 => 0x01DA,
|
||||
FnS => 0x01E3,
|
||||
Forward => 0x009F,
|
||||
ForwardMail => 0x00E9,
|
||||
Frameback => 0x01B4,
|
||||
FrameForward => 0x01B5,
|
||||
Front => 0x0084,
|
||||
FullScreen => 0x0174,
|
||||
G => 0x0022,
|
||||
Games => 0x01A1,
|
||||
Goto => 0x0162,
|
||||
GraphicsEditor => 0x01A8,
|
||||
Grave => 0x0029,
|
||||
Green => 0x018F,
|
||||
H => 0x0023,
|
||||
Hangeul => 0x007A,
|
||||
Hanja => 0x007B,
|
||||
Help => 0x008A,
|
||||
Henkan => 0x005C,
|
||||
Hiragana => 0x005B,
|
||||
Home => 0x0066,
|
||||
Homepage => 0x00AC,
|
||||
Hp => 0x00D3,
|
||||
I => 0x0017,
|
||||
Images => 0x01BA,
|
||||
Info => 0x0166,
|
||||
InsLine => 0x01C2,
|
||||
Insert => 0x006E,
|
||||
Iso => 0x00AA,
|
||||
J => 0x0024,
|
||||
Journal => 0x0242,
|
||||
K => 0x0025,
|
||||
Katakana => 0x005A,
|
||||
KatakanaHiragana => 0x005D,
|
||||
KbdLayoutNext => 0x0248,
|
||||
KbdLcdMenu1 => 0x02B8,
|
||||
KbdLcdMenu2 => 0x02B9,
|
||||
KbdLcdMenu3 => 0x02BA,
|
||||
KbdLcdMenu4 => 0x02BB,
|
||||
KbdLcdMenu5 => 0x02BC,
|
||||
KbdIllumDown => 0x00E5,
|
||||
KbdIllumToggle => 0x00E4,
|
||||
KbdIllumUp => 0x00E6,
|
||||
KbdInputAssistAccept => 0x0264,
|
||||
KbdInputAssistCancel => 0x0265,
|
||||
KbdInputAssistNext => 0x0261,
|
||||
KbdInputAssistNextgroup => 0x0263,
|
||||
KbdInputAssistPrev => 0x0260,
|
||||
KbdInputAssistPrevgroup => 0x0262,
|
||||
Keyboard => 0x0176,
|
||||
Kp0 => 0x0052,
|
||||
Kp1 => 0x004F,
|
||||
Kp2 => 0x0050,
|
||||
Kp3 => 0x0051,
|
||||
Kp4 => 0x004B,
|
||||
Kp5 => 0x004C,
|
||||
Kp6 => 0x004D,
|
||||
Kp7 => 0x0047,
|
||||
Kp8 => 0x0048,
|
||||
Kp9 => 0x0049,
|
||||
KpAsterisk => 0x0037,
|
||||
KpComma => 0x0079,
|
||||
KpDott => 0x0053,
|
||||
KpEnter => 0x0060,
|
||||
KpEqual => 0x0075,
|
||||
KpJpComma => 0x005F,
|
||||
KpLeftParen => 0x00B3,
|
||||
KpMinus => 0x004A,
|
||||
KpPlus => 0x004E,
|
||||
KpPlusMinus => 0x0076,
|
||||
KpRightParen => 0x00B4,
|
||||
KpSlash => 0x0062,
|
||||
L => 0x0026,
|
||||
Language => 0x0170,
|
||||
Last => 0x0195,
|
||||
Left => 0x0069,
|
||||
LeftDown => 0x0269,
|
||||
LeftUp => 0x0268,
|
||||
LeftAlt => 0x0038,
|
||||
LeftBrace => 0x001A,
|
||||
LeftCtrl => 0x001D,
|
||||
LeftMeta => 0x007D,
|
||||
LeftShift => 0x002A,
|
||||
LightsToggle => 0x021E,
|
||||
LineFeed => 0x0065,
|
||||
List => 0x018B,
|
||||
LogOff => 0x01B1,
|
||||
M => 0x0032,
|
||||
Macro => 0x0070,
|
||||
Macro1 => 0x0290,
|
||||
Macro10 => 0x0299,
|
||||
Macro11 => 0x029A,
|
||||
Macro12 => 0x029B,
|
||||
Macro13 => 0x029C,
|
||||
Macro14 => 0x029D,
|
||||
Macro15 => 0x029E,
|
||||
Macro16 => 0x029F,
|
||||
Macro17 => 0x02A0,
|
||||
Macro18 => 0x02A1,
|
||||
Macro19 => 0x02A2,
|
||||
Macro2 => 0x0291,
|
||||
Macro20 => 0x02A3,
|
||||
Macro21 => 0x02A4,
|
||||
Macro22 => 0x02A5,
|
||||
Macro23 => 0x02A6,
|
||||
Macro24 => 0x02A7,
|
||||
Macro25 => 0x02A8,
|
||||
Macro26 => 0x02A9,
|
||||
Macro27 => 0x02AA,
|
||||
Macro28 => 0x02AB,
|
||||
Macro29 => 0x02AC,
|
||||
Macro3 => 0x0292,
|
||||
Macro30 => 0x02AD,
|
||||
Macro4 => 0x0293,
|
||||
Macro5 => 0x0294,
|
||||
Macro6 => 0x0295,
|
||||
Macro7 => 0x0296,
|
||||
Macro8 => 0x0297,
|
||||
Macro9 => 0x0298,
|
||||
MacroPreset1 => 0x02B3,
|
||||
MacroPreset2 => 0x02B4,
|
||||
MacroPreset3 => 0x02B5,
|
||||
MacroPresetCycle => 0x02B2,
|
||||
MacroRecordStart => 0x02B0,
|
||||
MacroRecordStop => 0x02B1,
|
||||
Mail => 0x009B,
|
||||
Media => 0x00E2,
|
||||
MediaRepeat => 0x01B7,
|
||||
MediaTopMenu => 0x026B,
|
||||
Memo => 0x018C,
|
||||
Menu => 0x008B,
|
||||
Messenger => 0x01AE,
|
||||
Mhp => 0x016F,
|
||||
MicMute => 0x00F8,
|
||||
Minus => 0x000C,
|
||||
Mode => 0x0175,
|
||||
Move => 0x00AF,
|
||||
Mp3 => 0x0187,
|
||||
MsDos => 0x0097,
|
||||
Muhenkan => 0x005E,
|
||||
Mute => 0x0071,
|
||||
N => 0x0031,
|
||||
N0 => 0x000B,
|
||||
N1 => 0x0002,
|
||||
N102nd => 0x0056,
|
||||
N10ChannelsDown => 0x01B9,
|
||||
N10ChannelsUp => 0x01B8,
|
||||
N2 => 0x0003,
|
||||
N3 => 0x0004,
|
||||
N3dMode => 0x026F,
|
||||
N4 => 0x0005,
|
||||
N5 => 0x0006,
|
||||
N6 => 0x0007,
|
||||
N7 => 0x0008,
|
||||
N8 => 0x0009,
|
||||
N9 => 0x000A,
|
||||
New => 0x00B5,
|
||||
News => 0x01AB,
|
||||
Next => 0x0197,
|
||||
NextFavorite => 0x0270,
|
||||
Nextsong => 0x00A3,
|
||||
Numeric0 => 0x0200,
|
||||
Numeric1 => 0x0201,
|
||||
Numeric11 => 0x026C,
|
||||
Numeric12 => 0x026D,
|
||||
Numeric2 => 0x0202,
|
||||
Numeric3 => 0x0203,
|
||||
Numeric4 => 0x0204,
|
||||
Numeric5 => 0x0205,
|
||||
Numeric6 => 0x0206,
|
||||
Numeric7 => 0x0207,
|
||||
Numeric8 => 0x0208,
|
||||
Numeric9 => 0x0209,
|
||||
NumericA => 0x020C,
|
||||
NumericB => 0x020D,
|
||||
NumericC => 0x020E,
|
||||
NumericD => 0x020F,
|
||||
NumericPound => 0x020B,
|
||||
NumericStar => 0x020A,
|
||||
NumLock => 0x0045,
|
||||
O => 0x0018,
|
||||
Ok => 0x0160,
|
||||
OnscreenKeyboard => 0x0278,
|
||||
Open => 0x0086,
|
||||
Option => 0x0165,
|
||||
P => 0x0019,
|
||||
Pagedown => 0x006D,
|
||||
Pageup => 0x0068,
|
||||
Paste => 0x0087,
|
||||
Pause => 0x0077,
|
||||
PauseRecord => 0x0272,
|
||||
PauseCd => 0x00C9,
|
||||
Pc => 0x0178,
|
||||
Phone => 0x00A9,
|
||||
Play => 0x00CF,
|
||||
PlayCd => 0x00C8,
|
||||
Player => 0x0183,
|
||||
PlayPause => 0x00A4,
|
||||
Power => 0x0074,
|
||||
Power2 => 0x0164,
|
||||
Presentation => 0x01A9,
|
||||
Previous => 0x019C,
|
||||
PreviousSong => 0x00A5,
|
||||
Print => 0x00D2,
|
||||
PrivacyScreenToggle => 0x0279,
|
||||
Prog1 => 0x0094,
|
||||
Prog2 => 0x0095,
|
||||
Prog3 => 0x00CA,
|
||||
Prog4 => 0x00CB,
|
||||
Program => 0x016A,
|
||||
Props => 0x0082,
|
||||
Pvr => 0x016E,
|
||||
Q => 0x0010,
|
||||
Question => 0x00D6,
|
||||
R => 0x0013,
|
||||
Radio => 0x0181,
|
||||
Record => 0x00A7,
|
||||
Red => 0x018E,
|
||||
Redo => 0x00B6,
|
||||
Refresh => 0x00AD,
|
||||
Reply => 0x00E8,
|
||||
Reserved => 0x0000,
|
||||
Restart => 0x0198,
|
||||
Rewind => 0x00A8,
|
||||
RfKill => 0x00F7,
|
||||
Right => 0x006A,
|
||||
RightDown => 0x0267,
|
||||
RightUp => 0x0266,
|
||||
RightAlt => 0x0064,
|
||||
RightBrace => 0x001B,
|
||||
RightCtrl => 0x0061,
|
||||
RightMeta => 0x007E,
|
||||
RightShift => 0x0036,
|
||||
Ro => 0x0059,
|
||||
RootMenu => 0x026A,
|
||||
RotateDisplay => 0x0099,
|
||||
RotateLockToggle => 0x0231,
|
||||
S => 0x001F,
|
||||
Sat => 0x017D,
|
||||
Sat2 => 0x017E,
|
||||
Save => 0x00EA,
|
||||
Scale => 0x0078,
|
||||
Screen => 0x0177,
|
||||
Screenlock => 0x0098,
|
||||
Screensaver => 0x0245,
|
||||
ScrollDown => 0x00B2,
|
||||
ScrollLock => 0x0046,
|
||||
ScrollUp => 0x00B1,
|
||||
Search => 0x00D9,
|
||||
Select => 0x0161,
|
||||
SelectiveScreenshot => 0x027A,
|
||||
Semicolon => 0x0027,
|
||||
Send => 0x00E7,
|
||||
SendFile => 0x0091,
|
||||
Setup => 0x008D,
|
||||
Shop => 0x00DD,
|
||||
Shuffle => 0x019A,
|
||||
Slash => 0x0035,
|
||||
Sleep => 0x008E,
|
||||
Slow => 0x0199,
|
||||
SlowReverse => 0x0276,
|
||||
Sound => 0x00D5,
|
||||
Space => 0x0039,
|
||||
Spellcheck => 0x01B0,
|
||||
Sport => 0x00DC,
|
||||
Spreadsheet => 0x01A7,
|
||||
Stop => 0x0080,
|
||||
StopRecord => 0x0271,
|
||||
StopCd => 0x00A6,
|
||||
Subtitle => 0x0172,
|
||||
Suspend => 0x00CD,
|
||||
SwitchVideoMode => 0x00E3,
|
||||
SysRq => 0x0063,
|
||||
T => 0x0014,
|
||||
Tab => 0x000F,
|
||||
Tape => 0x0180,
|
||||
TaskManager => 0x0241,
|
||||
Teen => 0x019E,
|
||||
Text => 0x0184,
|
||||
Time => 0x0167,
|
||||
Title => 0x0171,
|
||||
TouchpadOff => 0x0214,
|
||||
TouchpadOn => 0x0213,
|
||||
TouchpadToggle => 0x0212,
|
||||
Tuner => 0x0182,
|
||||
Tv => 0x0179,
|
||||
Tv2 => 0x017A,
|
||||
Twen => 0x019F,
|
||||
U => 0x0016,
|
||||
Undo => 0x0083,
|
||||
Unknown => 0x00F0,
|
||||
Unmute => 0x0274,
|
||||
Up => 0x0067,
|
||||
Uwb => 0x00EF,
|
||||
V => 0x002F,
|
||||
Vcr => 0x017B,
|
||||
Vcr2 => 0x017C,
|
||||
Vendor => 0x0168,
|
||||
Video => 0x0189,
|
||||
VideoNext => 0x00F1,
|
||||
VideoPrev => 0x00F2,
|
||||
VideoPhone => 0x01A0,
|
||||
Vod => 0x0273,
|
||||
VoiceCommand => 0x0246,
|
||||
VoiceMail => 0x01AC,
|
||||
VolumeDown => 0x0072,
|
||||
VolumeUp => 0x0073,
|
||||
W => 0x0011,
|
||||
WakeUp => 0x008F,
|
||||
Wimax => 0x00F6,
|
||||
Wlan => 0x00EE,
|
||||
WordProcessor => 0x01A5,
|
||||
WpsButton => 0x0211,
|
||||
Wwan => 0x00F6,
|
||||
Www => 0x0096,
|
||||
X => 0x002D,
|
||||
Xfer => 0x0093,
|
||||
Y => 0x0015,
|
||||
Yellow => 0x0190,
|
||||
Yen => 0x007C,
|
||||
Z => 0x002C,
|
||||
ZenkakuHankaku => 0x0055,
|
||||
Zoom => 0x0174,
|
||||
ZoomIn => 0x01A2,
|
||||
ZoomOut => 0x01A3,
|
||||
ZoomReset => 0x01A4,
|
||||
};
|
||||
|
||||
Some(code)
|
||||
}
|
||||
|
||||
pub(crate) fn from_raw(code: u16) -> Option<Self> {
|
||||
use Key::*;
|
||||
|
||||
// This is generated from linux headers, some patterns are unreachable, and we don't care.
|
||||
#[allow(unreachable_patterns)]
|
||||
let key = match code {
|
||||
0x001E => A,
|
||||
0x0196 => Ab,
|
||||
0x01AD => AddressBook,
|
||||
0x0081 => Again,
|
||||
0x0230 => AlsToggle,
|
||||
0x00DE => AltErase,
|
||||
0x0173 => Angle,
|
||||
0x0028 => Apostrophe,
|
||||
0x0244 => Appselect,
|
||||
0x0169 => Archive,
|
||||
0x0177 => AspectRatio,
|
||||
0x0247 => Assistant,
|
||||
0x021C => AttendantOff,
|
||||
0x021B => AttendantOn,
|
||||
0x021D => AttendantToggle,
|
||||
0x0188 => Audio,
|
||||
0x026E => AudioDesc,
|
||||
0x0186 => Aux,
|
||||
0x0030 => B,
|
||||
0x009E => Back,
|
||||
0x002B => Backslash,
|
||||
0x000E => Backspace,
|
||||
0x00D1 => BassBoost,
|
||||
0x00EC => Battery,
|
||||
0x0191 => Blue,
|
||||
0x00ED => Bluetooth,
|
||||
0x009C => Bookmarks,
|
||||
0x019B => Break,
|
||||
0x00F4 => BrightnessAuto,
|
||||
0x00F3 => BrightnessCycle,
|
||||
0x0251 => BrightnessMax,
|
||||
0x0250 => BrightnessMin,
|
||||
0x00E0 => BrightnessDown,
|
||||
0x00E1 => BrightnessUp,
|
||||
0x01F1 => BrlDot1,
|
||||
0x01FA => BrlDot10,
|
||||
0x01F2 => BrlDot2,
|
||||
0x01F3 => BrlDot3,
|
||||
0x01F4 => BrlDot4,
|
||||
0x01F5 => BrlDot5,
|
||||
0x01F6 => BrlDot6,
|
||||
0x01F7 => BrlDot7,
|
||||
0x01F8 => BrlDot8,
|
||||
0x01F9 => BrlDot9,
|
||||
0x0240 => ButtonConfig,
|
||||
0x002E => C,
|
||||
0x008C => Calc,
|
||||
0x018D => Calendar,
|
||||
0x00D4 => Camera,
|
||||
0x0218 => CameraDown,
|
||||
0x0210 => CameraFocus,
|
||||
0x0219 => CameraLeft,
|
||||
0x021A => CameraRight,
|
||||
0x0217 => CameraUp,
|
||||
0x0215 => CameraZoomIn,
|
||||
0x0216 => CameraZoomOut,
|
||||
0x00DF => Cancel,
|
||||
0x003A => CapsLock,
|
||||
0x017F => Cd,
|
||||
0x016B => Channel,
|
||||
0x0193 => ChannelDown,
|
||||
0x0192 => ChannelUp,
|
||||
0x00D8 => Chat,
|
||||
0x0163 => Clear,
|
||||
0x00CE => Close,
|
||||
0x00A0 => CloseCd,
|
||||
0x0098 => Coffee,
|
||||
0x0033 => Comma,
|
||||
0x007F => Compose,
|
||||
0x009D => Computer,
|
||||
0x00AB => Config,
|
||||
0x00DA => Connect,
|
||||
0x01B6 => ContextMenu,
|
||||
0x0243 => Controlpanel,
|
||||
0x0085 => Copy,
|
||||
0x0089 => Cut,
|
||||
0x009A => CycleWindows,
|
||||
0x0020 => D,
|
||||
0x00CC => Dashboard,
|
||||
0x0277 => Data,
|
||||
0x01AA => Database,
|
||||
0x01C0 => DelEol,
|
||||
0x01C1 => DelEos,
|
||||
0x01C3 => DelLine,
|
||||
0x006F => Delete,
|
||||
0x0092 => DeleteFile,
|
||||
0x019D => Digits,
|
||||
0x018A => Directory,
|
||||
0x00F5 => DisplayOff,
|
||||
0x01AF => DisplayToggle,
|
||||
0x00EB => Documents,
|
||||
0x01B2 => Dollar,
|
||||
0x0034 => Dot,
|
||||
0x006C => Down,
|
||||
0x0185 => Dvd,
|
||||
0x0012 => E,
|
||||
0x00B0 => Edit,
|
||||
0x01A6 => Editor,
|
||||
0x00A1 => EjectCd,
|
||||
0x00A2 => EjectCloseCd,
|
||||
0x00D7 => Email,
|
||||
0x006B => End,
|
||||
0x001C => Enter,
|
||||
0x016D => Epg,
|
||||
0x000D => Equal,
|
||||
0x0001 => Esc,
|
||||
0x01B3 => Euro,
|
||||
0x00AE => Exit,
|
||||
0x0021 => F,
|
||||
0x003B => F1,
|
||||
0x0044 => F10,
|
||||
0x0057 => F11,
|
||||
0x0058 => F12,
|
||||
0x00B7 => F13,
|
||||
0x00B8 => F14,
|
||||
0x00B9 => F15,
|
||||
0x00BA => F16,
|
||||
0x00BB => F17,
|
||||
0x00BC => F18,
|
||||
0x00BD => F19,
|
||||
0x003C => F2,
|
||||
0x00BE => F20,
|
||||
0x00BF => F21,
|
||||
0x00C0 => F22,
|
||||
0x00C1 => F23,
|
||||
0x00C2 => F24,
|
||||
0x003D => F3,
|
||||
0x003E => F4,
|
||||
0x003F => F5,
|
||||
0x0040 => F6,
|
||||
0x0041 => F7,
|
||||
0x0042 => F8,
|
||||
0x0043 => F9,
|
||||
0x00D0 => FastForward,
|
||||
0x0275 => FastReverse,
|
||||
0x016C => Favorites,
|
||||
0x0090 => File,
|
||||
0x00DB => Finance,
|
||||
0x0088 => Find,
|
||||
0x0194 => First,
|
||||
0x01D0 => Fn,
|
||||
0x01DE => Fn1,
|
||||
0x01DF => Fn2,
|
||||
0x01E4 => FnB,
|
||||
0x01E0 => FnD,
|
||||
0x01E1 => FnE,
|
||||
0x01D1 => FnEsc,
|
||||
0x01E2 => FnF,
|
||||
0x01D2 => FnF1,
|
||||
0x01DB => FnF10,
|
||||
0x01DC => FnF11,
|
||||
0x01DD => FnF12,
|
||||
0x01D3 => FnF2,
|
||||
0x01D4 => FnF3,
|
||||
0x01D5 => FnF4,
|
||||
0x01D6 => FnF5,
|
||||
0x01D7 => FnF6,
|
||||
0x01D8 => FnF7,
|
||||
0x01D9 => FnF8,
|
||||
0x01DA => FnF9,
|
||||
0x01E3 => FnS,
|
||||
0x009F => Forward,
|
||||
0x00E9 => ForwardMail,
|
||||
0x01B4 => Frameback,
|
||||
0x01B5 => FrameForward,
|
||||
0x0084 => Front,
|
||||
0x0174 => FullScreen,
|
||||
0x0022 => G,
|
||||
0x01A1 => Games,
|
||||
0x0162 => Goto,
|
||||
0x01A8 => GraphicsEditor,
|
||||
0x0029 => Grave,
|
||||
0x018F => Green,
|
||||
0x0023 => H,
|
||||
0x007A => Hangeul,
|
||||
0x007B => Hanja,
|
||||
0x008A => Help,
|
||||
0x005C => Henkan,
|
||||
0x005B => Hiragana,
|
||||
0x0066 => Home,
|
||||
0x00AC => Homepage,
|
||||
0x00D3 => Hp,
|
||||
0x0017 => I,
|
||||
0x01BA => Images,
|
||||
0x0166 => Info,
|
||||
0x01C2 => InsLine,
|
||||
0x006E => Insert,
|
||||
0x00AA => Iso,
|
||||
0x0024 => J,
|
||||
0x0242 => Journal,
|
||||
0x0025 => K,
|
||||
0x005A => Katakana,
|
||||
0x005D => KatakanaHiragana,
|
||||
0x0248 => KbdLayoutNext,
|
||||
0x02B8 => KbdLcdMenu1,
|
||||
0x02B9 => KbdLcdMenu2,
|
||||
0x02BA => KbdLcdMenu3,
|
||||
0x02BB => KbdLcdMenu4,
|
||||
0x02BC => KbdLcdMenu5,
|
||||
0x00E5 => KbdIllumDown,
|
||||
0x00E4 => KbdIllumToggle,
|
||||
0x00E6 => KbdIllumUp,
|
||||
0x0264 => KbdInputAssistAccept,
|
||||
0x0265 => KbdInputAssistCancel,
|
||||
0x0261 => KbdInputAssistNext,
|
||||
0x0263 => KbdInputAssistNextgroup,
|
||||
0x0260 => KbdInputAssistPrev,
|
||||
0x0262 => KbdInputAssistPrevgroup,
|
||||
0x0176 => Keyboard,
|
||||
0x0052 => Kp0,
|
||||
0x004F => Kp1,
|
||||
0x0050 => Kp2,
|
||||
0x0051 => Kp3,
|
||||
0x004B => Kp4,
|
||||
0x004C => Kp5,
|
||||
0x004D => Kp6,
|
||||
0x0047 => Kp7,
|
||||
0x0048 => Kp8,
|
||||
0x0049 => Kp9,
|
||||
0x0037 => KpAsterisk,
|
||||
0x0079 => KpComma,
|
||||
0x0053 => KpDott,
|
||||
0x0060 => KpEnter,
|
||||
0x0075 => KpEqual,
|
||||
0x005F => KpJpComma,
|
||||
0x00B3 => KpLeftParen,
|
||||
0x004A => KpMinus,
|
||||
0x004E => KpPlus,
|
||||
0x0076 => KpPlusMinus,
|
||||
0x00B4 => KpRightParen,
|
||||
0x0062 => KpSlash,
|
||||
0x0026 => L,
|
||||
0x0170 => Language,
|
||||
0x0195 => Last,
|
||||
0x0069 => Left,
|
||||
0x0269 => LeftDown,
|
||||
0x0268 => LeftUp,
|
||||
0x0038 => LeftAlt,
|
||||
0x001A => LeftBrace,
|
||||
0x001D => LeftCtrl,
|
||||
0x007D => LeftMeta,
|
||||
0x002A => LeftShift,
|
||||
0x021E => LightsToggle,
|
||||
0x0065 => LineFeed,
|
||||
0x018B => List,
|
||||
0x01B1 => LogOff,
|
||||
0x0032 => M,
|
||||
0x0070 => Macro,
|
||||
0x0290 => Macro1,
|
||||
0x0299 => Macro10,
|
||||
0x029A => Macro11,
|
||||
0x029B => Macro12,
|
||||
0x029C => Macro13,
|
||||
0x029D => Macro14,
|
||||
0x029E => Macro15,
|
||||
0x029F => Macro16,
|
||||
0x02A0 => Macro17,
|
||||
0x02A1 => Macro18,
|
||||
0x02A2 => Macro19,
|
||||
0x0291 => Macro2,
|
||||
0x02A3 => Macro20,
|
||||
0x02A4 => Macro21,
|
||||
0x02A5 => Macro22,
|
||||
0x02A6 => Macro23,
|
||||
0x02A7 => Macro24,
|
||||
0x02A8 => Macro25,
|
||||
0x02A9 => Macro26,
|
||||
0x02AA => Macro27,
|
||||
0x02AB => Macro28,
|
||||
0x02AC => Macro29,
|
||||
0x0292 => Macro3,
|
||||
0x02AD => Macro30,
|
||||
0x0293 => Macro4,
|
||||
0x0294 => Macro5,
|
||||
0x0295 => Macro6,
|
||||
0x0296 => Macro7,
|
||||
0x0297 => Macro8,
|
||||
0x0298 => Macro9,
|
||||
0x02B3 => MacroPreset1,
|
||||
0x02B4 => MacroPreset2,
|
||||
0x02B5 => MacroPreset3,
|
||||
0x02B2 => MacroPresetCycle,
|
||||
0x02B0 => MacroRecordStart,
|
||||
0x02B1 => MacroRecordStop,
|
||||
0x009B => Mail,
|
||||
0x00E2 => Media,
|
||||
0x01B7 => MediaRepeat,
|
||||
0x026B => MediaTopMenu,
|
||||
0x018C => Memo,
|
||||
0x008B => Menu,
|
||||
0x01AE => Messenger,
|
||||
0x016F => Mhp,
|
||||
0x00F8 => MicMute,
|
||||
0x000C => Minus,
|
||||
0x0175 => Mode,
|
||||
0x00AF => Move,
|
||||
0x0187 => Mp3,
|
||||
0x0097 => MsDos,
|
||||
0x005E => Muhenkan,
|
||||
0x0071 => Mute,
|
||||
0x0031 => N,
|
||||
0x000B => N0,
|
||||
0x0002 => N1,
|
||||
0x0056 => N102nd,
|
||||
0x01B9 => N10ChannelsDown,
|
||||
0x01B8 => N10ChannelsUp,
|
||||
0x0003 => N2,
|
||||
0x0004 => N3,
|
||||
0x026F => N3dMode,
|
||||
0x0005 => N4,
|
||||
0x0006 => N5,
|
||||
0x0007 => N6,
|
||||
0x0008 => N7,
|
||||
0x0009 => N8,
|
||||
0x000A => N9,
|
||||
0x00B5 => New,
|
||||
0x01AB => News,
|
||||
0x0197 => Next,
|
||||
0x0270 => NextFavorite,
|
||||
0x00A3 => Nextsong,
|
||||
0x0200 => Numeric0,
|
||||
0x0201 => Numeric1,
|
||||
0x026C => Numeric11,
|
||||
0x026D => Numeric12,
|
||||
0x0202 => Numeric2,
|
||||
0x0203 => Numeric3,
|
||||
0x0204 => Numeric4,
|
||||
0x0205 => Numeric5,
|
||||
0x0206 => Numeric6,
|
||||
0x0207 => Numeric7,
|
||||
0x0208 => Numeric8,
|
||||
0x0209 => Numeric9,
|
||||
0x020C => NumericA,
|
||||
0x020D => NumericB,
|
||||
0x020E => NumericC,
|
||||
0x020F => NumericD,
|
||||
0x020B => NumericPound,
|
||||
0x020A => NumericStar,
|
||||
0x0045 => NumLock,
|
||||
0x0018 => O,
|
||||
0x0160 => Ok,
|
||||
0x0278 => OnscreenKeyboard,
|
||||
0x0086 => Open,
|
||||
0x0165 => Option,
|
||||
0x0019 => P,
|
||||
0x006D => Pagedown,
|
||||
0x0068 => Pageup,
|
||||
0x0087 => Paste,
|
||||
0x0077 => Pause,
|
||||
0x0272 => PauseRecord,
|
||||
0x00C9 => PauseCd,
|
||||
0x0178 => Pc,
|
||||
0x00A9 => Phone,
|
||||
0x00CF => Play,
|
||||
0x00C8 => PlayCd,
|
||||
0x0183 => Player,
|
||||
0x00A4 => PlayPause,
|
||||
0x0074 => Power,
|
||||
0x0164 => Power2,
|
||||
0x01A9 => Presentation,
|
||||
0x019C => Previous,
|
||||
0x00A5 => PreviousSong,
|
||||
0x00D2 => Print,
|
||||
0x0279 => PrivacyScreenToggle,
|
||||
0x0094 => Prog1,
|
||||
0x0095 => Prog2,
|
||||
0x00CA => Prog3,
|
||||
0x00CB => Prog4,
|
||||
0x016A => Program,
|
||||
0x0082 => Props,
|
||||
0x016E => Pvr,
|
||||
0x0010 => Q,
|
||||
0x00D6 => Question,
|
||||
0x0013 => R,
|
||||
0x0181 => Radio,
|
||||
0x00A7 => Record,
|
||||
0x018E => Red,
|
||||
0x00B6 => Redo,
|
||||
0x00AD => Refresh,
|
||||
0x00E8 => Reply,
|
||||
0x0000 => Reserved,
|
||||
0x0198 => Restart,
|
||||
0x00A8 => Rewind,
|
||||
0x00F7 => RfKill,
|
||||
0x006A => Right,
|
||||
0x0267 => RightDown,
|
||||
0x0266 => RightUp,
|
||||
0x0064 => RightAlt,
|
||||
0x001B => RightBrace,
|
||||
0x0061 => RightCtrl,
|
||||
0x007E => RightMeta,
|
||||
0x0036 => RightShift,
|
||||
0x0059 => Ro,
|
||||
0x026A => RootMenu,
|
||||
0x0099 => RotateDisplay,
|
||||
0x0231 => RotateLockToggle,
|
||||
0x001F => S,
|
||||
0x017D => Sat,
|
||||
0x017E => Sat2,
|
||||
0x00EA => Save,
|
||||
0x0078 => Scale,
|
||||
0x0245 => Screensaver,
|
||||
0x00B2 => ScrollDown,
|
||||
0x0046 => ScrollLock,
|
||||
0x00B1 => ScrollUp,
|
||||
0x00D9 => Search,
|
||||
0x0161 => Select,
|
||||
0x027A => SelectiveScreenshot,
|
||||
0x0027 => Semicolon,
|
||||
0x00E7 => Send,
|
||||
0x0091 => SendFile,
|
||||
0x008D => Setup,
|
||||
0x00DD => Shop,
|
||||
0x019A => Shuffle,
|
||||
0x0035 => Slash,
|
||||
0x008E => Sleep,
|
||||
0x0199 => Slow,
|
||||
0x0276 => SlowReverse,
|
||||
0x00D5 => Sound,
|
||||
0x0039 => Space,
|
||||
0x01B0 => Spellcheck,
|
||||
0x00DC => Sport,
|
||||
0x01A7 => Spreadsheet,
|
||||
0x0080 => Stop,
|
||||
0x0271 => StopRecord,
|
||||
0x00A6 => StopCd,
|
||||
0x0172 => Subtitle,
|
||||
0x00CD => Suspend,
|
||||
0x00E3 => SwitchVideoMode,
|
||||
0x0063 => SysRq,
|
||||
0x0014 => T,
|
||||
0x000F => Tab,
|
||||
0x0180 => Tape,
|
||||
0x0241 => TaskManager,
|
||||
0x019E => Teen,
|
||||
0x0184 => Text,
|
||||
0x0167 => Time,
|
||||
0x0171 => Title,
|
||||
0x0214 => TouchpadOff,
|
||||
0x0213 => TouchpadOn,
|
||||
0x0212 => TouchpadToggle,
|
||||
0x0182 => Tuner,
|
||||
0x0179 => Tv,
|
||||
0x017A => Tv2,
|
||||
0x019F => Twen,
|
||||
0x0016 => U,
|
||||
0x0083 => Undo,
|
||||
0x00F0 => Unknown,
|
||||
0x0274 => Unmute,
|
||||
0x0067 => Up,
|
||||
0x00EF => Uwb,
|
||||
0x002F => V,
|
||||
0x017B => Vcr,
|
||||
0x017C => Vcr2,
|
||||
0x0168 => Vendor,
|
||||
0x0189 => Video,
|
||||
0x00F1 => VideoNext,
|
||||
0x00F2 => VideoPrev,
|
||||
0x01A0 => VideoPhone,
|
||||
0x0273 => Vod,
|
||||
0x0246 => VoiceCommand,
|
||||
0x01AC => VoiceMail,
|
||||
0x0072 => VolumeDown,
|
||||
0x0073 => VolumeUp,
|
||||
0x0011 => W,
|
||||
0x008F => WakeUp,
|
||||
0x00EE => Wlan,
|
||||
0x01A5 => WordProcessor,
|
||||
0x0211 => WpsButton,
|
||||
0x00F6 => Wwan,
|
||||
0x0096 => Www,
|
||||
0x002D => X,
|
||||
0x0093 => Xfer,
|
||||
0x0015 => Y,
|
||||
0x0190 => Yellow,
|
||||
0x007C => Yen,
|
||||
0x002C => Z,
|
||||
0x0055 => ZenkakuHankaku,
|
||||
0x01A2 => ZoomIn,
|
||||
0x01A3 => ZoomOut,
|
||||
0x01A4 => ZoomReset,
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(key)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
use crate::event::Event;
|
||||
use crate::event_reader::{EventReader, OpenError};
|
||||
use crate::event_writer::EventWriter;
|
||||
use crate::linux::event_reader::{EventReader, OpenError};
|
||||
use crate::linux::event_writer::EventWriter;
|
||||
use futures::StreamExt;
|
||||
use inotify::{Inotify, WatchMask};
|
||||
use std::io::{Error, ErrorKind};
|
|
@ -48,7 +48,11 @@ impl EventWriter {
|
|||
}
|
||||
|
||||
pub async fn write(&mut self, event: Event) -> Result<(), Error> {
|
||||
self.write_raw(event.to_raw()).await
|
||||
if let Some(event) = event.to_raw() {
|
||||
return self.write_raw(event).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn write_raw(&mut self, event: input_event) -> Result<(), Error> {
|
6
input/src/windows.rs
Normal file
6
input/src/windows.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
mod event;
|
||||
mod event_manager;
|
||||
mod event_writer;
|
||||
|
||||
pub use event_manager::EventManager;
|
||||
pub use event_writer::EventWriter;
|
107
input/src/windows/event.rs
Normal file
107
input/src/windows/event.rs
Normal file
|
@ -0,0 +1,107 @@
|
|||
mod button;
|
||||
mod key;
|
||||
|
||||
use crate::event::{Axis, Direction, Event};
|
||||
use winapi::um::winuser::{self, INPUT_u, INPUT, KEYBDINPUT, MOUSEINPUT};
|
||||
|
||||
impl Event {
|
||||
pub(crate) fn to_raw(&self) -> Option<INPUT> {
|
||||
let event = match *self {
|
||||
Event::MouseScroll { delta } => INPUT {
|
||||
type_: winuser::INPUT_MOUSE,
|
||||
u: {
|
||||
let mi = MOUSEINPUT {
|
||||
dx: 0,
|
||||
dy: 0,
|
||||
mouseData: if delta == winuser::WHEEL_DELTA as _ {
|
||||
delta - 1
|
||||
} else {
|
||||
delta
|
||||
} as _,
|
||||
dwFlags: winuser::MOUSEEVENTF_WHEEL,
|
||||
time: 0,
|
||||
dwExtraInfo: 0,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let mut u: INPUT_u = std::mem::zeroed();
|
||||
*u.mi_mut() = mi;
|
||||
|
||||
u
|
||||
}
|
||||
},
|
||||
},
|
||||
Event::MouseMove {
|
||||
axis: Axis::X,
|
||||
delta,
|
||||
} => INPUT {
|
||||
type_: winuser::INPUT_MOUSE,
|
||||
u: {
|
||||
let mi = MOUSEINPUT {
|
||||
dx: delta,
|
||||
dy: 0,
|
||||
mouseData: 0,
|
||||
dwFlags: winuser::MOUSEEVENTF_MOVE,
|
||||
time: 0,
|
||||
dwExtraInfo: 0,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let mut u: INPUT_u = std::mem::zeroed();
|
||||
*u.mi_mut() = mi;
|
||||
|
||||
u
|
||||
}
|
||||
},
|
||||
},
|
||||
Event::MouseMove {
|
||||
axis: Axis::Y,
|
||||
delta,
|
||||
} => INPUT {
|
||||
type_: winuser::INPUT_MOUSE,
|
||||
u: {
|
||||
let mi = MOUSEINPUT {
|
||||
dx: 0,
|
||||
dy: delta,
|
||||
mouseData: 0,
|
||||
dwFlags: winuser::MOUSEEVENTF_MOVE,
|
||||
time: 0,
|
||||
dwExtraInfo: 0,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let mut u: INPUT_u = std::mem::zeroed();
|
||||
*u.mi_mut() = mi;
|
||||
|
||||
u
|
||||
}
|
||||
},
|
||||
},
|
||||
Event::Key { direction, kind } => INPUT {
|
||||
type_: winuser::INPUT_KEYBOARD,
|
||||
u: {
|
||||
let ki = KEYBDINPUT {
|
||||
wVk: kind.to_raw()?,
|
||||
wScan: 0,
|
||||
dwFlags: if direction == Direction::Up {
|
||||
winuser::KEYEVENTF_KEYUP
|
||||
} else {
|
||||
0
|
||||
},
|
||||
time: 0,
|
||||
dwExtraInfo: 0,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let mut u: INPUT_u = std::mem::zeroed();
|
||||
*u.ki_mut() = ki;
|
||||
|
||||
u
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Some(event)
|
||||
}
|
||||
}
|
11
input/src/windows/event/button.rs
Normal file
11
input/src/windows/event/button.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
use crate::event::Button;
|
||||
|
||||
impl Button {
|
||||
pub(crate) fn to_raw(&self) -> Option<u16> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub(crate) fn from_raw(code: u16) -> Option<Self> {
|
||||
todo!()
|
||||
}
|
||||
}
|
11
input/src/windows/event/key.rs
Normal file
11
input/src/windows/event/key.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
use crate::event::Key;
|
||||
|
||||
impl Key {
|
||||
pub(crate) fn to_raw(&self) -> Option<u16> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub(crate) fn from_raw(code: u16) -> Option<Self> {
|
||||
todo!()
|
||||
}
|
||||
}
|
18
input/src/windows/event_manager.rs
Normal file
18
input/src/windows/event_manager.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
use crate::event::Event;
|
||||
use std::io::{Error, ErrorKind};
|
||||
|
||||
pub struct EventManager(());
|
||||
|
||||
impl EventManager {
|
||||
pub async fn new() -> Result<Self, Error> {
|
||||
Err(Error::new(ErrorKind::Other, "Not implemented"))
|
||||
}
|
||||
|
||||
pub async fn read(&mut self) -> Result<Event, Error> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn write(&mut self, event: Event) -> Result<(), Error> {
|
||||
todo!()
|
||||
}
|
||||
}
|
31
input/src/windows/event_writer.rs
Normal file
31
input/src/windows/event_writer.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use crate::event::Event;
|
||||
use std::io::Error;
|
||||
use winapi::um::winuser::{self, INPUT};
|
||||
|
||||
pub struct EventWriter(());
|
||||
|
||||
impl EventWriter {
|
||||
pub async fn new() -> Result<Self, Error> {
|
||||
Ok(Self(()))
|
||||
}
|
||||
|
||||
pub async fn write(&mut self, event: Event) -> Result<(), Error> {
|
||||
if let Some(event) = event.to_raw() {
|
||||
return self.write_raw(event).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn write_raw(&mut self, mut event: INPUT) -> Result<(), Error> {
|
||||
let written = unsafe {
|
||||
winuser::SendInput(1, &mut event as *mut _, std::mem::size_of_val(&event) as _)
|
||||
};
|
||||
|
||||
if written != 1 {
|
||||
return Err(Error::last_os_error());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue