mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Total refactor of structure. Builds faster
This commit is contained in:
213
Cargo.lock
generated
213
Cargo.lock
generated
@@ -6,22 +6,13 @@ version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2"
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.6.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
|
||||
dependencies = [
|
||||
"memchr 2.3.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
|
||||
dependencies = [
|
||||
"memchr 2.3.3",
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -46,20 +37,25 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.35.0"
|
||||
version = "0.53.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b023955126e7909ab9fc1d1973965b8b004f1f388afb5c589640ab483b3b0ad2"
|
||||
checksum = "6bb26d6a69a335b8cb0e7c7e9775cd5666611dc50a37177c3f2cedcfc040e8c8"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"cfg-if",
|
||||
"clang-sys",
|
||||
"clap",
|
||||
"env_logger 0.5.13",
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"log",
|
||||
"peeking_take_while",
|
||||
"quote 0.3.15",
|
||||
"regex 0.2.11",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"which",
|
||||
]
|
||||
|
||||
@@ -92,9 +88,9 @@ checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
version = "0.2.3"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42aac45e9567d97474a834efdee3081b3c942b2205be932092f53354ce503d6c"
|
||||
checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
@@ -107,9 +103,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "0.22.0"
|
||||
version = "0.29.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "939a1a34310b120d26eba35c29475933128b0ec58e24b43327f8dbe6036fc538"
|
||||
checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
@@ -166,23 +162,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ed9afacaea0301eefb738c9deea725e6d53938004597cdc518a8cf9a7aa2f03"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote 1.0.3",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.5.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex 1.3.7",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.7.1"
|
||||
@@ -192,7 +175,7 @@ dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex 1.3.7",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
@@ -210,9 +193,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.2.11"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
|
||||
[[package]]
|
||||
name = "gumdrop"
|
||||
@@ -230,7 +213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "915ef07c710d84733522461de2a734d4d62a3fd39a4d4f404c2f385ef8618d05"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote 1.0.3",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
@@ -258,6 +241,12 @@ version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.69"
|
||||
@@ -318,15 +307,6 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.3.3"
|
||||
@@ -335,11 +315,12 @@ checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "3.2.1"
|
||||
version = "5.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b"
|
||||
checksum = "0b471253da97532da4b61552249c521e01e736071f71c1a4f7ebbfbf0a06aad6"
|
||||
dependencies = [
|
||||
"memchr 1.0.2",
|
||||
"memchr",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -375,12 +356,6 @@ version = "1.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.3.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.3"
|
||||
@@ -396,38 +371,16 @@ version = "0.1.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
|
||||
dependencies = [
|
||||
"aho-corasick 0.6.10",
|
||||
"memchr 2.3.3",
|
||||
"regex-syntax 0.5.6",
|
||||
"thread_local 0.3.6",
|
||||
"utf8-ranges",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692"
|
||||
dependencies = [
|
||||
"aho-corasick 0.7.10",
|
||||
"memchr 2.3.3",
|
||||
"regex-syntax 0.6.17",
|
||||
"thread_local 1.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
|
||||
dependencies = [
|
||||
"ucd-util",
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
"thread_local",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -443,23 +396,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac"
|
||||
|
||||
[[package]]
|
||||
name = "rog-core"
|
||||
version = "0.3.3"
|
||||
dependencies = [
|
||||
"dbus",
|
||||
"env_logger 0.7.1",
|
||||
"gumdrop",
|
||||
"log",
|
||||
"rog-lib",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rog-lib"
|
||||
name = "rog-daemon"
|
||||
version = "0.4.1"
|
||||
dependencies = [
|
||||
"aho-corasick 0.7.10",
|
||||
"aho-corasick",
|
||||
"dbus",
|
||||
"env_logger",
|
||||
"gumdrop",
|
||||
"log",
|
||||
"rusb",
|
||||
@@ -482,6 +424,12 @@ dependencies = [
|
||||
"libusb1-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.106"
|
||||
@@ -495,10 +443,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote 1.0.3",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
@@ -512,7 +466,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote 1.0.3",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
@@ -577,19 +531,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca972988113b7715266f91250ddb98070d033c62a011fa0fcc57434a649310dd"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote 1.0.3",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.0.1"
|
||||
@@ -608,30 +553,24 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ucd-util"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c85f514e095d348c279b1e5cd76795082cf15bd59b93207832abe0b1d8fed236"
|
||||
|
||||
[[package]]
|
||||
name = "uhid-sys"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f4aed8167c39250d6661cd6e80f05d0a549cf57e1a34c5ad66fff658a525706"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uhid-virt"
|
||||
version = "0.0.2"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c6ade685b787ea3b980b5a47bdc54ef3943adbd41a72ea5352a12a0dc9d821"
|
||||
checksum = "03cee38747e38b73c5dd979a88eebc20829b78e785c2fb120c452305231a6340"
|
||||
dependencies = [
|
||||
"enumflags2",
|
||||
"libc",
|
||||
"uhid-sys",
|
||||
"uhidrs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uhidrs-sys"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d78b2a68a0769dc3b501bcc9127f561220ff54b485b3dd9aa97718fda91dbdaa"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -646,12 +585,6 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
|
||||
[[package]]
|
||||
name = "utf8-ranges"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.8"
|
||||
@@ -665,10 +598,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "1.0.5"
|
||||
name = "version_check"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e84a603e7e0b1ce1aa1ee2b109c7be00155ce52df5081590d1ffb93f4f515cb2"
|
||||
checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "3.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
@@ -691,9 +630,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa515c5163a99cc82bab70fd3bfdd36d827be85de63737b40fcef2ce084a436e"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
42
Cargo.toml
42
Cargo.toml
@@ -1,20 +1,28 @@
|
||||
[workspace]
|
||||
members = ["rog-core", "rog-lib"]
|
||||
[package]
|
||||
name = "rog-daemon"
|
||||
version = "0.4.1"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
edition = "2018"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
debug = false
|
||||
opt-level = 3
|
||||
#panic = "abort"
|
||||
[lib]
|
||||
name = "daemon"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[profile.dev]
|
||||
lto = true
|
||||
debug = true
|
||||
opt-level = 2
|
||||
#panic = "abort"
|
||||
|
||||
[profile.bench]
|
||||
lto = true
|
||||
debug = false
|
||||
opt-level = 3
|
||||
[[bin]]
|
||||
name = "rog-core"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
rusb = "0.5"
|
||||
gumdrop = "0.8"
|
||||
dbus = "0.7"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
toml = "0.5"
|
||||
sysfs-class = "0.1.2"
|
||||
aho-corasick = "0.7"
|
||||
thiserror = "1.0.15"
|
||||
log = "0.4"
|
||||
uhid-virt = "0.0.3"
|
||||
#keycode = "0.3"
|
||||
env_logger = "0.7"
|
||||
283
rog-core/Cargo.lock
generated
283
rog-core/Cargo.lock
generated
@@ -1,283 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "adler32"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2"
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80"
|
||||
dependencies = [
|
||||
"bit-vec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit-vec"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dbus"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "add8dd36d6d34a084220eb9fe216d3e230d52b37c31702e1ffda4fb2d4ef950e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"libdbus-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filetime"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f59efc38004c988e4201d11d263b8171f49a2e7ec0bdbb71773433f271504a5e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gumdrop"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46571f5d540478cf70d2a42dd0d6d8e9f4b9cc7531544b93311e657b86568a0b"
|
||||
dependencies = [
|
||||
"gumdrop_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gumdrop_derive"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "915ef07c710d84733522461de2a734d4d62a3fd39a4d4f404c2f385ef8618d05"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
|
||||
|
||||
[[package]]
|
||||
name = "libdbus-sys"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc12a3bc971424edbbf7edaf6e5740483444db63aa8e23d3751ff12a30f306f0"
|
||||
dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libflate"
|
||||
version = "0.1.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9135df43b1f5d0e333385cb6e7897ecd1a43d7d11b91ac003f4d2c2d2401fdd"
|
||||
dependencies = [
|
||||
"adler32",
|
||||
"crc32fast",
|
||||
"rle-decode-fast",
|
||||
"take_mut",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libusb1-sys"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0318f131edc8211a9a3e40133be6fc93f0b686e14f59c6115eab4e7bd794b34"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"libflate",
|
||||
"pkg-config",
|
||||
"tar",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
||||
|
||||
[[package]]
|
||||
name = "rle-decode-fast"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac"
|
||||
|
||||
[[package]]
|
||||
name = "rog-core"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"dbus",
|
||||
"gumdrop",
|
||||
"rusb",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rusb"
|
||||
version = "0.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d10caa3e5fc7ad1879a679bf16d3304ea10614b8f2f1a1386be4ec942d44062a"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"libc",
|
||||
"libusb1-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399"
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "take_mut"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60"
|
||||
|
||||
[[package]]
|
||||
name = "tar"
|
||||
version = "0.4.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3196bfbffbba3e57481b6ea32249fbaf590396a52505a2615adbb79d9d826d3"
|
||||
dependencies = [
|
||||
"filetime",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"xattr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "xattr"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
@@ -1,14 +0,0 @@
|
||||
[package]
|
||||
name = "rog-core"
|
||||
version = "0.3.3"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
gumdrop = "0.8"
|
||||
dbus = "0.7"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
log = "0.4"
|
||||
env_logger = "0.7"
|
||||
rog-lib = { path = "../rog-lib" }
|
||||
@@ -1,118 +0,0 @@
|
||||
use crate::{DBUS_IFACE, DBUS_PATH};
|
||||
use dbus::{
|
||||
blocking::Connection,
|
||||
tree::{Factory, MethodErr},
|
||||
};
|
||||
use log::{error, info, warn};
|
||||
use rog_lib::{
|
||||
core::RogCore,
|
||||
laptops::{match_laptop, LaptopRunner},
|
||||
};
|
||||
use std::error::Error;
|
||||
use std::time::Duration;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
pub(crate) struct Daemon {
|
||||
rogcore: RogCore,
|
||||
laptop: Box<dyn LaptopRunner>,
|
||||
}
|
||||
|
||||
impl Daemon {
|
||||
pub(crate) fn new() -> Self {
|
||||
let laptop = match_laptop();
|
||||
|
||||
Daemon {
|
||||
rogcore: RogCore::new(&*laptop).map_or_else(
|
||||
|err| {
|
||||
error!("{}", err);
|
||||
panic!("{}", err);
|
||||
},
|
||||
|daemon| {
|
||||
info!("RogCore loaded");
|
||||
daemon
|
||||
},
|
||||
),
|
||||
laptop,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn start() -> Result<(), Box<dyn Error>> {
|
||||
let mut connection = Connection::new_system().map_or_else(
|
||||
|err| {
|
||||
error!("{:?}", err);
|
||||
panic!("{:?}", err);
|
||||
},
|
||||
|dbus| {
|
||||
info!("DBus connected");
|
||||
dbus
|
||||
},
|
||||
);
|
||||
connection.request_name(DBUS_IFACE, false, true, false)?;
|
||||
let factory = Factory::new_fnmut::<()>();
|
||||
|
||||
let daemon = Self::new();
|
||||
let daemon = Rc::new(RefCell::new(daemon));
|
||||
|
||||
// We create a tree with one object path inside and make that path introspectable.
|
||||
let tree = factory.tree(()).add(
|
||||
factory.object_path(DBUS_PATH, ()).introspectable().add(
|
||||
// We add an interface to the object path...
|
||||
factory
|
||||
.interface(DBUS_IFACE, ())
|
||||
// ...and a method inside the interface
|
||||
.add_m(
|
||||
factory
|
||||
.method("ledmessage", (), {
|
||||
let daemon = daemon.clone();
|
||||
move |m| {
|
||||
// Reads the args passed to the method
|
||||
let bytes: Vec<u8> = m.msg.read1()?;
|
||||
let supported =
|
||||
Vec::from(daemon.borrow().laptop.supported_modes());
|
||||
match daemon
|
||||
.borrow_mut()
|
||||
.rogcore
|
||||
.aura_set_and_save(&supported, &bytes[..])
|
||||
{
|
||||
Ok(_) => {
|
||||
let s = format!("Wrote {:x?}", bytes);
|
||||
let mret = m.msg.method_return().append1(&s);
|
||||
Ok(vec![mret])
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("{:?}", err);
|
||||
Err(MethodErr::failed(&err))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// Input?
|
||||
.outarg::<&str, _>("reply")
|
||||
.inarg::<Vec<u8>, _>("bytearray"),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// We add the tree to the connection so that incoming method calls will be handled.
|
||||
tree.start_receive(&connection);
|
||||
|
||||
loop {
|
||||
connection
|
||||
.process(Duration::from_millis(10))
|
||||
.unwrap_or_else(|err| {
|
||||
error!("{:?}", err);
|
||||
false
|
||||
});
|
||||
|
||||
// TODO: this needs to move to a thread, but there is unsafety
|
||||
let borrowed_daemon = daemon.borrow_mut();
|
||||
let mut rogcore = unsafe { &mut (*daemon.as_ptr()).rogcore };
|
||||
borrowed_daemon
|
||||
.laptop
|
||||
.run(&mut rogcore)
|
||||
.unwrap_or_else(|err| {
|
||||
error!("{:?}", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
283
rog-lib/Cargo.lock
generated
283
rog-lib/Cargo.lock
generated
@@ -1,283 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "adler32"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2"
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80"
|
||||
dependencies = [
|
||||
"bit-vec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit-vec"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dbus"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "add8dd36d6d34a084220eb9fe216d3e230d52b37c31702e1ffda4fb2d4ef950e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"libdbus-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filetime"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f59efc38004c988e4201d11d263b8171f49a2e7ec0bdbb71773433f271504a5e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gumdrop"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46571f5d540478cf70d2a42dd0d6d8e9f4b9cc7531544b93311e657b86568a0b"
|
||||
dependencies = [
|
||||
"gumdrop_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gumdrop_derive"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "915ef07c710d84733522461de2a734d4d62a3fd39a4d4f404c2f385ef8618d05"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
|
||||
|
||||
[[package]]
|
||||
name = "libdbus-sys"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc12a3bc971424edbbf7edaf6e5740483444db63aa8e23d3751ff12a30f306f0"
|
||||
dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libflate"
|
||||
version = "0.1.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9135df43b1f5d0e333385cb6e7897ecd1a43d7d11b91ac003f4d2c2d2401fdd"
|
||||
dependencies = [
|
||||
"adler32",
|
||||
"crc32fast",
|
||||
"rle-decode-fast",
|
||||
"take_mut",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libusb1-sys"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0318f131edc8211a9a3e40133be6fc93f0b686e14f59c6115eab4e7bd794b34"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"libflate",
|
||||
"pkg-config",
|
||||
"tar",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
||||
|
||||
[[package]]
|
||||
name = "rle-decode-fast"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac"
|
||||
|
||||
[[package]]
|
||||
name = "rog-core"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"dbus",
|
||||
"gumdrop",
|
||||
"rusb",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rusb"
|
||||
version = "0.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d10caa3e5fc7ad1879a679bf16d3304ea10614b8f2f1a1386be4ec942d44062a"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"libc",
|
||||
"libusb1-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399"
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "take_mut"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60"
|
||||
|
||||
[[package]]
|
||||
name = "tar"
|
||||
version = "0.4.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3196bfbffbba3e57481b6ea32249fbaf590396a52505a2615adbb79d9d826d3"
|
||||
dependencies = [
|
||||
"filetime",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"xattr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "xattr"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
@@ -1,18 +0,0 @@
|
||||
[package]
|
||||
name = "rog-lib"
|
||||
version = "0.4.1"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
rusb = "0.5"
|
||||
gumdrop = "0.8"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
toml = "0.5"
|
||||
sysfs-class = "0.1.2"
|
||||
aho-corasick = "0.7"
|
||||
thiserror = "1.0.15"
|
||||
log = "0.4"
|
||||
uhid-virt = "0.0.2"
|
||||
#keycode = "0.3"
|
||||
@@ -1,256 +0,0 @@
|
||||
use crate::aura::BuiltInModeByte;
|
||||
use crate::core::{Backlight, RogCore};
|
||||
use crate::error::AuraError;
|
||||
use crate::virt_device::ConsumerKeys;
|
||||
//use keycode::{KeyMap, KeyMappingId, KeyState, KeyboardState};
|
||||
use log::info;
|
||||
|
||||
pub fn match_laptop() -> Box<dyn LaptopRunner> {
|
||||
let dmi = sysfs_class::DmiId::default();
|
||||
let board_name = dmi.board_name().unwrap();
|
||||
match board_name.as_str() {
|
||||
// The hell does it have a \n for anyway?
|
||||
"GX502GW\n" => Box::new(LaptopGX502GW::new()),
|
||||
_ => {
|
||||
panic!("could not match laptop");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// All laptop models should implement this trait. The role of a `Laptop` is to
|
||||
/// "drive" the `RogCore`.
|
||||
///
|
||||
/// `do_hotkey_action` is passed the byte that a hotkey emits, and is expected to
|
||||
/// perform whichever action matches that. For now the only key bytes passed in are
|
||||
/// the ones which match `byte[0] == hotkey_group_byte`. On the GX502GW the keyboard
|
||||
/// has 3 explicit groups: main, vol+media, and the ones that the Linux kernel doesn't
|
||||
/// map.
|
||||
pub(crate) trait Laptop {
|
||||
fn hotkey_group_bytes(&self) -> &[u8];
|
||||
fn board_name(&self) -> &str;
|
||||
fn prod_family(&self) -> &str;
|
||||
}
|
||||
|
||||
/// The public interface for running a laptop. Primarily used by the daemon.
|
||||
pub trait LaptopRunner {
|
||||
fn run(&self, core: &mut RogCore) -> Result<(), AuraError>;
|
||||
fn led_iface_num(&self) -> u8;
|
||||
fn key_iface_num(&self) -> u8;
|
||||
fn usb_vendor(&self) -> u16;
|
||||
fn usb_product(&self) -> u16;
|
||||
fn supported_modes(&self) -> &[BuiltInModeByte];
|
||||
}
|
||||
|
||||
pub(crate) struct LaptopGX502GW {
|
||||
usb_vendor: u16,
|
||||
usb_product: u16,
|
||||
board_name: &'static str,
|
||||
prod_family: &'static str,
|
||||
hotkey_group_bytes: [u8; 2],
|
||||
min_led_bright: u8,
|
||||
max_led_bright: u8,
|
||||
led_iface_num: u8,
|
||||
key_iface_num: u8,
|
||||
supported_modes: [BuiltInModeByte; 12],
|
||||
backlight: Backlight,
|
||||
}
|
||||
|
||||
impl LaptopGX502GW {
|
||||
pub fn new() -> Self {
|
||||
// Find backlight
|
||||
LaptopGX502GW {
|
||||
usb_vendor: 0x0B05,
|
||||
usb_product: 0x1866,
|
||||
board_name: "GX502GW",
|
||||
prod_family: "Zephyrus S",
|
||||
hotkey_group_bytes: [0x5a, 0x02],
|
||||
min_led_bright: 0x00,
|
||||
max_led_bright: 0x03,
|
||||
led_iface_num: 0x81,
|
||||
key_iface_num: 0x83,
|
||||
supported_modes: [
|
||||
BuiltInModeByte::Stable,
|
||||
BuiltInModeByte::Breathe,
|
||||
BuiltInModeByte::Cycle,
|
||||
BuiltInModeByte::Rainbow,
|
||||
BuiltInModeByte::Rain,
|
||||
BuiltInModeByte::Random,
|
||||
BuiltInModeByte::Highlight,
|
||||
BuiltInModeByte::Laser,
|
||||
BuiltInModeByte::Ripple,
|
||||
BuiltInModeByte::Pulse,
|
||||
BuiltInModeByte::ThinZoomy,
|
||||
BuiltInModeByte::WideZoomy,
|
||||
],
|
||||
backlight: Backlight::new("intel_backlight").unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LaptopRunner for LaptopGX502GW {
|
||||
// TODO: This really needs to match against u16 in future
|
||||
fn run(&self, rogcore: &mut RogCore) -> Result<(), AuraError> {
|
||||
let mut key_buf = [0u8; 32];
|
||||
rogcore.poll_keyboard(&self.hotkey_group_bytes, &mut key_buf)?;
|
||||
|
||||
match GX502GWKeys::from(key_buf[1]) {
|
||||
GX502GWKeys::LedBrightUp => {
|
||||
let mut bright = rogcore.config().brightness;
|
||||
if bright < self.max_led_bright {
|
||||
bright += 1;
|
||||
rogcore.config_mut().brightness = bright;
|
||||
}
|
||||
let bytes = RogCore::aura_brightness_bytes(bright)?;
|
||||
rogcore.aura_set_and_save(&self.supported_modes, &bytes)?;
|
||||
}
|
||||
GX502GWKeys::LedBrightDown => {
|
||||
let mut bright = rogcore.config().brightness;
|
||||
if bright > self.min_led_bright {
|
||||
bright -= 1;
|
||||
rogcore.config_mut().brightness = bright;
|
||||
}
|
||||
let bytes = RogCore::aura_brightness_bytes(bright)?;
|
||||
rogcore.aura_set_and_save(&self.supported_modes, &bytes)?;
|
||||
}
|
||||
GX502GWKeys::AuraNext => {
|
||||
let mut mode = rogcore.config().current_mode[3] + 1;
|
||||
if mode > 0x0c {
|
||||
mode = 0x00
|
||||
} else if mode == 0x09 {
|
||||
mode = 0x0a
|
||||
}
|
||||
rogcore.config_mut().current_mode[3] = mode;
|
||||
if let Some(bytes) = rogcore.config_mut().get_current() {
|
||||
rogcore.aura_set_and_save(&self.supported_modes, &bytes)?;
|
||||
}
|
||||
}
|
||||
GX502GWKeys::AuraPrevious => {
|
||||
let mut mode = rogcore.config().current_mode[3];
|
||||
if mode == 0x00 {
|
||||
mode = 0x0c
|
||||
} else if mode - 1 == 0x09 {
|
||||
mode = 0x08
|
||||
} else {
|
||||
mode -= 1;
|
||||
}
|
||||
rogcore.config_mut().current_mode[3] = mode;
|
||||
if let Some(bytes) = rogcore.config_mut().get_current() {
|
||||
rogcore.aura_set_and_save(&self.supported_modes, &bytes)?;
|
||||
rogcore.config().write();
|
||||
}
|
||||
}
|
||||
GX502GWKeys::ScreenBrightUp => {
|
||||
self.backlight.step_up();
|
||||
}
|
||||
GX502GWKeys::ScreenBrightDown => {
|
||||
self.backlight.step_down();
|
||||
}
|
||||
GX502GWKeys::Sleep => {
|
||||
// Direct call to systemd
|
||||
rogcore.suspend_with_systemd();
|
||||
//rogcore.virt_keys().press([0x01, 0, 0, 0x82, 0, 0, 0, 0]);
|
||||
// Power menu
|
||||
//rogcore.virt_keys().press([0x01, 0, 0, 0x66, 0, 0, 0, 0]);
|
||||
}
|
||||
GX502GWKeys::AirplaneMode => {
|
||||
rogcore.toggle_airplane_mode();
|
||||
}
|
||||
|
||||
GX502GWKeys::MicToggle => {}
|
||||
GX502GWKeys::Fan => {}
|
||||
GX502GWKeys::ScreenToggle => {
|
||||
rogcore.virt_keys().press(ConsumerKeys::BacklightTog.into());
|
||||
}
|
||||
GX502GWKeys::TouchPadToggle => {
|
||||
// F21 key, Touchpad toggle
|
||||
rogcore.virt_keys().press([0x01, 0, 0, 0x70, 0, 0, 0, 0]);
|
||||
// rogcore.virt_keys().press([0x01, 0, 0, 0x71, 0, 0, 0, 0]); // Touchpad on F22
|
||||
// rogcore.virt_keys().press([0x01, 0, 0, 0x72, 0, 0, 0, 0]); // Touchpad off F23
|
||||
}
|
||||
GX502GWKeys::Rog => {
|
||||
rogcore.virt_keys().press([0x01, 0, 0, 0x68, 0, 0, 0, 0]); // XF86Tools? F13
|
||||
}
|
||||
|
||||
GX502GWKeys::None => {
|
||||
if key_buf[1] != 0 {
|
||||
info!(
|
||||
"Unmapped key, attempt to pass to virtual device: {:X?}",
|
||||
&key_buf[1]
|
||||
);
|
||||
let mut bytes = [0u8; 8];
|
||||
// TODO: code page
|
||||
bytes[0] = 0x02;
|
||||
bytes[1] = key_buf[1];
|
||||
rogcore.virt_keys().press(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn led_iface_num(&self) -> u8 {
|
||||
self.led_iface_num
|
||||
}
|
||||
fn key_iface_num(&self) -> u8 {
|
||||
self.key_iface_num
|
||||
}
|
||||
fn usb_vendor(&self) -> u16 {
|
||||
self.usb_vendor
|
||||
}
|
||||
fn usb_product(&self) -> u16 {
|
||||
self.usb_product
|
||||
}
|
||||
fn supported_modes(&self) -> &[BuiltInModeByte] {
|
||||
&self.supported_modes
|
||||
}
|
||||
}
|
||||
|
||||
impl Laptop for LaptopGX502GW {
|
||||
fn hotkey_group_bytes(&self) -> &[u8] {
|
||||
&self.hotkey_group_bytes
|
||||
}
|
||||
fn board_name(&self) -> &str {
|
||||
&self.board_name
|
||||
}
|
||||
fn prod_family(&self) -> &str {
|
||||
&self.prod_family
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum GX502GWKeys {
|
||||
Rog = 0x38,
|
||||
MicToggle = 0x7C,
|
||||
Fan = 0xAE,
|
||||
ScreenToggle = 0x35,
|
||||
ScreenBrightDown = 0x10,
|
||||
ScreenBrightUp = 0x20,
|
||||
TouchPadToggle = 0x6b,
|
||||
Sleep = 0x6C,
|
||||
AirplaneMode = 0x88,
|
||||
LedBrightUp = 0xC4,
|
||||
LedBrightDown = 0xC5,
|
||||
AuraPrevious = 0xB2,
|
||||
AuraNext = 0xB3,
|
||||
None,
|
||||
}
|
||||
|
||||
impl From<u8> for GX502GWKeys {
|
||||
fn from(byte: u8) -> Self {
|
||||
match byte {
|
||||
0x38 => GX502GWKeys::Rog,
|
||||
0x7C => GX502GWKeys::MicToggle,
|
||||
0xAE => GX502GWKeys::Fan,
|
||||
0x35 => GX502GWKeys::ScreenToggle,
|
||||
0x10 => GX502GWKeys::ScreenBrightDown,
|
||||
0x20 => GX502GWKeys::ScreenBrightUp,
|
||||
0x6b => GX502GWKeys::TouchPadToggle,
|
||||
0x6C => GX502GWKeys::Sleep,
|
||||
0x88 => GX502GWKeys::AirplaneMode,
|
||||
0xC4 => GX502GWKeys::LedBrightUp,
|
||||
0xC5 => GX502GWKeys::LedBrightDown,
|
||||
0xB2 => GX502GWKeys::AuraPrevious,
|
||||
0xB3 => GX502GWKeys::AuraNext,
|
||||
_ => GX502GWKeys::None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ use crate::{
|
||||
};
|
||||
use aho_corasick::AhoCorasick;
|
||||
use gumdrop::Options;
|
||||
use log::warn;
|
||||
use log::{error, warn};
|
||||
use rusb::DeviceHandle;
|
||||
use std::process::Command;
|
||||
use std::str::FromStr;
|
||||
@@ -32,7 +32,7 @@ static LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
/// - `LED_INIT4`
|
||||
/// - `LED_INIT2`
|
||||
/// - `LED_INIT4`
|
||||
pub struct RogCore {
|
||||
pub(crate) struct RogCore {
|
||||
handle: DeviceHandle<rusb::GlobalContext>,
|
||||
initialised: bool,
|
||||
led_endpoint: u8,
|
||||
@@ -42,7 +42,7 @@ pub struct RogCore {
|
||||
}
|
||||
|
||||
impl RogCore {
|
||||
pub fn new(laptop: &dyn LaptopRunner) -> Result<RogCore, AuraError> {
|
||||
pub(crate) fn new(laptop: &dyn Laptop) -> Result<RogCore, AuraError> {
|
||||
let mut dev_handle = RogCore::get_device(laptop.usb_vendor(), laptop.usb_product())?;
|
||||
dev_handle.set_active_configuration(0).unwrap_or(());
|
||||
|
||||
@@ -53,9 +53,9 @@ impl RogCore {
|
||||
for iface in dev_config.interfaces() {
|
||||
for desc in iface.descriptors() {
|
||||
for endpoint in desc.endpoint_descriptors() {
|
||||
if endpoint.address() == laptop.key_iface_num() {
|
||||
if endpoint.address() == laptop.key_endpoint() {
|
||||
keys_interface_num = desc.interface_number();
|
||||
} else if endpoint.address() == laptop.led_iface_num() {
|
||||
} else if endpoint.address() == laptop.led_endpoint() {
|
||||
led_interface_num = desc.interface_number();
|
||||
break;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ impl RogCore {
|
||||
handle: dev_handle,
|
||||
initialised: false,
|
||||
led_endpoint: led_interface_num,
|
||||
keys_endpoint: keys_interface_num,
|
||||
keys_endpoint: laptop.key_endpoint(),
|
||||
config: Config::default().read(),
|
||||
virt_keys: VirtKeys::new(),
|
||||
})
|
||||
@@ -142,26 +142,22 @@ impl RogCore {
|
||||
///
|
||||
/// `report_filter_bytes` is used to filter the data read from the interupt so
|
||||
/// only the relevant byte array is returned.
|
||||
pub(crate) fn poll_keyboard(
|
||||
&mut self,
|
||||
report_filter_bytes: &[u8],
|
||||
buf: &mut [u8; 32],
|
||||
) -> Result<Option<usize>, AuraError> {
|
||||
let res =
|
||||
match self
|
||||
.handle
|
||||
.read_interrupt(self.keys_endpoint, buf, Duration::from_micros(1))
|
||||
{
|
||||
Ok(o) => {
|
||||
if report_filter_bytes.contains(&buf[0]) {
|
||||
Ok(Some(o))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
pub(crate) fn poll_keyboard(&mut self, report_filter_bytes: &[u8]) -> Option<[u8; 32]> {
|
||||
let mut buf = [0u8; 32];
|
||||
match self
|
||||
.handle
|
||||
.read_interrupt(self.keys_endpoint, &mut buf, Duration::from_micros(1))
|
||||
{
|
||||
Ok(_) => {
|
||||
if report_filter_bytes.contains(&buf[0]) {
|
||||
return Some(buf);
|
||||
}
|
||||
Err(err) => Err(AuraError::UsbError(err)),
|
||||
};
|
||||
res
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Failed to read keyboard interrupt: {:?}", err);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// A direct call to systemd to suspend the PC.
|
||||
@@ -214,13 +210,6 @@ impl RogCore {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn aura_brightness_bytes(brightness: u8) -> Result<[u8; 17], AuraError> {
|
||||
// TODO: check brightness range
|
||||
Ok([
|
||||
0x5A, 0xBA, 0xC5, 0xC4, brightness, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
])
|
||||
}
|
||||
|
||||
pub fn aura_set_and_save(
|
||||
&mut self,
|
||||
supported_modes: &[BuiltInModeByte],
|
||||
@@ -319,3 +308,10 @@ impl FromStr for LedBrightness {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn aura_brightness_bytes(brightness: u8) -> [u8; 17] {
|
||||
// TODO: check brightness range
|
||||
[
|
||||
0x5A, 0xBA, 0xC5, 0xC4, brightness, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
]
|
||||
}
|
||||
98
src/daemon.rs
Normal file
98
src/daemon.rs
Normal file
@@ -0,0 +1,98 @@
|
||||
pub static DBUS_NAME: &'static str = "org.rogcore.Daemon";
|
||||
pub static DBUS_PATH: &'static str = "/org/rogcore/Daemon";
|
||||
pub static DBUS_IFACE: &'static str = "org.rogcore.Daemon";
|
||||
|
||||
use crate::{core::RogCore, laptops::match_laptop};
|
||||
use dbus::{
|
||||
blocking::Connection,
|
||||
tree::{Factory, MethodErr},
|
||||
};
|
||||
use log::{error, info, warn};
|
||||
use std::error::Error;
|
||||
use std::time::Duration;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
pub fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
let laptop = match_laptop();
|
||||
let rogcore = RogCore::new(&*laptop).map_or_else(
|
||||
|err| {
|
||||
error!("{}", err);
|
||||
panic!("{}", err);
|
||||
},
|
||||
|daemon| {
|
||||
info!("RogCore loaded");
|
||||
daemon
|
||||
},
|
||||
);
|
||||
|
||||
let mut connection = Connection::new_system().map_or_else(
|
||||
|err| {
|
||||
error!("{:?}", err);
|
||||
panic!("{:?}", err);
|
||||
},
|
||||
|dbus| {
|
||||
info!("DBus connected");
|
||||
dbus
|
||||
},
|
||||
);
|
||||
connection.request_name(DBUS_IFACE, false, true, false)?;
|
||||
let factory = Factory::new_fnmut::<()>();
|
||||
|
||||
let daemon = Rc::new(RefCell::new(rogcore));
|
||||
|
||||
// We create a tree with one object path inside and make that path introspectable.
|
||||
let tree = factory.tree(()).add(
|
||||
factory.object_path(DBUS_PATH, ()).introspectable().add(
|
||||
// We add an interface to the object path...
|
||||
factory
|
||||
.interface(DBUS_IFACE, ())
|
||||
// ...and a method inside the interface
|
||||
.add_m(
|
||||
factory
|
||||
.method("ledmessage", (), {
|
||||
let daemon = daemon.clone();
|
||||
let supported = Vec::from(laptop.supported_modes());
|
||||
move |m| {
|
||||
// Reads the args passed to the method
|
||||
let bytes: Vec<u8> = m.msg.read1()?;
|
||||
match daemon
|
||||
.borrow_mut()
|
||||
.aura_set_and_save(&supported, &bytes[..])
|
||||
{
|
||||
Ok(_) => {
|
||||
let s = format!("Wrote {:x?}", bytes);
|
||||
let mret = m.msg.method_return().append1(&s);
|
||||
Ok(vec![mret])
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("{:?}", err);
|
||||
Err(MethodErr::failed(&err))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// Input?
|
||||
.outarg::<&str, _>("reply")
|
||||
.inarg::<Vec<u8>, _>("bytearray"),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// We add the tree to the connection so that incoming method calls will be handled.
|
||||
tree.start_receive(&connection);
|
||||
|
||||
loop {
|
||||
connection
|
||||
.process(Duration::from_millis(10))
|
||||
.unwrap_or_else(|err| {
|
||||
error!("{:?}", err);
|
||||
false
|
||||
});
|
||||
|
||||
// TODO: this needs to move to a thread, but there is unsafety
|
||||
let mut borrowed_daemon = daemon.borrow_mut();
|
||||
laptop.run(&mut borrowed_daemon).unwrap_or_else(|err| {
|
||||
error!("{:?}", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
244
src/laptops.rs
Normal file
244
src/laptops.rs
Normal file
@@ -0,0 +1,244 @@
|
||||
use crate::aura::BuiltInModeByte;
|
||||
use crate::core::{aura_brightness_bytes, Backlight, RogCore};
|
||||
use crate::error::AuraError;
|
||||
use crate::virt_device::ConsumerKeys;
|
||||
//use keycode::{KeyMap, KeyMappingId, KeyState, KeyboardState};
|
||||
use log::info;
|
||||
|
||||
pub(crate) fn match_laptop() -> Box<dyn Laptop> {
|
||||
let dmi = sysfs_class::DmiId::default();
|
||||
let board_name = dmi.board_name().unwrap();
|
||||
match board_name.as_str() {
|
||||
// The hell does it have a \n for anyway?
|
||||
"GX502GW\n" => Box::new(LaptopGX502GW::new()),
|
||||
_ => {
|
||||
panic!("could not match laptop");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// All laptop models should implement this trait. The role of a `Laptop` is to
|
||||
/// "drive" the `RogCore`.
|
||||
///
|
||||
/// `do_hotkey_action` is passed the byte that a hotkey emits, and is expected to
|
||||
/// perform whichever action matches that. For now the only key bytes passed in are
|
||||
/// the ones which match `byte[0] == hotkey_group_byte`. On the GX502GW the keyboard
|
||||
/// has 3 explicit groups: main, vol+media, and the ones that the Linux kernel doesn't
|
||||
/// map.
|
||||
pub(crate) trait Laptop {
|
||||
fn board_name(&self) -> &str;
|
||||
fn prod_family(&self) -> &str;
|
||||
fn run(&self, core: &mut RogCore) -> Result<(), AuraError>;
|
||||
fn led_endpoint(&self) -> u8;
|
||||
fn key_endpoint(&self) -> u8;
|
||||
fn usb_vendor(&self) -> u16;
|
||||
fn usb_product(&self) -> u16;
|
||||
fn supported_modes(&self) -> &[BuiltInModeByte];
|
||||
}
|
||||
|
||||
pub(crate) struct LaptopGX502GW {
|
||||
usb_vendor: u16,
|
||||
usb_product: u16,
|
||||
board_name: &'static str,
|
||||
prod_family: &'static str,
|
||||
report_filter_bytes: [u8; 2],
|
||||
min_led_bright: u8,
|
||||
max_led_bright: u8,
|
||||
led_endpoint: u8,
|
||||
key_endpoint: u8,
|
||||
supported_modes: [BuiltInModeByte; 12],
|
||||
backlight: Backlight,
|
||||
}
|
||||
|
||||
impl LaptopGX502GW {
|
||||
pub fn new() -> Self {
|
||||
// Find backlight
|
||||
LaptopGX502GW {
|
||||
usb_vendor: 0x0B05,
|
||||
usb_product: 0x1866,
|
||||
board_name: "GX502GW",
|
||||
prod_family: "Zephyrus S",
|
||||
report_filter_bytes: [0x5a, 0x02],
|
||||
min_led_bright: 0x00,
|
||||
max_led_bright: 0x03,
|
||||
led_endpoint: 0x81,
|
||||
key_endpoint: 0x83,
|
||||
supported_modes: [
|
||||
BuiltInModeByte::Stable,
|
||||
BuiltInModeByte::Breathe,
|
||||
BuiltInModeByte::Cycle,
|
||||
BuiltInModeByte::Rainbow,
|
||||
BuiltInModeByte::Rain,
|
||||
BuiltInModeByte::Random,
|
||||
BuiltInModeByte::Highlight,
|
||||
BuiltInModeByte::Laser,
|
||||
BuiltInModeByte::Ripple,
|
||||
BuiltInModeByte::Pulse,
|
||||
BuiltInModeByte::ThinZoomy,
|
||||
BuiltInModeByte::WideZoomy,
|
||||
],
|
||||
backlight: Backlight::new("intel_backlight").unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Laptop for LaptopGX502GW {
|
||||
// TODO: This really needs to match against u16 in future
|
||||
fn run(&self, rogcore: &mut RogCore) -> Result<(), AuraError> {
|
||||
if let Some(key_buf) = rogcore.poll_keyboard(&self.report_filter_bytes) {
|
||||
match GX502GWKeys::from(key_buf[1]) {
|
||||
GX502GWKeys::LedBrightUp => {
|
||||
let mut bright = rogcore.config().brightness;
|
||||
if bright < self.max_led_bright {
|
||||
bright += 1;
|
||||
rogcore.config_mut().brightness = bright;
|
||||
}
|
||||
let bytes = aura_brightness_bytes(bright);
|
||||
rogcore.aura_set_and_save(&self.supported_modes, &bytes)?;
|
||||
}
|
||||
GX502GWKeys::LedBrightDown => {
|
||||
let mut bright = rogcore.config().brightness;
|
||||
if bright > self.min_led_bright {
|
||||
bright -= 1;
|
||||
rogcore.config_mut().brightness = bright;
|
||||
}
|
||||
let bytes = aura_brightness_bytes(bright);
|
||||
rogcore.aura_set_and_save(&self.supported_modes, &bytes)?;
|
||||
}
|
||||
GX502GWKeys::AuraNext => {
|
||||
let mut mode = rogcore.config().current_mode[3] + 1;
|
||||
if mode > 0x0c {
|
||||
mode = 0x00
|
||||
} else if mode == 0x09 {
|
||||
mode = 0x0a
|
||||
}
|
||||
rogcore.config_mut().current_mode[3] = mode;
|
||||
if let Some(bytes) = rogcore.config_mut().get_current() {
|
||||
rogcore.aura_set_and_save(&self.supported_modes, &bytes)?;
|
||||
}
|
||||
}
|
||||
GX502GWKeys::AuraPrevious => {
|
||||
let mut mode = rogcore.config().current_mode[3];
|
||||
if mode == 0x00 {
|
||||
mode = 0x0c
|
||||
} else if mode - 1 == 0x09 {
|
||||
mode = 0x08
|
||||
} else {
|
||||
mode -= 1;
|
||||
}
|
||||
rogcore.config_mut().current_mode[3] = mode;
|
||||
if let Some(bytes) = rogcore.config_mut().get_current() {
|
||||
rogcore.aura_set_and_save(&self.supported_modes, &bytes)?;
|
||||
rogcore.config().write();
|
||||
}
|
||||
}
|
||||
GX502GWKeys::ScreenBrightUp => {
|
||||
self.backlight.step_up();
|
||||
}
|
||||
GX502GWKeys::ScreenBrightDown => {
|
||||
self.backlight.step_down();
|
||||
}
|
||||
GX502GWKeys::Sleep => {
|
||||
// Direct call to systemd
|
||||
rogcore.suspend_with_systemd();
|
||||
//rogcore.virt_keys().press([0x01, 0, 0, 0x82, 0, 0, 0, 0]);
|
||||
// Power menu
|
||||
//rogcore.virt_keys().press([0x01, 0, 0, 0x66, 0, 0, 0, 0]);
|
||||
}
|
||||
GX502GWKeys::AirplaneMode => {
|
||||
rogcore.toggle_airplane_mode();
|
||||
}
|
||||
|
||||
GX502GWKeys::MicToggle => {}
|
||||
GX502GWKeys::Fan => {}
|
||||
GX502GWKeys::ScreenToggle => {
|
||||
rogcore.virt_keys().press(ConsumerKeys::BacklightTog.into());
|
||||
}
|
||||
GX502GWKeys::TouchPadToggle => {
|
||||
// F21 key, Touchpad toggle
|
||||
rogcore.virt_keys().press([0x01, 0, 0, 0x70, 0, 0, 0, 0]);
|
||||
// rogcore.virt_keys().press([0x01, 0, 0, 0x71, 0, 0, 0, 0]); // Touchpad on F22
|
||||
// rogcore.virt_keys().press([0x01, 0, 0, 0x72, 0, 0, 0, 0]); // Touchpad off F23
|
||||
}
|
||||
GX502GWKeys::Rog => {
|
||||
rogcore.virt_keys().press([0x01, 0, 0, 0x68, 0, 0, 0, 0]); // XF86Tools? F13
|
||||
}
|
||||
|
||||
GX502GWKeys::None => {
|
||||
if key_buf[0] != 0 && key_buf[1] != 0 {
|
||||
info!(
|
||||
"Unmapped key, attempt to pass to virtual device: {:X?}",
|
||||
&key_buf[1]
|
||||
);
|
||||
let mut bytes = [0u8; 8];
|
||||
// TODO: code page
|
||||
bytes[0] = key_buf[0];
|
||||
bytes[1] = key_buf[1];
|
||||
rogcore.virt_keys().press(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn led_endpoint(&self) -> u8 {
|
||||
self.led_endpoint
|
||||
}
|
||||
fn key_endpoint(&self) -> u8 {
|
||||
self.key_endpoint
|
||||
}
|
||||
fn usb_vendor(&self) -> u16 {
|
||||
self.usb_vendor
|
||||
}
|
||||
fn usb_product(&self) -> u16 {
|
||||
self.usb_product
|
||||
}
|
||||
fn supported_modes(&self) -> &[BuiltInModeByte] {
|
||||
&self.supported_modes
|
||||
}
|
||||
fn board_name(&self) -> &str {
|
||||
&self.board_name
|
||||
}
|
||||
fn prod_family(&self) -> &str {
|
||||
&self.prod_family
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum GX502GWKeys {
|
||||
Rog = 0x38,
|
||||
MicToggle = 0x7C,
|
||||
Fan = 0xAE,
|
||||
ScreenToggle = 0x35,
|
||||
ScreenBrightDown = 0x10,
|
||||
ScreenBrightUp = 0x20,
|
||||
TouchPadToggle = 0x6b,
|
||||
Sleep = 0x6C,
|
||||
AirplaneMode = 0x88,
|
||||
LedBrightUp = 0xC4,
|
||||
LedBrightDown = 0xC5,
|
||||
AuraPrevious = 0xB2,
|
||||
AuraNext = 0xB3,
|
||||
None,
|
||||
}
|
||||
|
||||
impl From<u8> for GX502GWKeys {
|
||||
fn from(byte: u8) -> Self {
|
||||
match byte {
|
||||
0x38 => GX502GWKeys::Rog,
|
||||
0x7C => GX502GWKeys::MicToggle,
|
||||
0xAE => GX502GWKeys::Fan,
|
||||
0x35 => GX502GWKeys::ScreenToggle,
|
||||
0x10 => GX502GWKeys::ScreenBrightDown,
|
||||
0x20 => GX502GWKeys::ScreenBrightUp,
|
||||
0x6b => GX502GWKeys::TouchPadToggle,
|
||||
0x6C => GX502GWKeys::Sleep,
|
||||
0x88 => GX502GWKeys::AirplaneMode,
|
||||
0xC4 => GX502GWKeys::LedBrightUp,
|
||||
0xC5 => GX502GWKeys::LedBrightDown,
|
||||
0xB2 => GX502GWKeys::AuraPrevious,
|
||||
0xB3 => GX502GWKeys::AuraNext,
|
||||
_ => GX502GWKeys::None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ mod config;
|
||||
/// The core module which allows writing to LEDs or polling the
|
||||
/// laptop keyboard attached devices
|
||||
pub mod core;
|
||||
pub mod daemon;
|
||||
mod error;
|
||||
pub mod laptops;
|
||||
mod virt_device;
|
||||
@@ -1,19 +1,13 @@
|
||||
mod daemon;
|
||||
|
||||
use crate::daemon::*;
|
||||
use daemon::{
|
||||
cli_options::SetAuraBuiltin,
|
||||
core::{aura_brightness_bytes, LedBrightness, LED_MSG_LEN},
|
||||
daemon::{start_daemon, DBUS_IFACE, DBUS_NAME, DBUS_PATH},
|
||||
};
|
||||
use dbus::Error as DbusError;
|
||||
use dbus::{ffidisp::Connection, Message};
|
||||
use env_logger::{Builder, Target};
|
||||
use gumdrop::Options;
|
||||
use log::LevelFilter;
|
||||
use rog_lib::{
|
||||
cli_options::SetAuraBuiltin,
|
||||
core::{LedBrightness, RogCore, LED_MSG_LEN},
|
||||
};
|
||||
|
||||
pub static DBUS_NAME: &'static str = "org.rogcore.Daemon";
|
||||
pub static DBUS_PATH: &'static str = "/org/rogcore/Daemon";
|
||||
pub static DBUS_IFACE: &'static str = "org.rogcore.Daemon";
|
||||
|
||||
#[derive(Debug, Options)]
|
||||
struct CLIStart {
|
||||
@@ -49,7 +43,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let parsed = CLIStart::parse_args_default_or_exit();
|
||||
if parsed.daemon {
|
||||
Daemon::start()?;
|
||||
start_daemon()?;
|
||||
}
|
||||
|
||||
match parsed.command {
|
||||
@@ -63,7 +57,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
match parsed.bright {
|
||||
Some(brightness) => {
|
||||
let bytes = RogCore::aura_brightness_bytes(brightness.level())?;
|
||||
let bytes = aura_brightness_bytes(brightness.level());
|
||||
dbus_led_builtin_write(&bytes)?;
|
||||
}
|
||||
_ => {}
|
||||
Reference in New Issue
Block a user