Compare commits

..

14 Commits

Author SHA1 Message Date
Luke D. Jones
efe64119c6 Prep 6.1.0-rc2 2025-01-12 17:53:32 +13:00
Luke D. Jones
128bc3fce1 Update readme, slash configs 2025-01-12 17:51:43 +13:00
Luke D. Jones
2123f369ad Small clippy cleanups 2025-01-04 20:04:07 +13:00
Luke D. Jones
2b7a2a5be3 Remove typeshare use 2025-01-03 16:37:22 +13:00
Luke D. Jones
1d9e89ef3d Update deps 2025-01-02 19:08:48 +13:00
Luke D. Jones
4011b3ebd4 ROGCC: begin using the new asus_armoury API 2025-01-01 14:47:08 +13:00
Luke D. Jones
f7456f0144 Allow changing of platform values with cli 2024-12-29 12:03:50 +13:00
Luke D. Jones
2ed2d82e03 Better print of firmware attributes in CLI 2024-12-29 11:36:22 +13:00
Luke D. Jones
d40f4733e2 Fix: prevent event loop error in ROGCC
Leftover code from parts of the refactor and tray crate change were
causing the app to crash due to the UI trying to issue a command on the
slint thread when the slint thread had not been created yet.

Closes #579
2024-12-28 22:06:16 +13:00
Luke Jones
98dc155e41 Merge branch 'feat/add-g533qs' into 'main'
feat(rog-aura): 🎸 Add G533QS aura support

See merge request asus-linux/asusctl!210
2024-12-28 04:32:17 +00:00
Luke D. Jones
fd3384decc Minor test of platform attributes 2024-12-28 10:56:34 +13:00
Luke D. Jones
a1a9c7077a Rename dbus. Add asus_armoury client source 2024-12-26 21:36:07 +13:00
Luke D. Jones
62aa1fe04f Add initial dbus draft of asus_armoury attrs 2024-12-26 16:41:17 +13:00
kamack38
72c0b24ead feat(rog-aura): 🎸 Add G533QS aura support 2024-12-23 00:18:46 +01:00
141 changed files with 2846 additions and 2254 deletions

View File

@@ -2,6 +2,12 @@
## [Unreleased] ## [Unreleased]
## [v6.1.0-rc2]
### Added
- asus-armoury driver support. WIP, will be adjusted/changed further
- More "Slash" display controls
## [v6.1.0-rc1] ## [v6.1.0-rc1]
### Added ### Added

260
Cargo.lock generated
View File

@@ -135,7 +135,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -176,7 +176,7 @@ dependencies = [
[[package]] [[package]]
name = "asusctl" name = "asusctl"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"dmi_id", "dmi_id",
"gumdrop", "gumdrop",
@@ -193,7 +193,7 @@ dependencies = [
[[package]] [[package]]
name = "asusd" name = "asusd"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"concat-idents", "concat-idents",
@@ -219,7 +219,7 @@ dependencies = [
[[package]] [[package]]
name = "asusd-user" name = "asusd-user"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"config-traits", "config-traits",
"dirs", "dirs",
@@ -350,7 +350,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -390,7 +390,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -407,7 +407,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -425,7 +425,7 @@ dependencies = [
"derive_utils", "derive_utils",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -550,7 +550,7 @@ dependencies = [
"regex", "regex",
"rustc-hash 1.1.0", "rustc-hash 1.1.0",
"shlex", "shlex",
"syn 2.0.91", "syn 2.0.93",
"which", "which",
] ]
@@ -571,7 +571,7 @@ dependencies = [
"regex", "regex",
"rustc-hash 2.1.0", "rustc-hash 2.1.0",
"shlex", "shlex",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -682,7 +682,7 @@ checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -750,9 +750,9 @@ checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.5" version = "1.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e" checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333"
dependencies = [ dependencies = [
"jobserver", "jobserver",
"libc", "libc",
@@ -885,7 +885,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f76990911f2267d837d9d0ad060aa63aaad170af40904b29461734c339030d4d" checksum = "f76990911f2267d837d9d0ad060aa63aaad170af40904b29461734c339030d4d"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -899,7 +899,7 @@ dependencies = [
[[package]] [[package]]
name = "config-traits" name = "config-traits"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"log", "log",
"ron", "ron",
@@ -948,7 +948,7 @@ dependencies = [
[[package]] [[package]]
name = "const-field-offset" name = "const-field-offset"
version = "0.1.5" version = "0.1.5"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"const-field-offset-macro", "const-field-offset-macro",
"field-offset", "field-offset",
@@ -957,11 +957,11 @@ dependencies = [
[[package]] [[package]]
name = "const-field-offset-macro" name = "const-field-offset-macro"
version = "0.1.5" version = "0.1.5"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -1079,10 +1079,6 @@ version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636"
[[package]]
name = "cpuctl"
version = "6.1.0-rc1"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.16" version = "0.2.16"
@@ -1201,7 +1197,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
"unicode-xid", "unicode-xid",
] ]
@@ -1213,7 +1209,7 @@ checksum = "65f152f4b8559c4da5d574bafc7af85454d706b4c5fe8b530d508cacbb6807ea"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -1281,7 +1277,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -1295,7 +1291,7 @@ dependencies = [
[[package]] [[package]]
name = "dmi_id" name = "dmi_id"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"log", "log",
"udev 0.8.0", "udev 0.8.0",
@@ -1397,7 +1393,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -1491,9 +1487,9 @@ dependencies = [
[[package]] [[package]]
name = "femtovg" name = "femtovg"
version = "0.11.2" version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eafc3dd3c956423a6669e1f6f9ab23261dbe45cdb24ce23dba38b0389b8a8ff8" checksum = "36d63bc3ab69493186eefc2568dddc21d2fe5f3c552edc64def6c42297ec9bbd"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"bytemuck", "bytemuck",
@@ -1608,7 +1604,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -1695,7 +1691,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -1849,9 +1845,9 @@ dependencies = [
[[package]] [[package]]
name = "glob" name = "glob"
version = "0.3.1" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
[[package]] [[package]]
name = "glow" name = "glow"
@@ -2168,8 +2164,8 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-backend-linuxkms" name = "i-slint-backend-linuxkms"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"calloop 0.14.2", "calloop 0.14.2",
"drm", "drm",
@@ -2186,8 +2182,8 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-backend-selector" name = "i-slint-backend-selector"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"i-slint-backend-linuxkms", "i-slint-backend-linuxkms",
@@ -2199,8 +2195,8 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-backend-winit" name = "i-slint-backend-winit"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"ashpd", "ashpd",
"cfg-if", "cfg-if",
@@ -2230,8 +2226,8 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-common" name = "i-slint-common"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"derive_more", "derive_more",
@@ -2242,8 +2238,8 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-compiler" name = "i-slint-compiler"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"by_address", "by_address",
"codemap", "codemap",
@@ -2272,8 +2268,8 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-core" name = "i-slint-core"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"auto_enums", "auto_enums",
"bitflags 2.6.0", "bitflags 2.6.0",
@@ -2317,18 +2313,18 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-core-macros" name = "i-slint-core-macros"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"quote", "quote",
"serde_json", "serde_json",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
name = "i-slint-renderer-femtovg" name = "i-slint-renderer-femtovg"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"const-field-offset", "const-field-offset",
@@ -2357,8 +2353,8 @@ dependencies = [
[[package]] [[package]]
name = "i-slint-renderer-skia" name = "i-slint-renderer-skia"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"cfg-if", "cfg-if",
@@ -2526,7 +2522,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -2691,7 +2687,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -3269,7 +3265,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -3320,7 +3316,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -3643,7 +3639,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -3765,7 +3761,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -3802,7 +3798,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30" checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -3825,7 +3821,7 @@ dependencies = [
"itertools 0.13.0", "itertools 0.13.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -3872,9 +3868,9 @@ dependencies = [
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.37" version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@@ -4094,7 +4090,7 @@ dependencies = [
[[package]] [[package]]
name = "rog-control-center" name = "rog-control-center"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"asusd", "asusd",
"concat-idents", "concat-idents",
@@ -4124,7 +4120,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_anime" name = "rog_anime"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"dmi_id", "dmi_id",
"gif 0.12.0", "gif 0.12.0",
@@ -4133,25 +4129,23 @@ dependencies = [
"pix", "pix",
"png_pong", "png_pong",
"serde", "serde",
"typeshare",
"zbus 5.2.0", "zbus 5.2.0",
] ]
[[package]] [[package]]
name = "rog_aura" name = "rog_aura"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"dmi_id", "dmi_id",
"log", "log",
"ron", "ron",
"serde", "serde",
"typeshare",
"zbus 5.2.0", "zbus 5.2.0",
] ]
[[package]] [[package]]
name = "rog_dbus" name = "rog_dbus"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"asusd", "asusd",
"rog_anime", "rog_anime",
@@ -4165,44 +4159,41 @@ dependencies = [
[[package]] [[package]]
name = "rog_platform" name = "rog_platform"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"concat-idents", "concat-idents",
"inotify", "inotify",
"log", "log",
"rusb", "rusb",
"serde", "serde",
"typeshare",
"udev 0.8.0", "udev 0.8.0",
"zbus 5.2.0", "zbus 5.2.0",
] ]
[[package]] [[package]]
name = "rog_profiles" name = "rog_profiles"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"log", "log",
"rog_platform", "rog_platform",
"serde", "serde",
"typeshare",
"udev 0.8.0", "udev 0.8.0",
"zbus 5.2.0", "zbus 5.2.0",
] ]
[[package]] [[package]]
name = "rog_scsi" name = "rog_scsi"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"ron", "ron",
"serde", "serde",
"sg", "sg",
"typeshare",
"zbus 5.2.0", "zbus 5.2.0",
] ]
[[package]] [[package]]
name = "rog_simulators" name = "rog_simulators"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"log", "log",
"rog_anime", "rog_anime",
@@ -4212,11 +4203,10 @@ dependencies = [
[[package]] [[package]]
name = "rog_slash" name = "rog_slash"
version = "6.1.0-rc1" version = "6.1.0-rc2"
dependencies = [ dependencies = [
"dmi_id", "dmi_id",
"serde", "serde",
"typeshare",
"zbus 5.2.0", "zbus 5.2.0",
] ]
@@ -4302,9 +4292,9 @@ dependencies = [
[[package]] [[package]]
name = "rustversion" name = "rustversion"
version = "1.0.18" version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
[[package]] [[package]]
name = "rustybuzz" name = "rustybuzz"
@@ -4419,22 +4409,22 @@ checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.216" version = "1.0.217"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.216" version = "1.0.217"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -4457,7 +4447,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -4584,8 +4574,8 @@ dependencies = [
[[package]] [[package]]
name = "slint" name = "slint"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"const-field-offset", "const-field-offset",
"i-slint-backend-selector", "i-slint-backend-selector",
@@ -4601,8 +4591,8 @@ dependencies = [
[[package]] [[package]]
name = "slint-build" name = "slint-build"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"i-slint-compiler", "i-slint-compiler",
"i-slint-core-macros", "i-slint-core-macros",
@@ -4613,8 +4603,8 @@ dependencies = [
[[package]] [[package]]
name = "slint-macros" name = "slint-macros"
version = "1.9.1" version = "1.9.2"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"i-slint-compiler", "i-slint-compiler",
"proc-macro2", "proc-macro2",
@@ -4799,7 +4789,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"rustversion", "rustversion",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -4840,9 +4830,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.91" version = "2.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035" checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -4863,7 +4853,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -4967,7 +4957,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -5099,7 +5089,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -5256,7 +5246,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -5320,28 +5310,6 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "typeshare"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19be0f411120091e76e13e5a0186d8e2bcc3e7e244afdb70152197f1a8486ceb"
dependencies = [
"chrono",
"serde",
"serde_json",
"typeshare-annotation",
]
[[package]]
name = "typeshare-annotation"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a615d6c2764852a2e88a4f16e9ce1ea49bb776b5872956309e170d63a042a34f"
dependencies = [
"quote",
"syn 2.0.91",
]
[[package]] [[package]]
name = "udev" name = "udev"
version = "0.8.0" version = "0.8.0"
@@ -5380,9 +5348,9 @@ dependencies = [
[[package]] [[package]]
name = "uhid-virt" name = "uhid-virt"
version = "0.0.7" version = "0.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f70f1f603b96df07624cdd31be4496a983a3f7f079cf2606aa289719114249f" checksum = "fad50862a51d693d984b07f6f6263a571554d415f5d1e16f4cbad2c266448e1b"
dependencies = [ dependencies = [
"enumflags2", "enumflags2",
"libc", "libc",
@@ -5391,11 +5359,11 @@ dependencies = [
[[package]] [[package]]
name = "uhidrs-sys" name = "uhidrs-sys"
version = "1.0.3" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e24880fbcee511571ed9104b9a5273d1563d11ccaaf54b7c05cc6c100b652f9f" checksum = "aec7103e0167479f230f6baae49dbf714074d91b2ff141983524d7417c0b98a8"
dependencies = [ dependencies = [
"bindgen 0.69.5", "bindgen 0.71.1",
] ]
[[package]] [[package]]
@@ -5575,7 +5543,7 @@ dependencies = [
[[package]] [[package]]
name = "vtable" name = "vtable"
version = "0.2.1" version = "0.2.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"const-field-offset", "const-field-offset",
"portable-atomic", "portable-atomic",
@@ -5586,11 +5554,11 @@ dependencies = [
[[package]] [[package]]
name = "vtable-macro" name = "vtable-macro"
version = "0.2.1" version = "0.2.1"
source = "git+https://github.com/slint-ui/slint.git#d6f83a2af663de2128104fe4241e8b12f308db8d" source = "git+https://github.com/slint-ui/slint.git#cf910d3f23b4e34c39f8388d9e917a22ba09a19e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -5639,7 +5607,7 @@ dependencies = [
"log", "log",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@@ -5674,7 +5642,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@@ -5925,7 +5893,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -5936,7 +5904,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -5947,7 +5915,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -5958,7 +5926,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -6266,9 +6234,9 @@ dependencies = [
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.6.20" version = "0.6.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" checksum = "e6f5bb5257f2407a5425c6e749bfd9692192a73e70a6060516ac04f889087d68"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@@ -6425,7 +6393,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
"synstructure", "synstructure",
] ]
@@ -6512,7 +6480,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
"zvariant_utils 2.1.0", "zvariant_utils 2.1.0",
] ]
@@ -6525,7 +6493,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
"zbus_names 4.1.0", "zbus_names 4.1.0",
"zvariant 5.1.0", "zvariant 5.1.0",
"zvariant_utils 3.0.2", "zvariant_utils 3.0.2",
@@ -6572,7 +6540,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -6592,7 +6560,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
"synstructure", "synstructure",
] ]
@@ -6615,7 +6583,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -6680,7 +6648,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
"zvariant_utils 2.1.0", "zvariant_utils 2.1.0",
] ]
@@ -6693,7 +6661,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
"zvariant_utils 3.0.2", "zvariant_utils 3.0.2",
] ]
@@ -6705,7 +6673,7 @@ checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.91", "syn 2.0.93",
] ]
[[package]] [[package]]
@@ -6718,6 +6686,6 @@ dependencies = [
"quote", "quote",
"serde", "serde",
"static_assertions", "static_assertions",
"syn 2.0.91", "syn 2.0.93",
"winnow", "winnow",
] ]

View File

@@ -1,5 +1,5 @@
[workspace.package] [workspace.package]
version = "6.1.0-rc1" version = "6.1.0-rc2"
rust-version = "1.82" rust-version = "1.82"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
@@ -12,36 +12,31 @@ edition = "2021"
[workspace] [workspace]
resolver = "2" resolver = "2"
members = [ members = [
"asusctl", "asusctl",
"asusd", "asusd",
"asusd-user", "asusd-user",
"config-traits", "config-traits",
"cpuctl", "dmi-id",
"dmi-id", "rog-platform",
"rog-platform", "rog-dbus",
"rog-dbus", "rog-anime",
"rog-anime", "rog-aura",
"rog-aura", "rog-profiles",
"rog-profiles", "rog-control-center",
"rog-control-center", "rog-slash",
"rog-slash", "simulators",
"simulators", "rog-scsi", "rog-scsi",
]
default-members = [
"asusctl",
"asusd",
"asusd-user",
"cpuctl",
"rog-control-center",
] ]
default-members = ["asusctl", "asusd", "asusd-user", "rog-control-center"]
[workspace.dependencies] [workspace.dependencies]
tokio = { version = "^1.39.0", default-features = false, features = [ tokio = { version = "^1.39.0", default-features = false, features = [
"macros", "macros",
"sync", "sync",
"time", "time",
"rt", "rt",
"rt-multi-thread", "rt-multi-thread",
] } ] }
concat-idents = "^1.1" concat-idents = "^1.1"
dirs = "^4.0" dirs = "^4.0"
@@ -53,7 +48,6 @@ logind-zbus = { version = "5.0.0" } #, default-features = false, features = ["no
serde = { version = "^1.0", features = ["serde_derive"] } serde = { version = "^1.0", features = ["serde_derive"] }
ron = "*" ron = "*"
typeshare = "1.0.0"
log = "^0.4" log = "^0.4"
env_logger = "^0.10.0" env_logger = "^0.10.0"
@@ -73,7 +67,7 @@ versions = "6.2"
notify-rust = { version = "4.11.0", features = ["z", "async"] } notify-rust = { version = "4.11.0", features = ["z", "async"] }
sg = {git = "https://github.com/flukejones/sg-rs.git"} sg = { git = "https://github.com/flukejones/sg-rs.git" }
[profile.release] [profile.release]
# thin = 57s, asusd = 9.0M # thin = 57s, asusd = 9.0M

View File

@@ -122,12 +122,6 @@ vendor:
tar pcfJ vendor_asusctl_$(VERSION).tar.xz vendor tar pcfJ vendor_asusctl_$(VERSION).tar.xz vendor
rm -rf vendor rm -rf vendor
bindings:
typeshare ./rog-anime/src/ --lang=typescript --output-file=bindings/ts/anime.ts
typeshare ./rog-aura/src/ --lang=typescript --output-file=bindings/ts/aura.ts
typeshare ./rog-profiles/src/ --lang=typescript --output-file=bindings/ts/profiles.ts
typeshare ./rog-platform/src/ --lang=typescript --output-file=bindings/ts/platform.ts
translate: translate:
find -name \*.slint | xargs slint-tr-extractor -o rog-control-center/translations/en/rog-control-center.po find -name \*.slint | xargs slint-tr-extractor -o rog-control-center/translations/en/rog-control-center.po

View File

@@ -1,6 +1,6 @@
# `asusctl` for ASUS ROG # `asusctl` for ASUS ROG
[Become a Patron!](https://www.patreon.com/bePatron?u=7602281) - [Asus Linux Website](https://asus-linux.org/) [![Become a Patron!](https://github.com/codebard/patron-button-and-widgets-by-codebard/blob/master/images/become_a_patron_button.png?raw=true)](https://www.patreon.com/bePatron?u=7602281) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/V7V5CLU67) - [Asus Linux Website](https://asus-linux.org/)
**WARNING:** Many features are developed in tandem with kernel patches. If you see a feature is missing you either need a patched kernel or latest release. **WARNING:** Many features are developed in tandem with kernel patches. If you see a feature is missing you either need a patched kernel or latest release.
@@ -11,7 +11,9 @@ Now includes a GUI, `rog-control-center`.
## Kernel support ## Kernel support
**The minimum supported kernel version is 6.10**, which will contain the patches from [here](https://lore.kernel.org/platform-driver-x86/20240404001652.86207-1-luke@ljones.dev/). This is especially required for 2023+ devices and possibly some late 2022 devices. Due to on-going driver work the minimum suggested kernel version is always **the latest*, as improvements and fixes are continuous.
Support for some new features is not avilable unless you run a patched kernel with the work I am doing [in this github repo](https://github.com/flukejones/linux/tree/wip/ally-6.13). Use the linked branch, or `wip/ally-6.12`. Everything that is done here is upstreamed eventually (a long process).
Z13 devices will need [these](https://lore.kernel.org/linux-input/20240416090402.31057-1-luke@ljones.dev/T/#t) Z13 devices will need [these](https://lore.kernel.org/linux-input/20240416090402.31057-1-luke@ljones.dev/T/#t)

View File

@@ -23,7 +23,7 @@ fn main() -> Result<(), Box<dyn Error>> {
Path::new(&args[1]), Path::new(&args[1]),
None, None,
args[2].parse::<f32>().unwrap(), args[2].parse::<f32>().unwrap(),
AnimeType::GA401, AnimeType::GA401
)?; )?;
let anime_type = get_anime_type(); let anime_type = get_anime_type();

View File

@@ -21,14 +21,11 @@ fn main() {
let brightness = args[2].parse::<f32>().unwrap(); let brightness = args[2].parse::<f32>().unwrap();
let anime_type = get_anime_type(); let anime_type = get_anime_type();
let mut seq = Sequences::new(anime_type); let mut seq = Sequences::new(anime_type);
seq.insert( seq.insert(0, &ActionLoader::AsusAnimation {
0, file: path.into(),
&ActionLoader::AsusAnimation { time: rog_anime::AnimTime::Infinite,
file: path.into(), brightness
time: rog_anime::AnimTime::Infinite, })
brightness,
},
)
.unwrap(); .unwrap();
loop { loop {

View File

@@ -27,10 +27,10 @@ fn main() -> Result<(), Box<dyn Error>> {
args[3].parse::<f32>().unwrap(), args[3].parse::<f32>().unwrap(),
Vec2::new( Vec2::new(
args[4].parse::<f32>().unwrap(), args[4].parse::<f32>().unwrap(),
args[5].parse::<f32>().unwrap(), args[5].parse::<f32>().unwrap()
), ),
args[6].parse::<f32>().unwrap(), args[6].parse::<f32>().unwrap(),
anime_type, anime_type
)?; )?;
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?).unwrap(); proxy.write(<AnimeDataBuffer>::try_from(&matrix)?).unwrap();

View File

@@ -30,10 +30,10 @@ fn main() -> Result<(), Box<dyn Error>> {
args[3].parse::<f32>().unwrap(), args[3].parse::<f32>().unwrap(),
Vec2::new( Vec2::new(
args[4].parse::<f32>().unwrap(), args[4].parse::<f32>().unwrap(),
args[5].parse::<f32>().unwrap(), args[5].parse::<f32>().unwrap()
), ),
args[6].parse::<f32>().unwrap(), args[6].parse::<f32>().unwrap(),
anime_type, anime_type
)?; )?;
loop { loop {

View File

@@ -36,10 +36,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Colour { Colour {
r: 200, r: 200,
g: 110, g: 110,
b: 0, b: 0
}, },
100, 100,
10, 10
)); ));
seq.push(zone); seq.push(zone);

View File

@@ -40,7 +40,7 @@ pub struct AnimeCommand {
#[options(no_short, meta = "", help = "Off with his head!!!")] #[options(no_short, meta = "", help = "Off with his head!!!")]
pub off_with_his_head: Option<bool>, pub off_with_his_head: Option<bool>,
#[options(command)] #[options(command)]
pub command: Option<AnimeActions>, pub command: Option<AnimeActions>
} }
#[derive(Options)] #[derive(Options)]
@@ -54,7 +54,7 @@ pub enum AnimeActions {
#[options(help = "display an animated diagonal/pixel-perfect GIF")] #[options(help = "display an animated diagonal/pixel-perfect GIF")]
PixelGif(AnimeGifDiagonal), PixelGif(AnimeGifDiagonal),
#[options(help = "change which builtin animations are shown")] #[options(help = "change which builtin animations are shown")]
SetBuiltins(Builtins), SetBuiltins(Builtins)
} }
#[derive(Options)] #[derive(Options)]
@@ -82,7 +82,7 @@ pub struct Builtins {
)] )]
pub shutdown: AnimShutdown, pub shutdown: AnimShutdown,
#[options(meta = "", help = "set/apply the animations <true/false>")] #[options(meta = "", help = "set/apply the animations <true/false>")]
pub set: Option<bool>, pub set: Option<bool>
} }
#[derive(Options)] #[derive(Options)]
@@ -100,7 +100,7 @@ pub struct AnimeImage {
#[options(meta = "", default = "0.0", help = "the angle in radians")] #[options(meta = "", default = "0.0", help = "the angle in radians")]
pub angle: f32, pub angle: f32,
#[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")] #[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")]
pub bright: f32, pub bright: f32
} }
#[derive(Options)] #[derive(Options)]
@@ -110,7 +110,7 @@ pub struct AnimeImageDiagonal {
#[options(meta = "", help = "full path to the png to display")] #[options(meta = "", help = "full path to the png to display")]
pub path: String, pub path: String,
#[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")] #[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")]
pub bright: f32, pub bright: f32
} }
#[derive(Options)] #[derive(Options)]
@@ -134,7 +134,7 @@ pub struct AnimeGif {
default = "1", default = "1",
help = "how many loops to play - 0 is infinite" help = "how many loops to play - 0 is infinite"
)] )]
pub loops: u32, pub loops: u32
} }
#[derive(Options)] #[derive(Options)]
@@ -150,5 +150,5 @@ pub struct AnimeGifDiagonal {
default = "1", default = "1",
help = "how many loops to play - 0 is infinite" help = "how many loops to play - 0 is infinite"
)] )]
pub loops: u32, pub loops: u32
} }

View File

@@ -17,7 +17,7 @@ pub struct LedPowerCommand1 {
#[options(meta = "", help = "Control boot animations <true/false>")] #[options(meta = "", help = "Control boot animations <true/false>")]
pub boot: Option<bool>, pub boot: Option<bool>,
#[options(meta = "", help = "Control suspend animations <true/false>")] #[options(meta = "", help = "Control suspend animations <true/false>")]
pub sleep: Option<bool>, pub sleep: Option<bool>
} }
#[derive(Options, Debug)] #[derive(Options, Debug)]
@@ -25,7 +25,7 @@ pub struct LedPowerCommand2 {
#[options(help = "print help message")] #[options(help = "print help message")]
pub help: bool, pub help: bool,
#[options(command)] #[options(command)]
pub command: Option<SetAuraZoneEnabled>, pub command: Option<SetAuraZoneEnabled>
} }
#[derive(Options, Debug)] #[derive(Options, Debug)]
@@ -42,7 +42,7 @@ pub enum SetAuraZoneEnabled {
#[options(help = "")] #[options(help = "")]
RearGlow(AuraPowerStates), RearGlow(AuraPowerStates),
#[options(help = "")] #[options(help = "")]
Ally(AuraPowerStates), Ally(AuraPowerStates)
} }
#[derive(Debug, Clone, Options)] #[derive(Debug, Clone, Options)]
@@ -56,12 +56,12 @@ pub struct AuraPowerStates {
#[options(help = "defaults to false if option unused")] #[options(help = "defaults to false if option unused")]
pub sleep: bool, pub sleep: bool,
#[options(help = "defaults to false if option unused")] #[options(help = "defaults to false if option unused")]
pub shutdown: bool, pub shutdown: bool
} }
#[derive(Options)] #[derive(Options)]
pub struct LedBrightness { pub struct LedBrightness {
level: Option<u8>, level: Option<u8>
} }
impl LedBrightness { impl LedBrightness {
pub fn new(level: Option<u8>) -> Self { pub fn new(level: Option<u8>) -> Self {
@@ -96,7 +96,7 @@ impl ToString for LedBrightness {
Some(0x00) => "low", Some(0x00) => "low",
Some(0x01) => "med", Some(0x01) => "med",
Some(0x02) => "high", Some(0x02) => "high",
_ => "unknown", _ => "unknown"
}; };
s.to_owned() s.to_owned()
} }
@@ -113,7 +113,7 @@ pub struct SingleSpeed {
meta = "", meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left" help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
)] )]
pub zone: AuraZone, pub zone: AuraZone
} }
#[derive(Debug, Clone, Options, Default)] #[derive(Debug, Clone, Options, Default)]
@@ -129,7 +129,7 @@ pub struct SingleSpeedDirection {
meta = "", meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left" help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
)] )]
pub zone: AuraZone, pub zone: AuraZone
} }
#[derive(Debug, Clone, Default, Options)] #[derive(Debug, Clone, Default, Options)]
@@ -143,7 +143,7 @@ pub struct SingleColour {
meta = "", meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left" help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
)] )]
pub zone: AuraZone, pub zone: AuraZone
} }
#[derive(Debug, Clone, Default, Options)] #[derive(Debug, Clone, Default, Options)]
@@ -159,7 +159,7 @@ pub struct SingleColourSpeed {
meta = "", meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left" help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
)] )]
pub zone: AuraZone, pub zone: AuraZone
} }
#[derive(Debug, Clone, Options, Default)] #[derive(Debug, Clone, Options, Default)]
@@ -177,7 +177,7 @@ pub struct TwoColourSpeed {
meta = "", meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left" help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
)] )]
pub zone: AuraZone, pub zone: AuraZone
} }
#[derive(Debug, Clone, Default, Options)] #[derive(Debug, Clone, Default, Options)]
@@ -191,7 +191,7 @@ pub struct MultiZone {
#[options(short = "c", meta = "", help = "set the RGB value e.g, ff00ff")] #[options(short = "c", meta = "", help = "set the RGB value e.g, ff00ff")]
pub colour3: Colour, pub colour3: Colour,
#[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")] #[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")]
pub colour4: Colour, pub colour4: Colour
} }
#[derive(Debug, Clone, Default, Options)] #[derive(Debug, Clone, Default, Options)]
@@ -207,7 +207,7 @@ pub struct MultiColourSpeed {
#[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")] #[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")]
pub colour4: Colour, pub colour4: Colour,
#[options(no_long, meta = "", help = "set the speed: low, med, high")] #[options(no_long, meta = "", help = "set the speed: low, med, high")]
pub speed: Speed, pub speed: Speed
} }
/// Byte value for setting the built-in mode. /// Byte value for setting the built-in mode.
@@ -239,7 +239,7 @@ pub enum SetAuraBuiltin {
#[options(help = "set a vertical line zooming from left")] #[options(help = "set a vertical line zooming from left")]
Comet(SingleColour), // 11 Comet(SingleColour), // 11
#[options(help = "set a wide vertical line zooming from left")] #[options(help = "set a wide vertical line zooming from left")]
Flash(SingleColour), // 12 Flash(SingleColour) // 12
} }
impl Default for SetAuraBuiltin { impl Default for SetAuraBuiltin {

View File

@@ -26,7 +26,7 @@ pub struct CliStart {
#[options(help = "Toggle one-shot battery charge to 100%")] #[options(help = "Toggle one-shot battery charge to 100%")]
pub one_shot_chg: bool, pub one_shot_chg: bool,
#[options(command)] #[options(command)]
pub command: Option<CliCommand>, pub command: Option<CliCommand>
} }
#[derive(Options)] #[derive(Options)]
@@ -50,7 +50,12 @@ pub enum CliCommand {
#[options(name = "scsi", help = "Manage SCSI external drive")] #[options(name = "scsi", help = "Manage SCSI external drive")]
Scsi(ScsiCommand), Scsi(ScsiCommand),
#[options(help = "Change bios settings")] #[options(help = "Change bios settings")]
Platform(PlatformCommand), PlatformOld(PlatformCommand),
#[options(
help = "Change platform settings. This is a new interface exposed by the asus-armoury \
driver, some of the settings will be the same as the older platform interface"
)]
Armoury(ArmouryCommand)
} }
#[derive(Debug, Clone, Options)] #[derive(Debug, Clone, Options)]
@@ -68,7 +73,7 @@ pub struct ProfileCommand {
pub profile_get: bool, pub profile_get: bool,
#[options(meta = "", help = "set the active profile")] #[options(meta = "", help = "set the active profile")]
pub profile_set: Option<ThrottlePolicy>, pub profile_set: Option<ThrottlePolicy>
} }
#[derive(Options)] #[derive(Options)]
@@ -80,13 +85,13 @@ pub struct LedModeCommand {
#[options(help = "switch to previous aura mode")] #[options(help = "switch to previous aura mode")]
pub prev_mode: bool, pub prev_mode: bool,
#[options(command)] #[options(command)]
pub command: Option<SetAuraBuiltin>, pub command: Option<SetAuraBuiltin>
} }
#[derive(Options)] #[derive(Options)]
pub struct GraphicsCommand { pub struct GraphicsCommand {
#[options(help = "print help message")] #[options(help = "print help message")]
pub help: bool, pub help: bool
} }
#[derive(Options, Debug)] #[derive(Options, Debug)]
@@ -119,5 +124,13 @@ pub struct PlatformCommand {
)] )]
pub panel_overdrive_set: Option<bool>, pub panel_overdrive_set: Option<bool>,
#[options(no_long, short = "o", help = "get panel overdrive")] #[options(no_long, short = "o", help = "get panel overdrive")]
pub panel_overdrive_get: bool, pub panel_overdrive_get: bool
}
#[derive(Options, Debug)]
pub struct ArmouryCommand {
#[options(help = "print help message")]
pub help: bool,
#[options(free)]
pub free: Vec<String>
} }

View File

@@ -45,5 +45,5 @@ pub struct FanCurveCommand {
help = "data format = 30c:1%,49c:2%,59c:3%,69c:4%,79c:31%,89c:49%,99c:56%,109c:58%. \ help = "data format = 30c:1%,49c:2%,59c:3%,69c:4%,79c:31%,89c:49%,99c:56%,109c:58%. \
`--mod-profile` required. If '%' is omitted the fan range is 0-255" `--mod-profile` required. If '%' is omitted the fan range is 0-255"
)] )]
pub data: Option<CurveData>, pub data: Option<CurveData>
} }

View File

@@ -13,6 +13,7 @@ use rog_anime::usb::get_anime_type;
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2}; use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2};
use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower}; use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower};
use rog_aura::{self, AuraDeviceType, AuraEffect, PowerZones}; use rog_aura::{self, AuraDeviceType, AuraEffect, PowerZones};
use rog_dbus::asus_armoury::AsusArmouryProxyBlocking;
use rog_dbus::list_iface_blocking; use rog_dbus::list_iface_blocking;
use rog_dbus::scsi_aura::ScsiAuraProxyBlocking; use rog_dbus::scsi_aura::ScsiAuraProxyBlocking;
use rog_dbus::zbus_anime::AnimeProxyBlocking; use rog_dbus::zbus_anime::AnimeProxyBlocking;
@@ -88,7 +89,7 @@ fn main() {
fn print_error_help( fn print_error_help(
err: &dyn std::error::Error, err: &dyn std::error::Error,
supported_interfaces: &[String], supported_interfaces: &[String],
supported_properties: &[Properties], supported_properties: &[Properties]
) { ) {
check_service("asusd"); check_service("asusd");
println!("\nError: {}\n", err); println!("\nError: {}\n", err);
@@ -129,11 +130,10 @@ fn check_service(name: &str) -> bool {
fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>> fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>, T: ProxyImpl<'static> + From<zbus::Proxy<'static>>
{ {
let conn = zbus::blocking::Connection::system().unwrap(); let conn = zbus::blocking::Connection::system().unwrap();
let f = let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").unwrap();
let interfaces = f.get_managed_objects().unwrap(); let interfaces = f.get_managed_objects().unwrap();
let mut paths = Vec::new(); let mut paths = Vec::new();
for v in interfaces.iter() { for v in interfaces.iter() {
@@ -141,22 +141,23 @@ where
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o); // e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
for k in v.1.keys() { for k in v.1.keys() {
if k.as_str() == iface_name { if k.as_str() == iface_name {
println!("Found {iface_name} device at {}, {}", v.0, k); // println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone()); paths.push(v.0.clone());
} }
} }
} }
if paths.len() > 1 { if paths.len() > 1 {
println!("Multiple aura devices found: {paths:?}"); println!("Multiple asusd interfaces devices found");
} }
if !paths.is_empty() { if !paths.is_empty() {
let mut ctrl = Vec::new(); let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(b));
for path in paths { for path in paths {
ctrl.push( ctrl.push(
T::builder(&conn) T::builder(&conn)
.path(path.clone())? .path(path.clone())?
.destination("org.asuslinux.Daemon")? .destination("xyz.ljones.Asusd")?
.build()?, .build()?
); );
} }
return Ok(ctrl); return Ok(ctrl);
@@ -169,7 +170,7 @@ fn do_parsed(
parsed: &CliStart, parsed: &CliStart,
supported_interfaces: &[String], supported_interfaces: &[String],
supported_properties: &[Properties], supported_properties: &[Properties],
conn: Connection, conn: Connection
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
match &parsed.command { match &parsed.command {
Some(CliCommand::Aura(mode)) => handle_led_mode(mode)?, Some(CliCommand::Aura(mode)) => handle_led_mode(mode)?,
@@ -185,9 +186,10 @@ fn do_parsed(
Some(CliCommand::Anime(cmd)) => handle_anime(cmd)?, Some(CliCommand::Anime(cmd)) => handle_anime(cmd)?,
Some(CliCommand::Slash(cmd)) => handle_slash(cmd)?, Some(CliCommand::Slash(cmd)) => handle_slash(cmd)?,
Some(CliCommand::Scsi(cmd)) => handle_scsi(cmd)?, Some(CliCommand::Scsi(cmd)) => handle_scsi(cmd)?,
Some(CliCommand::Platform(cmd)) => { Some(CliCommand::PlatformOld(cmd)) => {
handle_platform_properties(&conn, supported_properties, cmd)? handle_platform_properties(&conn, supported_properties, cmd)?
} }
Some(CliCommand::Armoury(cmd)) => handle_armoury_command(cmd)?,
None => { None => {
if (!parsed.show_supported if (!parsed.show_supported
&& parsed.kbd_bright.is_none() && parsed.kbd_bright.is_none()
@@ -201,7 +203,7 @@ fn do_parsed(
println!(); println!();
if let Some(cmdlist) = CliStart::command_list() { if let Some(cmdlist) = CliStart::command_list() {
let dev_type = let dev_type =
if let Ok(proxy) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") { if let Ok(proxy) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
// TODO: commands on all? // TODO: commands on all?
proxy proxy
.first() .first()
@@ -214,32 +216,37 @@ fn do_parsed(
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect(); let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
for command in commands.iter().filter(|command| { for command in commands.iter().filter(|command| {
if command.trim().starts_with("fan-curve") if command.trim().starts_with("fan-curve")
&& !supported_interfaces && !supported_interfaces.contains(&"xyz.ljones.FanCurves".to_string())
.contains(&"org.asuslinux.FanCurves".to_string())
{ {
return false; return false;
} }
if command.trim().starts_with("aura") if command.trim().starts_with("aura")
&& !supported_interfaces.contains(&"org.asuslinux.Aura".to_string()) && !supported_interfaces.contains(&"xyz.ljones.Aura".to_string())
{ {
return false; return false;
} }
if command.trim().starts_with("anime") if command.trim().starts_with("anime")
&& !supported_interfaces.contains(&"org.asuslinux.Anime".to_string()) && !supported_interfaces.contains(&"xyz.ljones.Anime".to_string())
{ {
return false; return false;
} }
if command.trim().starts_with("slash") if command.trim().starts_with("slash")
&& !supported_interfaces.contains(&"org.asuslinux.Slash".to_string()) && !supported_interfaces.contains(&"xyz.ljones.Slash".to_string())
{ {
return false; return false;
} }
if command.trim().starts_with("platform") if command.trim().starts_with("platform")
&& !supported_interfaces.contains(&"org.asuslinux.Platform".to_string()) && !supported_interfaces.contains(&"xyz.ljones.Platform".to_string())
{
return false;
}
if command.trim().starts_with("platform")
&& !supported_interfaces.contains(&"xyz.ljones.AsusArmoury".to_string())
{ {
return false; return false;
} }
@@ -267,14 +274,14 @@ fn do_parsed(
} }
if let Some(brightness) = &parsed.kbd_bright { if let Some(brightness) = &parsed.kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") { if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() { for aura in aura.iter() {
match brightness.level() { match brightness.level() {
None => { None => {
let level = aura.brightness()?; let level = aura.brightness()?;
println!("Current keyboard led brightness: {level:?}"); println!("Current keyboard led brightness: {level:?}");
} }
Some(level) => aura.set_brightness(rog_aura::LedBrightness::from(level))?, Some(level) => aura.set_brightness(rog_aura::LedBrightness::from(level))?
} }
} }
} else { } else {
@@ -283,7 +290,7 @@ fn do_parsed(
} }
if parsed.next_kbd_bright { if parsed.next_kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") { if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() { for aura in aura.iter() {
let brightness = aura.brightness()?; let brightness = aura.brightness()?;
aura.set_brightness(brightness.next())?; aura.set_brightness(brightness.next())?;
@@ -294,7 +301,7 @@ fn do_parsed(
} }
if parsed.prev_kbd_bright { if parsed.prev_kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") { if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() { for aura in aura.iter() {
let brightness = aura.brightness()?; let brightness = aura.brightness()?;
aura.set_brightness(brightness.prev())?; aura.set_brightness(brightness.prev())?;
@@ -310,7 +317,7 @@ fn do_parsed(
"Supported Platform Properties:\n{:#?}", "Supported Platform Properties:\n{:#?}",
supported_properties supported_properties
); );
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") { if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
// TODO: multiple RGB check // TODO: multiple RGB check
let bright = aura.first().unwrap().supported_brightness()?; let bright = aura.first().unwrap().supported_brightness()?;
let modes = aura.first().unwrap().supported_basic_modes()?; let modes = aura.first().unwrap().supported_basic_modes()?;
@@ -363,7 +370,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
println!("\n{}", lst); println!("\n{}", lst);
} }
} }
let animes = find_iface::<AnimeProxyBlocking>("org.asuslinux.Anime")?; let animes = find_iface::<AnimeProxyBlocking>("xyz.ljones.Anime")?;
for proxy in animes { for proxy in animes {
if let Some(enable) = cmd.enable_display { if let Some(enable) = cmd.enable_display {
proxy.set_enable_display(enable)?; proxy.set_enable_display(enable)?;
@@ -418,7 +425,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
image.angle, image.angle,
Vec2::new(image.x_pos, image.y_pos), Vec2::new(image.x_pos, image.y_pos),
image.bright, image.bright,
anime_type, anime_type
)?; )?;
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?)?; proxy.write(<AnimeDataBuffer>::try_from(&matrix)?)?;
@@ -437,7 +444,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
Path::new(&image.path), Path::new(&image.path),
None, None,
image.bright, image.bright,
anime_type, anime_type
)?; )?;
proxy.write(matrix.into_data_buffer(anime_type)?)?; proxy.write(matrix.into_data_buffer(anime_type)?)?;
@@ -459,7 +466,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
Vec2::new(gif.x_pos, gif.y_pos), Vec2::new(gif.x_pos, gif.y_pos),
AnimTime::Count(1), AnimTime::Count(1),
gif.bright, gif.bright,
anime_type, anime_type
)?; )?;
let mut loops = gif.loops as i32; let mut loops = gif.loops as i32;
@@ -490,7 +497,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
Path::new(&gif.path), Path::new(&gif.path),
AnimTime::Count(1), AnimTime::Count(1),
gif.bright, gif.bright,
anime_type, anime_type
)?; )?;
let mut loops = gif.loops as i32; let mut loops = gif.loops as i32;
@@ -523,7 +530,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
boot: builtins.boot, boot: builtins.boot,
awake: builtins.awake, awake: builtins.awake,
sleep: builtins.sleep, sleep: builtins.sleep,
shutdown: builtins.shutdown, shutdown: builtins.shutdown
})?; })?;
} }
} }
@@ -544,7 +551,12 @@ fn verify_brightness(brightness: f32) {
fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> { fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
if (cmd.brightness.is_none() if (cmd.brightness.is_none()
&& cmd.interval.is_none() && cmd.interval.is_none()
&& cmd.slash_mode.is_none() && cmd.show_on_boot.is_none()
&& cmd.show_on_shutdown.is_none()
&& cmd.show_on_sleep.is_none()
&& cmd.show_on_battery.is_none()
&& cmd.show_battery_warning.is_none()
&& cmd.mode.is_none()
&& !cmd.list && !cmd.list
&& !cmd.enable && !cmd.enable
&& !cmd.disable) && !cmd.disable)
@@ -556,7 +568,7 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
} }
} }
let slashes = find_iface::<SlashProxyBlocking>("org.asuslinux.Slash")?; let slashes = find_iface::<SlashProxyBlocking>("xyz.ljones.Slash")?;
for proxy in slashes { for proxy in slashes {
if cmd.enable { if cmd.enable {
proxy.set_enabled(true)?; proxy.set_enabled(true)?;
@@ -570,8 +582,24 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
if let Some(interval) = cmd.interval { if let Some(interval) = cmd.interval {
proxy.set_interval(interval)?; proxy.set_interval(interval)?;
} }
if let Some(slash_mode) = cmd.slash_mode { if let Some(slash_mode) = cmd.mode {
proxy.set_slash_mode(slash_mode)?; proxy.set_mode(slash_mode)?;
}
if let Some(show) = cmd.show_on_boot {
proxy.set_show_on_boot(show)?;
}
if let Some(show) = cmd.show_on_shutdown {
proxy.set_show_on_shutdown(show)?;
}
if let Some(show) = cmd.show_on_sleep {
proxy.set_show_on_sleep(show)?;
}
if let Some(show) = cmd.show_on_battery {
proxy.set_show_on_battery(show)?;
}
if let Some(show) = cmd.show_battery_warning {
proxy.set_show_battery_warning(show)?;
} }
} }
if cmd.list { if cmd.list {
@@ -594,7 +622,7 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box<dyn std::error::Error>> {
} }
} }
let scsis = find_iface::<ScsiAuraProxyBlocking>("org.asuslinux.ScsiAura")?; let scsis = find_iface::<ScsiAuraProxyBlocking>("xyz.ljones.ScsiAura")?;
for scsi in scsis { for scsi in scsis {
if let Some(enable) = cmd.enable { if let Some(enable) = cmd.enable {
@@ -609,8 +637,7 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box<dyn std::error::Error>> {
let mut mode = scsi.led_mode_data()?; let mut mode = scsi.led_mode_data()?;
let mut do_update = false; let mut do_update = false;
if !cmd.colours.is_empty() { if !cmd.colours.is_empty() {
let mut count = 0; for (count, c) in cmd.colours.iter().enumerate() {
for c in &cmd.colours {
if count == 0 { if count == 0 {
mode.colour1 = *c; mode.colour1 = *c;
} }
@@ -623,7 +650,6 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box<dyn std::error::Error>> {
if count == 3 { if count == 3 {
mode.colour4 = *c; mode.colour4 = *c;
} }
count += 1;
} }
do_update = true; do_update = true;
} }
@@ -668,7 +694,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
if let Some(cmdlist) = LedModeCommand::command_list() { if let Some(cmdlist) = LedModeCommand::command_list() {
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect(); let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
// TODO: multiple rgb check // TODO: multiple rgb check
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?; let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
let modes = aura.first().unwrap().supported_basic_modes()?; let modes = aura.first().unwrap().supported_basic_modes()?;
for command in commands.iter().filter(|command| { for command in commands.iter().filter(|command| {
for mode in &modes { for mode in &modes {
@@ -698,7 +724,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
println!("Please specify either next or previous"); println!("Please specify either next or previous");
return Ok(()); return Ok(());
} }
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?; let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
if mode.next_mode { if mode.next_mode {
for aura in aura { for aura in aura {
let mode = aura.led_mode()?; let mode = aura.led_mode()?;
@@ -735,7 +761,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
} }
fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error::Error>> { fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error::Error>> {
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?; let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
for aura in aura { for aura in aura {
let dev_type = aura.device_type()?; let dev_type = aura.device_type()?;
if !dev_type.is_old_laptop() && !dev_type.is_tuf_laptop() { if !dev_type.is_old_laptop() && !dev_type.is_tuf_laptop() {
@@ -767,7 +793,7 @@ fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error:
fn handle_led_power_1_do_1866( fn handle_led_power_1_do_1866(
aura: &AuraProxyBlocking, aura: &AuraProxyBlocking,
power: &LedPowerCommand1, power: &LedPowerCommand1
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
let mut states = Vec::new(); let mut states = Vec::new();
if power.keyboard { if power.keyboard {
@@ -776,7 +802,7 @@ fn handle_led_power_1_do_1866(
boot: power.boot.unwrap_or_default(), boot: power.boot.unwrap_or_default(),
awake: power.awake.unwrap_or_default(), awake: power.awake.unwrap_or_default(),
sleep: power.sleep.unwrap_or_default(), sleep: power.sleep.unwrap_or_default(),
shutdown: false, shutdown: false
}); });
} }
if power.lightbar { if power.lightbar {
@@ -785,7 +811,7 @@ fn handle_led_power_1_do_1866(
boot: power.boot.unwrap_or_default(), boot: power.boot.unwrap_or_default(),
awake: power.awake.unwrap_or_default(), awake: power.awake.unwrap_or_default(),
sleep: power.sleep.unwrap_or_default(), sleep: power.sleep.unwrap_or_default(),
shutdown: false, shutdown: false
}); });
} }
@@ -795,7 +821,7 @@ fn handle_led_power_1_do_1866(
} }
fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error::Error>> { fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error::Error>> {
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?; let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
for aura in aura { for aura in aura {
let dev_type = aura.device_type()?; let dev_type = aura.device_type()?;
if !dev_type.is_new_laptop() { if !dev_type.is_new_laptop() {
@@ -847,7 +873,7 @@ fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error:
aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(PowerZones::Lightbar, l), aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(PowerZones::Lightbar, l),
aura_cli::SetAuraZoneEnabled::Lid(l) => set(PowerZones::Lid, l), aura_cli::SetAuraZoneEnabled::Lid(l) => set(PowerZones::Lid, l),
aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(PowerZones::RearGlow, r), aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(PowerZones::RearGlow, r),
aura_cli::SetAuraZoneEnabled::Ally(r) => set(PowerZones::Ally, r), aura_cli::SetAuraZoneEnabled::Ally(r) => set(PowerZones::Ally, r)
} }
} }
@@ -861,7 +887,7 @@ fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error:
fn handle_throttle_profile( fn handle_throttle_profile(
conn: &Connection, conn: &Connection,
supported: &[Properties], supported: &[Properties],
cmd: &ProfileCommand, cmd: &ProfileCommand
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
if !supported.contains(&Properties::ThrottlePolicy) { if !supported.contains(&Properties::ThrottlePolicy) {
println!("Profiles not supported by either this kernel or by the laptop."); println!("Profiles not supported by either this kernel or by the laptop.");
@@ -905,7 +931,7 @@ fn handle_throttle_profile(
fn handle_fan_curve( fn handle_fan_curve(
conn: &Connection, conn: &Connection,
cmd: &FanCurveCommand, cmd: &FanCurveCommand
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
let Ok(fan_proxy) = FanCurvesProxyBlocking::new(conn).map_err(|e| { let Ok(fan_proxy) = FanCurvesProxyBlocking::new(conn).map_err(|e| {
println!("Fan-curves not supported by either this kernel or by the laptop: {e:?}"); println!("Fan-curves not supported by either this kernel or by the laptop: {e:?}");
@@ -984,7 +1010,7 @@ fn handle_fan_curve(
fn handle_platform_properties( fn handle_platform_properties(
conn: &Connection, conn: &Connection,
supported: &[Properties], supported: &[Properties],
cmd: &PlatformCommand, cmd: &PlatformCommand
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
{ {
if (cmd.gpu_mux_mode_set.is_none() if (cmd.gpu_mux_mode_set.is_none()
@@ -1068,3 +1094,93 @@ fn check_systemd_unit_enabled(name: &str) -> bool {
} }
false false
} }
fn print_firmware_attr(attr: &AsusArmouryProxyBlocking) -> Result<(), Box<dyn std::error::Error>> {
let name = attr.name()?;
println!("{}:", <&str>::from(name));
let attrs = attr.available_attrs()?;
if attrs.contains(&"min_value".to_string())
&& attrs.contains(&"max_value".to_string())
&& attrs.contains(&"current_value".to_string())
{
let c = attr.current_value()?;
let min = attr.min_value()?;
let max = attr.max_value()?;
println!(" current: {min}..[{c}]..{max}");
if attrs.contains(&"default_value".to_string()) {
println!(" default: {}\n", attr.default_value()?);
} else {
println!();
}
} else if attrs.contains(&"possible_values".to_string())
&& attrs.contains(&"current_value".to_string())
{
let c = attr.current_value()?;
let v = attr.possible_values()?;
for p in v.iter().enumerate() {
if p.0 == 0 {
print!(" current: [");
}
if *p.1 == c {
print!("({c})");
} else {
print!("{}", p.1);
}
if p.0 < v.len() - 1 {
print!(",");
}
if p.0 == v.len() - 1 {
print!("]");
}
}
if attrs.contains(&"default_value".to_string()) {
println!(" default: {}\n", attr.default_value()?);
} else {
println!("\n");
}
} else if attrs.contains(&"current_value".to_string()) {
let c = attr.current_value()?;
println!(" current: {c}\n");
} else {
println!();
}
Ok(())
}
fn handle_armoury_command(cmd: &ArmouryCommand) -> Result<(), Box<dyn std::error::Error>> {
{
if cmd.free.is_empty() || cmd.free.len() % 2 != 0 || cmd.help {
const USAGE: &str = "Usage: asusctl platform panel_overdrive 1 nv_dynamic_boost 5";
if cmd.free.len() % 2 != 0 {
println!(
"Incorrect number of args, each attribute label must be paired with a setting:"
);
println!("{USAGE}");
return Ok(());
}
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
println!("\n{USAGE}\n");
println!("Available firmware attributes: ");
for attr in attr.iter() {
print_firmware_attr(attr)?;
}
}
return Ok(());
}
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
for cmd in cmd.free.chunks(2) {
for attr in attr.iter() {
let name = attr.name()?;
if <&str>::from(name) == cmd[0] {
attr.set_current_value(cmd[1].parse()?)?;
print_firmware_attr(attr)?;
}
}
}
}
}
Ok(())
}

View File

@@ -31,5 +31,5 @@ pub struct ScsiCommand {
pub colours: Vec<Colour>, pub colours: Vec<Colour>,
#[options(help = "list available animations")] #[options(help = "list available animations")]
pub list: bool, pub list: bool
} }

View File

@@ -9,12 +9,27 @@ pub struct SlashCommand {
pub enable: bool, pub enable: bool,
#[options(help = "Ddisable the Slash Ledbar")] #[options(help = "Ddisable the Slash Ledbar")]
pub disable: bool, pub disable: bool,
#[options(meta = "", help = "Set brightness value <0-255>")] #[options(short = "l", meta = "", help = "Set brightness value <0-255>")]
pub brightness: Option<u8>, pub brightness: Option<u8>,
#[options(meta = "", help = "Set interval value <0-5>")] #[options(meta = "", help = "Set interval value <0-5>")]
pub interval: Option<u8>, pub interval: Option<u8>,
#[options(meta = "", help = "Set SlashMode (so 'list' for all options)")] #[options(meta = "", help = "Set SlashMode (so 'list' for all options)")]
pub slash_mode: Option<SlashMode>, pub mode: Option<SlashMode>,
#[options(help = "list available animations")] #[options(help = "list available animations")]
pub list: bool, pub list: bool,
#[options(short = "B", meta = "", help = "Show the animation on boot")]
pub show_on_boot: Option<bool>,
#[options(short = "S", meta = "", help = "Show the animation on shutdown")]
pub show_on_shutdown: Option<bool>,
#[options(short = "s", meta = "", help = "Show the animation on sleep")]
pub show_on_sleep: Option<bool>,
#[options(short = "b", meta = "", help = "Show the animation on battery")]
pub show_on_battery: Option<bool>,
#[options(
short = "w",
meta = "",
help = "Show the low-battery warning animation"
)]
pub show_battery_warning: Option<bool>
} }

View File

@@ -21,7 +21,7 @@ fn root_conf_dir() -> PathBuf {
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
pub struct ConfigAnime { pub struct ConfigAnime {
pub name: String, pub name: String,
pub anime: Vec<ActionLoader>, pub anime: Vec<ActionLoader>
} }
impl ConfigAnime { impl ConfigAnime {
@@ -52,8 +52,8 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new( time: AnimTime::Fade(Fade::new(
Duration::from_secs(2), Duration::from_secs(2),
None, None,
Duration::from_secs(2), Duration::from_secs(2)
)), ))
}, },
ActionLoader::AsusAnimation { ActionLoader::AsusAnimation {
file: "/usr/share/asusd/anime/asus/rog/Sunset.gif".into(), file: "/usr/share/asusd/anime/asus/rog/Sunset.gif".into(),
@@ -61,8 +61,8 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new( time: AnimTime::Fade(Fade::new(
Duration::from_secs(6), Duration::from_secs(6),
None, None,
Duration::from_secs(3), Duration::from_secs(3)
)), ))
}, },
ActionLoader::ImageAnimation { ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(), file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
@@ -73,8 +73,8 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new( time: AnimTime::Fade(Fade::new(
Duration::from_secs(2), Duration::from_secs(2),
Some(Duration::from_secs(2)), Some(Duration::from_secs(2)),
Duration::from_secs(2), Duration::from_secs(2)
)), ))
}, },
ActionLoader::Image { ActionLoader::Image {
file: "/usr/share/asusd/anime/custom/rust.png".into(), file: "/usr/share/asusd/anime/custom/rust.png".into(),
@@ -84,9 +84,9 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new( time: AnimTime::Fade(Fade::new(
Duration::from_secs(2), Duration::from_secs(2),
Some(Duration::from_secs(1)), Some(Duration::from_secs(1)),
Duration::from_secs(2), Duration::from_secs(2)
)), )),
brightness: 0.6, brightness: 0.6
}, },
ActionLoader::Pause(Duration::from_secs(1)), ActionLoader::Pause(Duration::from_secs(1)),
ActionLoader::ImageAnimation { ActionLoader::ImageAnimation {
@@ -95,9 +95,9 @@ impl Default for ConfigAnime {
angle: 0.0, angle: 0.0,
translation: Vec2::new(3.0, 2.0), translation: Vec2::new(3.0, 2.0),
brightness: 0.5, brightness: 0.5,
time: AnimTime::Count(2), time: AnimTime::Count(2)
}, },
], ]
} }
} }
} }
@@ -121,7 +121,7 @@ impl StdConfigLoad for ConfigAnime {}
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
pub struct ConfigAura { pub struct ConfigAura {
pub name: String, pub name: String,
pub aura: AuraSequences, pub aura: AuraSequences
} }
impl ConfigAura { impl ConfigAura {
@@ -139,14 +139,14 @@ impl Default for ConfigAura {
Colour { Colour {
r: 255, r: 255,
g: 0, g: 0,
b: 20, b: 20
}, },
Colour { Colour {
r: 20, r: 20,
g: 255, g: 255,
b: 0, b: 0
}, },
Speed::Low, Speed::Low
)); ));
seq.push(key.clone()); seq.push(key.clone());
@@ -161,7 +161,7 @@ impl Default for ConfigAura {
LedCode::F, LedCode::F,
Colour { r: 255, g: 0, b: 0 }, Colour { r: 255, g: 0, b: 0 },
Colour { r: 255, g: 0, b: 0 }, Colour { r: 255, g: 0, b: 0 },
Speed::High, Speed::High
)); ));
seq.push(key); seq.push(key);
@@ -176,13 +176,13 @@ impl Default for ConfigAura {
LedCode::N9, LedCode::N9,
Colour { r: 0, g: 0, b: 255 }, Colour { r: 0, g: 0, b: 255 },
80, 80,
40, 40
)); ));
seq.push(key); seq.push(key);
Self { Self {
name: "aura-default".to_owned(), name: "aura-default".to_owned(),
aura: seq, aura: seq
} }
} }
} }
@@ -209,14 +209,14 @@ pub struct ConfigBase {
/// Name of active anime config file in the user config directory /// Name of active anime config file in the user config directory
pub active_anime: Option<String>, pub active_anime: Option<String>,
/// Name of active aura config file in the user config directory /// Name of active aura config file in the user config directory
pub active_aura: Option<String>, pub active_aura: Option<String>
} }
impl StdConfig for ConfigBase { impl StdConfig for ConfigBase {
fn new() -> Self { fn new() -> Self {
Self { Self {
active_anime: Some("anime-default".to_owned()), active_anime: Some("anime-default".to_owned()),
active_aura: Some("aura-default".to_owned()), active_aura: Some("aura-default".to_owned())
} }
} }

View File

@@ -25,7 +25,7 @@ pub struct Timer {
/// Used only for `TimeType::Timer`, milliseonds to fade the image in for /// Used only for `TimeType::Timer`, milliseonds to fade the image in for
fade_in: u64, fade_in: u64,
/// Used only for `TimeType::Timer`, milliseonds to fade the image out for /// Used only for `TimeType::Timer`, milliseonds to fade the image out for
fade_out: u64, fade_out: u64
} }
impl From<Timer> for AnimTime { impl From<Timer> for AnimTime {
@@ -46,7 +46,7 @@ impl From<Timer> for AnimTime {
} }
} }
TimeType::Count => AnimTime::Count(time.count as u32), TimeType::Count => AnimTime::Count(time.count as u32),
TimeType::Infinite => AnimTime::Infinite, TimeType::Infinite => AnimTime::Infinite
} }
} }
} }
@@ -55,7 +55,7 @@ impl From<Timer> for AnimTime {
pub enum TimeType { pub enum TimeType {
Timer, Timer,
Count, Count,
Infinite, Infinite
} }
/// The inner object exists to allow the zbus proxy to share it with a runner /// The inner object exists to allow the zbus proxy to share it with a runner
@@ -63,19 +63,19 @@ pub enum TimeType {
pub struct CtrlAnimeInner<'a> { pub struct CtrlAnimeInner<'a> {
sequences: Sequences, sequences: Sequences,
client: AnimeProxyBlocking<'a>, client: AnimeProxyBlocking<'a>,
do_early_return: Arc<AtomicBool>, do_early_return: Arc<AtomicBool>
} }
impl CtrlAnimeInner<'static> { impl CtrlAnimeInner<'static> {
pub fn new( pub fn new(
sequences: Sequences, sequences: Sequences,
client: AnimeProxyBlocking<'static>, client: AnimeProxyBlocking<'static>,
do_early_return: Arc<AtomicBool>, do_early_return: Arc<AtomicBool>
) -> Result<Self, Error> { ) -> Result<Self, Error> {
Ok(Self { Ok(Self {
sequences, sequences,
client, client,
do_early_return, do_early_return
}) })
} }
@@ -130,7 +130,7 @@ pub struct CtrlAnime<'a> {
client: AnimeProxyBlocking<'a>, client: AnimeProxyBlocking<'a>,
inner: Arc<Mutex<CtrlAnimeInner<'a>>>, inner: Arc<Mutex<CtrlAnimeInner<'a>>>,
/// Must be the same Atomic as in CtrlAnimeInner /// Must be the same Atomic as in CtrlAnimeInner
inner_early_return: Arc<AtomicBool>, inner_early_return: Arc<AtomicBool>
} }
impl CtrlAnime<'static> { impl CtrlAnime<'static> {
@@ -138,23 +138,20 @@ impl CtrlAnime<'static> {
config: Arc<Mutex<ConfigAnime>>, config: Arc<Mutex<ConfigAnime>>,
inner: Arc<Mutex<CtrlAnimeInner<'static>>>, inner: Arc<Mutex<CtrlAnimeInner<'static>>>,
client: AnimeProxyBlocking<'static>, client: AnimeProxyBlocking<'static>,
inner_early_return: Arc<AtomicBool>, inner_early_return: Arc<AtomicBool>
) -> Result<Self, Error> { ) -> Result<Self, Error> {
Ok(CtrlAnime { Ok(CtrlAnime {
config, config,
client, client,
inner, inner,
inner_early_return, inner_early_return
}) })
} }
pub async fn add_to_server(self, server: &mut zbus::Connection) { pub async fn add_to_server(self, server: &mut zbus::Connection) {
server server
.object_server() .object_server()
.at( .at(&ObjectPath::from_str_unchecked("/xyz/ljones/Anime"), self)
&ObjectPath::from_str_unchecked("/org/asuslinux/Anime"),
self,
)
.await .await
.map_err(|err| { .map_err(|err| {
println!("CtrlAnime: add_to_server {}", err); println!("CtrlAnime: add_to_server {}", err);
@@ -170,14 +167,14 @@ impl CtrlAnime<'static> {
// - Do actions // - Do actions
// - Write config if required // - Write config if required
// - Unset inner_early_return // - Unset inner_early_return
#[interface(name = "org.asuslinux.Daemon")] #[interface(name = "xyz.ljones.Asusd")]
impl CtrlAnime<'static> { impl CtrlAnime<'static> {
pub fn insert_asus_gif( pub fn insert_asus_gif(
&mut self, &mut self,
index: u32, index: u32,
file: &str, file: &str,
time: Timer, time: Timer,
brightness: f32, brightness: f32
) -> zbus::fdo::Result<String> { ) -> zbus::fdo::Result<String> {
if let Ok(mut config) = self.config.try_lock() { if let Ok(mut config) = self.config.try_lock() {
let time: AnimTime = time.into(); let time: AnimTime = time.into();
@@ -185,7 +182,7 @@ impl CtrlAnime<'static> {
let action = ActionLoader::AsusAnimation { let action = ActionLoader::AsusAnimation {
file: file.into(), file: file.into(),
brightness, brightness,
time, time
}; };
// Must make the inner run loop return early // Must make the inner run loop return early
@@ -219,7 +216,7 @@ impl CtrlAnime<'static> {
angle: f32, angle: f32,
xy: (f32, f32), xy: (f32, f32),
time: Timer, time: Timer,
brightness: f32, brightness: f32
) -> zbus::fdo::Result<String> { ) -> zbus::fdo::Result<String> {
if let Ok(mut config) = self.config.try_lock() { if let Ok(mut config) = self.config.try_lock() {
let time: AnimTime = time.into(); let time: AnimTime = time.into();
@@ -231,7 +228,7 @@ impl CtrlAnime<'static> {
angle, angle,
translation, translation,
brightness, brightness,
time, time
}; };
// Must make the inner run loop return early // Must make the inner run loop return early
@@ -264,7 +261,7 @@ impl CtrlAnime<'static> {
angle: f32, angle: f32,
xy: (f32, f32), xy: (f32, f32),
time: Timer, time: Timer,
brightness: f32, brightness: f32
) -> zbus::fdo::Result<String> { ) -> zbus::fdo::Result<String> {
if let Ok(mut config) = self.config.try_lock() { if let Ok(mut config) = self.config.try_lock() {
let file = Path::new(&file); let file = Path::new(&file);
@@ -275,7 +272,7 @@ impl CtrlAnime<'static> {
angle, angle,
translation: Vec2::new(xy.0, xy.1), translation: Vec2::new(xy.0, xy.1),
brightness, brightness,
time, time
}; };
// Must make the inner run loop return early // Must make the inner run loop return early

View File

@@ -42,7 +42,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let early_return = Arc::new(AtomicBool::new(false)); let early_return = Arc::new(AtomicBool::new(false));
// Set up the anime data and run loop/thread // Set up the anime data and run loop/thread
if supported.contains(&"org.asuslinux.Anime".to_string()) { if supported.contains(&"xyz.ljones.Anime".to_string()) {
if let Some(cfg) = config.active_anime { if let Some(cfg) = config.active_anime {
let anime_type = get_anime_type(); let anime_type = get_anime_type();
let anime_config = ConfigAnime::new().set_name(cfg).load(); let anime_config = ConfigAnime::new().set_name(cfg).load();
@@ -61,16 +61,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
CtrlAnimeInner::new( CtrlAnimeInner::new(
anime, anime,
anime_proxy_blocking.clone(), anime_proxy_blocking.clone(),
early_return.clone(), early_return.clone()
) )
.unwrap(), .unwrap()
)); ));
// Need new client object for dbus control part // Need new client object for dbus control part
let anime_control = CtrlAnime::new( let anime_control = CtrlAnime::new(
anime_config, anime_config,
inner.clone(), inner.clone(),
anime_proxy_blocking, anime_proxy_blocking,
early_return, early_return
) )
.unwrap(); .unwrap();
anime_control.add_to_server(&mut connection).await; anime_control.add_to_server(&mut connection).await;

View File

@@ -8,7 +8,7 @@ pub enum Error {
ConfigLoadFail, ConfigLoadFail,
ConfigLockFail, ConfigLockFail,
XdgVars, XdgVars,
Anime(AnimeError), Anime(AnimeError)
} }
impl fmt::Display for Error { impl fmt::Display for Error {
@@ -19,7 +19,7 @@ impl fmt::Display for Error {
Error::ConfigLoadFail => write!(f, "Failed to load user config"), Error::ConfigLoadFail => write!(f, "Failed to load user config"),
Error::ConfigLockFail => write!(f, "Failed to lock user config"), Error::ConfigLockFail => write!(f, "Failed to lock user config"),
Error::XdgVars => write!(f, "XDG environment vars appear unset"), Error::XdgVars => write!(f, "XDG environment vars appear unset"),
Error::Anime(err) => write!(f, "Anime error: {}", err), Error::Anime(err) => write!(f, "Anime error: {}", err)
} }
} }
} }

View File

@@ -1,8 +1,8 @@
//! # `DBus` interface proxy for: `org.asuslinux.Daemon` //! # `DBus` interface proxy for: `xyz.ljones.Asusd`
//! //!
//! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection //! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection
//! data. Source: `Interface '/org/asuslinux/Anime' from service //! data. Source: `Interface '/xyz/ljones/Anime' from service
//! 'org.asuslinux.Daemon' on session bus`. //! 'xyz.ljones.Asusd' on session bus`.
//! //!
//! You may prefer to adapt it, instead of using it verbatim. //! You may prefer to adapt it, instead of using it verbatim.
//! //!
@@ -23,10 +23,7 @@
use zbus::proxy; use zbus::proxy;
#[proxy( #[proxy(interface = "xyz.ljones.Asusd", default_path = "/xyz/ljones/Anime")]
interface = "org.asuslinux.Daemon",
default_path = "/org/asuslinux/Anime"
)]
trait Daemon { trait Daemon {
/// InsertAsusGif method /// InsertAsusGif method
fn insert_asus_gif( fn insert_asus_gif(
@@ -35,7 +32,7 @@ trait Daemon {
file: &str, file: &str,
time: u32, time: u32,
count: u32, count: u32,
brightness: f64, brightness: f64
) -> zbus::Result<String>; ) -> zbus::Result<String>;
/// InsertImage method /// InsertImage method
@@ -46,7 +43,7 @@ trait Daemon {
scale: f64, scale: f64,
angle: f64, angle: f64,
xy: &(f64, f64), xy: &(f64, f64),
brightness: f64, brightness: f64
) -> zbus::Result<String>; ) -> zbus::Result<String>;
/// InsertImageGif method /// InsertImageGif method
@@ -59,7 +56,7 @@ trait Daemon {
xy: &(f64, f64), xy: &(f64, f64),
time: u32, time: u32,
count: u32, count: u32,
brightness: f64, brightness: f64
) -> zbus::Result<String>; ) -> zbus::Result<String>;
/// InsertPause method /// InsertPause method

155
asusd/src/asus_armoury.rs Normal file
View File

@@ -0,0 +1,155 @@
use log::error;
use rog_platform::firmware_attributes::{
AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes
};
use serde::{Deserialize, Serialize};
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::{fdo, interface, Connection};
use crate::error::RogError;
use crate::ASUS_ZBUS_PATH;
const MOD_NAME: &str = "asus_armoury";
#[derive(Debug, Default, Clone, Deserialize, Serialize, Type, Value, OwnedValue)]
pub struct PossibleValues {
strings: Vec<String>,
nums: Vec<i32>
}
fn dbus_path_for_attr(attr_name: &str) -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{attr_name}")).into()
}
pub struct AsusArmouryAttribute(Attribute);
impl AsusArmouryAttribute {
pub fn new(attr: Attribute) -> Self {
Self(attr)
}
pub async fn start_tasks(self, connection: &Connection) -> Result<(), RogError> {
// self.reload()
// .await
// .unwrap_or_else(|err| warn!("Controller error: {}", err));
let path = dbus_path_for_attr(self.0.name());
connection
.object_server()
.at(path.clone(), self)
.await
.map_err(|e| error!("Couldn't add server at path: {path}, {e:?}"))
.ok();
Ok(())
}
}
/// If return is `-1` on a property then there is avilable value for that
/// property
#[interface(name = "xyz.ljones.AsusArmoury")]
impl AsusArmouryAttribute {
#[zbus(property)]
async fn name(&self) -> FirmwareAttribute {
self.0.name().into()
}
#[zbus(property)]
async fn available_attrs(&self) -> Vec<String> {
let mut attrs = Vec::new();
if !matches!(self.0.default_value(), AttrValue::None) {
attrs.push("default_value".to_string());
}
if !matches!(self.0.min_value(), AttrValue::None) {
attrs.push("min_value".to_string());
}
if !matches!(self.0.max_value(), AttrValue::None) {
attrs.push("max_value".to_string());
}
if !matches!(self.0.scalar_increment(), AttrValue::None) {
attrs.push("scalar_increment".to_string());
}
if !matches!(self.0.possible_values(), AttrValue::None) {
attrs.push("possible_values".to_string());
}
// TODO: Don't unwrap, use error
if let Ok(value) = self.0.current_value().map_err(|e| {
error!("Failed to read: {e:?}");
e
}) {
if !matches!(value, AttrValue::None) {
attrs.push("current_value".to_string());
}
}
attrs
}
/// If return is `-1` then there is no default value
#[zbus(property)]
async fn default_value(&self) -> i32 {
match self.0.default_value() {
AttrValue::Integer(i) => *i,
_ => -1
}
}
#[zbus(property)]
async fn min_value(&self) -> i32 {
match self.0.min_value() {
AttrValue::Integer(i) => *i,
_ => -1
}
}
#[zbus(property)]
async fn max_value(&self) -> i32 {
match self.0.max_value() {
AttrValue::Integer(i) => *i,
_ => -1
}
}
#[zbus(property)]
async fn scalar_increment(&self) -> i32 {
match self.0.scalar_increment() {
AttrValue::Integer(i) => *i,
_ => -1
}
}
#[zbus(property)]
async fn possible_values(&self) -> Vec<i32> {
match self.0.possible_values() {
AttrValue::EnumInt(i) => i.clone(),
_ => Vec::default()
}
}
#[zbus(property)]
async fn current_value(&self) -> fdo::Result<i32> {
if let Ok(AttrValue::Integer(i)) = self.0.current_value() {
return Ok(i);
}
Err(fdo::Error::Failed(
"Could not read current value".to_string()
))
}
#[zbus(property)]
async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> {
Ok(self
.0
.set_current_value(AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?)
}
}
pub async fn start_attributes_zbus(server: &Connection) -> Result<(), RogError> {
for attr in FirmwareAttributes::new().attributes() {
AsusArmouryAttribute::new(attr.clone())
.start_tasks(server)
.await?;
}
Ok(())
}

View File

@@ -4,7 +4,7 @@ use config_traits::{StdConfig, StdConfigLoad};
use rog_anime::error::AnimeError; use rog_anime::error::AnimeError;
use rog_anime::usb::Brightness; use rog_anime::usb::Brightness;
use rog_anime::{ use rog_anime::{
ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2, ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -15,14 +15,14 @@ pub struct AniMeConfigCached {
pub system: Vec<ActionData>, pub system: Vec<ActionData>,
pub boot: Vec<ActionData>, pub boot: Vec<ActionData>,
pub wake: Vec<ActionData>, pub wake: Vec<ActionData>,
pub shutdown: Vec<ActionData>, pub shutdown: Vec<ActionData>
} }
impl AniMeConfigCached { impl AniMeConfigCached {
pub fn init_from_config( pub fn init_from_config(
&mut self, &mut self,
config: &AniMeConfig, config: &AniMeConfig,
anime_type: AnimeType, anime_type: AnimeType
) -> Result<(), AnimeError> { ) -> Result<(), AnimeError> {
let mut sys = Vec::with_capacity(config.system.len()); let mut sys = Vec::with_capacity(config.system.len());
for ani in &config.system { for ani in &config.system {
@@ -68,7 +68,7 @@ pub struct AniMeConfig {
pub off_when_suspended: bool, pub off_when_suspended: bool,
pub off_when_lid_closed: bool, pub off_when_lid_closed: bool,
pub brightness_on_battery: Brightness, pub brightness_on_battery: Brightness,
pub builtin_anims: Animations, pub builtin_anims: Animations
} }
impl Default for AniMeConfig { impl Default for AniMeConfig {
@@ -87,7 +87,7 @@ impl Default for AniMeConfig {
off_when_suspended: true, off_when_suspended: true,
off_when_lid_closed: true, off_when_lid_closed: true,
brightness_on_battery: Brightness::Low, brightness_on_battery: Brightness::Low,
builtin_anims: Animations::default(), builtin_anims: Animations::default()
} }
} }
} }
@@ -118,7 +118,7 @@ impl From<&AniMeConfig> for DeviceState {
off_when_unplugged: config.off_when_unplugged, off_when_unplugged: config.off_when_unplugged,
off_when_suspended: config.off_when_suspended, off_when_suspended: config.off_when_suspended,
off_when_lid_closed: config.off_when_lid_closed, off_when_lid_closed: config.off_when_lid_closed,
brightness_on_battery: config.brightness_on_battery, brightness_on_battery: config.brightness_on_battery
} }
} }
} }
@@ -138,38 +138,44 @@ impl AniMeConfig {
// create a default config here // create a default config here
AniMeConfig { AniMeConfig {
system: vec![], system: vec![],
boot: vec![ActionLoader::ImageAnimation { boot: vec![
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(), ActionLoader::ImageAnimation {
scale: 0.9, file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
angle: 0.65, scale: 0.9,
translation: Vec2::default(), angle: 0.65,
brightness: 1.0, translation: Vec2::default(),
time: AnimTime::Fade(Fade::new( brightness: 1.0,
Duration::from_secs(2), time: AnimTime::Fade(Fade::new(
Some(Duration::from_secs(2)), Duration::from_secs(2),
Duration::from_secs(2), Some(Duration::from_secs(2)),
)), Duration::from_secs(2)
}], ))
wake: vec![ActionLoader::ImageAnimation { },
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(), ],
scale: 0.9, wake: vec![
angle: 0.65, ActionLoader::ImageAnimation {
translation: Vec2::default(), file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
brightness: 1.0, scale: 0.9,
time: AnimTime::Fade(Fade::new( angle: 0.65,
Duration::from_secs(2), translation: Vec2::default(),
Some(Duration::from_secs(2)), brightness: 1.0,
Duration::from_secs(2), time: AnimTime::Fade(Fade::new(
)), Duration::from_secs(2),
}], Some(Duration::from_secs(2)),
shutdown: vec![ActionLoader::ImageAnimation { Duration::from_secs(2)
file: "/usr/share/asusd/anime/custom/sonic-wait.gif".into(), ))
scale: 0.9, },
angle: 0.0, ],
translation: Vec2::new(3.0, 2.0), shutdown: vec![
brightness: 1.0, ActionLoader::ImageAnimation {
time: AnimTime::Infinite, file: "/usr/share/asusd/anime/custom/sonic-wait.gif".into(),
}], scale: 0.9,
angle: 0.0,
translation: Vec2::new(3.0, 2.0),
brightness: 1.0,
time: AnimTime::Infinite
},
],
..Default::default() ..Default::default()
} }
} }

View File

@@ -11,7 +11,7 @@ use config_traits::StdConfig;
use log::{error, info, warn}; use log::{error, info, warn};
use rog_anime::usb::{ use rog_anime::usb::{
pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim, pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim,
pkts_for_init, Brightness, pkts_for_init, Brightness
}; };
use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType}; use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
@@ -30,14 +30,14 @@ pub struct AniMe {
// set to force thread to exit // set to force thread to exit
thread_exit: Arc<AtomicBool>, thread_exit: Arc<AtomicBool>,
// Set to false when the thread exits // Set to false when the thread exits
thread_running: Arc<AtomicBool>, thread_running: Arc<AtomicBool>
} }
impl AniMe { impl AniMe {
pub fn new( pub fn new(
hid: Option<Arc<Mutex<HidRaw>>>, hid: Option<Arc<Mutex<HidRaw>>>,
usb: Option<Arc<Mutex<USBRaw>>>, usb: Option<Arc<Mutex<USBRaw>>>,
config: Arc<Mutex<AniMeConfig>>, config: Arc<Mutex<AniMeConfig>>
) -> Self { ) -> Self {
Self { Self {
hid, hid,
@@ -45,7 +45,7 @@ impl AniMe {
config, config,
cache: AniMeConfigCached::default(), cache: AniMeConfigCached::default(),
thread_exit: Arc::new(AtomicBool::new(false)), thread_exit: Arc::new(AtomicBool::new(false)),
thread_running: Arc::new(AtomicBool::new(false)), thread_running: Arc::new(AtomicBool::new(false))
} }
} }
@@ -106,7 +106,7 @@ impl AniMe {
pub async fn set_builtins_enabled( pub async fn set_builtins_enabled(
&self, &self,
enabled: bool, enabled: bool,
bright: Brightness, bright: Brightness
) -> Result<(), RogError> { ) -> Result<(), RogError> {
self.write_bytes(&pkt_set_enable_powersave_anim(enabled)) self.write_bytes(&pkt_set_enable_powersave_anim(enabled))
.await?; .await?;
@@ -229,7 +229,7 @@ impl AniMe {
} }
inner inner
.write_bytes(&pkt_set_enable_powersave_anim( .write_bytes(&pkt_set_enable_powersave_anim(
inner.config.lock().await.builtin_anims_enabled, inner.config.lock().await.builtin_anims_enabled
)) ))
.await .await
.map_err(|err| { .map_err(|err| {

View File

@@ -5,7 +5,7 @@ use log::{error, warn};
use logind_zbus::manager::ManagerProxy; use logind_zbus::manager::ManagerProxy;
use rog_anime::usb::{ use rog_anime::usb::{
pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display, pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display,
pkt_set_enable_powersave_anim, Brightness, pkt_set_enable_powersave_anim, Brightness
}; };
use rog_anime::{Animations, AnimeDataBuffer, DeviceState}; use rog_anime::{Animations, AnimeDataBuffer, DeviceState};
use zbus::object_server::SignalEmitter; use zbus::object_server::SignalEmitter;
@@ -41,7 +41,7 @@ impl AniMeZbus {
pub async fn start_tasks( pub async fn start_tasks(
mut self, mut self,
connection: &Connection, connection: &Connection,
path: OwnedObjectPath, path: OwnedObjectPath
) -> Result<(), RogError> { ) -> Result<(), RogError> {
// let task = zbus.clone(); // let task = zbus.clone();
self.reload() self.reload()
@@ -60,7 +60,7 @@ impl AniMeZbus {
// None of these calls can be guarnateed to succeed unless we loop until okay // None of these calls can be guarnateed to succeed unless we loop until okay
// If the try_lock *does* succeed then any other thread trying to lock will not // If the try_lock *does* succeed then any other thread trying to lock will not
// grab it until we finish. // grab it until we finish.
#[interface(name = "org.asuslinux.Anime")] #[interface(name = "xyz.ljones.Anime")]
impl AniMeZbus { impl AniMeZbus {
/// Writes a data stream of length. Will force system thread to exit until /// Writes a data stream of length. Will force system thread to exit until
/// it is restarted /// it is restarted
@@ -166,10 +166,7 @@ impl AniMeZbus {
async fn set_builtin_animations(&self, settings: Animations) { async fn set_builtin_animations(&self, settings: Animations) {
self.0 self.0
.write_bytes(&pkt_set_builtin_animations( .write_bytes(&pkt_set_builtin_animations(
settings.boot, settings.boot, settings.awake, settings.sleep, settings.shutdown
settings.awake,
settings.sleep,
settings.shutdown,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -319,7 +316,7 @@ impl crate::CtrlTask for AniMeZbus {
inner inner
.write_bytes(&pkt_set_enable_display( .write_bytes(&pkt_set_enable_display(
!(sleeping && config.off_when_suspended), !(sleeping && config.off_when_suspended)
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -330,7 +327,7 @@ impl crate::CtrlTask for AniMeZbus {
if config.builtin_anims_enabled { if config.builtin_anims_enabled {
inner inner
.write_bytes(&pkt_set_enable_powersave_anim( .write_bytes(&pkt_set_enable_powersave_anim(
!(sleeping && config.off_when_suspended), !(sleeping && config.off_when_suspended)
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -433,7 +430,7 @@ impl crate::CtrlTask for AniMeZbus {
.ok(); .ok();
} }
} }
}, }
) )
.await; .await;
@@ -449,10 +446,7 @@ impl crate::Reloadable for AniMeZbus {
if config.builtin_anims_enabled { if config.builtin_anims_enabled {
self.0 self.0
.write_bytes(&pkt_set_builtin_animations( .write_bytes(&pkt_set_builtin_animations(
anim.boot, anim.boot, anim.awake, anim.sleep, anim.shutdown
anim.awake,
anim.sleep,
anim.shutdown,
)) ))
.await?; .await?;
} }

View File

@@ -5,7 +5,7 @@ use log::{debug, info, warn};
use rog_aura::aura_detection::LedSupportData; use rog_aura::aura_detection::LedSupportData;
use rog_aura::keyboard::LaptopAuraPower; use rog_aura::keyboard::LaptopAuraPower;
use rog_aura::{ use rog_aura::{
AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT, AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -29,7 +29,7 @@ pub struct AuraConfig {
pub multizone_on: bool, pub multizone_on: bool,
pub enabled: LaptopAuraPower, pub enabled: LaptopAuraPower,
#[serde(skip)] #[serde(skip)]
pub per_key_mode_active: bool, pub per_key_mode_active: bool
} }
impl StdConfig for AuraConfig { impl StdConfig for AuraConfig {
@@ -74,7 +74,7 @@ impl AuraConfig {
multizone: None, multizone: None,
multizone_on: false, multizone_on: false,
enabled, enabled,
per_key_mode_active: false, per_key_mode_active: false
}; };
for n in &config.support_data.basic_modes { for n in &config.support_data.basic_modes {
@@ -92,7 +92,7 @@ impl AuraConfig {
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]), colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]), colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
speed: Speed::Med, speed: Speed::Med,
direction: Direction::Left, direction: Direction::Left
}); });
} }
if let Some(m) = config.multizone.as_mut() { if let Some(m) = config.multizone.as_mut() {
@@ -156,7 +156,7 @@ impl AuraConfig {
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]), colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]), colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
speed: Speed::Med, speed: Speed::Med,
direction: Direction::Left, direction: Direction::Left
}); });
} }
if default.is_empty() { if default.is_empty() {
@@ -232,7 +232,7 @@ impl AuraConfig {
mod tests { mod tests {
use rog_aura::keyboard::AuraPowerState; use rog_aura::keyboard::AuraPowerState;
use rog_aura::{ use rog_aura::{
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed, AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed
}; };
use super::AuraConfig; use super::AuraConfig;
@@ -246,7 +246,7 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0xff, r: 0xff,
g: 0x00, g: 0x00,
b: 0xff, b: 0xff
}, },
zone: AuraZone::Key1, zone: AuraZone::Key1,
..Default::default() ..Default::default()
@@ -259,7 +259,7 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0x00, r: 0x00,
g: 0xff, g: 0xff,
b: 0xff, b: 0xff
}, },
zone: AuraZone::Key2, zone: AuraZone::Key2,
..Default::default() ..Default::default()
@@ -270,7 +270,7 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0xff, r: 0xff,
g: 0xff, g: 0xff,
b: 0x00, b: 0x00
}, },
zone: AuraZone::Key3, zone: AuraZone::Key3,
..Default::default() ..Default::default()
@@ -281,7 +281,7 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0x00, r: 0x00,
g: 0xff, g: 0xff,
b: 0x00, b: 0x00
}, },
zone: AuraZone::Key4, zone: AuraZone::Key4,
..Default::default() ..Default::default()
@@ -294,38 +294,26 @@ mod tests {
let res = config.multizone.unwrap(); let res = config.multizone.unwrap();
let sta = res.get(&AuraModeNum::Static).unwrap(); let sta = res.get(&AuraModeNum::Static).unwrap();
assert_eq!(sta.len(), 4); assert_eq!(sta.len(), 4);
assert_eq!( assert_eq!(sta[0].colour1, Colour {
sta[0].colour1, r: 0xff,
Colour { g: 0x00,
r: 0xff, b: 0xff
g: 0x00, });
b: 0xff assert_eq!(sta[1].colour1, Colour {
} r: 0x00,
); g: 0xff,
assert_eq!( b: 0xff
sta[1].colour1, });
Colour { assert_eq!(sta[2].colour1, Colour {
r: 0x00, r: 0xff,
g: 0xff, g: 0xff,
b: 0xff b: 0x00
} });
); assert_eq!(sta[3].colour1, Colour {
assert_eq!( r: 0x00,
sta[2].colour1, g: 0xff,
Colour { b: 0x00
r: 0xff, });
g: 0xff,
b: 0x00
}
);
assert_eq!(
sta[3].colour1,
Colour {
r: 0x00,
g: 0xff,
b: 0x00
}
);
} }
#[test] #[test]
@@ -383,28 +371,22 @@ mod tests {
assert_eq!(config.brightness, LedBrightness::Med); assert_eq!(config.brightness, LedBrightness::Med);
assert_eq!(config.builtins.len(), 5); assert_eq!(config.builtins.len(), 5);
assert_eq!( assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
config.builtins.first_entry().unwrap().get(), mode: AuraModeNum::Static,
&AuraEffect { zone: AuraZone::None,
mode: AuraModeNum::Static, colour1: Colour { r: 166, g: 0, b: 0 },
zone: AuraZone::None, colour2: Colour { r: 0, g: 0, b: 0 },
colour1: Colour { r: 166, g: 0, b: 0 }, speed: Speed::Med,
colour2: Colour { r: 0, g: 0, b: 0 }, direction: Direction::Right
speed: Speed::Med, });
direction: Direction::Right
}
);
assert_eq!(config.enabled.states.len(), 1); assert_eq!(config.enabled.states.len(), 1);
assert_eq!( assert_eq!(config.enabled.states[0], AuraPowerState {
config.enabled.states[0], zone: PowerZones::KeyboardAndLightbar,
AuraPowerState { boot: true,
zone: PowerZones::KeyboardAndLightbar, awake: true,
boot: true, sleep: true,
awake: true, shutdown: true
sleep: true, });
shutdown: true
}
);
} }
#[test] #[test]
@@ -414,27 +396,21 @@ mod tests {
assert_eq!(config.brightness, LedBrightness::Med); assert_eq!(config.brightness, LedBrightness::Med);
assert_eq!(config.builtins.len(), 12); assert_eq!(config.builtins.len(), 12);
assert_eq!( assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
config.builtins.first_entry().unwrap().get(), mode: AuraModeNum::Static,
&AuraEffect { zone: AuraZone::None,
mode: AuraModeNum::Static, colour1: Colour { r: 166, g: 0, b: 0 },
zone: AuraZone::None, colour2: Colour { r: 0, g: 0, b: 0 },
colour1: Colour { r: 166, g: 0, b: 0 }, speed: Speed::Med,
colour2: Colour { r: 0, g: 0, b: 0 }, direction: Direction::Right
speed: Speed::Med, });
direction: Direction::Right
}
);
assert_eq!(config.enabled.states.len(), 4); assert_eq!(config.enabled.states.len(), 4);
assert_eq!( assert_eq!(config.enabled.states[0], AuraPowerState {
config.enabled.states[0], zone: PowerZones::Keyboard,
AuraPowerState { boot: true,
zone: PowerZones::Keyboard, awake: true,
boot: true, sleep: true,
awake: true, shutdown: true
sleep: true, });
shutdown: true
}
);
} }
} }

View File

@@ -19,7 +19,7 @@ pub mod trait_impls;
pub struct Aura { pub struct Aura {
pub hid: Option<Arc<Mutex<HidRaw>>>, pub hid: Option<Arc<Mutex<HidRaw>>>,
pub backlight: Option<Arc<Mutex<KeyboardBacklight>>>, pub backlight: Option<Arc<Mutex<KeyboardBacklight>>>,
pub config: Arc<Mutex<AuraConfig>>, pub config: Arc<Mutex<AuraConfig>>
} }
impl Aura { impl Aura {
@@ -91,17 +91,13 @@ impl Aura {
pub async fn write_effect_and_apply( pub async fn write_effect_and_apply(
&self, &self,
dev_type: AuraDeviceType, dev_type: AuraDeviceType,
mode: &AuraEffect, mode: &AuraEffect
) -> Result<(), RogError> { ) -> Result<(), RogError> {
if matches!(dev_type, AuraDeviceType::LaptopKeyboardTuf) { if matches!(dev_type, AuraDeviceType::LaptopKeyboardTuf) {
if let Some(platform) = &self.backlight { if let Some(platform) = &self.backlight {
let buf = [ let buf = [
1, 1, mode.mode as u8, mode.colour1.r, mode.colour1.g, mode.colour1.b,
mode.mode as u8, mode.speed as u8
mode.colour1.r,
mode.colour1.g,
mode.colour1.b,
mode.speed as u8,
]; ];
platform.lock().await.set_kbd_rgb_mode(&buf)?; platform.lock().await.set_kbd_rgb_mode(&buf)?;
} }
@@ -125,7 +121,7 @@ impl Aura {
return Ok(()); return Ok(());
} }
Err(RogError::MissingFunction( Err(RogError::MissingFunction(
"No LED backlight control available".to_string(), "No LED backlight control available".to_string()
)) ))
} }
@@ -142,14 +138,24 @@ impl Aura {
let hid_raw = hid_raw.lock().await; let hid_raw = hid_raw.lock().await;
if let Some(p) = config.enabled.states.first() { if let Some(p) = config.enabled.states.first() {
if p.zone == PowerZones::Ally { if p.zone == PowerZones::Ally {
let msg = [0x5d, 0xd1, 0x09, 0x01, p.new_to_byte() as u8, 0x0, 0x0]; let msg = [
0x5d,
0xd1,
0x09,
0x01,
p.new_to_byte() as u8,
0x0,
0x0
];
hid_raw.write_bytes(&msg)?; hid_raw.write_bytes(&msg)?;
return Ok(()); return Ok(());
} }
} }
let bytes = config.enabled.to_bytes(config.led_type); let bytes = config.enabled.to_bytes(config.led_type);
let msg = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]]; let msg = [
0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]
];
hid_raw.write_bytes(&msg)?; hid_raw.write_bytes(&msg)?;
} }
Ok(()) Ok(())
@@ -161,7 +167,7 @@ impl Aura {
pub async fn write_effect_block( pub async fn write_effect_block(
&self, &self,
config: &mut AuraConfig, config: &mut AuraConfig,
effect: &AuraLaptopUsbPackets, effect: &AuraLaptopUsbPackets
) -> Result<(), RogError> { ) -> Result<(), RogError> {
if config.brightness == LedBrightness::Off { if config.brightness == LedBrightness::Off {
config.brightness = LedBrightness::Med; config.brightness = LedBrightness::Med;
@@ -194,7 +200,9 @@ impl Aura {
let r = row[9]; let r = row[9];
let g = row[10]; let g = row[10];
let b = row[11]; let b = row[11];
tuf.lock().await.set_kbd_rgb_mode(&[0, 0, r, g, b, 0])?; tuf.lock().await.set_kbd_rgb_mode(&[
0, 0, r, g, b, 0
])?;
} }
} }
} }
@@ -206,7 +214,9 @@ impl Aura {
if let Some(hid_raw) = &self.hid { if let Some(hid_raw) = &self.hid {
let mut config = self.config.lock().await; let mut config = self.config.lock().await;
if config.ally_fix.is_none() { if config.ally_fix.is_none() {
let msg = [0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff]; let msg = [
0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff
];
hid_raw.lock().await.write_bytes(&msg)?; hid_raw.lock().await.write_bytes(&msg)?;
info!("Reset Ally power settings to base"); info!("Reset Ally power settings to base");
config.ally_fix = Some(true); config.ally_fix = Some(true);

View File

@@ -14,7 +14,7 @@ use crate::error::RogError;
use crate::{CtrlTask, Reloadable}; use crate::{CtrlTask, Reloadable};
pub const AURA_ZBUS_NAME: &str = "Aura"; pub const AURA_ZBUS_NAME: &str = "Aura";
pub const AURA_ZBUS_PATH: &str = "/org/asuslinux"; pub const AURA_ZBUS_PATH: &str = "/xyz/ljones";
#[derive(Clone)] #[derive(Clone)]
pub struct AuraZbus(Aura); pub struct AuraZbus(Aura);
@@ -28,7 +28,7 @@ impl AuraZbus {
mut self, mut self,
connection: &Connection, connection: &Connection,
// _signal_ctx: SignalEmitter<'static>, // _signal_ctx: SignalEmitter<'static>,
path: OwnedObjectPath, path: OwnedObjectPath
) -> Result<(), RogError> { ) -> Result<(), RogError> {
// let task = zbus.clone(); // let task = zbus.clone();
// let signal_ctx = signal_ctx.clone(); // let signal_ctx = signal_ctx.clone();
@@ -50,7 +50,7 @@ impl AuraZbus {
/// The main interface for changing, reading, or notfying /// The main interface for changing, reading, or notfying
/// ///
/// LED commands are split between Brightness, Modes, Per-Key /// LED commands are split between Brightness, Modes, Per-Key
#[interface(name = "org.asuslinux.Aura")] #[interface(name = "xyz.ljones.Aura")]
impl AuraZbus { impl AuraZbus {
/// Return the device type for this Aura keyboard /// Return the device type for this Aura keyboard
#[zbus(property)] #[zbus(property)]
@@ -144,7 +144,7 @@ impl AuraZbus {
let mode = config.current_mode; let mode = config.current_mode;
match config.builtins.get(&mode) { match config.builtins.get(&mode) {
Some(effect) => Ok(effect.clone()), Some(effect) => Ok(effect.clone()),
None => Err(ZbErr::Failed("Could not get the current effect".into())), None => Err(ZbErr::Failed("Could not get the current effect".into()))
} }
} else { } else {
Err(ZbErr::Failed("Aura control couldn't lock self".to_string())) Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
@@ -227,7 +227,7 @@ impl AuraZbus {
impl CtrlTask for AuraZbus { impl CtrlTask for AuraZbus {
fn zbus_path() -> &'static str { fn zbus_path() -> &'static str {
"/org/asuslinux" "/xyz/ljones"
} }
async fn create_tasks(&self, _: SignalEmitter<'static>) -> Result<(), RogError> { async fn create_tasks(&self, _: SignalEmitter<'static>) -> Result<(), RogError> {
@@ -297,7 +297,7 @@ impl CtrlTask for AuraZbus {
move |_power_plugged| { move |_power_plugged| {
// power change // power change
async move {} async move {}
}, }
) )
.await; .await;

View File

@@ -23,8 +23,9 @@ use crate::aura_scsi::trait_impls::ScsiZbus;
use crate::aura_slash::trait_impls::SlashZbus; use crate::aura_slash::trait_impls::SlashZbus;
use crate::aura_types::DeviceHandle; use crate::aura_types::DeviceHandle;
use crate::error::RogError; use crate::error::RogError;
use crate::ASUS_ZBUS_PATH;
pub const ASUS_ZBUS_PATH: &str = "/org/asuslinux"; const MOD_NAME: &str = "aura";
/// Returns only the Device details concatenated in a form usable for /// Returns only the Device details concatenated in a form usable for
/// adding/appending to a filename /// adding/appending to a filename
@@ -54,26 +55,27 @@ pub fn filename_partial(parent: &Device) -> Option<OwnedObjectPath> {
fn dbus_path_for_dev(parent: &Device) -> Option<OwnedObjectPath> { fn dbus_path_for_dev(parent: &Device) -> Option<OwnedObjectPath> {
if let Some(filename) = filename_partial(parent) { if let Some(filename) = filename_partial(parent) {
return Some( return Some(
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{filename}")).into(), ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{filename}"))
.into()
); );
} }
None None
} }
fn dbus_path_for_tuf() -> OwnedObjectPath { fn dbus_path_for_tuf() -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/tuf")).into() ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/tuf")).into()
} }
fn dbus_path_for_slash() -> OwnedObjectPath { fn dbus_path_for_slash() -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/slash")).into() ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/slash")).into()
} }
fn dbus_path_for_anime() -> OwnedObjectPath { fn dbus_path_for_anime() -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/anime")).into() ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/anime")).into()
} }
fn dbus_path_for_scsi(prod_id: &str) -> OwnedObjectPath { fn dbus_path_for_scsi(prod_id: &str) -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{prod_id}_scsi")).into() ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{prod_id}_scsi")).into()
} }
fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool { fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool {
@@ -83,32 +85,23 @@ fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool {
false false
} }
// TODO:
// - make this the HID manager (and universal)
// - *really* need to make most of this actual kernel drivers
// - LED class
// - RGB modes (how, attribute?)
// - power features (how, attribute?)
// - what about per-key stuff?
// - how would the AniMe be exposed? Just a series of LEDs?
/// A device. /// A device.
/// ///
/// Each controller within should track its dbus path so it can be removed if /// Each controller within should track its dbus path so it can be removed if
/// required. /// required.
pub struct AsusDevice { pub struct AsusDevice {
device: DeviceHandle, device: DeviceHandle,
dbus_path: OwnedObjectPath, dbus_path: OwnedObjectPath
} }
pub struct DeviceManager { pub struct DeviceManager {
_dbus_connection: Connection, _dbus_connection: Connection
} }
impl DeviceManager { impl DeviceManager {
async fn init_hid_devices( async fn init_hid_devices(
connection: &Connection, connection: &Connection,
device: Device, device: Device
) -> Result<Vec<AsusDevice>, RogError> { ) -> Result<Vec<AsusDevice>, RogError> {
let mut devices = Vec::new(); let mut devices = Vec::new();
if let Some(usb_device) = device.parent_with_subsystem_devtype("usb", "usb_device")? { if let Some(usb_device) = device.parent_with_subsystem_devtype("usb", "usb_device")? {
@@ -129,7 +122,7 @@ impl DeviceManager {
// SLASH DEVICE // SLASH DEVICE
if let Ok(dev_type) = DeviceHandle::new_slash_hid( if let Ok(dev_type) = DeviceHandle::new_slash_hid(
dev.clone(), dev.clone(),
usb_id.to_str().unwrap_or_default(), usb_id.to_str().unwrap_or_default()
) )
.await .await
{ {
@@ -140,14 +133,14 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path, dbus_path: path
}); });
} }
} }
// ANIME MATRIX DEVICE // ANIME MATRIX DEVICE
if let Ok(dev_type) = DeviceHandle::maybe_anime_hid( if let Ok(dev_type) = DeviceHandle::maybe_anime_hid(
dev.clone(), dev.clone(),
usb_id.to_str().unwrap_or_default(), usb_id.to_str().unwrap_or_default()
) )
.await .await
{ {
@@ -158,14 +151,14 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path, dbus_path: path
}); });
} }
} }
// AURA LAPTOP DEVICE // AURA LAPTOP DEVICE
if let Ok(dev_type) = DeviceHandle::maybe_laptop_aura( if let Ok(dev_type) = DeviceHandle::maybe_laptop_aura(
Some(dev), Some(dev),
usb_id.to_str().unwrap_or_default(), usb_id.to_str().unwrap_or_default()
) )
.await .await
{ {
@@ -176,7 +169,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path, dbus_path: path
}); });
} }
} }
@@ -216,11 +209,11 @@ impl DeviceManager {
async fn init_scsi( async fn init_scsi(
connection: &Connection, connection: &Connection,
device: &Device, device: &Device,
path: OwnedObjectPath, path: OwnedObjectPath
) -> Option<AsusDevice> { ) -> Option<AsusDevice> {
// "ID_MODEL_ID" "1932" // "ID_MODEL_ID" "1932"
// "ID_VENDOR_ID" "0b05" // "ID_VENDOR_ID" "0b05"
if dev_prop_matches(&device, "ID_VENDOR_ID", "0b05") { if dev_prop_matches(device, "ID_VENDOR_ID", "0b05") {
if let Some(dev_node) = device.devnode() { if let Some(dev_node) = device.devnode() {
let prod_id = device let prod_id = device
.property_value("ID_MODEL_ID") .property_value("ID_MODEL_ID")
@@ -234,7 +227,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
return Some(AsusDevice { return Some(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path, dbus_path: path
}); });
} }
} }
@@ -275,7 +268,7 @@ impl DeviceManager {
found.push(path); found.push(path);
} }
} else { } else {
warn!("No serial for SCSI device"); debug!("No serial for SCSI device: {:?}", device.devpath());
} }
} }
@@ -312,7 +305,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path, dbus_path: path
}); });
} }
} else { } else {
@@ -329,7 +322,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path, dbus_path: path
}); });
} }
} else { } else {
@@ -355,7 +348,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path, dbus_path: path
}); });
} }
} }
@@ -373,7 +366,7 @@ impl DeviceManager {
let conn_copy = connection.clone(); let conn_copy = connection.clone();
let devices = Arc::new(Mutex::new(Self::find_all_devices(&conn_copy).await)); let devices = Arc::new(Mutex::new(Self::find_all_devices(&conn_copy).await));
let manager = Self { let manager = Self {
_dbus_connection: connection, _dbus_connection: connection
}; };
// TODO: The /sysfs/ LEDs don't cause events, so they need to be manually // TODO: The /sysfs/ LEDs don't cause events, so they need to be manually
@@ -433,14 +426,11 @@ impl DeviceManager {
info!("removing: {path:?}"); info!("removing: {path:?}");
let dev = devices.lock().await.remove(index); let dev = devices.lock().await.remove(index);
let path = path.clone(); let path = path.clone();
match dev.device { if let DeviceHandle::Scsi(_) = dev.device {
DeviceHandle::Scsi(_) => { conn_copy
conn_copy .object_server()
.object_server() .remove::<ScsiZbus, _>(&path)
.remove::<ScsiZbus, _>(&path) .await?;
.await?;
}
_ => {}
} }
} }
} else if action == "add" { } else if action == "add" {
@@ -510,7 +500,7 @@ impl DeviceManager {
.remove::<ScsiZbus, _>(&path) .remove::<ScsiZbus, _>(&path)
.await? .await?
} }
_ => todo!(), _ => todo!()
}; };
info!("AuraManager removed: {path:?}, {res}"); info!("AuraManager removed: {path:?}, {res}");
} }

View File

@@ -14,7 +14,7 @@ pub struct ScsiConfig {
pub dev_type: AuraDeviceType, pub dev_type: AuraDeviceType,
pub enabled: bool, pub enabled: bool,
pub current_mode: AuraMode, pub current_mode: AuraMode,
pub modes: BTreeMap<AuraMode, AuraEffect>, pub modes: BTreeMap<AuraMode, AuraEffect>
} }
impl ScsiConfig { impl ScsiConfig {
@@ -38,61 +38,61 @@ impl Default for ScsiConfig {
(AuraMode::Off, AuraEffect::default_with_mode(AuraMode::Off)), (AuraMode::Off, AuraEffect::default_with_mode(AuraMode::Off)),
( (
AuraMode::Static, AuraMode::Static,
AuraEffect::default_with_mode(AuraMode::Static), AuraEffect::default_with_mode(AuraMode::Static)
), ),
( (
AuraMode::Breathe, AuraMode::Breathe,
AuraEffect::default_with_mode(AuraMode::Breathe), AuraEffect::default_with_mode(AuraMode::Breathe)
), ),
( (
AuraMode::Flashing, AuraMode::Flashing,
AuraEffect::default_with_mode(AuraMode::Flashing), AuraEffect::default_with_mode(AuraMode::Flashing)
), ),
( (
AuraMode::RainbowCycle, AuraMode::RainbowCycle,
AuraEffect::default_with_mode(AuraMode::RainbowCycle), AuraEffect::default_with_mode(AuraMode::RainbowCycle)
), ),
( (
AuraMode::RainbowWave, AuraMode::RainbowWave,
AuraEffect::default_with_mode(AuraMode::RainbowWave), AuraEffect::default_with_mode(AuraMode::RainbowWave)
), ),
( (
AuraMode::RainbowCycleBreathe, AuraMode::RainbowCycleBreathe,
AuraEffect::default_with_mode(AuraMode::RainbowCycleBreathe), AuraEffect::default_with_mode(AuraMode::RainbowCycleBreathe)
), ),
( (
AuraMode::ChaseFade, AuraMode::ChaseFade,
AuraEffect::default_with_mode(AuraMode::ChaseFade), AuraEffect::default_with_mode(AuraMode::ChaseFade)
), ),
( (
AuraMode::RainbowCycleChaseFade, AuraMode::RainbowCycleChaseFade,
AuraEffect::default_with_mode(AuraMode::RainbowCycleChaseFade), AuraEffect::default_with_mode(AuraMode::RainbowCycleChaseFade)
), ),
( (
AuraMode::Chase, AuraMode::Chase,
AuraEffect::default_with_mode(AuraMode::Chase), AuraEffect::default_with_mode(AuraMode::Chase)
), ),
( (
AuraMode::RainbowCycleChase, AuraMode::RainbowCycleChase,
AuraEffect::default_with_mode(AuraMode::RainbowCycleChase), AuraEffect::default_with_mode(AuraMode::RainbowCycleChase)
), ),
( (
AuraMode::RainbowCycleWave, AuraMode::RainbowCycleWave,
AuraEffect::default_with_mode(AuraMode::RainbowCycleWave), AuraEffect::default_with_mode(AuraMode::RainbowCycleWave)
), ),
( (
AuraMode::RainbowPulseChase, AuraMode::RainbowPulseChase,
AuraEffect::default_with_mode(AuraMode::RainbowPulseChase), AuraEffect::default_with_mode(AuraMode::RainbowPulseChase)
), ),
( (
AuraMode::RandomFlicker, AuraMode::RandomFlicker,
AuraEffect::default_with_mode(AuraMode::RandomFlicker), AuraEffect::default_with_mode(AuraMode::RandomFlicker)
), ),
( (
AuraMode::DoubleFade, AuraMode::DoubleFade,
AuraEffect::default_with_mode(AuraMode::DoubleFade), AuraEffect::default_with_mode(AuraMode::DoubleFade)
), )
]), ])
} }
} }
} }

View File

@@ -12,7 +12,7 @@ pub mod trait_impls;
#[derive(Clone)] #[derive(Clone)]
pub struct ScsiAura { pub struct ScsiAura {
device: Arc<Mutex<Device>>, device: Arc<Mutex<Device>>,
config: Arc<Mutex<ScsiConfig>>, config: Arc<Mutex<ScsiConfig>>
} }
impl ScsiAura { impl ScsiAura {

View File

@@ -22,7 +22,7 @@ impl ScsiZbus {
pub async fn start_tasks( pub async fn start_tasks(
self, self,
connection: &Connection, connection: &Connection,
path: OwnedObjectPath, path: OwnedObjectPath
) -> Result<(), RogError> { ) -> Result<(), RogError> {
connection connection
.object_server() .object_server()
@@ -34,7 +34,7 @@ impl ScsiZbus {
} }
} }
#[interface(name = "org.asuslinux.ScsiAura")] #[interface(name = "xyz.ljones.ScsiAura")]
impl ScsiZbus { impl ScsiZbus {
/// Return the device type for this Aura keyboard /// Return the device type for this Aura keyboard
#[zbus(property)] #[zbus(property)]
@@ -87,7 +87,7 @@ impl ScsiZbus {
let mode = config.current_mode; let mode = config.current_mode;
match config.modes.get(&mode) { match config.modes.get(&mode) {
Some(effect) => Ok(effect.clone()), Some(effect) => Ok(effect.clone()),
None => Err(ZbErr::Failed("Could not get the current effect".into())), None => Err(ZbErr::Failed("Could not get the current effect".into()))
} }
} else { } else {
Err(ZbErr::Failed("Aura control couldn't lock self".to_string())) Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))

View File

@@ -9,20 +9,30 @@ const CONFIG_FILE: &str = "slash.ron";
pub struct SlashConfig { pub struct SlashConfig {
#[serde(skip)] #[serde(skip)]
pub slash_type: SlashType, pub slash_type: SlashType,
pub slash_enabled: bool, pub enabled: bool,
pub slash_brightness: u8, pub brightness: u8,
pub slash_interval: u8, pub display_interval: u8,
pub slash_mode: SlashMode, pub display_mode: SlashMode,
pub show_on_boot: bool,
pub show_on_shutdown: bool,
pub show_on_sleep: bool,
pub show_on_battery: bool,
pub show_battery_warning: bool
} }
impl Default for SlashConfig { impl Default for SlashConfig {
fn default() -> Self { fn default() -> Self {
SlashConfig { SlashConfig {
slash_enabled: true, enabled: true,
slash_brightness: 255, brightness: 255,
slash_interval: 0, display_interval: 0,
slash_mode: SlashMode::Bounce, display_mode: SlashMode::Bounce,
slash_type: SlashType::Unsupported, slash_type: SlashType::Unsupported,
show_on_boot: true,
show_on_shutdown: true,
show_on_sleep: true,
show_on_battery: true,
show_battery_warning: true
} }
} }
} }
@@ -45,10 +55,10 @@ impl StdConfigLoad for SlashConfig {}
impl From<&SlashConfig> for DeviceState { impl From<&SlashConfig> for DeviceState {
fn from(config: &SlashConfig) -> Self { fn from(config: &SlashConfig) -> Self {
DeviceState { DeviceState {
slash_enabled: config.slash_enabled, slash_enabled: config.enabled,
slash_brightness: config.slash_brightness, slash_brightness: config.brightness,
slash_interval: config.slash_interval, slash_interval: config.display_interval,
slash_mode: config.slash_mode, slash_mode: config.display_mode
} }
} }
} }

View File

@@ -3,7 +3,7 @@ use std::sync::Arc;
use config::SlashConfig; use config::SlashConfig;
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw; use rog_platform::usb_raw::USBRaw;
use rog_slash::usb::{pkt_set_mode, pkt_set_options, pkts_for_init}; use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init};
use rog_slash::SlashType; use rog_slash::SlashType;
use tokio::sync::{Mutex, MutexGuard}; use tokio::sync::{Mutex, MutexGuard};
@@ -16,14 +16,14 @@ pub mod trait_impls;
pub struct Slash { pub struct Slash {
hid: Option<Arc<Mutex<HidRaw>>>, hid: Option<Arc<Mutex<HidRaw>>>,
usb: Option<Arc<Mutex<USBRaw>>>, usb: Option<Arc<Mutex<USBRaw>>>,
config: Arc<Mutex<SlashConfig>>, config: Arc<Mutex<SlashConfig>>
} }
impl Slash { impl Slash {
pub fn new( pub fn new(
hid: Option<Arc<Mutex<HidRaw>>>, hid: Option<Arc<Mutex<HidRaw>>>,
usb: Option<Arc<Mutex<USBRaw>>>, usb: Option<Arc<Mutex<USBRaw>>>,
config: Arc<Mutex<SlashConfig>>, config: Arc<Mutex<SlashConfig>>
) -> Self { ) -> Self {
Self { hid, usb, config } Self { hid, usb, config }
} }
@@ -53,15 +53,15 @@ impl Slash {
} }
// Apply config upon initialization // Apply config upon initialization
let option_packets = pkt_set_options( let option_packets = get_options_packet(
config.slash_type, config.slash_type,
config.slash_enabled, config.enabled,
config.slash_brightness, config.brightness,
config.slash_interval, config.display_interval
); );
self.write_bytes(&option_packets).await?; self.write_bytes(&option_packets).await?;
let mode_packets = pkt_set_mode(config.slash_type, config.slash_mode); let mode_packets = pkt_set_mode(config.slash_type, config.display_mode);
// self.node.write_bytes(&mode_packets[0])?; // self.node.write_bytes(&mode_packets[0])?;
self.write_bytes(&mode_packets[1]).await?; self.write_bytes(&mode_packets[1]).await?;

View File

@@ -1,6 +1,9 @@
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{debug, error, warn}; use log::{debug, error, warn};
use rog_slash::usb::{pkt_save, pkt_set_mode, pkt_set_options}; use rog_slash::usb::{
get_battery_saver_packet, get_boot_packet, get_low_battery_packet, get_options_packet,
get_shutdown_packet, get_sleep_packet, pkt_save, pkt_set_mode
};
use rog_slash::{DeviceState, SlashMode}; use rog_slash::{DeviceState, SlashMode};
use zbus::zvariant::OwnedObjectPath; use zbus::zvariant::OwnedObjectPath;
use zbus::{interface, Connection}; use zbus::{interface, Connection};
@@ -20,7 +23,7 @@ impl SlashZbus {
pub async fn start_tasks( pub async fn start_tasks(
mut self, mut self,
connection: &Connection, connection: &Connection,
path: OwnedObjectPath, path: OwnedObjectPath
) -> Result<(), RogError> { ) -> Result<(), RogError> {
// let task = zbus.clone(); // let task = zbus.clone();
self.reload() self.reload()
@@ -36,30 +39,30 @@ impl SlashZbus {
} }
} }
#[interface(name = "org.asuslinux.Slash")] #[interface(name = "xyz.ljones.Slash")]
impl SlashZbus { impl SlashZbus {
/// Get enabled or not /// Get enabled or not
#[zbus(property)] #[zbus(property)]
async fn enabled(&self) -> bool { async fn enabled(&self) -> bool {
let lock = self.0.lock_config().await; let lock = self.0.lock_config().await;
lock.slash_enabled lock.enabled
} }
/// Set enabled true or false /// Set enabled true or false
#[zbus(property)] #[zbus(property)]
async fn set_enabled(&self, enabled: bool) { async fn set_enabled(&self, enabled: bool) {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
let brightness = if enabled && config.slash_brightness == 0 { let brightness = if enabled && config.brightness == 0 {
0x88 0x88
} else { } else {
config.slash_brightness config.brightness
}; };
self.0 self.0
.write_bytes(&pkt_set_options( .write_bytes(&get_options_packet(
config.slash_type, config.slash_type,
enabled, enabled,
brightness, brightness,
config.slash_interval, config.display_interval
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -67,8 +70,8 @@ impl SlashZbus {
}) })
.ok(); .ok();
config.slash_enabled = enabled; config.enabled = enabled;
config.slash_brightness = brightness; config.brightness = brightness;
config.write(); config.write();
} }
@@ -76,7 +79,7 @@ impl SlashZbus {
#[zbus(property)] #[zbus(property)]
async fn brightness(&self) -> u8 { async fn brightness(&self) -> u8 {
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
config.slash_brightness config.brightness
} }
/// Set brightness level /// Set brightness level
@@ -85,11 +88,11 @@ impl SlashZbus {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
let enabled = brightness > 0; let enabled = brightness > 0;
self.0 self.0
.write_bytes(&pkt_set_options( .write_bytes(&get_options_packet(
config.slash_type, config.slash_type,
enabled, enabled,
brightness, brightness,
config.slash_interval, config.display_interval
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -97,15 +100,15 @@ impl SlashZbus {
}) })
.ok(); .ok();
config.slash_enabled = enabled; config.enabled = enabled;
config.slash_brightness = brightness; config.brightness = brightness;
config.write(); config.write();
} }
#[zbus(property)] #[zbus(property)]
async fn interval(&self) -> u8 { async fn interval(&self) -> u8 {
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
config.slash_interval config.display_interval
} }
/// Set interval between slash animations (0-255) /// Set interval between slash animations (0-255)
@@ -113,11 +116,8 @@ impl SlashZbus {
async fn set_interval(&self, interval: u8) { async fn set_interval(&self, interval: u8) {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&pkt_set_options( .write_bytes(&get_options_packet(
config.slash_type, config.slash_type, config.enabled, config.brightness, interval
config.slash_enabled,
config.slash_brightness,
interval,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -125,40 +125,29 @@ impl SlashZbus {
}) })
.ok(); .ok();
config.slash_interval = interval; config.display_interval = interval;
config.write(); config.write();
} }
#[zbus(property)] #[zbus(property)]
async fn slash_mode(&self) -> u8 { async fn mode(&self) -> zbus::fdo::Result<u8> {
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
config.slash_interval Ok(config.display_interval)
} }
/// Set interval between slash animations (0-255) /// Set interval between slash animations (0-255)
#[zbus(property)] #[zbus(property)]
async fn set_slash_mode(&self, slash_mode: SlashMode) { async fn set_mode(&self, mode: SlashMode) -> zbus::Result<()> {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
let command_packets = pkt_set_mode(config.slash_type, slash_mode); let command_packets = pkt_set_mode(config.slash_type, mode);
// self.node.write_bytes(&command_packets[0])?; // self.node.write_bytes(&command_packets[0])?;
self.0 self.0.write_bytes(&command_packets[1]).await?;
.write_bytes(&command_packets[1]) self.0.write_bytes(&pkt_save(config.slash_type)).await?;
.await
.map_err(|err| {
warn!("ctrl_slash::set_options {}", err);
})
.ok();
self.0
.write_bytes(&pkt_save(config.slash_type))
.await
.map_err(|err| {
warn!("ctrl_slash::set_options {}", err);
})
.ok();
config.slash_mode = slash_mode; config.display_mode = mode;
config.write(); config.write();
Ok(())
} }
/// Get the device state as stored by asusd /// Get the device state as stored by asusd
@@ -167,6 +156,91 @@ impl SlashZbus {
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
DeviceState::from(&*config) DeviceState::from(&*config)
} }
#[zbus(property)]
async fn show_on_boot(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_boot)
}
#[zbus(property)]
async fn set_show_on_boot(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_boot_packet(config.slash_type, enable))
.await?;
config.show_on_boot = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_sleep(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_sleep)
}
#[zbus(property)]
async fn set_show_on_sleep(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_sleep_packet(config.slash_type, enable))
.await?;
config.show_on_sleep = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_shutdown(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_shutdown)
}
#[zbus(property)]
async fn set_show_on_shutdown(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_shutdown_packet(config.slash_type, enable))
.await?;
config.show_on_shutdown = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_battery(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_battery)
}
#[zbus(property)]
async fn set_show_on_battery(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_battery_saver_packet(config.slash_type, enable))
.await?;
config.show_on_battery = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_battery_warning(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_battery_warning)
}
#[zbus(property)]
async fn set_show_battery_warning(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_low_battery_packet(config.slash_type, enable))
.await?;
config.show_battery_warning = enable;
config.write();
Ok(())
}
} }
impl Reloadable for SlashZbus { impl Reloadable for SlashZbus {
@@ -174,17 +248,40 @@ impl Reloadable for SlashZbus {
debug!("reloading slash settings"); debug!("reloading slash settings");
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&pkt_set_options( .write_bytes(&get_options_packet(
config.slash_type, config.slash_type,
config.slash_enabled, config.enabled,
config.slash_brightness, config.brightness,
config.slash_interval, config.display_interval
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
warn!("ctrl_slash::set_options {}", err); warn!("set_options {}", err);
}) })
.ok(); .ok();
macro_rules! write_bytes_with_warning {
($packet_fn:expr, $cfg:ident, $warn_msg:expr) => {
self.0
.write_bytes(&$packet_fn(config.slash_type, config.$cfg))
.await
.map_err(|err| {
warn!("{} {}", $warn_msg, err);
})
.ok();
};
}
write_bytes_with_warning!(get_boot_packet, show_on_boot, "show_on_boot");
write_bytes_with_warning!(get_sleep_packet, show_on_sleep, "show_on_sleep");
write_bytes_with_warning!(get_shutdown_packet, show_on_shutdown, "show_on_shutdown");
write_bytes_with_warning!(get_battery_saver_packet, show_on_battery, "show_on_battery");
write_bytes_with_warning!(
get_low_battery_packet,
show_battery_warning,
"show_battery_warning"
);
Ok(()) Ok(())
} }
} }

View File

@@ -31,7 +31,7 @@ pub enum _DeviceHandle {
LedClass(KeyboardBacklight), LedClass(KeyboardBacklight),
/// TODO /// TODO
MulticolourLed, MulticolourLed,
None, None
} }
#[derive(Clone)] #[derive(Clone)]
@@ -47,14 +47,14 @@ pub enum DeviceHandle {
TufLedClass(Arc<Mutex<HidRaw>>), TufLedClass(Arc<Mutex<HidRaw>>),
/// TODO /// TODO
MulticolourLed, MulticolourLed,
None, None
} }
impl DeviceHandle { impl DeviceHandle {
/// Try Slash HID. If one exists it is initialsed and returned. /// Try Slash HID. If one exists it is initialsed and returned.
pub async fn new_slash_hid( pub async fn new_slash_hid(
device: Arc<Mutex<HidRaw>>, device: Arc<Mutex<HidRaw>>,
prod_id: &str, prod_id: &str
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
debug!("Testing for HIDRAW Slash"); debug!("Testing for HIDRAW Slash");
let slash_type = SlashType::from_dmi(); let slash_type = SlashType::from_dmi();
@@ -93,7 +93,7 @@ impl DeviceHandle {
let slash = Slash::new( let slash = Slash::new(
None, None,
Some(Arc::new(Mutex::new(usb))), Some(Arc::new(Mutex::new(usb))),
Arc::new(Mutex::new(config)), Arc::new(Mutex::new(config))
); );
slash.do_initialization().await?; slash.do_initialization().await?;
Ok(Self::Slash(slash)) Ok(Self::Slash(slash))
@@ -105,7 +105,7 @@ impl DeviceHandle {
/// Try AniMe Matrix HID. If one exists it is initialsed and returned. /// Try AniMe Matrix HID. If one exists it is initialsed and returned.
pub async fn maybe_anime_hid( pub async fn maybe_anime_hid(
device: Arc<Mutex<HidRaw>>, device: Arc<Mutex<HidRaw>>,
prod_id: &str, prod_id: &str
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
debug!("Testing for HIDRAW AniMe"); debug!("Testing for HIDRAW AniMe");
let anime_type = AnimeType::from_dmi(); let anime_type = AnimeType::from_dmi();
@@ -139,13 +139,13 @@ impl DeviceHandle {
let mut anime = AniMe::new( let mut anime = AniMe::new(
None, None,
Some(Arc::new(Mutex::new(usb))), Some(Arc::new(Mutex::new(usb))),
Arc::new(Mutex::new(config)), Arc::new(Mutex::new(config))
); );
anime.do_initialization().await?; anime.do_initialization().await?;
Ok(Self::AniMe(anime)) Ok(Self::AniMe(anime))
} else { } else {
Err(RogError::NotFound( Err(RogError::NotFound(
"No AnimeMatrix device found".to_string(), "No AnimeMatrix device found".to_string()
)) ))
} }
} }
@@ -169,7 +169,7 @@ impl DeviceHandle {
pub async fn maybe_laptop_aura( pub async fn maybe_laptop_aura(
device: Option<Arc<Mutex<HidRaw>>>, device: Option<Arc<Mutex<HidRaw>>>,
prod_id: &str, prod_id: &str
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
debug!("Testing for laptop aura"); debug!("Testing for laptop aura");
let aura_type = AuraDeviceType::from(prod_id); let aura_type = AuraDeviceType::from(prod_id);
@@ -196,7 +196,7 @@ impl DeviceHandle {
let aura = Aura { let aura = Aura {
hid: device, hid: device,
backlight, backlight,
config: Arc::new(Mutex::new(config)), config: Arc::new(Mutex::new(config))
}; };
aura.do_initialization().await?; aura.do_initialization().await?;
Ok(Self::Aura(aura)) Ok(Self::Aura(aura))

View File

@@ -60,7 +60,7 @@ pub struct Config {
pub nv_temp_target: Option<u8>, pub nv_temp_target: Option<u8>,
/// Temporary state for AC/Batt /// Temporary state for AC/Batt
#[serde(skip)] #[serde(skip)]
pub last_power_plugged: u8, pub last_power_plugged: u8
} }
impl Default for Config { impl Default for Config {
@@ -89,7 +89,7 @@ impl Default for Config {
ppt_platform_sppt: Default::default(), ppt_platform_sppt: Default::default(),
nv_dynamic_boost: Default::default(), nv_dynamic_boost: Default::default(),
nv_temp_target: Default::default(), nv_temp_target: Default::default(),
last_power_plugged: Default::default(), last_power_plugged: Default::default()
} }
} }
} }
@@ -137,7 +137,7 @@ pub struct Config507 {
pub ppt_apu_sppt: Option<u8>, pub ppt_apu_sppt: Option<u8>,
pub ppt_platform_sppt: Option<u8>, pub ppt_platform_sppt: Option<u8>,
pub nv_dynamic_boost: Option<u8>, pub nv_dynamic_boost: Option<u8>,
pub nv_temp_target: Option<u8>, pub nv_temp_target: Option<u8>
} }
impl From<Config507> for Config { impl From<Config507> for Config {
@@ -167,7 +167,7 @@ impl From<Config507> for Config {
ppt_platform_sppt: c.ppt_platform_sppt, ppt_platform_sppt: c.ppt_platform_sppt,
nv_dynamic_boost: c.nv_dynamic_boost, nv_dynamic_boost: c.nv_dynamic_boost,
nv_temp_target: c.nv_temp_target, nv_temp_target: c.nv_temp_target,
last_power_plugged: 0, last_power_plugged: 0
} }
} }
} }

View File

@@ -17,13 +17,13 @@ use crate::error::RogError;
use crate::{CtrlTask, CONFIG_PATH_BASE}; use crate::{CtrlTask, CONFIG_PATH_BASE};
pub const FAN_CURVE_ZBUS_NAME: &str = "FanCurves"; pub const FAN_CURVE_ZBUS_NAME: &str = "FanCurves";
pub const FAN_CURVE_ZBUS_PATH: &str = "/org/asuslinux"; pub const FAN_CURVE_ZBUS_PATH: &str = "/xyz/ljones";
#[derive(Deserialize, Serialize, Debug, Default)] #[derive(Deserialize, Serialize, Debug, Default)]
pub struct FanCurveConfig { pub struct FanCurveConfig {
pub profiles: FanCurveProfiles, pub profiles: FanCurveProfiles,
#[serde(skip)] #[serde(skip)]
pub current: u8, pub current: u8
} }
impl StdConfig for FanCurveConfig { impl StdConfig for FanCurveConfig {
@@ -47,7 +47,7 @@ impl StdConfigLoad for FanCurveConfig {}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct CtrlFanCurveZbus { pub struct CtrlFanCurveZbus {
config: Arc<Mutex<FanCurveConfig>>, config: Arc<Mutex<FanCurveConfig>>,
platform: RogPlatform, platform: RogPlatform
} }
// Non-zbus-derive impl // Non-zbus-derive impl
@@ -69,7 +69,7 @@ impl CtrlFanCurveZbus {
for this in [ for this in [
ThrottlePolicy::Balanced, ThrottlePolicy::Balanced,
ThrottlePolicy::Performance, ThrottlePolicy::Performance,
ThrottlePolicy::Quiet, ThrottlePolicy::Quiet
] { ] {
// For each profile we need to switch to it before we // For each profile we need to switch to it before we
// can read the existing values from hardware. The ACPI method used // can read the existing values from hardware. The ACPI method used
@@ -93,7 +93,7 @@ impl CtrlFanCurveZbus {
return Ok(Self { return Ok(Self {
config: Arc::new(Mutex::new(config)), config: Arc::new(Mutex::new(config)),
platform, platform
}); });
} }
@@ -101,14 +101,14 @@ impl CtrlFanCurveZbus {
} }
} }
#[interface(name = "org.asuslinux.FanCurves")] #[interface(name = "xyz.ljones.FanCurves")]
impl CtrlFanCurveZbus { impl CtrlFanCurveZbus {
/// Set all fan curves for a profile to enabled status. Will also activate a /// Set all fan curves for a profile to enabled status. Will also activate a
/// fan curve if in the same profile mode /// fan curve if in the same profile mode
async fn set_fan_curves_enabled( async fn set_fan_curves_enabled(
&mut self, &mut self,
profile: ThrottlePolicy, profile: ThrottlePolicy,
enabled: bool, enabled: bool
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.config self.config
.lock() .lock()
@@ -130,7 +130,7 @@ impl CtrlFanCurveZbus {
&mut self, &mut self,
profile: ThrottlePolicy, profile: ThrottlePolicy,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool, enabled: bool
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.config self.config
.lock() .lock()
@@ -149,7 +149,7 @@ impl CtrlFanCurveZbus {
/// Get the fan-curve data for the currently active ThrottlePolicy /// Get the fan-curve data for the currently active ThrottlePolicy
async fn fan_curve_data( async fn fan_curve_data(
&mut self, &mut self,
profile: ThrottlePolicy, profile: ThrottlePolicy
) -> zbus::fdo::Result<Vec<CurveData>> { ) -> zbus::fdo::Result<Vec<CurveData>> {
let curve = self let curve = self
.config .config
@@ -166,7 +166,7 @@ impl CtrlFanCurveZbus {
async fn set_fan_curve( async fn set_fan_curve(
&mut self, &mut self,
profile: ThrottlePolicy, profile: ThrottlePolicy,
curve: CurveData, curve: CurveData
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.config self.config
.lock() .lock()
@@ -256,7 +256,7 @@ impl CtrlTask for CtrlFanCurveZbus {
.profiles .profiles
.write_profile_curve_to_platform( .write_profile_curve_to_platform(
profile.into(), profile.into(),
&mut find_fan_curve_node().unwrap(), &mut find_fan_curve_node().unwrap()
) )
.map_err(|e| warn!("write_profile_curve_to_platform, {}", e)) .map_err(|e| warn!("write_profile_curve_to_platform, {}", e))
.ok(); .ok();

View File

@@ -5,7 +5,6 @@ use std::sync::Arc;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP}; use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
// use rog_platform::firmware_attributes::FirmwareAttributes;
use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy}; use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy};
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
use zbus::export::futures_util::lock::Mutex; use zbus::export::futures_util::lock::Mutex;
@@ -17,7 +16,7 @@ use crate::config::Config;
use crate::error::RogError; use crate::error::RogError;
use crate::{task_watch_item, task_watch_item_notify, CtrlTask, ReloadAndNotify}; use crate::{task_watch_item, task_watch_item_notify, CtrlTask, ReloadAndNotify};
const PLATFORM_ZBUS_PATH: &str = "/org/asuslinux"; const PLATFORM_ZBUS_PATH: &str = "/xyz/ljones";
macro_rules! platform_get_value { macro_rules! platform_get_value {
($self:ident, $property:tt, $prop_name:literal) => { ($self:ident, $property:tt, $prop_name:literal) => {
@@ -87,16 +86,15 @@ pub struct CtrlPlatform {
power: AsusPower, power: AsusPower,
platform: RogPlatform, platform: RogPlatform,
cpu_control: Option<CPUControl>, cpu_control: Option<CPUControl>,
config: Arc<Mutex<Config>>, config: Arc<Mutex<Config>>
} }
impl CtrlPlatform { impl CtrlPlatform {
pub fn new( pub fn new(
config: Arc<Mutex<Config>>, config: Arc<Mutex<Config>>,
config_path: &Path, config_path: &Path,
signal_context: SignalEmitter<'static>, signal_context: SignalEmitter<'static>
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
// let attrs = FirmwareAttributes::new();
let platform = RogPlatform::new()?; let platform = RogPlatform::new()?;
let power = AsusPower::new()?; let power = AsusPower::new()?;
@@ -114,7 +112,7 @@ impl CtrlPlatform {
config, config,
cpu_control: CPUControl::new() cpu_control: CPUControl::new()
.map_err(|e| error!("Couldn't get CPU control sysfs: {e}")) .map_err(|e| error!("Couldn't get CPU control sysfs: {e}"))
.ok(), .ok()
}; };
let mut inotify_self = ret_self.clone(); let mut inotify_self = ret_self.clone();
@@ -133,7 +131,7 @@ impl CtrlPlatform {
inotify::WatchMask::MODIFY inotify::WatchMask::MODIFY
| inotify::WatchMask::CLOSE_WRITE | inotify::WatchMask::CLOSE_WRITE
| inotify::WatchMask::ATTRIB | inotify::WatchMask::ATTRIB
| inotify::WatchMask::CREATE, | inotify::WatchMask::CREATE
) )
.inspect_err(|e| { .inspect_err(|e| {
if e.kind() == std::io::ErrorKind::NotFound { if e.kind() == std::io::ErrorKind::NotFound {
@@ -186,7 +184,7 @@ impl CtrlPlatform {
if limit > 0 if limit > 0
&& std::mem::replace( && std::mem::replace(
&mut self.config.lock().await.charge_control_end_threshold, &mut self.config.lock().await.charge_control_end_threshold,
limit, limit
) != limit ) != limit
{ {
self.power self.power
@@ -268,7 +266,7 @@ impl CtrlPlatform {
match throttle { match throttle {
ThrottlePolicy::Balanced => self.config.lock().await.throttle_balanced_epp, ThrottlePolicy::Balanced => self.config.lock().await.throttle_balanced_epp,
ThrottlePolicy::Performance => self.config.lock().await.throttle_performance_epp, ThrottlePolicy::Performance => self.config.lock().await.throttle_performance_epp,
ThrottlePolicy::Quiet => self.config.lock().await.throttle_quiet_epp, ThrottlePolicy::Quiet => self.config.lock().await.throttle_quiet_epp
} }
} }
@@ -302,7 +300,7 @@ impl CtrlPlatform {
} }
} }
#[interface(name = "org.asuslinux.Platform")] #[interface(name = "xyz.ljones.Platform")]
impl CtrlPlatform { impl CtrlPlatform {
#[zbus(property)] #[zbus(property)]
async fn version(&self) -> String { async fn version(&self) -> String {
@@ -379,7 +377,7 @@ impl CtrlPlatform {
async fn one_shot_full_charge(&self) -> Result<(), FdoErr> { async fn one_shot_full_charge(&self) -> Result<(), FdoErr> {
let base_limit = std::mem::replace( let base_limit = std::mem::replace(
&mut self.config.lock().await.charge_control_end_threshold, &mut self.config.lock().await.charge_control_end_threshold,
100, 100
); );
if base_limit != 100 { if base_limit != 100 {
self.power.set_charge_control_end_threshold(100)?; self.power.set_charge_control_end_threshold(100)?;
@@ -407,7 +405,7 @@ impl CtrlPlatform {
self.config.lock().await.write(); self.config.lock().await.write();
} else { } else {
return Err(FdoErr::NotSupported( return Err(FdoErr::NotSupported(
"RogPlatform: set_gpu_mux_mode not supported".to_owned(), "RogPlatform: set_gpu_mux_mode not supported".to_owned()
)); ));
} }
Ok(()) Ok(())
@@ -417,7 +415,7 @@ impl CtrlPlatform {
/// If fan-curves are supported will also activate a fan curve for profile. /// If fan-curves are supported will also activate a fan curve for profile.
async fn next_throttle_thermal_policy( async fn next_throttle_thermal_policy(
&mut self, &mut self,
#[zbus(signal_context)] ctxt: SignalEmitter<'_>, #[zbus(signal_context)] ctxt: SignalEmitter<'_>
) -> Result<(), FdoErr> { ) -> Result<(), FdoErr> {
let policy: ThrottlePolicy = let policy: ThrottlePolicy =
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy") platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
@@ -437,7 +435,7 @@ impl CtrlPlatform {
Ok(self.throttle_thermal_policy_changed(&ctxt).await?) Ok(self.throttle_thermal_policy_changed(&ctxt).await?)
} else { } else {
Err(FdoErr::NotSupported( Err(FdoErr::NotSupported(
"RogPlatform: throttle_thermal_policy not supported".to_owned(), "RogPlatform: throttle_thermal_policy not supported".to_owned()
)) ))
} }
} }
@@ -464,7 +462,7 @@ impl CtrlPlatform {
}) })
} else { } else {
Err(FdoErr::NotSupported( Err(FdoErr::NotSupported(
"RogPlatform: throttle_thermal_policy not supported".to_owned(), "RogPlatform: throttle_thermal_policy not supported".to_owned()
)) ))
} }
} }
@@ -489,7 +487,7 @@ impl CtrlPlatform {
#[zbus(property)] #[zbus(property)]
async fn set_throttle_policy_on_battery( async fn set_throttle_policy_on_battery(
&mut self, &mut self,
policy: ThrottlePolicy, policy: ThrottlePolicy
) -> Result<(), FdoErr> { ) -> Result<(), FdoErr> {
self.config.lock().await.throttle_policy_on_battery = policy; self.config.lock().await.throttle_policy_on_battery = policy;
self.set_throttle_thermal_policy(policy).await?; self.set_throttle_thermal_policy(policy).await?;
@@ -749,7 +747,7 @@ impl ReloadAndNotify for CtrlPlatform {
async fn reload_and_notify( async fn reload_and_notify(
&mut self, &mut self,
signal_context: &SignalEmitter<'static>, signal_context: &SignalEmitter<'static>,
data: Self::Data, data: Self::Data
) -> Result<(), RogError> { ) -> Result<(), RogError> {
let mut config = self.config.lock().await; let mut config = self.config.lock().await;
if *config != data { if *config != data {
@@ -951,7 +949,7 @@ impl CtrlTask for CtrlPlatform {
platform1 platform1
.power .power
.set_charge_control_end_threshold( .set_charge_control_end_threshold(
platform1.config.lock().await.charge_control_end_threshold, platform1.config.lock().await.charge_control_end_threshold
) )
.ok(); .ok();
} }
@@ -996,7 +994,7 @@ impl CtrlTask for CtrlPlatform {
platform2 platform2
.power .power
.set_charge_control_end_threshold( .set_charge_control_end_threshold(
lock.base_charge_control_end_threshold, lock.base_charge_control_end_threshold
) )
.map_err(|err| { .map_err(|err| {
warn!("CtrlCharge: charge_control_end_threshold {}", err); warn!("CtrlCharge: charge_control_end_threshold {}", err);
@@ -1026,7 +1024,7 @@ impl CtrlTask for CtrlPlatform {
platform3.restore_charge_limit().await; platform3.restore_charge_limit().await;
} }
} }
}, }
) )
.await; .await;

View File

@@ -4,6 +4,7 @@ use std::sync::Arc;
use ::zbus::export::futures_util::lock::Mutex; use ::zbus::export::futures_util::lock::Mutex;
use ::zbus::Connection; use ::zbus::Connection;
use asusd::asus_armoury::start_attributes_zbus;
use asusd::aura_manager::DeviceManager; use asusd::aura_manager::DeviceManager;
use asusd::config::Config; use asusd::config::Config;
use asusd::ctrl_fancurves::CtrlFanCurveZbus; use asusd::ctrl_fancurves::CtrlFanCurveZbus;
@@ -26,7 +27,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let is_service = match env::var_os("IS_SERVICE") { let is_service = match env::var_os("IS_SERVICE") {
Some(val) => val == "1", Some(val) => val == "1",
None => true, None => true
}; };
if !is_service { if !is_service {
@@ -56,23 +57,20 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// println!("{:?}", supported.supported_functions()); // println!("{:?}", supported.supported_functions());
// Start zbus server // Start zbus server
let mut connection = Connection::system().await?; let mut server = Connection::system().await?;
connection server.object_server().at("/", ObjectManager).await.unwrap();
.object_server()
.at("/", ObjectManager)
.await
.unwrap();
let config = Config::new().load(); let config = Config::new().load();
let cfg_path = config.file_path(); let cfg_path = config.file_path();
let config = Arc::new(Mutex::new(config)); let config = Arc::new(Mutex::new(config));
// supported.add_to_server(&mut connection).await; // supported.add_to_server(&mut connection).await;
start_attributes_zbus(&server).await?;
match CtrlFanCurveZbus::new() { match CtrlFanCurveZbus::new() {
Ok(ctrl) => { Ok(ctrl) => {
let sig_ctx = CtrlFanCurveZbus::signal_context(&connection)?; let sig_ctx = CtrlFanCurveZbus::signal_context(&server)?;
start_tasks(ctrl, &mut connection, sig_ctx).await?; start_tasks(ctrl, &mut server, sig_ctx).await?;
} }
Err(err) => { Err(err) => {
error!("FanCurves: {}", err); error!("FanCurves: {}", err);
@@ -82,24 +80,24 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
match CtrlPlatform::new( match CtrlPlatform::new(
config.clone(), config.clone(),
&cfg_path, &cfg_path,
CtrlPlatform::signal_context(&connection)?, CtrlPlatform::signal_context(&server)?
) { ) {
Ok(ctrl) => { Ok(ctrl) => {
let sig_ctx = CtrlPlatform::signal_context(&connection)?; let sig_ctx = CtrlPlatform::signal_context(&server)?;
start_tasks(ctrl, &mut connection, sig_ctx).await?; start_tasks(ctrl, &mut server, sig_ctx).await?;
} }
Err(err) => { Err(err) => {
error!("CtrlPlatform: {}", err); error!("CtrlPlatform: {}", err);
} }
} }
let _ = DeviceManager::new(connection.clone()).await?; let _ = DeviceManager::new(server.clone()).await?;
// Request dbus name after finishing initalizing all functions // Request dbus name after finishing initalizing all functions
connection.request_name(DBUS_NAME).await?; server.request_name(DBUS_NAME).await?;
loop { loop {
// This is just a blocker to idle and ensure the reator reacts // This is just a blocker to idle and ensure the reator reacts
connection.executor().tick().await; server.executor().tick().await;
} }
} }

View File

@@ -37,7 +37,7 @@ pub enum RogError {
SystemdUnitAction(String), SystemdUnitAction(String),
SystemdUnitWaitTimeout(String), SystemdUnitWaitTimeout(String),
Command(String, std::io::Error), Command(String, std::io::Error),
ParseRon(ron::Error), ParseRon(ron::Error)
} }
impl fmt::Display for RogError { impl fmt::Display for RogError {
@@ -87,7 +87,7 @@ impl fmt::Display for RogError {
) )
} }
RogError::Command(func, error) => write!(f, "Command exec error: {}: {}", func, error), RogError::Command(func, error) => write!(f, "Command exec error: {}: {}", func, error),
RogError::ParseRon(error) => write!(f, "Parse config error: {}", error), RogError::ParseRon(error) => write!(f, "Parse config error: {}", error)
} }
} }
} }
@@ -142,3 +142,10 @@ impl From<RogError> for zbus::fdo::Error {
zbus::fdo::Error::Failed(format!("{}", err)) zbus::fdo::Error::Failed(format!("{}", err))
} }
} }
impl From<RogError> for zbus::Error {
#[inline]
fn from(err: RogError) -> Self {
zbus::Error::Failure(format!("{}", err))
}
}

View File

@@ -6,6 +6,7 @@ pub mod ctrl_fancurves;
/// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode /// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode
pub mod ctrl_platform; pub mod ctrl_platform;
pub mod asus_armoury;
pub mod aura_anime; pub mod aura_anime;
pub mod aura_laptop; pub mod aura_laptop;
pub mod aura_manager; pub mod aura_manager;
@@ -30,9 +31,11 @@ use zbus::Connection;
use crate::error::RogError; use crate::error::RogError;
const CONFIG_PATH_BASE: &str = "/etc/asusd/"; const CONFIG_PATH_BASE: &str = "/etc/asusd/";
pub static DBUS_NAME: &str = "org.asuslinux.Daemon"; pub const ASUS_ZBUS_PATH: &str = "/xyz/ljones";
pub static DBUS_PATH: &str = "/org/asuslinux/Daemon";
pub static DBUS_IFACE: &str = "org.asuslinux.Daemon"; pub static DBUS_NAME: &str = "xyz.ljones.Asusd";
pub static DBUS_PATH: &str = "/xyz/ljones/Daemon";
pub static DBUS_IFACE: &str = "xyz.ljones.Asusd";
/// This macro adds a function which spawns an `inotify` task on the passed in /// This macro adds a function which spawns an `inotify` task on the passed in
/// `Executor`. /// `Executor`.
@@ -146,7 +149,7 @@ pub trait ReloadAndNotify {
fn reload_and_notify( fn reload_and_notify(
&mut self, &mut self,
signal_context: &SignalEmitter<'static>, signal_context: &SignalEmitter<'static>,
data: Self::Data, data: Self::Data
) -> impl Future<Output = Result<(), RogError>> + Send; ) -> impl Future<Output = Result<(), RogError>> + Send;
} }
@@ -156,7 +159,7 @@ pub trait ZbusRun {
fn add_to_server_helper( fn add_to_server_helper(
iface: impl Interface, iface: impl Interface,
path: &str, path: &str,
server: &mut Connection, server: &mut Connection
) -> impl Future<Output = ()> + Send { ) -> impl Future<Output = ()> + Send {
async move { async move {
server server
@@ -185,7 +188,7 @@ pub trait CtrlTask {
/// separate thread. /// separate thread.
fn create_tasks( fn create_tasks(
&self, &self,
signal: SignalEmitter<'static>, signal: SignalEmitter<'static>
) -> impl Future<Output = Result<(), RogError>> + Send; ) -> impl Future<Output = Result<(), RogError>> + Send;
// /// Create a timed repeating task // /// Create a timed repeating task
@@ -209,7 +212,7 @@ pub trait CtrlTask {
mut on_prepare_for_sleep: F1, mut on_prepare_for_sleep: F1,
mut on_prepare_for_shutdown: F2, mut on_prepare_for_shutdown: F2,
mut on_lid_change: F3, mut on_lid_change: F3,
mut on_external_power_change: F4, mut on_external_power_change: F4
) -> impl Future<Output = ()> + Send ) -> impl Future<Output = ()> + Send
where where
F1: FnMut(bool) -> Fut1 + Send + 'static, F1: FnMut(bool) -> Fut1 + Send + 'static,
@@ -219,7 +222,7 @@ pub trait CtrlTask {
Fut1: Future<Output = ()> + Send, Fut1: Future<Output = ()> + Send,
Fut2: Future<Output = ()> + Send, Fut2: Future<Output = ()> + Send,
Fut3: Future<Output = ()> + Send, Fut3: Future<Output = ()> + Send,
Fut4: Future<Output = ()> + Send, Fut4: Future<Output = ()> + Send
{ {
async { async {
let connection = Connection::system() let connection = Connection::system()
@@ -299,10 +302,10 @@ pub trait GetSupported {
pub async fn start_tasks<T>( pub async fn start_tasks<T>(
mut zbus: T, mut zbus: T,
connection: &mut Connection, connection: &mut Connection,
signal_ctx: SignalEmitter<'static>, signal_ctx: SignalEmitter<'static>
) -> Result<(), RogError> ) -> Result<(), RogError>
where where
T: ZbusRun + Reloadable + CtrlTask + Clone, T: ZbusRun + Reloadable + CtrlTask + Clone
{ {
let zbus_clone = zbus.clone(); let zbus_clone = zbus.clone();

View File

@@ -19,7 +19,7 @@ use serde::Serialize;
/// implemented, the rest are intended to be free methods. /// implemented, the rest are intended to be free methods.
pub trait StdConfig pub trait StdConfig
where where
Self: Serialize + DeserializeOwned, Self: Serialize + DeserializeOwned
{ {
/// Taking over the standard `new()` to ensure things can be generic /// Taking over the standard `new()` to ensure things can be generic
fn new() -> Self; fn new() -> Self;

View File

@@ -1,11 +0,0 @@
[package]
name = "cpuctl"
license.workspace = true
version.workspace = true
readme.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true
edition.workspace = true
[dependencies]

View File

@@ -1,14 +0,0 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

View File

@@ -3,24 +3,24 @@
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig> <busconfig>
<policy group="adm"> <policy group="adm">
<allow send_destination="org.asuslinux.Daemon"/> <allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="org.asuslinux.Daemon"/> <allow receive_sender="xyz.ljones.Asusd"/>
</policy> </policy>
<policy group="sudo"> <policy group="sudo">
<allow send_destination="org.asuslinux.Daemon"/> <allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="org.asuslinux.Daemon"/> <allow receive_sender="xyz.ljones.Asusd"/>
</policy> </policy>
<policy group="users"> <policy group="users">
<allow send_destination="org.asuslinux.Daemon"/> <allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="org.asuslinux.Daemon"/> <allow receive_sender="xyz.ljones.Asusd"/>
</policy> </policy>
<policy group="wheel"> <policy group="wheel">
<allow send_destination="org.asuslinux.Daemon"/> <allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="org.asuslinux.Daemon"/> <allow receive_sender="xyz.ljones.Asusd"/>
</policy> </policy>
<policy user="root"> <policy user="root">
<allow own="org.asuslinux.Daemon"/> <allow own="xyz.ljones.Asusd"/>
<allow send_destination="org.asuslinux.Daemon"/> <allow send_destination="xyz.ljones.Asusd"/>
<allow receive_sender="org.asuslinux.Daemon"/> <allow receive_sender="xyz.ljones.Asusd"/>
</policy> </policy>
</busconfig> </busconfig>

View File

@@ -13,6 +13,6 @@ ExecStart=/usr/bin/asusd
Restart=on-failure Restart=on-failure
RestartSec=1 RestartSec=1
Type=dbus Type=dbus
BusName=org.asuslinux.Daemon BusName=xyz.ljones.Asusd
SELinuxContext=system_u:system_r:unconfined_t:s0 SELinuxContext=system_u:system_r:unconfined_t:s0
#SELinuxContext=system_u:object_r:modules_object_t:s0 #SELinuxContext=system_u:object_r:modules_object_t:s0

View File

@@ -135,7 +135,7 @@ impl crate::ZbusAdd for CtrlAnimeZbus {
} }
} }
#[dbus_interface(name = "org.asuslinux.Daemon")] #[dbus_interface(name = "xyz.ljones.Asusd")]
impl CtrlAnimeZbus { impl CtrlAnimeZbus {
async fn <zbus method>() { async fn <zbus method>() {
let lock = self.inner.lock().await; let lock = self.inner.lock().await;

View File

@@ -12,7 +12,7 @@ pub struct DMIID {
pub bios_vendor: String, pub bios_vendor: String,
pub bios_version: String, pub bios_version: String,
pub product_family: String, pub product_family: String,
pub product_name: String, pub product_name: String
} }
impl DMIID { impl DMIID {
@@ -77,7 +77,7 @@ impl DMIID {
product_name: device product_name: device
.attribute_value("product_name") .attribute_value("product_name")
.map(|s| s.to_string_lossy().to_string()) .map(|s| s.to_string_lossy().to_string())
.unwrap_or("Unknown".to_string()), .unwrap_or("Unknown".to_string())
}); });
} }
Err("dmi not found".into()) Err("dmi not found".into())

View File

@@ -30,7 +30,6 @@ log.workspace = true
serde.workspace = true serde.workspace = true
glam.workspace = true glam.workspace = true
typeshare.workspace = true
zbus = { workspace = true, optional = true } zbus = { workspace = true, optional = true }

View File

@@ -6,7 +6,6 @@ use std::time::{Duration, Instant};
use dmi_id::DMIID; use dmi_id::DMIID;
use log::info; use log::info;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
@@ -23,27 +22,29 @@ const BLOCK_END: usize = 634;
const PANE_LEN: usize = BLOCK_END - BLOCK_START; const PANE_LEN: usize = BLOCK_END - BLOCK_START;
/// First packet is for GA401 + GA402 /// First packet is for GA401 + GA402
pub const USB_PREFIX1: [u8; 7] = [0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02]; pub const USB_PREFIX1: [u8; 7] = [
0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02
];
/// Second packet is for GA401 + GA402 /// Second packet is for GA401 + GA402
pub const USB_PREFIX2: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02]; pub const USB_PREFIX2: [u8; 7] = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02
];
/// Third packet is for GA402 matrix /// Third packet is for GA402 matrix
pub const USB_PREFIX3: [u8; 7] = [0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02]; pub const USB_PREFIX3: [u8; 7] = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02
];
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[typeshare]
#[derive(Default, Deserialize, PartialEq, Eq, Clone, Copy, Serialize, Debug)] #[derive(Default, Deserialize, PartialEq, Eq, Clone, Copy, Serialize, Debug)]
pub struct Animations { pub struct Animations {
pub boot: AnimBooting, pub boot: AnimBooting,
pub awake: AnimAwake, pub awake: AnimAwake,
pub sleep: AnimSleeping, pub sleep: AnimSleeping,
pub shutdown: AnimShutdown, pub shutdown: AnimShutdown
} }
// TODO: move this out // TODO: move this out
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))] #[cfg_attr(feature = "dbus", derive(Type))]
#[typeshare]
#[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub struct DeviceState { pub struct DeviceState {
pub display_enabled: bool, pub display_enabled: bool,
@@ -53,10 +54,9 @@ pub struct DeviceState {
pub off_when_unplugged: bool, pub off_when_unplugged: bool,
pub off_when_suspended: bool, pub off_when_suspended: bool,
pub off_when_lid_closed: bool, pub off_when_lid_closed: bool,
pub brightness_on_battery: Brightness, pub brightness_on_battery: Brightness
} }
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))] #[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize, Default)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize, Default)]
pub enum AnimeType { pub enum AnimeType {
@@ -64,7 +64,7 @@ pub enum AnimeType {
GA402, GA402,
GU604, GU604,
#[default] #[default]
Unsupported, Unsupported
} }
impl FromStr for AnimeType { impl FromStr for AnimeType {
@@ -75,7 +75,7 @@ impl FromStr for AnimeType {
"ga401" | "GA401" => Self::GA401, "ga401" | "GA401" => Self::GA401,
"ga402" | "GA402" => Self::GA402, "ga402" | "GA402" => Self::GA402,
"gu604" | "GU604" => Self::GU604, "gu604" | "GU604" => Self::GU604,
_ => Self::Unsupported, _ => Self::Unsupported
}) })
} }
} }
@@ -98,7 +98,7 @@ impl AnimeType {
pub fn width(&self) -> usize { pub fn width(&self) -> usize {
match self { match self {
AnimeType::GU604 => 70, AnimeType::GU604 => 70,
_ => 74, _ => 74
} }
} }
@@ -107,7 +107,7 @@ impl AnimeType {
match self { match self {
AnimeType::GA401 => 36, AnimeType::GA401 => 36,
AnimeType::GU604 => 43, AnimeType::GU604 => 43,
_ => 39, _ => 39
} }
} }
@@ -116,7 +116,7 @@ impl AnimeType {
match self { match self {
AnimeType::GA401 => PANE_LEN * 2, AnimeType::GA401 => PANE_LEN * 2,
AnimeType::GU604 => PANE_LEN * 3, AnimeType::GU604 => PANE_LEN * 3,
_ => PANE_LEN * 3, _ => PANE_LEN * 3
} }
} }
} }
@@ -127,7 +127,7 @@ impl AnimeType {
#[derive(Debug, Clone, Deserialize, Serialize)] #[derive(Debug, Clone, Deserialize, Serialize)]
pub struct AnimeDataBuffer { pub struct AnimeDataBuffer {
data: Vec<u8>, data: Vec<u8>,
anime: AnimeType, anime: AnimeType
} }
impl AnimeDataBuffer { impl AnimeDataBuffer {
@@ -137,7 +137,7 @@ impl AnimeDataBuffer {
AnimeDataBuffer { AnimeDataBuffer {
data: vec![0u8; len], data: vec![0u8; len],
anime, anime
} }
} }
@@ -180,7 +180,7 @@ impl TryFrom<AnimeDataBuffer> for AnimePacketType {
let mut buffers = match anime.anime { let mut buffers = match anime.anime {
AnimeType::GA401 => vec![[0; 640]; 2], AnimeType::GA401 => vec![[0; 640]; 2],
AnimeType::GA402 | AnimeType::GU604 | AnimeType::Unsupported => vec![[0; 640]; 3], AnimeType::GA402 | AnimeType::GU604 | AnimeType::Unsupported => vec![[0; 640]; 3]
}; };
for (idx, chunk) in anime.data.as_slice().chunks(PANE_LEN).enumerate() { for (idx, chunk) in anime.data.as_slice().chunks(PANE_LEN).enumerate() {

View File

@@ -20,7 +20,7 @@ impl AnimeDiagonal {
Self( Self(
anime_type, anime_type,
vec![vec![0; anime_type.width()]; anime_type.height()], vec![vec![0; anime_type.width()]; anime_type.height()],
duration, duration
) )
} }
@@ -49,7 +49,7 @@ impl AnimeDiagonal {
path: &Path, path: &Path,
duration: Option<Duration>, duration: Option<Duration>,
bright: f32, bright: f32,
anime_type: AnimeType, anime_type: AnimeType
) -> Result<Self> { ) -> Result<Self> {
let data = std::fs::read(path).map_err(|e| { let data = std::fs::read(path).map_err(|e| {
error!("Could not open {path:?}: {e:?}"); error!("Could not open {path:?}: {e:?}");
@@ -86,7 +86,7 @@ impl AnimeDiagonal {
png_pong::PngRaster::Rgba16(ras) => { png_pong::PngRaster::Rgba16(ras) => {
Self::pixels_from_16bit(ras, &mut matrix, bright, false); Self::pixels_from_16bit(ras, &mut matrix, bright, false);
} }
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format), png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format)
}; };
Ok(matrix) Ok(matrix)
@@ -96,9 +96,9 @@ impl AnimeDiagonal {
ras: &pix::Raster<P>, ras: &pix::Raster<P>,
matrix: &mut AnimeDiagonal, matrix: &mut AnimeDiagonal,
bright: f32, bright: f32,
grey: bool, grey: bool
) where ) where
P: pix::el::Pixel<Chan = pix::chan::Ch8>, P: pix::el::Pixel<Chan = pix::chan::Ch8>
{ {
let width = ras.width(); let width = ras.width();
for (y, row) in ras.pixels().chunks(width as usize).enumerate() { for (y, row) in ras.pixels().chunks(width as usize).enumerate() {
@@ -121,9 +121,9 @@ impl AnimeDiagonal {
ras: &pix::Raster<P>, ras: &pix::Raster<P>,
matrix: &mut AnimeDiagonal, matrix: &mut AnimeDiagonal,
bright: f32, bright: f32,
grey: bool, grey: bool
) where ) where
P: pix::el::Pixel<Chan = pix::chan::Ch16>, P: pix::el::Pixel<Chan = pix::chan::Ch16>
{ {
let width = ras.width(); let width = ras.width();
for (y, row) in ras.pixels().chunks(width as usize).enumerate() { for (y, row) in ras.pixels().chunks(width as usize).enumerate() {
@@ -146,7 +146,7 @@ impl AnimeDiagonal {
match anime_type { match anime_type {
AnimeType::GA401 => self.to_ga401_packets(), AnimeType::GA401 => self.to_ga401_packets(),
AnimeType::GU604 => self.to_gu604_packets(), AnimeType::GU604 => self.to_gu604_packets(),
_ => self.to_ga402_packets(), _ => self.to_ga402_packets()
} }
} }
@@ -224,7 +224,7 @@ impl AnimeDiagonal {
x: usize, x: usize,
y: usize, y: usize,
start_index: &mut usize, start_index: &mut usize,
len: usize, len: usize
) { ) {
buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len)); buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len));
*start_index += len; *start_index += len;
@@ -307,7 +307,7 @@ impl AnimeDiagonal {
x: usize, x: usize,
y: usize, y: usize,
start_index: &mut usize, start_index: &mut usize,
len: usize, len: usize
) { ) {
buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len)); buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len));
*start_index += len; *start_index += len;

View File

@@ -24,7 +24,7 @@ pub enum AnimeError {
DataBufferLength, DataBufferLength,
PixelGifWidth(usize), PixelGifWidth(usize),
PixelGifHeight(usize), PixelGifHeight(usize),
ParseError(String), ParseError(String)
} }
impl fmt::Display for AnimeError { impl fmt::Display for AnimeError {
@@ -61,7 +61,7 @@ impl fmt::Display for AnimeError {
AnimeError::PixelGifHeight(n) => write!( AnimeError::PixelGifHeight(n) => write!(
f, f,
"The gif used for pixel-perfect gif is is taller than {n}" "The gif used for pixel-perfect gif is is taller than {n}"
), )
} }
} }
} }

View File

@@ -16,7 +16,7 @@ pub struct AnimeFrame {
/// the `asusd` daemon over dbus or converted to USB packet with /// the `asusd` daemon over dbus or converted to USB packet with
/// `AnimePacketType::from(buffer)` /// `AnimePacketType::from(buffer)`
data: AnimeDataBuffer, data: AnimeDataBuffer,
delay: Duration, delay: Duration
} }
impl AnimeFrame { impl AnimeFrame {
@@ -44,7 +44,7 @@ pub enum AnimTime {
/// Run for infinite time /// Run for infinite time
Infinite, Infinite,
/// Fade in, play for, fade out /// Fade in, play for, fade out
Fade(Fade), Fade(Fade)
} }
impl Default for AnimTime { impl Default for AnimTime {
@@ -59,7 +59,7 @@ impl Default for AnimTime {
pub struct Fade { pub struct Fade {
fade_in: Duration, fade_in: Duration,
show_for: Option<Duration>, show_for: Option<Duration>,
fade_out: Duration, fade_out: Duration
} }
impl Fade { impl Fade {
@@ -67,7 +67,7 @@ impl Fade {
Self { Self {
fade_in, fade_in,
show_for, show_for,
fade_out, fade_out
} }
} }
@@ -100,7 +100,7 @@ impl AnimeGif {
file_name: &Path, file_name: &Path,
duration: AnimTime, duration: AnimTime,
brightness: f32, brightness: f32,
anime_type: AnimeType, anime_type: AnimeType
) -> Result<Self> { ) -> Result<Self> {
let mut matrix = AnimeDiagonal::new(anime_type, None); let mut matrix = AnimeDiagonal::new(anime_type, None);
@@ -142,7 +142,7 @@ impl AnimeGif {
frames.push(AnimeFrame { frames.push(AnimeFrame {
data: matrix.into_data_buffer(anime_type)?, data: matrix.into_data_buffer(anime_type)?,
delay: Duration::from_millis(wait as u64), delay: Duration::from_millis(wait as u64)
}); });
} }
Ok(Self(frames, duration)) Ok(Self(frames, duration))
@@ -154,7 +154,7 @@ impl AnimeGif {
file_name: &Path, file_name: &Path,
anime_type: AnimeType, anime_type: AnimeType,
duration: AnimTime, duration: AnimTime,
brightness: f32, brightness: f32
) -> Result<Self> { ) -> Result<Self> {
let image = AnimeDiagonal::from_png(file_name, None, brightness, anime_type)?; let image = AnimeDiagonal::from_png(file_name, None, brightness, anime_type)?;
@@ -170,7 +170,7 @@ impl AnimeGif {
let single = AnimeFrame { let single = AnimeFrame {
data: image.into_data_buffer(anime_type)?, data: image.into_data_buffer(anime_type)?,
delay: Duration::from_millis(30), delay: Duration::from_millis(30)
}; };
let frames = vec![single; frame_count as usize]; let frames = vec![single; frame_count as usize];
@@ -187,7 +187,7 @@ impl AnimeGif {
translation: Vec2, translation: Vec2,
duration: AnimTime, duration: AnimTime,
brightness: f32, brightness: f32,
anime_type: AnimeType, anime_type: AnimeType
) -> Result<Self> { ) -> Result<Self> {
let mut frames = Vec::new(); let mut frames = Vec::new();
let mut decoder = gif::DecodeOptions::new(); let mut decoder = gif::DecodeOptions::new();
@@ -211,7 +211,7 @@ impl AnimeGif {
brightness, brightness,
pixels, pixels,
decoder.width() as u32, decoder.width() as u32,
anime_type, anime_type
)?; )?;
while let Some(frame) = decoder.read_next_frame()? { while let Some(frame) = decoder.read_next_frame()? {
@@ -226,7 +226,7 @@ impl AnimeGif {
brightness, brightness,
pixels, pixels,
width as u32, width as u32,
anime_type, anime_type
)?; )?;
} }
for (y, row) in frame.buffer.chunks(frame.width as usize * 4).enumerate() { for (y, row) in frame.buffer.chunks(frame.width as usize * 4).enumerate() {
@@ -239,7 +239,7 @@ impl AnimeGif {
(x + frame.left as usize) + ((y + frame.top as usize) * width as usize); (x + frame.left as usize) + ((y + frame.top as usize) * width as usize);
image.get_mut()[pos] = Pixel { image.get_mut()[pos] = Pixel {
color: ((px[0] as u32 + px[1] as u32 + px[2] as u32) / 3), color: ((px[0] as u32 + px[1] as u32 + px[2] as u32) / 3),
alpha: 1.0, alpha: 1.0
}; };
} }
} }
@@ -247,7 +247,7 @@ impl AnimeGif {
frames.push(AnimeFrame { frames.push(AnimeFrame {
data: <AnimeDataBuffer>::try_from(&image)?, data: <AnimeDataBuffer>::try_from(&image)?,
delay: Duration::from_millis(wait as u64), delay: Duration::from_millis(wait as u64)
}); });
} }
Ok(Self(frames, duration)) Ok(Self(frames, duration))
@@ -265,7 +265,7 @@ impl AnimeGif {
translation: Vec2, translation: Vec2,
duration: AnimTime, duration: AnimTime,
brightness: f32, brightness: f32,
anime_type: AnimeType, anime_type: AnimeType
) -> Result<Self> { ) -> Result<Self> {
let image = let image =
AnimeImage::from_png(file_name, scale, angle, translation, brightness, anime_type)?; AnimeImage::from_png(file_name, scale, angle, translation, brightness, anime_type)?;
@@ -282,7 +282,7 @@ impl AnimeGif {
let single = AnimeFrame { let single = AnimeFrame {
data: <AnimeDataBuffer>::try_from(&image)?, data: <AnimeDataBuffer>::try_from(&image)?,
delay: Duration::from_millis(30), delay: Duration::from_millis(30)
}; };
let frames = vec![single; frame_count as usize]; let frames = vec![single; frame_count as usize];

View File

@@ -18,7 +18,7 @@ const HEIGHT: usize = 55;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct AnimeGrid { pub struct AnimeGrid {
anime_type: AnimeType, anime_type: AnimeType,
data: [[u8; WIDTH]; HEIGHT], data: [[u8; WIDTH]; HEIGHT]
} }
impl AnimeGrid { impl AnimeGrid {
@@ -26,7 +26,7 @@ impl AnimeGrid {
pub fn new(anime_type: AnimeType) -> Self { pub fn new(anime_type: AnimeType) -> Self {
Self { Self {
anime_type, anime_type,
data: [[0u8; WIDTH]; HEIGHT], data: [[0u8; WIDTH]; HEIGHT]
} }
} }
@@ -174,7 +174,7 @@ mod tests {
0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0,
0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0
]; ];
assert_eq!(matrix.data(), &data_cmp); assert_eq!(matrix.data(), &data_cmp);
} }

View File

@@ -13,7 +13,7 @@ use crate::AnimeType;
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct Pixel { pub struct Pixel {
pub color: u32, pub color: u32,
pub alpha: f32, pub alpha: f32
} }
impl Default for Pixel { impl Default for Pixel {
@@ -21,7 +21,7 @@ impl Default for Pixel {
fn default() -> Self { fn default() -> Self {
Pixel { Pixel {
color: 0, color: 0,
alpha: 0.0, alpha: 0.0
} }
} }
} }
@@ -76,7 +76,7 @@ pub struct AnimeImage {
/// The type of the display. The GA401 and GA402 use the same controller and /// The type of the display. The GA401 and GA402 use the same controller and
/// therefore same ID, so the identifier must be by laptop model in /// therefore same ID, so the identifier must be by laptop model in
/// `AnimeType`. /// `AnimeType`.
anime_type: AnimeType, anime_type: AnimeType
} }
impl AnimeImage { impl AnimeImage {
@@ -88,7 +88,7 @@ impl AnimeImage {
bright: f32, bright: f32,
pixels: Vec<Pixel>, pixels: Vec<Pixel>,
width: u32, width: u32,
anime_type: AnimeType, anime_type: AnimeType
) -> Result<Self> { ) -> Result<Self> {
if !(0.0..=1.0).contains(&bright) { if !(0.0..=1.0).contains(&bright) {
return Err(AnimeError::InvalidBrightness(bright)); return Err(AnimeError::InvalidBrightness(bright));
@@ -102,7 +102,7 @@ impl AnimeImage {
led_pos: Self::generate_image_positioning(anime_type), led_pos: Self::generate_image_positioning(anime_type),
img_pixels: pixels, img_pixels: pixels,
width, width,
anime_type, anime_type
}) })
} }
@@ -121,7 +121,7 @@ impl AnimeImage {
match anime_type { match anime_type {
AnimeType::GA401 => 0.8, AnimeType::GA401 => 0.8,
AnimeType::GU604 => 0.78, AnimeType::GU604 => 0.78,
_ => 0.77, _ => 0.77
} }
} }
@@ -138,7 +138,7 @@ impl AnimeImage {
match anime_type { match anime_type {
AnimeType::GA401 => 0.3, AnimeType::GA401 => 0.3,
AnimeType::GU604 => 0.28, AnimeType::GU604 => 0.28,
_ => 0.283, _ => 0.283
} }
} }
@@ -237,7 +237,7 @@ impl AnimeImage {
AnimeType::GA401 => (33.0 + 0.5) * Self::scale_x(anime_type), AnimeType::GA401 => (33.0 + 0.5) * Self::scale_x(anime_type),
AnimeType::GU604 => (38.0 + 0.5) * Self::scale_x(anime_type), AnimeType::GU604 => (38.0 + 0.5) * Self::scale_x(anime_type),
_ => (35.0 + 0.5) * Self::scale_x(anime_type), _ => (35.0 + 0.5) * Self::scale_x(anime_type)
} }
} }
@@ -246,7 +246,7 @@ impl AnimeImage {
match anime_type { match anime_type {
AnimeType::GA401 => 55, AnimeType::GA401 => 55,
AnimeType::GU604 => 62, AnimeType::GU604 => 62,
_ => 61, _ => 61
} }
} }
@@ -257,7 +257,7 @@ impl AnimeImage {
AnimeType::GA401 => (54.0 + 1.0) * Self::scale_y(anime_type), AnimeType::GA401 => (54.0 + 1.0) * Self::scale_y(anime_type),
AnimeType::GU604 => 62.0 * Self::scale_y(anime_type), AnimeType::GU604 => 62.0 * Self::scale_y(anime_type),
// GA402 may not have dead pixels and require only the physical LED count // GA402 may not have dead pixels and require only the physical LED count
_ => 61.0 * Self::scale_y(anime_type), _ => 61.0 * Self::scale_y(anime_type)
} }
} }
@@ -267,11 +267,11 @@ impl AnimeImage {
AnimeType::GA401 => match y { AnimeType::GA401 => match y {
0 | 2 | 4 => 33, 0 | 2 | 4 => 33,
1 | 3 => 35, // Some rows are padded 1 | 3 => 35, // Some rows are padded
_ => 36 - y / 2, _ => 36 - y / 2
}, },
AnimeType::GU604 => AnimeImage::width(anime_type, y), AnimeType::GU604 => AnimeImage::width(anime_type, y),
// GA402 does not have padding, equivalent to width // GA402 does not have padding, equivalent to width
_ => AnimeImage::width(anime_type, y), _ => AnimeImage::width(anime_type, y)
} }
} }
@@ -321,7 +321,9 @@ impl AnimeImage {
let pos = Vec3::new(led.x(), led.y(), 1.0); let pos = Vec3::new(led.x(), led.y(), 1.0);
let x0 = led_from_px.mul_vec3(pos + Vec3::new(0.0, -0.5, 0.0)); let x0 = led_from_px.mul_vec3(pos + Vec3::new(0.0, -0.5, 0.0));
const GROUP: [f32; 4] = [0.0, 0.5, 1.0, 1.5]; const GROUP: [f32; 4] = [
0.0, 0.5, 1.0, 1.5
];
for u in &GROUP { for u in &GROUP {
for v in &GROUP { for v in &GROUP {
let sample = x0 + *u * du + *v * dv; let sample = x0 + *u * du + *v * dv;
@@ -397,7 +399,7 @@ impl AnimeImage {
let led_from_cm = Mat3::from_scale(Vec2::new( let led_from_cm = Mat3::from_scale(Vec2::new(
1.0 / AnimeImage::scale_x(self.anime_type), 1.0 / AnimeImage::scale_x(self.anime_type),
1.0 / AnimeImage::scale_y(self.anime_type), 1.0 / AnimeImage::scale_y(self.anime_type)
)); ));
let transform = let transform =
@@ -420,7 +422,7 @@ impl AnimeImage {
angle: f32, angle: f32,
translation: Vec2, translation: Vec2,
bright: f32, bright: f32,
anime_type: AnimeType, anime_type: AnimeType
) -> Result<Self> { ) -> Result<Self> {
let data = std::fs::read(path).map_err(|e| { let data = std::fs::read(path).map_err(|e| {
error!("Could not open {path:?}: {e:?}"); error!("Could not open {path:?}: {e:?}");
@@ -464,7 +466,7 @@ impl AnimeImage {
width = ras.width(); width = ras.width();
Self::pixels_from_16bit(ras, false) Self::pixels_from_16bit(ras, false)
} }
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format), png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format)
}; };
let mut matrix = AnimeImage::new( let mut matrix = AnimeImage::new(
@@ -474,7 +476,7 @@ impl AnimeImage {
bright, bright,
pixels, pixels,
width, width,
anime_type, anime_type
)?; )?;
matrix.update(); matrix.update();
@@ -483,7 +485,7 @@ impl AnimeImage {
fn pixels_from_8bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel> fn pixels_from_8bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel>
where where
P: pix::el::Pixel<Chan = pix::chan::Ch8>, P: pix::el::Pixel<Chan = pix::chan::Ch8>
{ {
ras.pixels() ras.pixels()
.iter() .iter()
@@ -495,14 +497,14 @@ impl AnimeImage {
+ (<u8>::from(px.two()) / 3) as u32 + (<u8>::from(px.two()) / 3) as u32
+ (<u8>::from(px.three()) / 3) as u32 + (<u8>::from(px.three()) / 3) as u32
}, },
alpha: <f32>::from(px.alpha()), alpha: <f32>::from(px.alpha())
}) })
.collect() .collect()
} }
fn pixels_from_16bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel> fn pixels_from_16bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel>
where where
P: pix::el::Pixel<Chan = pix::chan::Ch16>, P: pix::el::Pixel<Chan = pix::chan::Ch16>
{ {
ras.pixels() ras.pixels()
.iter() .iter()
@@ -514,7 +516,7 @@ impl AnimeImage {
+ ((<u16>::from(px.two()) / 3) >> 8) as u32 + ((<u16>::from(px.two()) / 3) >> 8) as u32
+ ((<u16>::from(px.three()) / 3) >> 8) as u32 + ((<u16>::from(px.three()) / 3) >> 8) as u32
}, },
alpha: <f32>::from(px.alpha()), alpha: <f32>::from(px.alpha())
}) })
.collect() .collect()
} }
@@ -651,7 +653,7 @@ mod tests {
Vec2::default(), Vec2::default(),
AnimTime::Infinite, AnimTime::Infinite,
1.0, 1.0,
AnimeType::GA402, AnimeType::GA402
) )
.unwrap(); .unwrap();
matrix.frames()[0].frame(); matrix.frames()[0].frame();

View File

@@ -16,13 +16,13 @@ pub enum ActionLoader {
AsusAnimation { AsusAnimation {
file: PathBuf, file: PathBuf,
time: AnimTime, time: AnimTime,
brightness: f32, brightness: f32
}, },
/// Image designed to be pixel perfect using the slanted template /// Image designed to be pixel perfect using the slanted template
AsusImage { AsusImage {
file: PathBuf, file: PathBuf,
time: AnimTime, time: AnimTime,
brightness: f32, brightness: f32
}, },
/// Animated gif. If the file is a png a static gif is created using the /// Animated gif. If the file is a png a static gif is created using the
/// `time` properties /// `time` properties
@@ -32,7 +32,7 @@ pub enum ActionLoader {
angle: f32, angle: f32,
translation: Vec2, translation: Vec2,
time: AnimTime, time: AnimTime,
brightness: f32, brightness: f32
}, },
Image { Image {
file: PathBuf, file: PathBuf,
@@ -40,10 +40,10 @@ pub enum ActionLoader {
angle: f32, angle: f32,
translation: Vec2, translation: Vec2,
time: AnimTime, time: AnimTime,
brightness: f32, brightness: f32
}, },
/// A pause to be used between sequences /// A pause to be used between sequences
Pause(Duration), Pause(Duration)
} }
/// All the possible `AniMe` actions that can be used. The enum is intended to /// All the possible `AniMe` actions that can be used. The enum is intended to
@@ -64,7 +64,7 @@ pub enum ActionData {
/// Placeholder /// Placeholder
TimeDate, TimeDate,
/// Placeholder /// Placeholder
Matrix, Matrix
} }
impl ActionData { impl ActionData {
@@ -73,17 +73,14 @@ impl ActionData {
ActionLoader::AsusAnimation { ActionLoader::AsusAnimation {
file, file,
time, time,
brightness, brightness
} => ActionData::Animation(AnimeGif::from_diagonal_gif( } => ActionData::Animation(AnimeGif::from_diagonal_gif(
file, file, *time, *brightness, anime_type
*time,
*brightness,
anime_type,
)?), )?),
ActionLoader::AsusImage { ActionLoader::AsusImage {
file, file,
time, time,
brightness, brightness
} => match time { } => match time {
AnimTime::Infinite => { AnimTime::Infinite => {
let image = AnimeDiagonal::from_png(file, None, *brightness, anime_type)?; let image = AnimeDiagonal::from_png(file, None, *brightness, anime_type)?;
@@ -91,11 +88,8 @@ impl ActionData {
ActionData::Image(Box::new(data)) ActionData::Image(Box::new(data))
} }
_ => ActionData::Animation(AnimeGif::from_diagonal_png( _ => ActionData::Animation(AnimeGif::from_diagonal_png(
file, file, anime_type, *time, *brightness
anime_type, )?)
*time,
*brightness,
)?),
}, },
ActionLoader::ImageAnimation { ActionLoader::ImageAnimation {
file, file,
@@ -103,29 +97,17 @@ impl ActionData {
angle, angle,
translation, translation,
time, time,
brightness, brightness
} => { } => {
if let Some(ext) = file.extension() { if let Some(ext) = file.extension() {
if ext.to_string_lossy().to_lowercase() == "png" { if ext.to_string_lossy().to_lowercase() == "png" {
return Ok(ActionData::Animation(AnimeGif::from_png( return Ok(ActionData::Animation(AnimeGif::from_png(
file, file, *scale, *angle, *translation, *time, *brightness, anime_type
*scale,
*angle,
*translation,
*time,
*brightness,
anime_type,
)?)); )?));
} }
} }
ActionData::Animation(AnimeGif::from_gif( ActionData::Animation(AnimeGif::from_gif(
file, file, *scale, *angle, *translation, *time, *brightness, anime_type
*scale,
*angle,
*translation,
*time,
*brightness,
anime_type,
)?) )?)
} }
ActionLoader::Image { ActionLoader::Image {
@@ -134,34 +116,23 @@ impl ActionData {
angle, angle,
translation, translation,
brightness, brightness,
time, time
} => { } => {
match time { match time {
AnimTime::Infinite => { AnimTime::Infinite => {
// If no time then create a plain static image // If no time then create a plain static image
let image = AnimeImage::from_png( let image = AnimeImage::from_png(
file, file, *scale, *angle, *translation, *brightness, anime_type
*scale,
*angle,
*translation,
*brightness,
anime_type,
)?; )?;
let data = <AnimeDataBuffer>::try_from(&image)?; let data = <AnimeDataBuffer>::try_from(&image)?;
ActionData::Image(Box::new(data)) ActionData::Image(Box::new(data))
} }
_ => ActionData::Animation(AnimeGif::from_png( _ => ActionData::Animation(AnimeGif::from_png(
file, file, *scale, *angle, *translation, *time, *brightness, anime_type
*scale, )?)
*angle,
*translation,
*time,
*brightness,
anime_type,
)?),
} }
} }
ActionLoader::Pause(duration) => ActionData::Pause(*duration), ActionLoader::Pause(duration) => ActionData::Pause(*duration)
}; };
Ok(a) Ok(a)
} }
@@ -200,7 +171,7 @@ impl Sequences {
pub fn iter(&self) -> ActionIterator<'_> { pub fn iter(&self) -> ActionIterator<'_> {
ActionIterator { ActionIterator {
actions: self, actions: self,
next_idx: 0, next_idx: 0
} }
} }
} }
@@ -208,7 +179,7 @@ impl Sequences {
/// Iteractor helper for iterating over all the actions in `Sequences` /// Iteractor helper for iterating over all the actions in `Sequences`
pub struct ActionIterator<'a> { pub struct ActionIterator<'a> {
actions: &'a Sequences, actions: &'a Sequences,
next_idx: usize, next_idx: usize
} }
impl<'a> Iterator for ActionIterator<'a> { impl<'a> Iterator for ActionIterator<'a> {

View File

@@ -12,7 +12,6 @@ use std::str::FromStr;
use dmi_id::DMIID; use dmi_id::DMIID;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
@@ -29,7 +28,6 @@ pub const PROD_ID: u16 = 0x193b;
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "u") zvariant(signature = "u")
)] )]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
/// Base LED brightness of the display /// Base LED brightness of the display
pub enum Brightness { pub enum Brightness {
@@ -37,7 +35,7 @@ pub enum Brightness {
Low = 1, Low = 1,
#[default] #[default]
Med = 2, Med = 2,
High = 3, High = 3
} }
impl FromStr for Brightness { impl FromStr for Brightness {
@@ -49,7 +47,7 @@ impl FromStr for Brightness {
"Low" | "low" => Brightness::Low, "Low" | "low" => Brightness::Low,
"Med" | "med" => Brightness::Med, "Med" | "med" => Brightness::Med,
"High" | "high" => Brightness::High, "High" | "high" => Brightness::High,
_ => Brightness::Med, _ => Brightness::Med
}) })
} }
} }
@@ -60,7 +58,7 @@ impl From<u8> for Brightness {
0 => Brightness::Off, 0 => Brightness::Off,
1 => Brightness::Low, 1 => Brightness::Low,
3 => Brightness::High, 3 => Brightness::High,
_ => Brightness::Med, _ => Brightness::Med
} }
} }
} }
@@ -82,12 +80,11 @@ impl From<Brightness> for i32 {
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "s") zvariant(signature = "s")
)] )]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimBooting { pub enum AnimBooting {
#[default] #[default]
GlitchConstruction = 0, GlitchConstruction = 0,
StaticEmergence = 1, StaticEmergence = 1
} }
impl FromStr for AnimBooting { impl FromStr for AnimBooting {
@@ -97,7 +94,7 @@ impl FromStr for AnimBooting {
match s { match s {
"GlitchConstruction" => Ok(Self::GlitchConstruction), "GlitchConstruction" => Ok(Self::GlitchConstruction),
"StaticEmergence" => Ok(Self::StaticEmergence), "StaticEmergence" => Ok(Self::StaticEmergence),
_ => Err(AnimeError::ParseError(s.to_owned())), _ => Err(AnimeError::ParseError(s.to_owned()))
} }
} }
} }
@@ -107,7 +104,7 @@ impl From<i32> for AnimBooting {
match value { match value {
0 => Self::GlitchConstruction, 0 => Self::GlitchConstruction,
1 => Self::StaticEmergence, 1 => Self::StaticEmergence,
_ => Self::default(), _ => Self::default()
} }
} }
} }
@@ -123,12 +120,11 @@ impl From<AnimBooting> for i32 {
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "s") zvariant(signature = "s")
)] )]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimAwake { pub enum AnimAwake {
#[default] #[default]
BinaryBannerScroll = 0, BinaryBannerScroll = 0,
RogLogoGlitch = 1, RogLogoGlitch = 1
} }
impl FromStr for AnimAwake { impl FromStr for AnimAwake {
@@ -138,7 +134,7 @@ impl FromStr for AnimAwake {
match s { match s {
"BinaryBannerScroll" => Ok(Self::BinaryBannerScroll), "BinaryBannerScroll" => Ok(Self::BinaryBannerScroll),
"RogLogoGlitch" => Ok(Self::RogLogoGlitch), "RogLogoGlitch" => Ok(Self::RogLogoGlitch),
_ => Err(AnimeError::ParseError(s.to_owned())), _ => Err(AnimeError::ParseError(s.to_owned()))
} }
} }
} }
@@ -148,7 +144,7 @@ impl From<i32> for AnimAwake {
match value { match value {
0 => Self::BinaryBannerScroll, 0 => Self::BinaryBannerScroll,
1 => Self::RogLogoGlitch, 1 => Self::RogLogoGlitch,
_ => Self::default(), _ => Self::default()
} }
} }
} }
@@ -164,12 +160,11 @@ impl From<AnimAwake> for i32 {
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "s") zvariant(signature = "s")
)] )]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimSleeping { pub enum AnimSleeping {
#[default] #[default]
BannerSwipe = 0, BannerSwipe = 0,
Starfield = 1, Starfield = 1
} }
impl FromStr for AnimSleeping { impl FromStr for AnimSleeping {
@@ -179,7 +174,7 @@ impl FromStr for AnimSleeping {
match s { match s {
"BannerSwipe" => Ok(Self::BannerSwipe), "BannerSwipe" => Ok(Self::BannerSwipe),
"Starfield" => Ok(Self::Starfield), "Starfield" => Ok(Self::Starfield),
_ => Err(AnimeError::ParseError(s.to_owned())), _ => Err(AnimeError::ParseError(s.to_owned()))
} }
} }
} }
@@ -189,7 +184,7 @@ impl From<i32> for AnimSleeping {
match value { match value {
0 => Self::BannerSwipe, 0 => Self::BannerSwipe,
1 => Self::Starfield, 1 => Self::Starfield,
_ => Self::default(), _ => Self::default()
} }
} }
} }
@@ -205,12 +200,11 @@ impl From<AnimSleeping> for i32 {
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "s") zvariant(signature = "s")
)] )]
#[typeshare]
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
pub enum AnimShutdown { pub enum AnimShutdown {
#[default] #[default]
GlitchOut = 0, GlitchOut = 0,
SeeYa = 1, SeeYa = 1
} }
impl FromStr for AnimShutdown { impl FromStr for AnimShutdown {
@@ -220,7 +214,7 @@ impl FromStr for AnimShutdown {
match s { match s {
"GlitchOut" => Ok(Self::GlitchOut), "GlitchOut" => Ok(Self::GlitchOut),
"SeeYa" => Ok(Self::SeeYa), "SeeYa" => Ok(Self::SeeYa),
_ => Err(AnimeError::ParseError(s.to_owned())), _ => Err(AnimeError::ParseError(s.to_owned()))
} }
} }
} }
@@ -230,7 +224,7 @@ impl From<i32> for AnimShutdown {
match value { match value {
0 => Self::GlitchOut, 0 => Self::GlitchOut,
1 => Self::SeeYa, 1 => Self::SeeYa,
_ => Self::default(), _ => Self::default()
} }
} }
} }
@@ -332,7 +326,7 @@ pub const fn pkt_set_builtin_animations(
boot: AnimBooting, boot: AnimBooting,
awake: AnimAwake, awake: AnimAwake,
sleep: AnimSleeping, sleep: AnimSleeping,
shutdown: AnimShutdown, shutdown: AnimShutdown
) -> [u8; PACKET_SIZE] { ) -> [u8; PACKET_SIZE] {
let mut pkt = [0; PACKET_SIZE]; let mut pkt = [0; PACKET_SIZE];
pkt[0] = DEV_PAGE; pkt[0] = DEV_PAGE;

View File

@@ -52,7 +52,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -100,7 +100,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let mut matrix = AnimeImage::new( let mut matrix = AnimeImage::new(
@@ -110,7 +110,7 @@ mod tests {
0.0, 0.0,
vec![Pixel::default(); 1000], vec![Pixel::default(); 1000],
100, 100,
AnimeType::GA401, AnimeType::GA401
) )
.unwrap(); .unwrap();
matrix.edge_outline(); matrix.edge_outline();
@@ -175,7 +175,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -223,7 +223,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

View File

@@ -52,7 +52,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x2, 0x74, 0x2, 0x73, 0x2, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x2, 0x74, 0x2, 0x73, 0x2, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
@@ -100,7 +100,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt2_check = [ let pkt2_check = [
0x5e, 0xc0, 0x2, 0xe7, 0x4, 0x73, 0x2, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x2, 0xe7, 0x4, 0x73, 0x2, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00,
@@ -148,7 +148,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let mut matrix = AnimeImage::new( let mut matrix = AnimeImage::new(
@@ -158,7 +158,7 @@ mod tests {
0.0, 0.0,
vec![Pixel::default(); 1000], vec![Pixel::default(); 1000],
100, 100,
AnimeType::GA402, AnimeType::GA402
) )
.unwrap(); .unwrap();
matrix.edge_outline(); matrix.edge_outline();
@@ -218,7 +218,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00,
@@ -266,7 +266,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt2_check = [ let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
@@ -314,7 +314,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
@@ -378,7 +378,7 @@ mod tests {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -426,7 +426,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt2_check = [ let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
@@ -474,7 +474,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

View File

@@ -52,7 +52,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -100,7 +100,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt2_check = [ let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -148,7 +148,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let mut matrix = AnimeImage::new( let mut matrix = AnimeImage::new(
@@ -158,7 +158,7 @@ mod tests {
0.0, 0.0,
vec![Pixel::default(); 1000], vec![Pixel::default(); 1000],
100, 100,
AnimeType::GU604, AnimeType::GU604
) )
.unwrap(); .unwrap();
matrix.edge_outline(); matrix.edge_outline();
@@ -218,7 +218,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -266,7 +266,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let pkt2_check = [ let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -314,7 +314,7 @@ mod tests {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]; ];
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

View File

@@ -23,6 +23,5 @@ dmi_id = { path = "../dmi-id" }
# cli and logging # cli and logging
log.workspace = true log.workspace = true
typeshare.workspace = true
ron = { version = "*", optional = true } ron = { version = "*", optional = true }

View File

@@ -179,6 +179,15 @@
advanced_type: PerKey, advanced_type: PerKey,
power_zones: [Keyboard, Lightbar], power_zones: [Keyboard, Lightbar],
), ),
(
device_name: "G533QS",
product_id: "18c6",
layout_name: "g533q-per-key",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
( (
device_name: "G533Z", device_name: "G533Z",
product_id: "", product_id: "",

View File

@@ -54,7 +54,7 @@ pub struct LedSupportData {
#[serde(default)] #[serde(default)]
pub advanced_type: AdvancedAuraType, pub advanced_type: AdvancedAuraType,
/// If empty will default to `Keyboard` power zone /// If empty will default to `Keyboard` power zone
pub power_zones: Vec<PowerZones>, pub power_zones: Vec<PowerZones>
} }
impl LedSupportData { impl LedSupportData {
@@ -116,7 +116,7 @@ impl LedSupportFile {
basic_modes: vec![AuraModeNum::Static], basic_modes: vec![AuraModeNum::Static],
basic_zones: vec![], basic_zones: vec![],
advanced_type: AdvancedAuraType::None, advanced_type: AdvancedAuraType::None,
power_zones: vec![PowerZones::Keyboard], power_zones: vec![PowerZones::Keyboard]
} }
} }
@@ -191,9 +191,16 @@ mod tests {
product_id: String::new(), product_id: String::new(),
layout_name: "ga401".to_owned(), layout_name: "ga401".to_owned(),
basic_modes: vec![AuraModeNum::Static], basic_modes: vec![AuraModeNum::Static],
basic_zones: vec![AuraZone::Key1, AuraZone::Logo, AuraZone::BarLeft], basic_zones: vec![
AuraZone::Key1,
AuraZone::Logo,
AuraZone::BarLeft,
],
advanced_type: AdvancedAuraType::Zoned(vec![LedCode::LightbarRight]), advanced_type: AdvancedAuraType::Zoned(vec![LedCode::LightbarRight]),
power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow], power_zones: vec![
PowerZones::Keyboard,
PowerZones::RearGlow,
]
}; };
assert!(ron::to_string(&led).is_ok()); assert!(ron::to_string(&led).is_ok());
@@ -214,9 +221,7 @@ mod tests {
tmp_sort.0.sort_by(|a, b| a.product_id.cmp(&b.product_id)); tmp_sort.0.sort_by(|a, b| a.product_id.cmp(&b.product_id));
tmp_sort.0.sort_by(|a, b| a.device_name.cmp(&b.device_name)); tmp_sort.0.sort_by(|a, b| a.device_name.cmp(&b.device_name));
for model in tmp_sort.0.iter_mut() { for model in tmp_sort.0.iter_mut() {
model model.basic_modes.sort_by_key(|a| *a as u8);
.basic_modes
.sort_by(|a, b| (*a as u8).cmp(&(*b as u8)));
} }
if tmp != tmp_sort { if tmp != tmp_sort {
let sorted = let sorted =

View File

@@ -2,14 +2,12 @@ use std::fmt::Display;
use std::str::FromStr; use std::str::FromStr;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
use crate::error::Error; use crate::error::Error;
use crate::AURA_LAPTOP_LED_MSG_LEN; use crate::AURA_LAPTOP_LED_MSG_LEN;
#[typeshare]
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)] #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
@@ -21,7 +19,7 @@ pub enum LedBrightness {
Low = 1, Low = 1,
#[default] #[default]
Med = 2, Med = 2,
High = 3, High = 3
} }
impl LedBrightness { impl LedBrightness {
@@ -30,7 +28,7 @@ impl LedBrightness {
Self::Off => Self::Low, Self::Off => Self::Low,
Self::Low => Self::Med, Self::Low => Self::Med,
Self::Med => Self::High, Self::Med => Self::High,
Self::High => Self::Off, Self::High => Self::Off
} }
} }
@@ -39,7 +37,7 @@ impl LedBrightness {
Self::Off => Self::High, Self::Off => Self::High,
Self::Low => Self::Off, Self::Low => Self::Off,
Self::Med => Self::Low, Self::Med => Self::Low,
Self::High => Self::Med, Self::High => Self::Med
} }
} }
} }
@@ -50,7 +48,7 @@ impl From<u8> for LedBrightness {
0 => LedBrightness::Off, 0 => LedBrightness::Off,
1 => LedBrightness::Low, 1 => LedBrightness::Low,
3 => LedBrightness::High, 3 => LedBrightness::High,
_ => LedBrightness::Med, _ => LedBrightness::Med
} }
} }
} }
@@ -74,18 +72,17 @@ impl From<i32> for LedBrightness {
1 => LedBrightness::Low, 1 => LedBrightness::Low,
2 => LedBrightness::Med, 2 => LedBrightness::Med,
3 => LedBrightness::High, 3 => LedBrightness::High,
_ => LedBrightness::Med, _ => LedBrightness::Med
} }
} }
} }
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Debug, Clone, PartialEq, Eq, Copy, Deserialize, Serialize)] #[derive(Debug, Clone, PartialEq, Eq, Copy, Deserialize, Serialize)]
pub struct Colour { pub struct Colour {
pub r: u8, pub r: u8,
pub g: u8, pub g: u8,
pub b: u8, pub b: u8
} }
impl Default for Colour { impl Default for Colour {
@@ -113,14 +110,18 @@ impl From<&[f32; 3]> for Colour {
Self { Self {
r: (255.0 * c[0]) as u8, r: (255.0 * c[0]) as u8,
g: (255.0 * c[1]) as u8, g: (255.0 * c[1]) as u8,
b: (255.0 * c[2]) as u8, b: (255.0 * c[2]) as u8
} }
} }
} }
impl From<Colour> for [f32; 3] { impl From<Colour> for [f32; 3] {
fn from(c: Colour) -> Self { fn from(c: Colour) -> Self {
[c.r as f32 / 255.0, c.g as f32 / 255.0, c.b as f32 / 255.0] [
c.r as f32 / 255.0,
c.g as f32 / 255.0,
c.b as f32 / 255.0
]
} }
} }
@@ -129,18 +130,19 @@ impl From<&[u8; 3]> for Colour {
Self { Self {
r: c[0], r: c[0],
g: c[1], g: c[1],
b: c[2], b: c[2]
} }
} }
} }
impl From<Colour> for [u8; 3] { impl From<Colour> for [u8; 3] {
fn from(c: Colour) -> Self { fn from(c: Colour) -> Self {
[c.r, c.g, c.b] [
c.r, c.g, c.b
]
} }
} }
#[typeshare]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
@@ -151,7 +153,7 @@ pub enum Speed {
Low = 0xe1, Low = 0xe1,
#[default] #[default]
Med = 0xeb, Med = 0xeb,
High = 0xf5, High = 0xf5
} }
impl FromStr for Speed { impl FromStr for Speed {
@@ -163,7 +165,7 @@ impl FromStr for Speed {
"low" => Ok(Speed::Low), "low" => Ok(Speed::Low),
"med" => Ok(Speed::Med), "med" => Ok(Speed::Med),
"high" => Ok(Speed::High), "high" => Ok(Speed::High),
_ => Err(Error::ParseSpeed), _ => Err(Error::ParseSpeed)
} }
} }
} }
@@ -173,7 +175,7 @@ impl From<i32> for Speed {
match value { match value {
0 => Self::Low, 0 => Self::Low,
2 => Self::High, 2 => Self::High,
_ => Self::Med, _ => Self::Med
} }
} }
} }
@@ -183,7 +185,7 @@ impl From<Speed> for i32 {
match value { match value {
Speed::Low => 0, Speed::Low => 0,
Speed::Med => 1, Speed::Med => 1,
Speed::High => 2, Speed::High => 2
} }
} }
} }
@@ -193,14 +195,13 @@ impl From<Speed> for u8 {
match s { match s {
Speed::Low => 0, Speed::Low => 0,
Speed::Med => 1, Speed::Med => 1,
Speed::High => 2, Speed::High => 2
} }
} }
} }
/// Used for Rainbow mode. /// Used for Rainbow mode.
/// ///
/// Enum corresponds to the required integer value /// Enum corresponds to the required integer value
#[typeshare]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
@@ -212,7 +213,7 @@ pub enum Direction {
Right = 0, Right = 0,
Left = 1, Left = 1,
Up = 2, Up = 2,
Down = 3, Down = 3
} }
impl FromStr for Direction { impl FromStr for Direction {
@@ -225,7 +226,7 @@ impl FromStr for Direction {
"up" => Ok(Direction::Up), "up" => Ok(Direction::Up),
"down" => Ok(Direction::Down), "down" => Ok(Direction::Down),
"left" => Ok(Direction::Left), "left" => Ok(Direction::Left),
_ => Err(Error::ParseDirection), _ => Err(Error::ParseDirection)
} }
} }
} }
@@ -236,7 +237,7 @@ impl From<i32> for Direction {
1 => Self::Left, 1 => Self::Left,
2 => Self::Up, 2 => Self::Up,
3 => Self::Down, 3 => Self::Down,
_ => Self::Right, _ => Self::Right
} }
} }
} }
@@ -248,7 +249,6 @@ impl From<Direction> for i32 {
} }
/// Enum of modes that convert to the actual number required by a USB HID packet /// Enum of modes that convert to the actual number required by a USB HID packet
#[typeshare]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
@@ -270,7 +270,7 @@ pub enum AuraModeNum {
Ripple = 8, Ripple = 8,
Pulse = 10, Pulse = 10,
Comet = 11, Comet = 11,
Flash = 12, Flash = 12
} }
impl Display for AuraModeNum { impl Display for AuraModeNum {
@@ -299,7 +299,7 @@ impl From<&AuraModeNum> for &str {
AuraModeNum::Ripple => "Ripple", AuraModeNum::Ripple => "Ripple",
AuraModeNum::Pulse => "Pulse", AuraModeNum::Pulse => "Pulse",
AuraModeNum::Comet => "Comet", AuraModeNum::Comet => "Comet",
AuraModeNum::Flash => "Flash", AuraModeNum::Flash => "Flash"
} }
} }
} }
@@ -317,7 +317,7 @@ impl From<&str> for AuraModeNum {
"Pulse" => AuraModeNum::Pulse, "Pulse" => AuraModeNum::Pulse,
"Comet" => AuraModeNum::Comet, "Comet" => AuraModeNum::Comet,
"Flash" => AuraModeNum::Flash, "Flash" => AuraModeNum::Flash,
_ => AuraModeNum::Static, _ => AuraModeNum::Static
} }
} }
} }
@@ -336,7 +336,7 @@ impl From<u8> for AuraModeNum {
10 => AuraModeNum::Pulse, 10 => AuraModeNum::Pulse,
11 => AuraModeNum::Comet, 11 => AuraModeNum::Comet,
12 => AuraModeNum::Flash, 12 => AuraModeNum::Flash,
_ => AuraModeNum::Static, _ => AuraModeNum::Static
} }
} }
} }
@@ -360,7 +360,6 @@ impl From<AuraEffect> for AuraModeNum {
} }
/// Base effects have no zoning, while multizone is 1-4 /// Base effects have no zoning, while multizone is 1-4
#[typeshare]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
@@ -384,7 +383,7 @@ pub enum AuraZone {
/// The left part of a lightbar (typically on the front of laptop) /// The left part of a lightbar (typically on the front of laptop)
BarLeft = 6, BarLeft = 6,
/// The right part of a lightbar /// The right part of a lightbar
BarRight = 7, BarRight = 7
} }
impl FromStr for AuraZone { impl FromStr for AuraZone {
@@ -401,7 +400,7 @@ impl FromStr for AuraZone {
"5" | "logo" => Ok(AuraZone::Logo), "5" | "logo" => Ok(AuraZone::Logo),
"6" | "lightbar-left" => Ok(AuraZone::BarLeft), "6" | "lightbar-left" => Ok(AuraZone::BarLeft),
"7" | "lightbar-right" => Ok(AuraZone::BarRight), "7" | "lightbar-right" => Ok(AuraZone::BarRight),
_ => Err(Error::ParseSpeed), _ => Err(Error::ParseSpeed)
} }
} }
} }
@@ -416,7 +415,7 @@ impl From<i32> for AuraZone {
5 => Self::Logo, 5 => Self::Logo,
6 => Self::BarLeft, 6 => Self::BarLeft,
7 => Self::BarRight, 7 => Self::BarRight,
_ => Self::default(), _ => Self::default()
} }
} }
} }
@@ -432,7 +431,6 @@ impl From<AuraZone> for i32 {
/// ```rust /// ```rust
/// // let bytes: [u8; LED_MSG_LEN] = mode.into(); /// // let bytes: [u8; LED_MSG_LEN] = mode.into();
/// ``` /// ```
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct AuraEffect { pub struct AuraEffect {
@@ -447,7 +445,7 @@ pub struct AuraEffect {
/// One of three speeds for modes that support speed (most that animate) /// One of three speeds for modes that support speed (most that animate)
pub speed: Speed, pub speed: Speed,
/// Up, down, left, right. Only Rainbow mode seems to use this /// Up, down, left, right. Only Rainbow mode seems to use this
pub direction: Direction, pub direction: Direction
} }
impl AuraEffect { impl AuraEffect {
@@ -483,7 +481,7 @@ impl Default for AuraEffect {
colour1: Colour { r: 166, g: 0, b: 0 }, colour1: Colour { r: 166, g: 0, b: 0 },
colour2: Colour { r: 0, g: 0, b: 0 }, colour2: Colour { r: 0, g: 0, b: 0 },
speed: Speed::Med, speed: Speed::Med,
direction: Direction::Right, direction: Direction::Right
} }
} }
} }
@@ -543,7 +541,7 @@ impl From<&AuraEffect> for Vec<u8> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ use crate::{
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed, AURA_LAPTOP_LED_MSG_LEN, AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed, AURA_LAPTOP_LED_MSG_LEN
}; };
#[test] #[test]
@@ -554,18 +552,18 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0xff, r: 0xff,
g: 0x11, g: 0x11,
b: 0xdd, b: 0xdd
}, },
colour2: Colour::default(), colour2: Colour::default(),
speed: Speed::Med, speed: Speed::Med,
direction: Direction::Right, direction: Direction::Right
}; };
let ar = <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st); let ar = <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st);
println!("{:02x?}", ar); println!("{:02x?}", ar);
let check = [ let check = [
0x5d, 0xb3, 0x0, 0x0, 0xff, 0x11, 0xdd, 0xeb, 0x0, 0x0, 0xa6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x0, 0x0, 0xff, 0x11, 0xdd, 0xeb, 0x0, 0x0, 0xa6, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0
]; ];
assert_eq!(ar, check); assert_eq!(ar, check);
} }
@@ -578,15 +576,15 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0xff, r: 0xff,
g: 0, g: 0,
b: 0, b: 0
}, },
colour2: Colour { r: 0, g: 0, b: 0 }, colour2: Colour { r: 0, g: 0, b: 0 },
speed: Speed::Low, speed: Speed::Low,
direction: Direction::Left, direction: Direction::Left
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x01, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x01, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -597,11 +595,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0xff, r: 0xff,
g: 0xff, g: 0xff,
b: 0, b: 0
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x02, 0x00, 0xff, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x02, 0x00, 0xff, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -612,11 +610,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0, r: 0,
g: 0xff, g: 0xff,
b: 0xff, b: 0xff
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -627,11 +625,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0xff, r: 0xff,
g: 0x00, g: 0x00,
b: 0xff, b: 0xff
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x04, 0x00, 0xff, 0x00, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x04, 0x00, 0xff, 0x00, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -642,11 +640,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0x2c, r: 0x2c,
g: 0xff, g: 0xff,
b: 0x00, b: 0x00
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x05, 0x00, 0x2c, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x05, 0x00, 0x2c, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -657,11 +655,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0xff, r: 0xff,
g: 0x00, g: 0x00,
b: 0x00, b: 0x00
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x06, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x06, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -672,11 +670,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0xff, r: 0xff,
g: 0x00, g: 0x00,
b: 0xcd, b: 0xcd
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x07, 0x00, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x07, 0x00, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -686,7 +684,7 @@ mod tests {
st.mode = AuraModeNum::RainbowWave; st.mode = AuraModeNum::RainbowWave;
let capture = [ let capture = [
0x5d, 0xb3, 0x07, 0x03, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x07, 0x03, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],

View File

@@ -11,7 +11,7 @@ pub struct InputBased {
/// - temperature /// - temperature
/// - fan speed /// - fan speed
/// - time /// - time
input: Box<dyn InputForEffect>, input: Box<dyn InputForEffect>
} }
impl EffectState for InputBased { impl EffectState for InputBased {

View File

@@ -19,7 +19,7 @@ pub struct Breathe {
#[serde(skip)] #[serde(skip)]
count_flipped: bool, count_flipped: bool,
#[serde(skip)] #[serde(skip)]
use_colour1: bool, use_colour1: bool
} }
impl Breathe { impl Breathe {
@@ -31,7 +31,7 @@ impl Breathe {
speed, speed,
colour: colour1, colour: colour1,
count_flipped: false, count_flipped: false,
use_colour1: true, use_colour1: true
} }
} }
} }

View File

@@ -13,7 +13,7 @@ pub struct DoomFlicker {
#[serde(skip)] #[serde(skip)]
count: u8, count: u8,
#[serde(skip)] #[serde(skip)]
colour: Colour, colour: Colour
} }
impl DoomFlicker { impl DoomFlicker {
@@ -24,7 +24,7 @@ impl DoomFlicker {
count: 4, count: 4,
max_percentage, max_percentage,
min_percentage, min_percentage,
start_colour: colour, start_colour: colour
} }
} }
} }
@@ -53,13 +53,13 @@ impl EffectState for DoomFlicker {
let max_light = Colour { let max_light = Colour {
r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8, r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8,
g: (start_colour.g as f32 / 100.0 * *max_percentage as f32) as u8, g: (start_colour.g as f32 / 100.0 * *max_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8, b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8
}; };
// min light is a percentage of the set colour // min light is a percentage of the set colour
let min_light = Colour { let min_light = Colour {
r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8, r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8,
g: (start_colour.g as f32 / 100.0 * *min_percentage as f32) as u8, g: (start_colour.g as f32 / 100.0 * *min_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8, b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8
}; };
// Convert the 255 to percentage // Convert the 255 to percentage
@@ -96,7 +96,7 @@ pub struct DoomLightFlash {
#[serde(skip)] #[serde(skip)]
count: u8, count: u8,
#[serde(skip)] #[serde(skip)]
colour: Colour, colour: Colour
} }
impl DoomLightFlash { impl DoomLightFlash {
@@ -109,7 +109,7 @@ impl DoomLightFlash {
min_percentage, min_percentage,
start_colour: colour, start_colour: colour,
max_time: 32, max_time: 32,
min_time: 7, min_time: 7
} }
} }
} }
@@ -135,13 +135,13 @@ impl EffectState for DoomLightFlash {
let max_light = Colour { let max_light = Colour {
r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8, r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8,
g: (start_colour.g as f32 / 100.0 * *max_percentage as f32) as u8, g: (start_colour.g as f32 / 100.0 * *max_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8, b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8
}; };
// min light is a percentage of the set colour // min light is a percentage of the set colour
let min_light = Colour { let min_light = Colour {
r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8, r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8,
g: (start_colour.g as f32 / 100.0 * *min_percentage as f32) as u8, g: (start_colour.g as f32 / 100.0 * *min_percentage as f32) as u8,
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8, b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8
}; };
if *colour == max_light { if *colour == max_light {

View File

@@ -32,7 +32,7 @@ pub const RNDTABLE: [i32; 256] = [
206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95, 28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95, 28, 139, 123, 98, 125, 196, 15, 70, 194, 253,
54, 14, 109, 226, 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36, 17, 46, 52, 54, 14, 109, 226, 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36, 17, 46, 52,
231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106, 197, 242, 98, 43, 39, 175, 254, 145, 190, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106, 197, 242, 98, 43, 39, 175, 254, 145, 190,
84, 118, 222, 187, 136, 120, 163, 236, 249, 84, 118, 222, 187, 136, 120, 163, 236, 249
]; ];
pub fn p_random() -> i32 { pub fn p_random() -> i32 {
@@ -67,7 +67,7 @@ pub(crate) trait EffectState {
#[derive(Debug, Deserialize, Serialize, Default)] #[derive(Debug, Deserialize, Serialize, Default)]
pub struct AdvancedEffects { pub struct AdvancedEffects {
effects: Vec<Effect>, effects: Vec<Effect>,
zoned: bool, zoned: bool
} }
impl AdvancedEffects { impl AdvancedEffects {
@@ -75,7 +75,7 @@ impl AdvancedEffects {
pub fn new(zoned: bool) -> Self { pub fn new(zoned: bool) -> Self {
Self { Self {
effects: Default::default(), effects: Default::default(),
zoned, zoned
} }
} }
@@ -186,7 +186,7 @@ pub enum Effect {
Static(Static), Static(Static),
Breathe(Breathe), Breathe(Breathe),
DoomFlicker(DoomFlicker), DoomFlicker(DoomFlicker),
DoomLightFlash(DoomLightFlash), DoomLightFlash(DoomLightFlash)
} }
impl Default for Effect { impl Default for Effect {
@@ -207,14 +207,12 @@ mod tests {
fn single_key_next_state_then_create() { fn single_key_next_state_then_create() {
let layout = KeyLayout::default_layout(); let layout = KeyLayout::default_layout();
let mut seq = AdvancedEffects::new(false); let mut seq = AdvancedEffects::new(false);
seq.effects.push(Effect::Static(Static::new( seq.effects
LedCode::F, .push(Effect::Static(Static::new(LedCode::F, Colour {
Colour {
r: 255, r: 255,
g: 127, g: 127,
b: 0, b: 0
}, })));
)));
seq.next_state(&layout); seq.next_state(&layout);
let packets = seq.create_packets(); let packets = seq.create_packets();
@@ -234,14 +232,14 @@ mod tests {
Colour { Colour {
r: 255, r: 255,
g: 127, g: 127,
b: 0, b: 0
}, },
Colour { Colour {
r: 127, r: 127,
g: 0, g: 0,
b: 255, b: 255
}, },
Speed::Med, Speed::Med
))); )));
let s = let s =
@@ -276,10 +274,10 @@ mod tests {
Colour { Colour {
r: 255, r: 255,
g: 127, g: 127,
b: 80, b: 80
}, },
100, 100,
10, 10
))); )));
seq.next_state(&layout); seq.next_state(&layout);

View File

@@ -8,14 +8,14 @@ use crate::{effect_state_impl, Colour};
pub struct Static { pub struct Static {
led: LedCode, led: LedCode,
/// The starting colour /// The starting colour
colour: Colour, colour: Colour
} }
impl Static { impl Static {
pub fn new(address: LedCode, colour: Colour) -> Self { pub fn new(address: LedCode, colour: Colour) -> Self {
Self { Self {
led: address, led: address,
colour, colour
} }
} }
} }

View File

@@ -8,7 +8,7 @@ pub enum Error {
ParseBrightness, ParseBrightness,
IoPath(String, std::io::Error), IoPath(String, std::io::Error),
Ron(ron::Error), Ron(ron::Error),
RonParse(ron::error::SpannedError), RonParse(ron::error::SpannedError)
} }
impl fmt::Display for Error { impl fmt::Display for Error {
@@ -21,7 +21,7 @@ impl fmt::Display for Error {
Error::ParseBrightness => write!(f, "Could not parse brightness"), Error::ParseBrightness => write!(f, "Could not parse brightness"),
Error::IoPath(path, io) => write!(f, "IO Error: {path}, {io}"), Error::IoPath(path, io) => write!(f, "IO Error: {path}, {io}"),
Error::Ron(e) => write!(f, "RON Parse Error: {e}"), Error::Ron(e) => write!(f, "RON Parse Error: {e}"),
Error::RonParse(e) => write!(f, "RON Parse Error: {e}"), Error::RonParse(e) => write!(f, "RON Parse Error: {e}")
} }
} }
} }

View File

@@ -1,6 +1,5 @@
use log::warn; use log::warn;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::Type; use zbus::zvariant::Type;
@@ -165,7 +164,7 @@ pub enum LedCode {
/// To be ignored by effects /// To be ignored by effects
Spacing, Spacing,
/// To be ignored by effects /// To be ignored by effects
Blocking, Blocking
} }
impl LedCode { impl LedCode {
@@ -194,7 +193,6 @@ impl LedCode {
} }
/// Represents the per-key raw USB packets /// Represents the per-key raw USB packets
#[typeshare]
pub type AuraLaptopUsbPackets = Vec<Vec<u8>>; pub type AuraLaptopUsbPackets = Vec<Vec<u8>>;
/// A `UsbPackets` contains all data to change the full set of keyboard /// A `UsbPackets` contains all data to change the full set of keyboard
@@ -204,7 +202,6 @@ pub type AuraLaptopUsbPackets = Vec<Vec<u8>>;
/// to the keyboard EC. One row controls one group of keys, these keys are not /// to the keyboard EC. One row controls one group of keys, these keys are not
/// necessarily all on the same row of the keyboard, with some splitting between /// necessarily all on the same row of the keyboard, with some splitting between
/// two rows. /// two rows.
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))] #[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Debug, Clone, Deserialize, Serialize)] #[derive(Debug, Clone, Deserialize, Serialize)]
pub struct LedUsbPackets { pub struct LedUsbPackets {
@@ -213,7 +210,7 @@ pub struct LedUsbPackets {
/// Wether or not this packet collection is zoned. The determines which /// Wether or not this packet collection is zoned. The determines which
/// starting bytes are used and what the indexing is for lightbar RGB /// starting bytes are used and what the indexing is for lightbar RGB
/// colours /// colours
zoned: bool, zoned: bool
} }
impl Default for LedUsbPackets { impl Default for LedUsbPackets {
@@ -247,7 +244,7 @@ impl LedUsbPackets {
} }
Self { Self {
usb_packets: set, usb_packets: set,
zoned: false, zoned: false
} }
} }
@@ -277,7 +274,7 @@ impl LedUsbPackets {
} }
Self { Self {
usb_packets: vec![pkt], usb_packets: vec![pkt],
zoned: true, zoned: true
} }
} }
@@ -636,7 +633,7 @@ impl From<&LedCode> for &str {
LedCode::ZonedKbLeft => "Left Zone (zone 1)", LedCode::ZonedKbLeft => "Left Zone (zone 1)",
LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)", LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)",
LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)", LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)",
LedCode::ZonedKbRight => "Right Zone (zone 4)", LedCode::ZonedKbRight => "Right Zone (zone 4)"
} }
} }
} }

View File

@@ -26,12 +26,12 @@ pub enum KeyShape {
pad_left: f32, pad_left: f32,
pad_right: f32, pad_right: f32,
pad_top: f32, pad_top: f32,
pad_bottom: f32, pad_bottom: f32
}, },
Blank { Blank {
width: f32, width: f32,
height: f32, height: f32
}, }
} }
impl KeyShape { impl KeyShape {
@@ -41,7 +41,7 @@ impl KeyShape {
pad_left: f32, pad_left: f32,
pad_right: f32, pad_right: f32,
pad_top: f32, pad_top: f32,
pad_bottom: f32, pad_bottom: f32
) -> Self { ) -> Self {
Self::Led { Self::Led {
width, width,
@@ -49,7 +49,7 @@ impl KeyShape {
pad_left, pad_left,
pad_right, pad_right,
pad_top, pad_top,
pad_bottom, pad_bottom
} }
} }
@@ -66,7 +66,7 @@ impl KeyShape {
pad_left, pad_left,
pad_right, pad_right,
pad_top, pad_top,
pad_bottom, pad_bottom
} => { } => {
*width *= scale; *width *= scale;
*height *= scale; *height *= scale;
@@ -97,7 +97,7 @@ pub struct KeyRow {
row: Vec<(LedCode, String)>, row: Vec<(LedCode, String)>,
/// The final data structure merged key_shapes and rows /// The final data structure merged key_shapes and rows
#[serde(skip)] #[serde(skip)]
built_row: Vec<(LedCode, KeyShape)>, built_row: Vec<(LedCode, KeyShape)>
} }
impl KeyRow { impl KeyRow {
@@ -106,7 +106,7 @@ impl KeyRow {
pad_left, pad_left,
pad_top, pad_top,
row, row,
built_row: Default::default(), built_row: Default::default()
} }
} }
@@ -132,7 +132,7 @@ impl KeyRow {
pad_bottom, pad_bottom,
.. ..
} => height + pad_top + pad_bottom, } => height + pad_top + pad_bottom,
KeyShape::Blank { height, .. } => *height, KeyShape::Blank { height, .. } => *height
}; };
if h < height { if h < height {
@@ -156,7 +156,7 @@ impl KeyRow {
pad_right, pad_right,
.. ..
} => w += width + pad_left + pad_right, } => w += width + pad_left + pad_right,
KeyShape::Blank { width, .. } => w += width, KeyShape::Blank { width, .. } => w += width
} }
} }
w w
@@ -185,7 +185,7 @@ pub struct KeyLayout {
/// Should be copied from the `LaptopLedData` as laptops may have the same /// Should be copied from the `LaptopLedData` as laptops may have the same
/// layout, but different EC features. /// layout, but different EC features.
#[serde(skip)] #[serde(skip)]
advanced_type: AdvancedAuraType, advanced_type: AdvancedAuraType
} }
impl KeyLayout { impl KeyLayout {
@@ -195,7 +195,7 @@ impl KeyLayout {
if buf.is_empty() { if buf.is_empty() {
Err(Error::IoPath( Err(Error::IoPath(
path.to_string_lossy().to_string(), path.to_string_lossy().to_string(),
std::io::ErrorKind::InvalidData.into(), std::io::ErrorKind::InvalidData.into()
)) ))
} else { } else {
let mut data = ron::from_str::<Self>(&buf)?; let mut data = ron::from_str::<Self>(&buf)?;
@@ -332,121 +332,97 @@ impl KeyLayout {
advanced_type: AdvancedAuraType::None, advanced_type: AdvancedAuraType::None,
key_shapes: HashMap::from([( key_shapes: HashMap::from([(
"regular".to_owned(), "regular".to_owned(),
KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1), KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1)
)]), )]),
key_rows: vec![ key_rows: vec![
KeyRow::new( KeyRow::new(0.1, 0.1, vec![
0.1, (LedCode::Esc, "regular".to_owned()),
0.1, (LedCode::F1, "regular".to_owned()),
vec![ (LedCode::F2, "regular".to_owned()),
(LedCode::Esc, "regular".to_owned()), (LedCode::F3, "regular".to_owned()),
(LedCode::F1, "regular".to_owned()), (LedCode::F4, "regular".to_owned()),
(LedCode::F2, "regular".to_owned()), // not sure which key to put here
(LedCode::F3, "regular".to_owned()), (LedCode::F5, "regular".to_owned()),
(LedCode::F4, "regular".to_owned()), (LedCode::F6, "regular".to_owned()),
// not sure which key to put here (LedCode::F7, "regular".to_owned()),
(LedCode::F5, "regular".to_owned()), (LedCode::F8, "regular".to_owned()),
(LedCode::F6, "regular".to_owned()), (LedCode::F9, "regular".to_owned()),
(LedCode::F7, "regular".to_owned()), (LedCode::F10, "regular".to_owned()),
(LedCode::F8, "regular".to_owned()), (LedCode::F11, "regular".to_owned()),
(LedCode::F9, "regular".to_owned()), (LedCode::F12, "regular".to_owned()),
(LedCode::F10, "regular".to_owned()), ]),
(LedCode::F11, "regular".to_owned()), KeyRow::new(0.1, 0.1, vec![
(LedCode::F12, "regular".to_owned()), (LedCode::Tilde, "regular".to_owned()),
], (LedCode::N1, "regular".to_owned()),
), (LedCode::N2, "regular".to_owned()),
KeyRow::new( (LedCode::N3, "regular".to_owned()),
0.1, (LedCode::N4, "regular".to_owned()),
0.1, (LedCode::N5, "regular".to_owned()),
vec![ (LedCode::N6, "regular".to_owned()),
(LedCode::Tilde, "regular".to_owned()), (LedCode::N7, "regular".to_owned()),
(LedCode::N1, "regular".to_owned()), (LedCode::N8, "regular".to_owned()),
(LedCode::N2, "regular".to_owned()), (LedCode::N9, "regular".to_owned()),
(LedCode::N3, "regular".to_owned()), (LedCode::N0, "regular".to_owned()),
(LedCode::N4, "regular".to_owned()), (LedCode::Hyphen, "regular".to_owned()),
(LedCode::N5, "regular".to_owned()), (LedCode::Equals, "regular".to_owned()),
(LedCode::N6, "regular".to_owned()), (LedCode::Backspace, "regular".to_owned()),
(LedCode::N7, "regular".to_owned()), ]),
(LedCode::N8, "regular".to_owned()), KeyRow::new(0.1, 0.1, vec![
(LedCode::N9, "regular".to_owned()), (LedCode::Tab, "regular".to_owned()),
(LedCode::N0, "regular".to_owned()), (LedCode::Q, "regular".to_owned()),
(LedCode::Hyphen, "regular".to_owned()), (LedCode::W, "regular".to_owned()),
(LedCode::Equals, "regular".to_owned()), (LedCode::E, "regular".to_owned()),
(LedCode::Backspace, "regular".to_owned()), (LedCode::R, "regular".to_owned()),
], (LedCode::T, "regular".to_owned()),
), (LedCode::Y, "regular".to_owned()),
KeyRow::new( (LedCode::U, "regular".to_owned()),
0.1, (LedCode::I, "regular".to_owned()),
0.1, (LedCode::O, "regular".to_owned()),
vec![ (LedCode::P, "regular".to_owned()),
(LedCode::Tab, "regular".to_owned()), (LedCode::LBracket, "regular".to_owned()),
(LedCode::Q, "regular".to_owned()), (LedCode::RBracket, "regular".to_owned()),
(LedCode::W, "regular".to_owned()), (LedCode::BackSlash, "regular".to_owned()),
(LedCode::E, "regular".to_owned()), ]),
(LedCode::R, "regular".to_owned()), KeyRow::new(0.1, 0.1, vec![
(LedCode::T, "regular".to_owned()), (LedCode::Caps, "regular".to_owned()),
(LedCode::Y, "regular".to_owned()), (LedCode::A, "regular".to_owned()),
(LedCode::U, "regular".to_owned()), (LedCode::S, "regular".to_owned()),
(LedCode::I, "regular".to_owned()), (LedCode::D, "regular".to_owned()),
(LedCode::O, "regular".to_owned()), (LedCode::F, "regular".to_owned()),
(LedCode::P, "regular".to_owned()), (LedCode::G, "regular".to_owned()),
(LedCode::LBracket, "regular".to_owned()), (LedCode::H, "regular".to_owned()),
(LedCode::RBracket, "regular".to_owned()), (LedCode::J, "regular".to_owned()),
(LedCode::BackSlash, "regular".to_owned()), (LedCode::K, "regular".to_owned()),
], (LedCode::L, "regular".to_owned()),
), (LedCode::SemiColon, "regular".to_owned()),
KeyRow::new( (LedCode::Quote, "regular".to_owned()),
0.1, (LedCode::Return, "regular".to_owned()),
0.1, ]),
vec![ KeyRow::new(0.1, 0.1, vec![
(LedCode::Caps, "regular".to_owned()), (LedCode::LShift, "regular".to_owned()),
(LedCode::A, "regular".to_owned()), (LedCode::Z, "regular".to_owned()),
(LedCode::S, "regular".to_owned()), (LedCode::X, "regular".to_owned()),
(LedCode::D, "regular".to_owned()), (LedCode::C, "regular".to_owned()),
(LedCode::F, "regular".to_owned()), (LedCode::V, "regular".to_owned()),
(LedCode::G, "regular".to_owned()), (LedCode::B, "regular".to_owned()),
(LedCode::H, "regular".to_owned()), (LedCode::N, "regular".to_owned()),
(LedCode::J, "regular".to_owned()), (LedCode::M, "regular".to_owned()),
(LedCode::K, "regular".to_owned()), (LedCode::Comma, "regular".to_owned()),
(LedCode::L, "regular".to_owned()), (LedCode::Period, "regular".to_owned()),
(LedCode::SemiColon, "regular".to_owned()), (LedCode::FwdSlash, "regular".to_owned()),
(LedCode::Quote, "regular".to_owned()), (LedCode::Rshift, "regular".to_owned()),
(LedCode::Return, "regular".to_owned()), ]),
], KeyRow::new(0.1, 0.1, vec![
), (LedCode::LCtrl, "regular".to_owned()),
KeyRow::new( (LedCode::LFn, "regular".to_owned()),
0.1, (LedCode::Meta, "regular".to_owned()),
0.1, (LedCode::LAlt, "regular".to_owned()),
vec![ (LedCode::Spacebar, "regular".to_owned()),
(LedCode::LShift, "regular".to_owned()), (LedCode::RAlt, "regular".to_owned()),
(LedCode::Z, "regular".to_owned()), (LedCode::PrtSc, "regular".to_owned()),
(LedCode::X, "regular".to_owned()), (LedCode::RCtrl, "regular".to_owned()),
(LedCode::C, "regular".to_owned()), ]),
(LedCode::V, "regular".to_owned()), ]
(LedCode::B, "regular".to_owned()),
(LedCode::N, "regular".to_owned()),
(LedCode::M, "regular".to_owned()),
(LedCode::Comma, "regular".to_owned()),
(LedCode::Period, "regular".to_owned()),
(LedCode::FwdSlash, "regular".to_owned()),
(LedCode::Rshift, "regular".to_owned()),
],
),
KeyRow::new(
0.1,
0.1,
vec![
(LedCode::LCtrl, "regular".to_owned()),
(LedCode::LFn, "regular".to_owned()),
(LedCode::Meta, "regular".to_owned()),
(LedCode::LAlt, "regular".to_owned()),
(LedCode::Spacebar, "regular".to_owned()),
(LedCode::RAlt, "regular".to_owned()),
(LedCode::PrtSc, "regular".to_owned()),
(LedCode::RCtrl, "regular".to_owned()),
],
),
],
} }
} }
} }

View File

@@ -16,5 +16,5 @@ pub enum AdvancedAuraType {
#[default] #[default]
None, None,
Zoned(Vec<LedCode>), Zoned(Vec<LedCode>),
PerKey, PerKey
} }

View File

@@ -5,7 +5,6 @@ use std::ops::{BitAnd, BitOr};
use log::warn; use log::warn;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
@@ -16,7 +15,6 @@ use crate::{AuraDeviceType, PowerZones};
/// - 2021+, the struct is a single zone with 4 states /// - 2021+, the struct is a single zone with 4 states
/// - pre-2021, the struct is 1 or 2 zones and 3 states /// - pre-2021, the struct is 1 or 2 zones and 3 states
/// - Tuf, the struct is 1 zone and 3 states /// - Tuf, the struct is 1 zone and 3 states
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct AuraPowerState { pub struct AuraPowerState {
@@ -25,7 +23,7 @@ pub struct AuraPowerState {
pub awake: bool, pub awake: bool,
pub sleep: bool, pub sleep: bool,
/// Ignored for pre-2021 and Tuf /// Ignored for pre-2021 and Tuf
pub shutdown: bool, pub shutdown: bool
} }
impl Default for AuraPowerState { impl Default for AuraPowerState {
@@ -36,7 +34,7 @@ impl Default for AuraPowerState {
boot: true, boot: true,
awake: true, awake: true,
sleep: true, sleep: true,
shutdown: true, shutdown: true
} }
} }
} }
@@ -48,13 +46,15 @@ impl AuraPowerState {
boot: true, boot: true,
awake: true, awake: true,
sleep: true, sleep: true,
shutdown: true, shutdown: true
} }
} }
fn tuf_to_bytes(&self) -> Vec<u8> { fn tuf_to_bytes(&self) -> Vec<u8> {
// &cmd, &boot, &awake, &sleep, &keyboard // &cmd, &boot, &awake, &sleep, &keyboard
vec![1, self.boot as u8, self.awake as u8, self.sleep as u8, 1] vec![
1, self.boot as u8, self.awake as u8, self.sleep as u8, 1,
]
} }
/// # Bits for older 0x1866 keyboard model /// # Bits for older 0x1866 keyboard model
@@ -106,50 +106,49 @@ impl AuraPowerState {
match self.zone { match self.zone {
PowerZones::Logo => { PowerZones::Logo => {
self.boot as u32 self.boot as u32
| (self.awake as u32) << 2 | ((self.awake as u32) << 2)
| (self.sleep as u32) << 4 | ((self.sleep as u32) << 4)
| (self.shutdown as u32) << 6 | ((self.shutdown as u32) << 6)
} }
PowerZones::Ally => { PowerZones::Ally => {
(self.boot as u32) (self.boot as u32)
| (self.awake as u32) << 1 | ((self.awake as u32) << 1)
| (self.sleep as u32) << 2 | ((self.sleep as u32) << 2)
| (self.shutdown as u32) << 3 | ((self.shutdown as u32) << 3)
} }
PowerZones::Keyboard => { PowerZones::Keyboard => {
(self.boot as u32) << 1 ((self.boot as u32) << 1)
| (self.awake as u32) << 3 | ((self.awake as u32) << 3)
| (self.sleep as u32) << 5 | ((self.sleep as u32) << 5)
| (self.shutdown as u32) << 7 | ((self.shutdown as u32) << 7)
} }
PowerZones::Lightbar => { PowerZones::Lightbar => {
(self.boot as u32) << (7 + 2) ((self.boot as u32) << (7 + 2))
| (self.awake as u32) << (7 + 3) | ((self.awake as u32) << (7 + 3))
| (self.sleep as u32) << (7 + 4) | ((self.sleep as u32) << (7 + 4))
| (self.shutdown as u32) << (7 + 5) | ((self.shutdown as u32) << (7 + 5))
} }
PowerZones::Lid => { PowerZones::Lid => {
(self.boot as u32) << (15 + 1) ((self.boot as u32) << (15 + 1))
| (self.awake as u32) << (15 + 2) | ((self.awake as u32) << (15 + 2))
| (self.sleep as u32) << (15 + 3) | ((self.sleep as u32) << (15 + 3))
| (self.shutdown as u32) << (15 + 4) | ((self.shutdown as u32) << (15 + 4))
} }
PowerZones::RearGlow => { PowerZones::RearGlow => {
(self.boot as u32) << (23 + 1) ((self.boot as u32) << (23 + 1))
| (self.awake as u32) << (23 + 2) | ((self.awake as u32) << (23 + 2))
| (self.sleep as u32) << (23 + 3) | ((self.sleep as u32) << (23 + 3))
| (self.shutdown as u32) << (23 + 4) | ((self.shutdown as u32) << (23 + 4))
} }
PowerZones::None | PowerZones::KeyboardAndLightbar => 0, PowerZones::None | PowerZones::KeyboardAndLightbar => 0
} }
} }
} }
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct LaptopAuraPower { pub struct LaptopAuraPower {
pub states: Vec<AuraPowerState>, pub states: Vec<AuraPowerState>
} }
impl LaptopAuraPower { impl LaptopAuraPower {
@@ -207,26 +206,32 @@ impl LaptopAuraPower {
// 3. KeyboardAndLightbar // 3. KeyboardAndLightbar
if support_data.power_zones.contains(&PowerZones::Lightbar) { if support_data.power_zones.contains(&PowerZones::Lightbar) {
Self { Self {
states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)], states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)]
} }
} else { } else {
Self { Self {
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)], states: vec![AuraPowerState::default_for(PowerZones::Keyboard)]
} }
} }
} }
AuraDeviceType::LaptopKeyboardTuf => Self { AuraDeviceType::LaptopKeyboardTuf => Self {
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)], states: vec![AuraPowerState::default_for(PowerZones::Keyboard)]
}, },
AuraDeviceType::ScsiExtDisk => todo!(), AuraDeviceType::ScsiExtDisk => todo!(),
AuraDeviceType::AnimeOrSlash => todo!(), AuraDeviceType::AnimeOrSlash => todo!()
} }
} }
pub fn to_bytes(&self, aura_type: AuraDeviceType) -> Vec<u8> { pub fn to_bytes(&self, aura_type: AuraDeviceType) -> Vec<u8> {
if let Some(stuff) = self.states.first() { if let Some(stuff) = self.states.first() {
if stuff.zone == PowerZones::Ally { if stuff.zone == PowerZones::Ally {
return vec![0x5d, 0xd1, 0x09, 0x01, stuff.new_to_byte() as u8]; return vec![
0x5d,
0xd1,
0x09,
0x01,
stuff.new_to_byte() as u8,
];
} }
} }
match aura_type { match aura_type {
@@ -261,7 +266,7 @@ impl LaptopAuraPower {
self.new_to_bytes() self.new_to_bytes()
} }
AuraDeviceType::ScsiExtDisk => todo!("scsi disk not implemented yet"), AuraDeviceType::ScsiExtDisk => todo!("scsi disk not implemented yet"),
AuraDeviceType::AnimeOrSlash => todo!("anime/slash not implemented yet"), AuraDeviceType::AnimeOrSlash => todo!("anime/slash not implemented yet")
} }
} }
} }
@@ -280,7 +285,7 @@ enum OldAuraPower {
Boot = 0xc31209, Boot = 0xc31209,
Sleep = 0x300804, Sleep = 0x300804,
Keyboard = 0x080000, Keyboard = 0x080000,
Lightbar = 0x040500, Lightbar = 0x040500
} }
impl BitOr<OldAuraPower> for OldAuraPower { impl BitOr<OldAuraPower> for OldAuraPower {
@@ -321,26 +326,30 @@ mod test {
#[test] #[test]
fn check_0x1866_control_bytes() { fn check_0x1866_control_bytes() {
let power = LaptopAuraPower { let power = LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Keyboard, AuraPowerState {
boot: false, zone: PowerZones::Keyboard,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]); assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]);
let power = LaptopAuraPower { let power = LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lightbar, AuraPowerState {
boot: false, zone: PowerZones::Lightbar,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
@@ -360,16 +369,16 @@ mod test {
boot: true, boot: true,
awake: true, awake: true,
sleep: true, sleep: true,
shutdown: false, shutdown: false
}, },
AuraPowerState { AuraPowerState {
zone: PowerZones::Lightbar, zone: PowerZones::Lightbar,
boot: true, boot: true,
awake: true, awake: true,
sleep: true, sleep: true,
shutdown: false, shutdown: false
}, },
], ]
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
@@ -379,184 +388,224 @@ mod test {
#[test] #[test]
fn check_0x19b6_control_bytes_binary_rep() { fn check_0x19b6_control_bytes_binary_rep() {
let boot_logo_ = to_binary_string_post2021(&LaptopAuraPower { let boot_logo_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Logo, AuraPowerState {
boot: true, zone: PowerZones::Logo,
awake: false, boot: true,
sleep: false, awake: false,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}); });
let boot_keyb_ = to_binary_string_post2021(&LaptopAuraPower { let boot_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Keyboard, AuraPowerState {
boot: true, zone: PowerZones::Keyboard,
awake: false, boot: true,
sleep: false, awake: false,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}); });
let sleep_logo = to_binary_string_post2021(&LaptopAuraPower { let sleep_logo = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Logo, AuraPowerState {
boot: false, zone: PowerZones::Logo,
awake: false, boot: false,
sleep: true, awake: false,
shutdown: false, sleep: true,
}], shutdown: false
},
]
}); });
let sleep_keyb = to_binary_string_post2021(&LaptopAuraPower { let sleep_keyb = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Keyboard, AuraPowerState {
boot: false, zone: PowerZones::Keyboard,
awake: false, boot: false,
sleep: true, awake: false,
shutdown: false, sleep: true,
}], shutdown: false
},
]
}); });
let awake_logo = to_binary_string_post2021(&LaptopAuraPower { let awake_logo = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Logo, AuraPowerState {
boot: false, zone: PowerZones::Logo,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}); });
let awake_keyb = to_binary_string_post2021(&LaptopAuraPower { let awake_keyb = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Keyboard, AuraPowerState {
boot: false, zone: PowerZones::Keyboard,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}); });
let shut_logo_ = to_binary_string_post2021(&LaptopAuraPower { let shut_logo_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Logo, AuraPowerState {
boot: false, zone: PowerZones::Logo,
awake: false, boot: false,
sleep: false, awake: false,
shutdown: true, sleep: false,
}], shutdown: true
},
]
}); });
let shut_keyb_ = to_binary_string_post2021(&LaptopAuraPower { let shut_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Keyboard, AuraPowerState {
boot: false, zone: PowerZones::Keyboard,
awake: false, boot: false,
sleep: false, awake: false,
shutdown: true, sleep: false,
}], shutdown: true
},
]
}); });
let boot_bar__ = to_binary_string_post2021(&LaptopAuraPower { let boot_bar__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lightbar, AuraPowerState {
boot: true, zone: PowerZones::Lightbar,
awake: false, boot: true,
sleep: false, awake: false,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}); });
let awake_bar_ = to_binary_string_post2021(&LaptopAuraPower { let awake_bar_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lightbar, AuraPowerState {
boot: false, zone: PowerZones::Lightbar,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}); });
let sleep_bar_ = to_binary_string_post2021(&LaptopAuraPower { let sleep_bar_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lightbar, AuraPowerState {
boot: false, zone: PowerZones::Lightbar,
awake: false, boot: false,
sleep: true, awake: false,
shutdown: false, sleep: true,
}], shutdown: false
},
]
}); });
let shut_bar__ = to_binary_string_post2021(&LaptopAuraPower { let shut_bar__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lightbar, AuraPowerState {
boot: false, zone: PowerZones::Lightbar,
awake: false, boot: false,
sleep: false, awake: false,
shutdown: true, sleep: false,
}], shutdown: true
},
]
}); });
let boot_lid__ = to_binary_string_post2021(&LaptopAuraPower { let boot_lid__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lid, AuraPowerState {
boot: true, zone: PowerZones::Lid,
awake: false, boot: true,
sleep: false, awake: false,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}); });
let awake_lid_ = to_binary_string_post2021(&LaptopAuraPower { let awake_lid_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lid, AuraPowerState {
boot: false, zone: PowerZones::Lid,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}); });
let sleep_lid_ = to_binary_string_post2021(&LaptopAuraPower { let sleep_lid_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lid, AuraPowerState {
boot: false, zone: PowerZones::Lid,
awake: false, boot: false,
sleep: true, awake: false,
shutdown: false, sleep: true,
}], shutdown: false
},
]
}); });
let shut_lid__ = to_binary_string_post2021(&LaptopAuraPower { let shut_lid__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::Lid, AuraPowerState {
boot: false, zone: PowerZones::Lid,
awake: false, boot: false,
sleep: false, awake: false,
shutdown: true, sleep: false,
}], shutdown: true
},
]
}); });
let boot_rear_ = to_binary_string_post2021(&LaptopAuraPower { let boot_rear_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::RearGlow, AuraPowerState {
boot: true, zone: PowerZones::RearGlow,
awake: false, boot: true,
sleep: false, awake: false,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}); });
let awake_rear = to_binary_string_post2021(&LaptopAuraPower { let awake_rear = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::RearGlow, AuraPowerState {
boot: false, zone: PowerZones::RearGlow,
awake: true, boot: false,
sleep: false, awake: true,
shutdown: false, sleep: false,
}], shutdown: false
},
]
}); });
let sleep_rear = to_binary_string_post2021(&LaptopAuraPower { let sleep_rear = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::RearGlow, AuraPowerState {
boot: false, zone: PowerZones::RearGlow,
awake: false, boot: false,
sleep: true, awake: false,
shutdown: false, sleep: true,
}], shutdown: false
},
]
}); });
let shut_rear_ = to_binary_string_post2021(&LaptopAuraPower { let shut_rear_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![AuraPowerState { states: vec![
zone: PowerZones::RearGlow, AuraPowerState {
boot: false, zone: PowerZones::RearGlow,
awake: false, boot: false,
sleep: false, awake: false,
shutdown: true, sleep: false,
}], shutdown: true
},
]
}); });
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000"); assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
@@ -606,7 +655,7 @@ mod test {
zone: PowerZones::RearGlow, zone: PowerZones::RearGlow,
..Default::default() ..Default::default()
}, },
], ]
}); });
assert_eq!(byte1, "11111111, 00011110, 00001111, 00001111"); assert_eq!(byte1, "11111111, 00011110, 00001111, 00001111");
} }

View File

@@ -6,7 +6,6 @@
use std::fmt::Debug; use std::fmt::Debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
@@ -30,41 +29,42 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const RED: Colour = Colour { pub const RED: Colour = Colour {
r: 0xff, r: 0xff,
g: 0x00, g: 0x00,
b: 0x00, b: 0x00
}; };
pub const GREEN: Colour = Colour { pub const GREEN: Colour = Colour {
r: 0x00, r: 0x00,
g: 0xff, g: 0xff,
b: 0x00, b: 0x00
}; };
pub const BLUE: Colour = Colour { pub const BLUE: Colour = Colour {
r: 0x00, r: 0x00,
g: 0x00, g: 0x00,
b: 0xff, b: 0xff
}; };
pub const VIOLET: Colour = Colour { pub const VIOLET: Colour = Colour {
r: 0x9b, r: 0x9b,
g: 0x26, g: 0x26,
b: 0xb6, b: 0xb6
}; };
pub const TEAL: Colour = Colour { pub const TEAL: Colour = Colour {
r: 0x00, r: 0x00,
g: 0x7c, g: 0x7c,
b: 0x80, b: 0x80
}; };
pub const YELLOW: Colour = Colour { pub const YELLOW: Colour = Colour {
r: 0xff, r: 0xff,
g: 0xef, g: 0xef,
b: 0x00, b: 0x00
}; };
pub const ORANGE: Colour = Colour { pub const ORANGE: Colour = Colour {
r: 0xff, r: 0xff,
g: 0xa4, g: 0xa4,
b: 0x00, b: 0x00
}; };
pub const GRADIENT: [Colour; 7] = [RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE]; pub const GRADIENT: [Colour; 7] = [
RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE
];
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AuraDeviceType { pub enum AuraDeviceType {
@@ -76,7 +76,7 @@ pub enum AuraDeviceType {
ScsiExtDisk = 3, ScsiExtDisk = 3,
Ally = 4, Ally = 4,
AnimeOrSlash = 5, AnimeOrSlash = 5,
Unknown = 255, Unknown = 255
} }
impl AuraDeviceType { impl AuraDeviceType {
@@ -110,13 +110,12 @@ impl From<&str> for AuraDeviceType {
"1abe" | "1b4c" => Self::Ally, "1abe" | "1b4c" => Self::Ally,
"19b3" | "193b" => Self::AnimeOrSlash, "19b3" | "193b" => Self::AnimeOrSlash,
"19b6" => Self::LaptopKeyboard2021, "19b6" => Self::LaptopKeyboard2021,
_ => Self::Unknown, _ => Self::Unknown
} }
} }
} }
/// The powerr zones this laptop supports /// The powerr zones this laptop supports
#[typeshare]
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
@@ -139,5 +138,5 @@ pub enum PowerZones {
KeyboardAndLightbar = 5, KeyboardAndLightbar = 5,
/// Ally specific for creating correct packet /// Ally specific for creating correct packet
Ally = 6, Ally = 6,
None = 255, None = 255
} }

View File

@@ -1,4 +1,7 @@
// Only these two packets must be 17 bytes // Only these two packets must be 17 bytes
pub const AURA_LAPTOP_LED_APPLY: [u8; 17] = pub const AURA_LAPTOP_LED_APPLY: [u8; 17] = [
[0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; 0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
pub const AURA_LAPTOP_LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; ];
pub const AURA_LAPTOP_LED_SET: [u8; 17] = [
0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
];

View File

@@ -20,7 +20,7 @@ fn main() {
CompilerConfiguration::new() CompilerConfiguration::new()
// .embed_resources(EmbedResourcesKind::EmbedFiles) // .embed_resources(EmbedResourcesKind::EmbedFiles)
.with_include_paths(vec![include]) .with_include_paths(vec![include])
.with_style("fluent-dark".into()), .with_style("fluent-dark".into())
) )
.unwrap(); .unwrap();
} }

View File

@@ -23,5 +23,5 @@ pub struct CliStart {
help = "put ROGCC in layout viewing mode - this is helpful for finding existing layouts \ help = "put ROGCC in layout viewing mode - this is helpful for finding existing layouts \
that might match your laptop" that might match your laptop"
)] )]
pub layout_viewing: bool, pub layout_viewing: bool
} }

View File

@@ -21,7 +21,7 @@ pub struct Config {
pub fullscreen_width: u32, pub fullscreen_width: u32,
pub fullscreen_height: u32, pub fullscreen_height: u32,
// This field must be last // This field must be last
pub notifications: EnabledNotifications, pub notifications: EnabledNotifications
} }
impl Default for Config { impl Default for Config {
@@ -36,7 +36,7 @@ impl Default for Config {
fullscreen_height: 1080, fullscreen_height: 1080,
notifications: EnabledNotifications::default(), notifications: EnabledNotifications::default(),
ac_command: String::new(), ac_command: String::new(),
bat_command: String::new(), bat_command: String::new()
} }
} }
} }
@@ -77,7 +77,7 @@ pub struct Config461 {
pub enable_dgpu_notifications: bool, pub enable_dgpu_notifications: bool,
pub dark_mode: bool, pub dark_mode: bool,
// This field must be last // This field must be last
pub enabled_notifications: EnabledNotifications, pub enabled_notifications: EnabledNotifications
} }
impl From<Config461> for Config { impl From<Config461> for Config {
@@ -92,7 +92,7 @@ impl From<Config461> for Config {
start_fullscreen: false, start_fullscreen: false,
fullscreen_width: 1920, fullscreen_width: 1920,
fullscreen_height: 1080, fullscreen_height: 1080,
notifications: c.enabled_notifications, notifications: c.enabled_notifications
} }
} }
} }

View File

@@ -9,7 +9,7 @@ pub enum Error {
ConfigLockFail, ConfigLockFail,
XdgVars, XdgVars,
Zbus(zbus::Error), Zbus(zbus::Error),
Notification(notify_rust::error::Error), Notification(notify_rust::error::Error)
} }
impl fmt::Display for Error { impl fmt::Display for Error {
@@ -21,7 +21,7 @@ impl fmt::Display for Error {
Error::ConfigLockFail => write!(f, "Failed to lock user config"), Error::ConfigLockFail => write!(f, "Failed to lock user config"),
Error::XdgVars => write!(f, "XDG environment vars appear unset"), Error::XdgVars => write!(f, "XDG environment vars appear unset"),
Error::Zbus(err) => write!(f, "Error: {}", err), Error::Zbus(err) => write!(f, "Error: {}", err),
Error::Notification(err) => write!(f, "Notification Error: {}", err), Error::Notification(err) => write!(f, "Notification Error: {}", err)
} }
} }
} }

View File

@@ -15,7 +15,7 @@ pub mod notify;
pub mod tray; pub mod tray;
pub mod types; pub mod types;
pub mod ui; pub mod ui;
pub mod zbus; pub mod zbus_proxies;
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png"; pub const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png";
@@ -38,5 +38,5 @@ pub enum Page {
System, System,
AuraEffects, AuraEffects,
AnimeMatrix, AnimeMatrix,
FanCurves, FanCurves
} }

View File

@@ -1,4 +1,3 @@
use std::borrow::BorrowMut;
use std::env::args; use std::env::args;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::exit; use std::process::exit;
@@ -17,8 +16,8 @@ use rog_control_center::notify::start_notifications;
use rog_control_center::slint::ComponentHandle; use rog_control_center::slint::ComponentHandle;
use rog_control_center::tray::init_tray; use rog_control_center::tray::init_tray;
use rog_control_center::ui::setup_window; use rog_control_center::ui::setup_window;
use rog_control_center::zbus::{ use rog_control_center::zbus_proxies::{
AppState, ROGCCZbus, ROGCCZbusProxyBlocking, ZBUS_IFACE, ZBUS_PATH, AppState, ROGCCZbus, ROGCCZbusProxyBlocking, ZBUS_IFACE, ZBUS_PATH
}; };
use rog_control_center::{print_versions, MainWindow}; use rog_control_center::{print_versions, MainWindow};
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
@@ -118,11 +117,6 @@ async fn main() -> Result<()> {
config.startup_in_background = false; config.startup_in_background = false;
} }
if config.startup_in_background {
config.run_in_background = true;
}
config.write();
let enable_tray_icon = config.enable_tray_icon; let enable_tray_icon = config.enable_tray_icon;
let startup_in_background = config.startup_in_background; let startup_in_background = config.startup_in_background;
let config = Arc::new(Mutex::new(config)); let config = Arc::new(Mutex::new(config));
@@ -159,11 +153,12 @@ async fn main() -> Result<()> {
state = *lock; state = *lock;
} }
// This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300));
if state == AppState::MainWindowShouldOpen { if state == AppState::MainWindowShouldOpen {
if let Ok(mut lock) = app_state.lock() { if let Ok(mut lock) = app_state.lock() {
*lock = AppState::MainWindowOpen; *lock = AppState::MainWindowOpen;
} }
sleep(Duration::from_millis(50));
let config_copy = config.clone(); let config_copy = config.clone();
let app_state_copy = app_state.clone(); let app_state_copy = app_state.clone();
@@ -203,18 +198,7 @@ async fn main() -> Result<()> {
exit(0); exit(0);
} }
} }
slint::invoke_from_event_loop(move || {
UI.with(|ui| {
let mut ui = ui.take();
if let Some(ui) = ui.borrow_mut() {
ui.window().hide().unwrap();
}
});
})
.unwrap();
} }
sleep(Duration::from_millis(300));
} }
}); });
@@ -223,42 +207,6 @@ async fn main() -> Result<()> {
Ok(()) Ok(())
} }
// /// Bah.. the icon dosn't work on wayland anyway, but we'll leave it in for
// now. fn load_icon() -> IconData {
// let path = PathBuf::from(APP_ICON_PATH);
// let mut rgba = Vec::new();
// let mut height = 512;
// let mut width = 512;
// if path.exists() {
// if let Ok(data) = std::fs::read(path)
// .map_err(|e| error!("Error reading app icon: {e:?}"))
// .map_err(|e| error!("Error opening app icon: {e:?}"))
// {
// let data = std::io::Cursor::new(data);
// let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
// let png_pong::Step { raster, delay: _ } =
// decoder.last().unwrap().unwrap();
// if let png_pong::PngRaster::Rgba8(ras) = raster {
// rgba = ras.as_u8_slice().to_vec();
// width = ras.width();
// height = ras.height();
// info!("Loaded app icon. Not actually supported in Wayland
// yet"); }
// }
// } else {
// error!("Missing {APP_ICON_PATH}");
// }
// IconData {
// height,
// width,
// rgba
//
//
// / }
// }
fn do_cli_help(parsed: &CliStart) -> bool { fn do_cli_help(parsed: &CliStart) -> bool {
if parsed.help { if parsed.help {
println!("{}", CliStart::usage()); println!("{}", CliStart::usage());

View File

@@ -5,7 +5,7 @@ use rog_aura::{AuraEffect, AuraModeNum, AuraZone};
use rog_platform::platform::GpuMode; use rog_platform::platform::GpuMode;
use rog_platform::supported::{ use rog_platform::supported::{
AdvancedAura, AnimeSupportedFunctions, ChargeSupportedFunctions, LedSupportedFunctions, AdvancedAura, AnimeSupportedFunctions, ChargeSupportedFunctions, LedSupportedFunctions,
PlatformProfileFunctions, RogBiosSupportedFunctions, SupportedFunctions, PlatformProfileFunctions, RogBiosSupportedFunctions, SupportedFunctions
}; };
use rog_profiles::fan_curve_set::{CurveData, FanCurveSet}; use rog_profiles::fan_curve_set::{CurveData, FanCurveSet};
use supergfxctl::pci_device::{GfxMode, GfxPower}; use supergfxctl::pci_device::{GfxMode, GfxPower};
@@ -16,7 +16,7 @@ const NOPE: &str = "";
#[derive(Default)] #[derive(Default)]
pub struct DaemonProxyBlocking<'a> { pub struct DaemonProxyBlocking<'a> {
_phantom: &'a str, _phantom: &'a str
} }
impl<'a> DaemonProxyBlocking<'a> { impl<'a> DaemonProxyBlocking<'a> {
@@ -35,7 +35,7 @@ impl<'a> DaemonProxyBlocking<'a> {
#[derive(Default)] #[derive(Default)]
pub struct RogDbusClientBlocking<'a> { pub struct RogDbusClientBlocking<'a> {
_phantom: &'a str, _phantom: &'a str
} }
impl<'a> RogDbusClientBlocking<'a> { impl<'a> RogDbusClientBlocking<'a> {
@@ -125,10 +125,18 @@ impl Profile {
pub fn fan_curve_data(&self, _p: rog_profiles::Profile) -> Result<FanCurveSet> { pub fn fan_curve_data(&self, _p: rog_profiles::Profile) -> Result<FanCurveSet> {
let mut curve = FanCurveSet::default(); let mut curve = FanCurveSet::default();
curve.cpu.pwm = [30, 40, 60, 100, 140, 180, 200, 250]; curve.cpu.pwm = [
curve.cpu.temp = [20, 30, 40, 50, 70, 80, 90, 100]; 30, 40, 60, 100, 140, 180, 200, 250
curve.gpu.pwm = [40, 80, 100, 140, 170, 200, 230, 250]; ];
curve.gpu.temp = [20, 30, 40, 50, 70, 80, 90, 100]; curve.cpu.temp = [
20, 30, 40, 50, 70, 80, 90, 100
];
curve.gpu.pwm = [
40, 80, 100, 140, 170, 200, 230, 250
];
curve.gpu.temp = [
20, 30, 40, 50, 70, 80, 90, 100
];
Ok(curve) Ok(curve)
} }
@@ -196,7 +204,7 @@ impl Led {
AuraDevRog2::AwakeKeyb, AuraDevRog2::AwakeKeyb,
AuraDevRog2::SleepLogo, AuraDevRog2::SleepLogo,
AuraDevRog2::AwakeLogo, AuraDevRog2::AwakeLogo,
], ]
}) })
} }
@@ -234,11 +242,11 @@ impl Supported {
Ok(SupportedFunctions { Ok(SupportedFunctions {
anime_ctrl: AnimeSupportedFunctions(true), anime_ctrl: AnimeSupportedFunctions(true),
charge_ctrl: ChargeSupportedFunctions { charge_ctrl: ChargeSupportedFunctions {
charge_level_set: true, charge_level_set: true
}, },
platform_profile: PlatformProfileFunctions { platform_profile: PlatformProfileFunctions {
platform_profile: true, platform_profile: true,
fan_curves: true, fan_curves: true
}, },
keyboard_led: LedSupportedFunctions { keyboard_led: LedSupportedFunctions {
dev_id: AuraDevice::X19b6, dev_id: AuraDevice::X19b6,
@@ -259,7 +267,7 @@ impl Supported {
AuraZone::BarRight, AuraZone::BarRight,
AuraZone::Logo, AuraZone::Logo,
], ],
advanced_type: AdvancedAura::PerKey, advanced_type: AdvancedAura::PerKey
}, },
rog_bios_ctrl: RogBiosSupportedFunctions { rog_bios_ctrl: RogBiosSupportedFunctions {
post_sound: true, post_sound: true,
@@ -267,8 +275,8 @@ impl Supported {
panel_overdrive: true, panel_overdrive: true,
dgpu_disable: true, dgpu_disable: true,
mini_led_mode: true, mini_led_mode: true,
egpu_enable: true, egpu_enable: true
}, }
}) })
} }
} }

View File

@@ -32,7 +32,7 @@ const NOTIF_HEADER: &str = "ROG Control";
pub struct EnabledNotifications { pub struct EnabledNotifications {
pub enabled: bool, pub enabled: bool,
pub receive_notify_gfx: bool, pub receive_notify_gfx: bool,
pub receive_notify_gfx_status: bool, pub receive_notify_gfx_status: bool
} }
impl Default for EnabledNotifications { impl Default for EnabledNotifications {
@@ -40,7 +40,7 @@ impl Default for EnabledNotifications {
Self { Self {
enabled: true, enabled: true,
receive_notify_gfx: true, receive_notify_gfx: true,
receive_notify_gfx_status: true, receive_notify_gfx_status: true
} }
} }
} }
@@ -93,7 +93,7 @@ fn start_dpu_status_mon(config: Arc<Mutex<Config>>) {
pub fn start_notifications( pub fn start_notifications(
config: Arc<Mutex<Config>>, config: Arc<Mutex<Config>>,
rt: &Runtime, rt: &Runtime
) -> Result<Vec<JoinHandle<()>>> { ) -> Result<Vec<JoinHandle<()>>> {
// Setup the AC/BAT commands that will run on power status change // Setup the AC/BAT commands that will run on power status change
let config_copy = config.clone(); let config_copy = config.clone();
@@ -213,7 +213,7 @@ pub fn start_notifications(
supergfxctl::actions::UserActionRequired::Reboot => { supergfxctl::actions::UserActionRequired::Reboot => {
do_mux_notification("Graphics mode change requires reboot", &mode) do_mux_notification("Graphics mode change requires reboot", &mode)
} }
_ => do_gfx_action_notif(<&str>::from(action), *action, mode), _ => do_gfx_action_notif(<&str>::from(action), *action, mode)
} }
.map_err(|e| { .map_err(|e| {
error!("zbus signal: do_gfx_action_notif: {e}"); error!("zbus signal: do_gfx_action_notif: {e}");
@@ -265,13 +265,13 @@ fn convert_gfx_mode(gfx: GfxMode) -> GpuMode {
GfxMode::Vfio => GpuMode::Vfio, GfxMode::Vfio => GpuMode::Vfio,
GfxMode::AsusEgpu => GpuMode::Egpu, GfxMode::AsusEgpu => GpuMode::Egpu,
GfxMode::AsusMuxDgpu => GpuMode::Ultimate, GfxMode::AsusMuxDgpu => GpuMode::Ultimate,
GfxMode::None => GpuMode::Error, GfxMode::None => GpuMode::Error
} }
} }
fn base_notification<T>(message: &str, data: &T) -> Notification fn base_notification<T>(message: &str, data: &T) -> Notification
where where
T: Display, T: Display
{ {
let mut notif = Notification::new(); let mut notif = Notification::new();
notif notif
@@ -289,7 +289,7 @@ fn do_gpu_status_notif(message: &str, data: &GfxPower) -> Notification {
GfxPower::Off => "asus_notif_green", GfxPower::Off => "asus_notif_green",
GfxPower::AsusDisabled => "asus_notif_white", GfxPower::AsusDisabled => "asus_notif_white",
GfxPower::AsusMuxDiscreet | GfxPower::Active => "asus_notif_red", GfxPower::AsusMuxDiscreet | GfxPower::Active => "asus_notif_red",
GfxPower::Unknown => "gpu-integrated", GfxPower::Unknown => "gpu-integrated"
}; };
notif.icon(icon); notif.icon(icon);
notif notif
@@ -329,7 +329,9 @@ fn do_gfx_action_notif(message: &str, action: GfxUserAction, mode: GpuMode) -> R
handle.wait_for_action(|id| { handle.wait_for_action(|id| {
if id == "gfx-mode-session-action" { if id == "gfx-mode-session-action" {
let mut cmd = Command::new("qdbus"); let mut cmd = Command::new("qdbus");
cmd.args(["org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0"]); cmd.args([
"org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0"
]);
cmd.spawn().ok(); cmd.spawn().ok();
} else if id == "__closed" { } else if id == "__closed" {
// TODO: cancel the switching // TODO: cancel the switching
@@ -371,7 +373,9 @@ fn do_mux_notification(message: &str, m: &GpuMode) -> Result<()> {
handle.wait_for_action(|id| { handle.wait_for_action(|id| {
if id == "gfx-mode-session-action" { if id == "gfx-mode-session-action" {
let mut cmd = Command::new("qdbus"); let mut cmd = Command::new("qdbus");
cmd.args(["org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0"]); cmd.args([
"org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0"
]);
cmd.spawn().ok(); cmd.spawn().ok();
} else if id == "__closed" { } else if id == "__closed" {
// TODO: cancel the switching // TODO: cancel the switching

View File

@@ -14,7 +14,7 @@ use supergfxctl::zbus_proxy::DaemonProxy as GfxProxy;
use versions::Versioning; use versions::Versioning;
use crate::config::Config; use crate::config::Config;
use crate::zbus::{AppState, ROGCCZbusProxyBlocking}; use crate::zbus_proxies::{AppState, ROGCCZbusProxyBlocking};
const TRAY_LABEL: &str = "ROG Control Center"; const TRAY_LABEL: &str = "ROG Control Center";
const TRAY_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/"; const TRAY_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/";
@@ -24,7 +24,7 @@ struct Icons {
rog_red: Icon, rog_red: Icon,
rog_green: Icon, rog_green: Icon,
rog_white: Icon, rog_white: Icon,
gpu_integrated: Icon, gpu_integrated: Icon
} }
static ICONS: OnceLock<Icons> = OnceLock::new(); static ICONS: OnceLock<Icons> = OnceLock::new();
@@ -48,14 +48,14 @@ fn read_icon(file: &Path) -> Icon {
Icon { Icon {
width: width as i32, width: width as i32,
height: height as i32, height: height as i32,
data: img.into_raw(), data: img.into_raw()
} }
} }
struct AsusTray { struct AsusTray {
current_title: String, current_title: String,
current_icon: Icon, current_icon: Icon,
proxy: ROGCCZbusProxyBlocking<'static>, proxy: ROGCCZbusProxyBlocking<'static>
} }
impl ksni::Tray for AsusTray { impl ksni::Tray for AsusTray {
@@ -103,7 +103,7 @@ async fn set_tray_icon_and_tip(
mode: GfxMode, mode: GfxMode,
power: GfxPower, power: GfxPower,
tray: &mut Handle<AsusTray>, tray: &mut Handle<AsusTray>,
supergfx_active: bool, supergfx_active: bool
) { ) {
if let Some(icons) = ICONS.get() { if let Some(icons) = ICONS.get() {
let icon = match power { let icon = match power {
@@ -163,7 +163,7 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
let tray = AsusTray { let tray = AsusTray {
current_title: TRAY_LABEL.to_string(), current_title: TRAY_LABEL.to_string(),
current_icon: rog_red.clone(), current_icon: rog_red.clone(),
proxy, proxy
}; };
let mut tray = tray let mut tray = tray
@@ -186,7 +186,7 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
rog_red: rog_red.clone(), rog_red: rog_red.clone(),
rog_green, rog_green,
rog_white, rog_white,
gpu_integrated, gpu_integrated
}); });
let mut has_supergfx = false; let mut has_supergfx = false;
@@ -207,7 +207,7 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
} }
} }
} }
Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}"), Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}")
} }
info!("Started ROGTray"); info!("Started ROGTray");

View File

@@ -1,6 +1,6 @@
use crate::slint_generatedMainWindow::{ use crate::slint_generatedMainWindow::{
AuraDevType as SlintDeviceType, AuraPowerState as SlintAuraPowerState, AuraDevType as SlintDeviceType, AuraPowerState as SlintAuraPowerState,
LaptopAuraPower as SlintLaptopAuraPower, LaptopAuraPower as SlintLaptopAuraPower
}; };
impl From<rog_aura::AuraEffect> for crate::slint_generatedMainWindow::AuraEffect { impl From<rog_aura::AuraEffect> for crate::slint_generatedMainWindow::AuraEffect {
@@ -10,20 +10,20 @@ impl From<rog_aura::AuraEffect> for crate::slint_generatedMainWindow::AuraEffect
red: m.colour1.r, red: m.colour1.r,
green: m.colour1.g, green: m.colour1.g,
blue: m.colour1.b, blue: m.colour1.b,
alpha: 255, alpha: 255
} }
.into(), .into(),
colour2: RgbaColor { colour2: RgbaColor {
red: m.colour2.r, red: m.colour2.r,
green: m.colour2.g, green: m.colour2.g,
blue: m.colour2.b, blue: m.colour2.b,
alpha: 255, alpha: 255
} }
.into(), .into(),
direction: m.direction.into(), direction: m.direction.into(),
mode: m.mode.into(), mode: m.mode.into(),
speed: m.speed.into(), speed: m.speed.into(),
zone: m.zone.into(), zone: m.zone.into()
} }
} }
} }
@@ -36,17 +36,17 @@ impl From<crate::slint_generatedMainWindow::AuraEffect> for rog_aura::AuraEffect
colour1: rog_aura::Colour { colour1: rog_aura::Colour {
r: c1.red, r: c1.red,
g: c1.green, g: c1.green,
b: c1.blue, b: c1.blue
}, },
colour2: rog_aura::Colour { colour2: rog_aura::Colour {
r: c2.red, r: c2.red,
g: c2.green, g: c2.green,
b: c2.blue, b: c2.blue
}, },
direction: m.direction.into(), direction: m.direction.into(),
mode: m.mode.into(), mode: m.mode.into(),
speed: m.speed.into(), speed: m.speed.into(),
zone: m.zone.into(), zone: m.zone.into()
} }
} }
} }
@@ -66,7 +66,7 @@ impl From<PowerZones> for SlintPowerZones {
PowerZones::RearGlow => SlintPowerZones::RearGlow, PowerZones::RearGlow => SlintPowerZones::RearGlow,
PowerZones::KeyboardAndLightbar => SlintPowerZones::KeyboardAndLightbar, PowerZones::KeyboardAndLightbar => SlintPowerZones::KeyboardAndLightbar,
PowerZones::Ally => SlintPowerZones::Ally, PowerZones::Ally => SlintPowerZones::Ally,
PowerZones::None => SlintPowerZones::Keyboard, PowerZones::None => SlintPowerZones::Keyboard
} }
} }
} }
@@ -80,7 +80,7 @@ impl From<SlintPowerZones> for PowerZones {
SlintPowerZones::Lid => PowerZones::Lid, SlintPowerZones::Lid => PowerZones::Lid,
SlintPowerZones::RearGlow => PowerZones::RearGlow, SlintPowerZones::RearGlow => PowerZones::RearGlow,
SlintPowerZones::KeyboardAndLightbar => PowerZones::KeyboardAndLightbar, SlintPowerZones::KeyboardAndLightbar => PowerZones::KeyboardAndLightbar,
SlintPowerZones::Ally => PowerZones::Ally, SlintPowerZones::Ally => PowerZones::Ally
} }
} }
} }
@@ -92,7 +92,7 @@ impl From<SlintAuraPowerState> for AuraPowerState {
boot: value.boot, boot: value.boot,
awake: value.awake, awake: value.awake,
sleep: value.sleep, sleep: value.sleep,
shutdown: value.shutdown, shutdown: value.shutdown
} }
} }
} }
@@ -106,7 +106,7 @@ impl From<AuraPowerState> for SlintAuraPowerState {
sleep: value.sleep, sleep: value.sleep,
shutdown: value.shutdown, shutdown: value.shutdown,
zone, zone,
zone_name_idx: zone as i32, zone_name_idx: zone as i32
} }
} }
} }
@@ -120,7 +120,7 @@ impl From<&AuraPowerState> for SlintAuraPowerState {
sleep: value.sleep, sleep: value.sleep,
shutdown: value.shutdown, shutdown: value.shutdown,
zone, zone,
zone_name_idx: zone as i32, zone_name_idx: zone as i32
} }
} }
} }
@@ -140,7 +140,7 @@ impl From<LaptopAuraPower> for SlintLaptopAuraPower {
let converted: Vec<SlintAuraPowerState> = let converted: Vec<SlintAuraPowerState> =
value.states.iter().map(SlintAuraPowerState::from).collect(); value.states.iter().map(SlintAuraPowerState::from).collect();
Self { Self {
states: ModelRc::from(converted.as_slice()), states: ModelRc::from(converted.as_slice())
} }
} }
} }
@@ -154,7 +154,7 @@ impl From<SlintDeviceType> for AuraDeviceType {
SlintDeviceType::ScsiExtDisk => Self::ScsiExtDisk, SlintDeviceType::ScsiExtDisk => Self::ScsiExtDisk,
SlintDeviceType::Unknown => Self::Unknown, SlintDeviceType::Unknown => Self::Unknown,
SlintDeviceType::Ally => Self::Ally, SlintDeviceType::Ally => Self::Ally,
SlintDeviceType::AnimeOrSlash => Self::AnimeOrSlash, SlintDeviceType::AnimeOrSlash => Self::AnimeOrSlash
} }
} }
} }
@@ -168,7 +168,7 @@ impl From<AuraDeviceType> for SlintDeviceType {
AuraDeviceType::ScsiExtDisk => SlintDeviceType::ScsiExtDisk, AuraDeviceType::ScsiExtDisk => SlintDeviceType::ScsiExtDisk,
AuraDeviceType::Unknown => SlintDeviceType::Unknown, AuraDeviceType::Unknown => SlintDeviceType::Unknown,
AuraDeviceType::Ally => SlintDeviceType::Ally, AuraDeviceType::Ally => SlintDeviceType::Ally,
AuraDeviceType::AnimeOrSlash => SlintDeviceType::AnimeOrSlash, AuraDeviceType::AnimeOrSlash => SlintDeviceType::AnimeOrSlash
} }
} }
} }

View File

@@ -8,7 +8,7 @@ impl From<Profile> for ThrottlePolicy {
match value { match value {
Profile::Balanced => ThrottlePolicy::Balanced, Profile::Balanced => ThrottlePolicy::Balanced,
Profile::Performance => ThrottlePolicy::Performance, Profile::Performance => ThrottlePolicy::Performance,
Profile::Quiet => ThrottlePolicy::Quiet, Profile::Quiet => ThrottlePolicy::Quiet
} }
} }
} }
@@ -18,7 +18,7 @@ impl From<ThrottlePolicy> for Profile {
match value { match value {
ThrottlePolicy::Balanced => Profile::Balanced, ThrottlePolicy::Balanced => Profile::Balanced,
ThrottlePolicy::Performance => Profile::Performance, ThrottlePolicy::Performance => Profile::Performance,
ThrottlePolicy::Quiet => Profile::Quiet, ThrottlePolicy::Quiet => Profile::Quiet
} }
} }
} }
@@ -28,7 +28,7 @@ impl From<FanType> for FanCurvePU {
match value { match value {
FanType::CPU => FanCurvePU::CPU, FanType::CPU => FanCurvePU::CPU,
FanType::Middle => FanCurvePU::MID, FanType::Middle => FanCurvePU::MID,
FanType::GPU => FanCurvePU::GPU, FanType::GPU => FanCurvePU::GPU
} }
} }
} }
@@ -38,7 +38,7 @@ impl From<FanCurvePU> for FanType {
match value { match value {
FanCurvePU::CPU => FanType::CPU, FanCurvePU::CPU => FanType::CPU,
FanCurvePU::GPU => FanType::GPU, FanCurvePU::GPU => FanType::GPU,
FanCurvePU::MID => FanType::Middle, FanCurvePU::MID => FanType::Middle
} }
} }
} }

View File

@@ -16,21 +16,6 @@ use crate::ui::setup_fans::setup_fan_curve_page;
use crate::ui::setup_system::{setup_system_page, setup_system_page_callbacks}; use crate::ui::setup_system::{setup_system_page, setup_system_page_callbacks};
use crate::{AppSettingsPageData, MainWindow}; use crate::{AppSettingsPageData, MainWindow};
// This macro expects are consistent naming between proxy calls and slint
// globals
#[macro_export]
macro_rules! set_ui_props_async {
($ui:ident, $proxy:ident, $global:ident, $proxy_fn:ident) => {
if let Ok(value) = $proxy.$proxy_fn().await {
$ui.upgrade_in_event_loop(move |handle| {
concat_idents::concat_idents!(set = set_, $proxy_fn {
handle.global::<$global>().set(value.into());
});
}).ok();
}
};
}
// this macro sets up: // this macro sets up:
// - a link from UI callback -> dbus proxy property // - a link from UI callback -> dbus proxy property
// - a link from dbus property signal -> UI state // - a link from dbus property signal -> UI state
@@ -82,7 +67,7 @@ pub fn show_toast(
success: SharedString, success: SharedString,
fail: SharedString, fail: SharedString,
handle: Weak<MainWindow>, handle: Weak<MainWindow>,
result: zbus::Result<()>, result: zbus::Result<()>
) { ) {
match result { match result {
Ok(_) => { Ok(_) => {
@@ -92,7 +77,7 @@ pub fn show_toast(
log::warn!("{fail}: {e}"); log::warn!("{fail}: {e}");
handle.unwrap().invoke_show_toast(fail) handle.unwrap().invoke_show_toast(fail)
}) })
.ok(), .ok()
}; };
} }
@@ -112,14 +97,14 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
ui.set_sidebar_items_avilable( ui.set_sidebar_items_avilable(
[ [
// Needs to match the order of slint sidebar items // Needs to match the order of slint sidebar items
available.contains(&"org.asuslinux.Platform".to_string()), available.contains(&"xyz.ljones.Platform".to_string()),
available.contains(&"org.asuslinux.Aura".to_string()), available.contains(&"xyz.ljones.Aura".to_string()),
available.contains(&"org.asuslinux.Anime".to_string()), available.contains(&"xyz.ljones.Anime".to_string()),
available.contains(&"org.asuslinux.FanCurves".to_string()), available.contains(&"xyz.ljones.FanCurves".to_string()),
true,
true, true,
true
] ]
.into(), .into()
); );
ui.on_exit_app(move || { ui.on_exit_app(move || {
@@ -127,17 +112,17 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
}); });
setup_app_settings_page(&ui, config.clone()); setup_app_settings_page(&ui, config.clone());
if available.contains(&"org.asuslinux.Platform".to_string()) { if available.contains(&"xyz.ljones.Platform".to_string()) {
setup_system_page(&ui, config.clone()); setup_system_page(&ui, config.clone());
setup_system_page_callbacks(&ui, config.clone()); setup_system_page_callbacks(&ui, config.clone());
} }
if available.contains(&"org.asuslinux.Aura".to_string()) { if available.contains(&"xyz.ljones.Aura".to_string()) {
setup_aura_page(&ui, config.clone()); setup_aura_page(&ui, config.clone());
} }
if available.contains(&"org.asuslinux.Anime".to_string()) { if available.contains(&"xyz.ljones.Anime".to_string()) {
setup_anime_page(&ui, config.clone()); setup_anime_page(&ui, config.clone());
} }
if available.contains(&"org.asuslinux.FanCurves".to_string()) { if available.contains(&"xyz.ljones.FanCurves".to_string()) {
setup_fan_curve_page(&ui, config); setup_fan_curve_page(&ui, config);
} }
ui ui

View File

@@ -52,9 +52,9 @@ pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
boot: boot.into(), boot: boot.into(),
awake: awake.into(), awake: awake.into(),
sleep: sleep.into(), sleep: sleep.into(),
shutdown: shutdown.into(), shutdown: shutdown.into()
}) })
.await, .await
); );
}); });
}); });

View File

@@ -9,7 +9,7 @@ use slint::{ComponentHandle, Model, RgbaColor, SharedString};
use crate::config::Config; use crate::config::Config;
use crate::ui::show_toast; use crate::ui::show_toast;
use crate::{ use crate::{
set_ui_callbacks, set_ui_props_async, AuraPageData, MainWindow, PowerZones as SlintPowerZones, set_ui_callbacks, set_ui_props_async, AuraPageData, MainWindow, PowerZones as SlintPowerZones
}; };
fn decode_hex(s: &str) -> RgbaColor<u8> { fn decode_hex(s: &str) -> RgbaColor<u8> {
@@ -19,7 +19,7 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
alpha: 255, alpha: 255,
red: 0, red: 0,
green: 0, green: 0,
blue: 0, blue: 0
}; };
} }
let c: Vec<u8> = (0..s.len()) let c: Vec<u8> = (0..s.len())
@@ -30,7 +30,7 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
alpha: 255, alpha: 255,
red: *c.first().unwrap_or(&255), red: *c.first().unwrap_or(&255),
green: *c.get(1).unwrap_or(&128), green: *c.get(1).unwrap_or(&128),
blue: *c.get(2).unwrap_or(&32), blue: *c.get(2).unwrap_or(&32)
} }
} }
@@ -38,12 +38,12 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
// TODO: return all // TODO: return all
async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Error>> { async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Error>> {
let conn = zbus::Connection::system().await?; let conn = zbus::Connection::system().await?;
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").await?; let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").await?;
let interfaces = f.get_managed_objects().await?; let interfaces = f.get_managed_objects().await?;
let mut aura_paths = Vec::new(); let mut aura_paths = Vec::new();
for v in interfaces.iter() { for v in interfaces.iter() {
for k in v.1.keys() { for k in v.1.keys() {
if k.as_str() == "org.asuslinux.Aura" { if k.as_str() == "xyz.ljones.Aura" {
println!("Found aura device at {}, {}", v.0, k); println!("Found aura device at {}, {}", v.0, k);
aura_paths.push(v.0.clone()); aura_paths.push(v.0.clone());
} }
@@ -56,7 +56,7 @@ async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Err
if let Some(path) = aura_paths.first() { if let Some(path) = aura_paths.first() {
return Ok(AuraProxy::builder(&conn) return Ok(AuraProxy::builder(&conn)
.path(path.clone())? .path(path.clone())?
.destination("org.asuslinux.Daemon")? .destination("xyz.ljones.Asusd")?
.build() .build()
.await?); .await?);
} }
@@ -198,7 +198,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
"Aura power settings changed".into(), "Aura power settings changed".into(),
"Failed to set Aura power settings".into(), "Failed to set Aura power settings".into(),
handle_copy, handle_copy,
proxy_copy.set_led_power(power).await, proxy_copy.set_led_power(power).await
); );
}); });
}); });

View File

@@ -13,7 +13,7 @@ pub fn update_fan_data(
handle: Weak<MainWindow>, handle: Weak<MainWindow>,
bal: Vec<CurveData>, bal: Vec<CurveData>,
perf: Vec<CurveData>, perf: Vec<CurveData>,
quiet: Vec<CurveData>, quiet: Vec<CurveData>
) { ) {
handle handle
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
@@ -24,7 +24,7 @@ pub fn update_fan_data(
.zip(pwm.iter()) .zip(pwm.iter())
.map(|(x, y)| Node { .map(|(x, y)| Node {
x: *x as f32, x: *x as f32,
y: *y as f32, y: *y as f32
}) })
.collect(); .collect();
tmp.as_slice().into() tmp.as_slice().into()
@@ -199,6 +199,6 @@ fn fan_data_for(fan: FanType, enabled: bool, data: Vec<Node>) -> CurveData {
fan: fan.into(), fan: fan.into(),
pwm, pwm,
temp, temp,
enabled, enabled
} }
} }

View File

@@ -1,40 +1,202 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use concat_idents::concat_idents;
use rog_dbus::asus_armoury::AsusArmouryProxy;
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking}; use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
use rog_platform::firmware_attributes::FirmwareAttribute;
use rog_platform::platform::Properties; use rog_platform::platform::Properties;
use slint::ComponentHandle; use slint::ComponentHandle;
use super::show_toast; use super::show_toast;
use crate::config::Config; use crate::config::Config;
use crate::{ use crate::zbus_proxies::find_iface_async;
set_ui_callbacks, set_ui_props_async, AvailableSystemProperties, MainWindow, SystemPageData, use crate::{set_ui_props_async, AttrMinMax, MainWindow, SystemPageData};
const MINMAX: AttrMinMax = AttrMinMax {
min: 0,
max: 0,
val: -1.0
}; };
pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) { pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let conn = zbus::blocking::Connection::system().unwrap(); let conn = zbus::blocking::Connection::system().unwrap();
let platform = PlatformProxyBlocking::new(&conn).unwrap(); let platform = PlatformProxyBlocking::new(&conn).unwrap();
// let armoury_attrs =
// find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury").unwrap();
// Null everything before the setup step
ui.global::<SystemPageData>()
.set_charge_control_end_threshold(-1.0);
ui.global::<SystemPageData>()
.set_throttle_thermal_policy(-1);
ui.global::<SystemPageData>().set_panel_overdrive(-1);
ui.global::<SystemPageData>().set_boot_sound(-1);
ui.global::<SystemPageData>().set_mini_led_mode(-1);
ui.global::<SystemPageData>().set_ppt_pl1_spl(MINMAX);
ui.global::<SystemPageData>().set_ppt_pl2_sppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_fppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_apu_sppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_platform_sppt(MINMAX);
ui.global::<SystemPageData>().set_nv_dynamic_boost(MINMAX);
ui.global::<SystemPageData>().set_nv_temp_target(MINMAX);
let sys_props = platform.supported_properties().unwrap(); let sys_props = platform.supported_properties().unwrap();
log::debug!("Available system properties: {sys_props:?}"); log::debug!("Available system properties: {sys_props:?}");
let props = AvailableSystemProperties { if sys_props.contains(&Properties::ChargeControlEndThreshold) {
ac_command: true, ui.global::<SystemPageData>()
bat_command: true, .set_charge_control_end_threshold(60.0);
charge_control_end_threshold: sys_props.contains(&Properties::ChargeControlEndThreshold), }
disable_nvidia_powerd_on_battery: true, }
mini_led_mode: sys_props.contains(&Properties::MiniLedMode),
nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost),
nv_temp_target: sys_props.contains(&Properties::NvTempTarget),
panel_od: sys_props.contains(&Properties::PanelOd),
boot_sound: sys_props.contains(&Properties::PostAnimationSound),
ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt),
ppt_fppt: sys_props.contains(&Properties::PptFppt),
ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl),
ppt_pl2_sppt: sys_props.contains(&Properties::PptPl2Sppt),
ppt_platform_sppt: sys_props.contains(&Properties::PptPlatformSppt),
throttle_thermal_policy: sys_props.contains(&Properties::ThrottlePolicy),
};
ui.global::<SystemPageData>().set_available(props); macro_rules! convert_value {
(bool, $value:expr) => {
$value == 1
};
(i32, $value:expr) => {
$value as i32
};
(f32, $value:expr) => {
$value as f32
};
}
macro_rules! convert_to_dbus {
(bool, $value:expr) => {
if $value {
1
} else {
0
}
};
(i32, $value:expr) => {
$value as i32
};
(f32, $value:expr) => {
$value as i32
};
}
macro_rules! init_property {
($property:ident, $handle:expr, $value:expr, $type:tt) => {{
concat_idents!(setter = set_, $property {
$handle.global::<SystemPageData>().setter(convert_value!($type, $value));
});
}};
}
// For initial setup of min/max/val values
macro_rules! init_minmax_property {
($property:ident, $handle:expr, $attr:expr) => {
let proxy_copy = $attr.clone();
let handle_copy = $handle.as_weak();
tokio::spawn(async move {
let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap();
let val = proxy_copy.current_value().await.unwrap() as f32;
handle_copy
.upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property {
handle
.global::<SystemPageData>()
.setter(AttrMinMax { min, max, val });
});
})
.ok();
});
};
}
// For handling callbacks from UI value changes
macro_rules! setup_callback {
($property:ident, $handle:expr, $attr:expr, $type:tt) => {
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
concat_idents!(on_callback = on_cb_, $property {
$handle
.global::<SystemPageData>()
.on_callback(move |v| {
let handle_copy = handle_copy.clone();
let proxy_copy = proxy_copy.clone();
tokio::spawn(async move {
show_toast(
format!("{} successfully set to {}", stringify!($property), v).into(),
format!("Setting {} failed", stringify!($property)).into(),
handle_copy,
proxy_copy.set_current_value(convert_to_dbus!($type, v)).await,
);
});
});
});
};
}
macro_rules! setup_external {
($property:ident, $type:tt, $handle:expr, $attr:expr, $value:expr) => {{
// EXTERNAL CHANGES
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
concat_idents!(setter = set_, $property {
tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await;
use zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
dbg!(out);
handle_copy
.upgrade_in_event_loop(move |handle| {
handle
.global::<SystemPageData>()
.setter(convert_value!($type, out));
})
.ok();
}
}
});
});
}};
}
// For handling external value changes
macro_rules! setup_minmax_external {
($property:ident, $handle:expr, $attr:expr) => {
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await;
use zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
concat_idents!(getter = get_, $property {
handle_copy
.upgrade_in_event_loop(move |handle| {
let mut tmp: AttrMinMax =
handle.global::<SystemPageData>().getter();
tmp.val = out as f32;
concat_idents!(setter = set_, $property {
handle.global::<SystemPageData>().setter(tmp);
});
})
.ok();
});
}
}
});
};
}
// This macro expects are consistent naming between proxy calls and slint
// globals
#[macro_export]
macro_rules! set_ui_props_async {
($ui:ident, $proxy:ident, $global:ident, $proxy_fn:ident) => {
if let Ok(value) = $proxy.$proxy_fn().await {
$ui.upgrade_in_event_loop(move |handle| {
concat_idents::concat_idents!(set = set_, $proxy_fn {
handle.global::<$global>().set(value.into());
});
}).ok();
}
};
} }
pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>) { pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
@@ -46,6 +208,9 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
// Create the connections/proxies here to prevent future delays in process // Create the connections/proxies here to prevent future delays in process
let conn = zbus::Connection::system().await.unwrap(); let conn = zbus::Connection::system().await.unwrap();
let platform = PlatformProxy::new(&conn).await.unwrap(); let platform = PlatformProxy::new(&conn).await.unwrap();
let armoury_attrs = find_iface_async::<AsusArmouryProxy>("xyz.ljones.AsusArmoury")
.await
.unwrap();
set_ui_props_async!( set_ui_props_async!(
handle, handle,
@@ -74,169 +239,78 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
change_throttle_policy_on_ac change_throttle_policy_on_ac
); );
set_ui_props_async!(handle, platform, SystemPageData, panel_od); for attr in armoury_attrs {
set_ui_props_async!(handle, platform, SystemPageData, boot_sound); if let Ok(value) = attr.current_value().await {
set_ui_props_async!(handle, platform, SystemPageData, mini_led_mode); let name = attr.name().await.unwrap();
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl1_spl); handle
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl2_sppt); .upgrade_in_event_loop(move |handle| match name {
set_ui_props_async!(handle, platform, SystemPageData, ppt_fppt); FirmwareAttribute::ApuMem => {}
set_ui_props_async!(handle, platform, SystemPageData, ppt_apu_sppt); FirmwareAttribute::CoresPerformance => {}
set_ui_props_async!(handle, platform, SystemPageData, ppt_platform_sppt); FirmwareAttribute::CoresEfficiency => {}
set_ui_props_async!(handle, platform, SystemPageData, nv_dynamic_boost); FirmwareAttribute::PptPl1Spl => {
set_ui_props_async!(handle, platform, SystemPageData, nv_temp_target); init_minmax_property!(ppt_pl1_spl, handle, attr);
setup_callback!(ppt_pl1_spl, handle, attr, i32);
let sys_props = platform.supported_properties().await.unwrap(); setup_minmax_external!(ppt_pl1_spl, handle, attr);
log::debug!("Available system properties: {sys_props:?}"); }
let props = AvailableSystemProperties { FirmwareAttribute::PptPl2Sppt => {
ac_command: true, init_minmax_property!(ppt_pl2_sppt, handle, attr);
bat_command: true, setup_callback!(ppt_pl2_sppt, handle, attr, i32);
charge_control_end_threshold: sys_props setup_minmax_external!(ppt_pl2_sppt, handle, attr);
.contains(&Properties::ChargeControlEndThreshold), }
disable_nvidia_powerd_on_battery: true, FirmwareAttribute::PptApuSppt => {
mini_led_mode: sys_props.contains(&Properties::MiniLedMode), init_minmax_property!(ppt_apu_sppt, handle, attr);
nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost), setup_callback!(ppt_apu_sppt, handle, attr, i32);
nv_temp_target: sys_props.contains(&Properties::NvTempTarget), setup_minmax_external!(ppt_apu_sppt, handle, attr);
panel_od: sys_props.contains(&Properties::PanelOd), }
boot_sound: sys_props.contains(&Properties::PostAnimationSound), FirmwareAttribute::PptPlatformSppt => {
ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt), init_minmax_property!(ppt_platform_sppt, handle, attr);
ppt_fppt: sys_props.contains(&Properties::PptFppt), setup_callback!(ppt_platform_sppt, handle, attr, i32);
ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl), setup_minmax_external!(ppt_platform_sppt, handle, attr);
ppt_pl2_sppt: sys_props.contains(&Properties::PptPl2Sppt), }
ppt_platform_sppt: sys_props.contains(&Properties::PptPlatformSppt), FirmwareAttribute::PptFppt => {
throttle_thermal_policy: sys_props.contains(&Properties::ThrottlePolicy), init_minmax_property!(ppt_fppt, handle, attr);
}; setup_callback!(ppt_fppt, handle, attr, i32);
setup_minmax_external!(ppt_fppt, handle, attr);
// TODO: move the fail/sucess messages to slint }
handle FirmwareAttribute::NvDynamicBoost => {
.upgrade_in_event_loop(move |handle| { init_minmax_property!(nv_dynamic_boost, handle, attr);
handle.global::<SystemPageData>().set_available(props); setup_callback!(nv_dynamic_boost, handle, attr, i32);
setup_minmax_external!(nv_dynamic_boost, handle, attr);
set_ui_callbacks!(handle, }
SystemPageData(as f32), FirmwareAttribute::NvTempTarget => {
platform.charge_control_end_threshold(as u8), init_minmax_property!(nv_temp_target, handle, attr);
"Charge limit successfully set to {}", setup_callback!(nv_temp_target, handle, attr, i32);
"Setting Charge limit failed" setup_minmax_external!(nv_temp_target, handle, attr);
); }
set_ui_callbacks!( FirmwareAttribute::DgpuBaseTgp => {}
handle, FirmwareAttribute::DgpuTgp => {}
SystemPageData(), FirmwareAttribute::ChargeMode => {}
platform.panel_od(), FirmwareAttribute::BootSound => {
"Panel OverDrive successfully set to {}", init_property!(boot_sound, handle, value, i32);
"Setting Panel OverDrive failed" setup_callback!(boot_sound, handle, attr, i32);
); setup_external!(boot_sound, i32, handle, attr, value)
set_ui_callbacks!( }
handle, FirmwareAttribute::McuPowersave => {}
SystemPageData(), FirmwareAttribute::PanelOverdrive => {
platform.boot_sound(), init_property!(panel_overdrive, handle, value, i32);
"POST Animation sound successfully set to {}", setup_callback!(panel_overdrive, handle, attr, i32);
"Setting POST Animation sound failed" setup_external!(panel_overdrive, i32, handle, attr, value)
); }
set_ui_callbacks!( FirmwareAttribute::PanelHdMode => {}
handle, FirmwareAttribute::EgpuConnected => {}
SystemPageData(), FirmwareAttribute::EgpuEnable => {}
platform.mini_led_mode(), FirmwareAttribute::DgpuDisable => {}
"MiniLED mode successfully set to {}", FirmwareAttribute::GpuMuxMode => {}
"Setting MiniLED mode failed" FirmwareAttribute::MiniLedMode => {
); init_property!(mini_led_mode, handle, value, i32);
set_ui_callbacks!(handle, setup_callback!(mini_led_mode, handle, attr, i32);
SystemPageData(as i32), setup_external!(mini_led_mode, i32, handle, attr, value)
platform.throttle_thermal_policy(.into()), }
"Throttle policy set to {}", FirmwareAttribute::PendingReboot => {}
"Setting Throttle policy failed" FirmwareAttribute::None => {}
); })
.ok();
set_ui_callbacks!(handle, }
SystemPageData(as i32), }
platform.throttle_balanced_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_performance_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_quiet_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.throttle_policy_linked_epp(),
"Throttle policy linked to EPP: {}",
"Setting Throttle policy linked to EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_policy_on_ac(.into()),
"Throttle policy on AC set to {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform.change_throttle_policy_on_ac(.into()),
"Throttle policy on AC enabled: {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_policy_on_battery(.into()),
"Throttle policy on abttery set to {}",
"Setting Throttle policy on battery failed"
);
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform.change_throttle_policy_on_battery(.into()),
"Throttle policy on battery enabled: {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_pl1_spl(as u8),
"ppt_pl1_spl successfully set to {}",
"Setting ppt_pl1_spl failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_pl2_sppt(as u8),
"ppt_pl2_sppt successfully set to {}",
"Setting ppt_pl2_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_fppt(as u8),
"ppt_fppt successfully set to {}",
"Setting ppt_fppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_apu_sppt(as u8),
"ppt_apu_sppt successfully set to {}",
"Setting ppt_apu_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_platform_sppt(as u8),
"ppt_platform_sppt successfully set to {}",
"Setting ppt_platform_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.nv_temp_target(as u8),
"nv_temp_target successfully set to {}",
"Setting nv_temp_target failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.nv_dynamic_boost(as u8),
"nv_dynamic_boost successfully set to {}",
"Setting nv_dynamic_boost failed"
);
})
.unwrap();
}); });
} }

View File

@@ -1,68 +0,0 @@
use std::sync::{Arc, Mutex};
use zbus::zvariant::{OwnedValue, Type, Value};
use zbus::{interface, proxy};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Type, Value, OwnedValue)]
#[zvariant(signature = "u")]
pub enum AppState {
MainWindowOpen = 0,
/// If the app is running, open the main window
MainWindowShouldOpen = 1,
MainWindowClosed = 2,
StartingUp = 3,
QuitApp = 4,
LockFailed = 5,
}
pub struct ROGCCZbus {
state: Arc<Mutex<AppState>>,
}
impl ROGCCZbus {
pub fn new() -> Self {
Self {
state: Arc::new(Mutex::new(AppState::StartingUp)),
}
}
pub fn clone_state(&self) -> Arc<Mutex<AppState>> {
self.state.clone()
}
}
pub const ZBUS_PATH: &str = "/xyz/ljones/rogcc";
pub const ZBUS_IFACE: &str = "xyz.ljones.rogcc";
#[interface(name = "xyz.ljones.rogcc")]
impl ROGCCZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
async fn state(&self) -> AppState {
if let Ok(lock) = self.state.try_lock() {
return *lock;
}
AppState::LockFailed
}
#[zbus(property)]
async fn set_state(&self, state: AppState) {
if let Ok(mut lock) = self.state.try_lock() {
*lock = state;
}
}
}
#[proxy(
interface = "xyz.ljones.rogcc",
default_service = "xyz.ljones.rogcc",
default_path = "/xyz/ljones/rogcc"
)]
pub trait ROGCCZbus {
/// EnableDisplay property
#[zbus(property)]
fn state(&self) -> zbus::Result<AppState>;
#[zbus(property)]
fn set_state(&self, state: AppState) -> zbus::Result<()>;
}

View File

@@ -0,0 +1,150 @@
use std::sync::{Arc, Mutex};
use zbus::blocking::proxy::ProxyImpl;
use zbus::blocking::{fdo, Connection};
use zbus::zvariant::{OwnedValue, Type, Value};
use zbus::{interface, proxy};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Type, Value, OwnedValue)]
#[zvariant(signature = "u")]
pub enum AppState {
MainWindowOpen = 0,
/// If the app is running, open the main window
MainWindowShouldOpen = 1,
MainWindowClosed = 2,
StartingUp = 3,
QuitApp = 4,
LockFailed = 5
}
pub struct ROGCCZbus {
state: Arc<Mutex<AppState>>
}
impl ROGCCZbus {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self {
state: Arc::new(Mutex::new(AppState::StartingUp))
}
}
pub fn clone_state(&self) -> Arc<Mutex<AppState>> {
self.state.clone()
}
}
pub const ZBUS_PATH: &str = "/xyz/ljones/rogcc";
pub const ZBUS_IFACE: &str = "xyz.ljones.rogcc";
#[interface(name = "xyz.ljones.rogcc")]
impl ROGCCZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
async fn state(&self) -> AppState {
if let Ok(lock) = self.state.try_lock() {
return *lock;
}
AppState::LockFailed
}
#[zbus(property)]
async fn set_state(&self, state: AppState) {
if let Ok(mut lock) = self.state.try_lock() {
*lock = state;
}
}
}
#[proxy(
interface = "xyz.ljones.rogcc",
default_service = "xyz.ljones.rogcc",
default_path = "/xyz/ljones/rogcc"
)]
pub trait ROGCCZbus {
/// EnableDisplay property
#[zbus(property)]
fn state(&self) -> zbus::Result<AppState>;
#[zbus(property)]
fn set_state(&self, state: AppState) -> zbus::Result<()>;
}
pub fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>
{
let conn = Connection::system().unwrap();
let f = fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
let interfaces = f.get_managed_objects().unwrap();
let mut paths = Vec::new();
for v in interfaces.iter() {
// let o: Vec<zbus::names::OwnedInterfaceName> = v.1.keys().map(|e|
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
for k in v.1.keys() {
if k.as_str() == iface_name {
// println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone());
}
}
}
if paths.len() > 1 {
println!("Multiple asusd interfaces devices found");
}
if !paths.is_empty() {
let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(b));
for path in paths {
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("xyz.ljones.Asusd")?
.build()?
);
}
return Ok(ctrl);
}
Err("No Aura interface".into())
}
pub async fn find_iface_async<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where
T: zbus::proxy::ProxyImpl<'static> + From<zbus::Proxy<'static>>
{
let conn = zbus::Connection::system().await.unwrap();
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/")
.await
.unwrap();
let interfaces = f.get_managed_objects().await.unwrap();
let mut paths = Vec::new();
for v in interfaces.iter() {
// let o: Vec<zbus::names::OwnedInterfaceName> = v.1.keys().map(|e|
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
for k in v.1.keys() {
if k.as_str() == iface_name {
// println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone());
}
}
}
if paths.len() > 1 {
println!("Multiple asusd interfaces devices found");
}
if !paths.is_empty() {
let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(b));
for path in paths {
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("xyz.ljones.Asusd")?
.build()
.await?
);
}
return Ok(ctrl);
}
Err("No Aura interface".into())
}

View File

@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-12-24 22:29+0000\n" "POT-Creation-Date: 2025-01-12 04:36+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -12,157 +12,157 @@ msgstr ""
"Language: \n" "Language: \n"
"Plural-Forms: nplurals=1; plural=0;\n" "Plural-Forms: nplurals=1; plural=0;\n"
#: rog-control-center/ui/pages/system.slint:26 #: rog-control-center/ui/pages/system.slint:19
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Balanced" msgid "Balanced"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:26 rog-control-center/ui/pages/system.slint:30 #: rog-control-center/ui/pages/system.slint:19 rog-control-center/ui/pages/system.slint:23
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Performance" msgid "Performance"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:26 #: rog-control-center/ui/pages/system.slint:19
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Quiet" msgid "Quiet"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:29 #: rog-control-center/ui/pages/system.slint:22
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Default" msgid "Default"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:31 #: rog-control-center/ui/pages/system.slint:24
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "BalancePerformance" msgid "BalancePerformance"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:32 #: rog-control-center/ui/pages/system.slint:25
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "BalancePower" msgid "BalancePower"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:33 #: rog-control-center/ui/pages/system.slint:26
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Power" msgid "Power"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:110 #: rog-control-center/ui/pages/system.slint:122
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Base system settings" msgid "Power settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:115
msgctxt "PageSystem"
msgid "Charge limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:127 #: rog-control-center/ui/pages/system.slint:127
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy" msgid "Charge limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:137 #: rog-control-center/ui/pages/system.slint:139
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Advanced" msgid "Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:149 #: rog-control-center/ui/pages/system.slint:149
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Advanced"
msgstr ""
#: rog-control-center/ui/pages/system.slint:167
msgctxt "PageSystem"
msgid "Armoury settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:175
msgctxt "PageSystem"
msgid "Panel Overdrive" msgid "Panel Overdrive"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:157
msgctxt "PageSystem"
msgid "MiniLED Mode"
msgstr ""
#: rog-control-center/ui/pages/system.slint:165
msgctxt "PageSystem"
msgid "POST boot sound"
msgstr ""
#: rog-control-center/ui/pages/system.slint:183 #: rog-control-center/ui/pages/system.slint:183
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "System performance settings" msgid "MiniLED Mode"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:188 #: rog-control-center/ui/pages/system.slint:191
msgctxt "PageSystem"
msgid "POST boot sound"
msgstr ""
#: rog-control-center/ui/pages/system.slint:200
msgctxt "ppt_pl1_spl" msgctxt "ppt_pl1_spl"
msgid "PL1, sustained power limit" msgid "PL1, sustained power limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:198 #: rog-control-center/ui/pages/system.slint:211
msgctxt "ppt_pl2_sppt" msgctxt "ppt_pl2_sppt"
msgid "PL2, turbo power limit" msgid "PL2, turbo power limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:208 #: rog-control-center/ui/pages/system.slint:222
msgctxt "ppt_fppt" msgctxt "ppt_fppt"
msgid "FPPT, Fast Power Limit" msgid "FPPT, Fast Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:218 #: rog-control-center/ui/pages/system.slint:233
msgctxt "ppt_apu_sppt" msgctxt "ppt_apu_sppt"
msgid "SPPT, APU slow power limit" msgid "SPPT, APU slow power limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:228 #: rog-control-center/ui/pages/system.slint:244
msgctxt "ppt_platform_sppt" msgctxt "ppt_platform_sppt"
msgid "Slow package power tracking limit" msgid "Slow package power tracking limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:238 #: rog-control-center/ui/pages/system.slint:255
msgctxt "nv_dynamic_boost" msgctxt "nv_dynamic_boost"
msgid "dGPU boost overclock" msgid "dGPU boost overclock"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:248 #: rog-control-center/ui/pages/system.slint:266
msgctxt "nv_temp_target" msgctxt "nv_temp_target"
msgid "dGPU temperature max" msgid "dGPU temperature max"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:294 #: rog-control-center/ui/pages/system.slint:313
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Energy Performance Preference linked to Throttle Policy" msgid "Energy Performance Preference linked to Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:298 #: rog-control-center/ui/pages/system.slint:317
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Change EPP based on Throttle Policy" msgid "Change EPP based on Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:306 #: rog-control-center/ui/pages/system.slint:325
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Balanced Policy" msgid "EPP for Balanced Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:316 #: rog-control-center/ui/pages/system.slint:335
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Performance Policy" msgid "EPP for Performance Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:326 #: rog-control-center/ui/pages/system.slint:345
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Quiet Policy" msgid "EPP for Quiet Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:344 #: rog-control-center/ui/pages/system.slint:363
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy for power state" msgid "Throttle Policy for power state"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:350 #: rog-control-center/ui/pages/system.slint:369
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy on Battery" msgid "Throttle Policy on Battery"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:360 rog-control-center/ui/pages/system.slint:381 #: rog-control-center/ui/pages/system.slint:379 rog-control-center/ui/pages/system.slint:400
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Enabled" msgid "Enabled"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:371 #: rog-control-center/ui/pages/system.slint:390
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy on AC" msgid "Throttle Policy on AC"
msgstr "" msgstr ""

View File

@@ -1,6 +1,6 @@
import { Palette, Button, VerticalBox } from "std-widgets.slint"; import { Palette, Button, VerticalBox } from "std-widgets.slint";
import { AppSize } from "globals.slint"; import { AppSize } from "globals.slint";
import { PageSystem, AvailableSystemProperties, SystemPageData } from "pages/system.slint"; import { PageSystem, SystemPageData, AttrMinMax } from "pages/system.slint";
import { SideBar } from "widgets/sidebar.slint"; import { SideBar } from "widgets/sidebar.slint";
import { PageAbout } from "pages/about.slint"; import { PageAbout } from "pages/about.slint";
import { PageFans } from "pages/fans.slint"; import { PageFans } from "pages/fans.slint";
@@ -15,7 +15,7 @@ import { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones,
export { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect } export { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect }
import { PageAppSettings, AppSettingsPageData } from "pages/app_settings.slint"; import { PageAppSettings, AppSettingsPageData } from "pages/app_settings.slint";
export { AppSize, AvailableSystemProperties, SystemPageData, AnimePageData, AppSettingsPageData } export { AppSize, AttrMinMax, SystemPageData, AnimePageData, AppSettingsPageData }
export component MainWindow inherits Window { export component MainWindow inherits Window {
title: "ROG Control"; title: "ROG Control";
@@ -134,7 +134,8 @@ export component MainWindow inherits Window {
y: 0px; y: 0px;
width: root.width; width: root.width;
height: 32px; height: 32px;
opacity: 0.8; opacity: 1.0;
background: Colors.grey;
TouchArea { TouchArea {
height: 100%; height: 100%;
width: 100%; width: 100%;

View File

@@ -1,30 +1,23 @@
import { SystemSlider, SystemDropdown, SystemToggle } from "../widgets/common.slint"; import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint";
import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox} from "std-widgets.slint"; import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox} from "std-widgets.slint";
export struct AvailableSystemProperties { export struct AttrMinMax {
charge_control_end_threshold: bool, min: int,
panel_od: bool, max: int,
boot_sound: bool, val: float,
mini_led_mode: bool, }
disable_nvidia_powerd_on_battery: bool,
ac_command: bool, export struct AttrPossible {
bat_command: bool, range: [int],
throttle_thermal_policy: bool, val: int,
ppt_pl1_spl: bool,
ppt_pl2_sppt: bool,
ppt_fppt: bool,
ppt_apu_sppt: bool,
ppt_platform_sppt: bool,
nv_dynamic_boost: bool,
nv_temp_target: bool,
} }
export global SystemPageData { export global SystemPageData {
in-out property <float> charge_control_end_threshold: 30; in-out property <float> charge_control_end_threshold: 30;
callback set_charge_control_end_threshold(/* charge limit */ int); callback cb_charge_control_end_threshold(/* charge limit */ int);
in-out property <int> throttle_thermal_policy: 0; in-out property <int> throttle_thermal_policy: 0;
in-out property <[string]> throttle_policy_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")]; in-out property <[string]> throttle_policy_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")];
callback set_throttle_thermal_policy(int); callback cb_throttle_thermal_policy(int);
in-out property <[string]> energy_performance_choices: [ in-out property <[string]> energy_performance_choices: [
@tr("Default"), @tr("Default"),
@tr("Performance"), @tr("Performance"),
@@ -33,59 +26,78 @@ export global SystemPageData {
@tr("Power") @tr("Power")
]; ];
in-out property <int> throttle_balanced_epp: 0; in-out property <int> throttle_balanced_epp: 0;
callback set_throttle_balanced_epp(int); callback cb_throttle_balanced_epp(int);
in-out property <int> throttle_performance_epp: 0; in-out property <int> throttle_performance_epp: 0;
callback set_throttle_performance_epp(int); callback cb_throttle_performance_epp(int);
in-out property <int> throttle_quiet_epp: 0; in-out property <int> throttle_quiet_epp: 0;
callback set_throttle_quiet_epp(int); callback cb_throttle_quiet_epp(int);
// if the EPP should change with throttle // if the EPP should change with throttle
in-out property <bool> throttle_policy_linked_epp: true; in-out property <bool> throttle_policy_linked_epp: true;
callback set_throttle_policy_linked_epp(bool); callback cb_throttle_policy_linked_epp(bool);
in-out property <int> throttle_policy_on_ac: 0; in-out property <int> throttle_policy_on_ac: 0;
callback set_throttle_policy_on_ac(int); callback cb_throttle_policy_on_ac(int);
in-out property <bool> change_throttle_policy_on_ac: true; in-out property <bool> change_throttle_policy_on_ac: true;
callback set_change_throttle_policy_on_ac(bool); callback cb_change_throttle_policy_on_ac(bool);
in-out property <int> throttle_policy_on_battery: 0; in-out property <int> throttle_policy_on_battery: 0;
callback set_throttle_policy_on_battery(int); callback cb_throttle_policy_on_battery(int);
in-out property <bool> change_throttle_policy_on_battery: true; in-out property <bool> change_throttle_policy_on_battery: true;
callback set_change_throttle_policy_on_battery(bool); callback cb_change_throttle_policy_on_battery(bool);
in-out property <bool> panel_od; //
callback set_panel_od(bool); in-out property <int> panel_overdrive;
in-out property <bool> boot_sound; callback cb_panel_overdrive(int);
callback set_boot_sound(bool); in-out property <int> boot_sound;
in-out property <bool> mini_led_mode; callback cb_boot_sound(int);
callback set_mini_led_mode(bool); in-out property <int> mini_led_mode;
in-out property <float> ppt_pl1_spl: 5; callback cb_mini_led_mode(int);
callback set_ppt_pl1_spl(int);
in-out property <float> ppt_pl2_sppt: 5; in-out property <AttrMinMax> ppt_pl1_spl: {
callback set_ppt_pl2_sppt(int); min: 0,
in-out property <float> ppt_fppt: 5; max: 100,
callback set_ppt_fppt(int); val: 20,
in-out property <float> ppt_apu_sppt: 5;
callback set_ppt_apu_sppt(int);
in-out property <float> ppt_platform_sppt: 5;
callback set_ppt_platform_sppt(int);
in-out property <float> nv_dynamic_boost: 5;
callback set_nv_dynamic_boost(int);
in-out property <float> nv_temp_target: 75;
callback set_nv_temp_target(int);
in-out property <AvailableSystemProperties> available: {
charge_control_end_threshold: true,
panel_od: true,
boot_sound: true,
mini_led_mode: true,
disable_nvidia_powerd_on_battery: true,
ac_command: true,
bat_command: true,
throttle_thermal_policy: true,
ppt_pl1_spl: true,
ppt_pl2_sppt: true,
ppt_fppt: true,
ppt_apu_sppt: true,
ppt_platform_sppt: true,
nv_dynamic_boost: true,
nv_temp_target: true,
}; };
callback cb_ppt_pl1_spl(int);
in-out property <AttrMinMax> ppt_pl2_sppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_pl2_sppt(int);
in-out property <AttrMinMax> ppt_fppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_fppt(int);
in-out property <AttrMinMax> ppt_apu_sppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_apu_sppt(int);
in-out property <AttrMinMax> ppt_platform_sppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_platform_sppt(int);
in-out property <AttrMinMax> nv_dynamic_boost: {
min: 0,
max: 30,
val: 5,
};
callback cb_nv_dynamic_boost(int);
in-out property <AttrMinMax> nv_temp_target: {
min: 0,
max: 80,
val: 75,
};
callback cb_nv_temp_target(int);
} }
export component PageSystem inherits Rectangle { export component PageSystem inherits Rectangle {
@@ -107,21 +119,21 @@ export component PageSystem inherits Rectangle {
font-size: 18px; font-size: 18px;
color: Palette.control-foreground; color: Palette.control-foreground;
horizontal-alignment: TextHorizontalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("Base system settings"); text: @tr("Power settings");
} }
} }
if SystemPageData.available.charge-control-end-threshold: SystemSlider { if SystemPageData.charge_control_end_threshold != -1: SystemSlider {
text: @tr("Charge limit"); text: @tr("Charge limit");
minimum: 20; minimum: 20;
maximum: 100; maximum: 100;
value <=> SystemPageData.charge_control_end_threshold; value <=> SystemPageData.charge_control_end_threshold;
released => { released => {
SystemPageData.set_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold)) SystemPageData.cb_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold))
} }
} }
if SystemPageData.available.throttle-thermal-policy: HorizontalLayout { if SystemPageData.throttle_thermal_policy != -1: HorizontalLayout {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy"); text: @tr("Throttle Policy");
@@ -129,7 +141,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy]; current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.throttle_policy_choices;
selected => { selected => {
SystemPageData.set_throttle_thermal_policy(SystemPageData.throttle_thermal_policy) SystemPageData.cb_throttle_thermal_policy(SystemPageData.throttle_thermal_policy)
} }
} }
@@ -142,34 +154,6 @@ export component PageSystem inherits Rectangle {
} }
} }
HorizontalBox {
padding: 0px;
spacing: 10px;
if SystemPageData.available.panel-od: SystemToggle {
text: @tr("Panel Overdrive");
checked <=> SystemPageData.panel_od;
toggled => {
SystemPageData.set_panel_od(SystemPageData.panel_od)
}
}
if SystemPageData.available.mini-led-mode: SystemToggle {
text: @tr("MiniLED Mode");
checked <=> SystemPageData.mini_led_mode;
toggled => {
SystemPageData.set_mini_led_mode(SystemPageData.mini_led_mode)
}
}
if SystemPageData.available.boot-sound: SystemToggle {
text: @tr("POST boot sound");
checked <=> SystemPageData.boot_sound;
toggled => {
SystemPageData.set_boot_sound(SystemPageData.boot_sound)
}
}
}
Rectangle { Rectangle {
background: Palette.alternate-background; background: Palette.alternate-background;
border-color: Palette.accent-background; border-color: Palette.accent-background;
@@ -180,77 +164,112 @@ export component PageSystem inherits Rectangle {
font-size: 18px; font-size: 18px;
color: Palette.control-foreground; color: Palette.control-foreground;
horizontal-alignment: TextHorizontalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("System performance settings"); text: @tr("Armoury settings");
} }
} }
if SystemPageData.available.ppt-pl1-spl: SystemSlider { HorizontalBox {
padding: 0px;
spacing: 10px;
if SystemPageData.panel_overdrive != -1: SystemToggleInt {
text: @tr("Panel Overdrive");
checked_int <=> SystemPageData.panel_overdrive;
toggled => {
SystemPageData.cb_panel_overdrive(SystemPageData.panel_overdrive)
}
}
if SystemPageData.mini_led_mode != -1: SystemToggleInt {
text: @tr("MiniLED Mode");
checked_int <=> SystemPageData.mini_led_mode;
toggled => {
SystemPageData.cb_mini_led_mode(SystemPageData.mini_led_mode)
}
}
if SystemPageData.boot_sound != -1: SystemToggleInt {
text: @tr("POST boot sound");
checked_int <=> SystemPageData.boot_sound;
toggled => {
SystemPageData.cb_boot_sound(SystemPageData.boot_sound)
}
}
}
if SystemPageData.ppt_pl1_spl.val != -1: SystemSlider {
text: @tr("ppt_pl1_spl" => "PL1, sustained power limit"); text: @tr("ppt_pl1_spl" => "PL1, sustained power limit");
minimum: 5; minimum: SystemPageData.ppt_pl1_spl.min;
maximum: 250; maximum: SystemPageData.ppt_pl1_spl.max;
value <=> SystemPageData.ppt_pl1_spl; value: SystemPageData.ppt_pl1_spl.val;
released => { released => {
SystemPageData.set_ppt_pl1_spl(Math.round(SystemPageData.ppt_pl1_spl)) SystemPageData.ppt_pl1_spl.val = self.value;
SystemPageData.cb_ppt_pl1_spl(Math.round(self.value))
} }
} }
if SystemPageData.available.ppt-pl2-sppt: SystemSlider { if SystemPageData.ppt_pl2_sppt.val != -1: SystemSlider {
text: @tr("ppt_pl2_sppt" => "PL2, turbo power limit"); text: @tr("ppt_pl2_sppt" => "PL2, turbo power limit");
minimum: 5; minimum: SystemPageData.ppt_pl2_sppt.min;
maximum: 250; maximum: SystemPageData.ppt_pl2_sppt.max;
value <=> SystemPageData.ppt_pl2_sppt; value: SystemPageData.ppt_pl2_sppt.val;
released => { released => {
SystemPageData.set_ppt_pl2_sppt(Math.round(SystemPageData.ppt_pl2_sppt)) SystemPageData.ppt_pl2_sppt.val = self.value;
SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value))
} }
} }
if SystemPageData.available.ppt-fppt: SystemSlider { if SystemPageData.ppt_fppt.val != -1: SystemSlider {
text: @tr("ppt_fppt" => "FPPT, Fast Power Limit"); text: @tr("ppt_fppt" => "FPPT, Fast Power Limit");
minimum: 5; minimum: SystemPageData.ppt_fppt.min;
maximum: 250; maximum: SystemPageData.ppt_fppt.max;
value <=> SystemPageData.ppt_fppt; value: SystemPageData.ppt_fppt.val;
released => { released => {
SystemPageData.set_ppt_fppt(Math.round(SystemPageData.ppt_fppt)) SystemPageData.ppt_fppt.val = self.value;
SystemPageData.cb_ppt_fppt(Math.round(self.value))
} }
} }
if SystemPageData.available.ppt-apu-sppt: SystemSlider { if SystemPageData.ppt_apu_sppt.val != -1: SystemSlider {
text: @tr("ppt_apu_sppt" => "SPPT, APU slow power limit"); text: @tr("ppt_apu_sppt" => "SPPT, APU slow power limit");
minimum: 5; minimum: SystemPageData.ppt_apu_sppt.min;
maximum: 130; maximum: SystemPageData.ppt_apu_sppt.max;
value <=> SystemPageData.ppt_apu_sppt; value: SystemPageData.ppt_apu_sppt.val;
released => { released => {
SystemPageData.set_ppt_apu_sppt(Math.round(SystemPageData.ppt_apu_sppt)) SystemPageData.ppt_apu_sppt.val = self.value;
SystemPageData.cb_ppt_apu_sppt(Math.round(self.value))
} }
} }
if SystemPageData.available.ppt-platform-sppt: SystemSlider { if SystemPageData.ppt_platform_sppt.val != -1: SystemSlider {
text: @tr("ppt_platform_sppt" => "Slow package power tracking limit"); text: @tr("ppt_platform_sppt" => "Slow package power tracking limit");
maximum: 130; minimum: SystemPageData.ppt_platform_sppt.min;
minimum: 5; maximum: SystemPageData.ppt_platform_sppt.max;
value <=> SystemPageData.ppt_platform_sppt; value: SystemPageData.ppt_platform_sppt.val;
released => { released => {
SystemPageData.set_ppt_platform_sppt(Math.round(SystemPageData.ppt_platform_sppt)) SystemPageData.ppt_platform_sppt.val = self.value;
SystemPageData.cb_ppt_platform_sppt(Math.round(self.value))
} }
} }
if SystemPageData.available.nv-dynamic-boost: SystemSlider { if SystemPageData.nv_dynamic_boost.val != -1: SystemSlider {
text: @tr("nv_dynamic_boost" => "dGPU boost overclock"); text: @tr("nv_dynamic_boost" => "dGPU boost overclock");
minimum: 5; minimum: SystemPageData.nv_dynamic_boost.min;
maximum: 25; maximum: SystemPageData.nv_dynamic_boost.max;
value <=> SystemPageData.nv_dynamic_boost; value: SystemPageData.nv_dynamic_boost.val;
released => { released => {
SystemPageData.set_nv_dynamic_boost(Math.round(SystemPageData.nv_dynamic_boost)) SystemPageData.nv_dynamic_boost.val = self.value;
SystemPageData.cb_nv_dynamic_boost(Math.round(self.value))
} }
} }
if SystemPageData.available.nv-temp-target: SystemSlider { if SystemPageData.nv_temp_target.val != -1: SystemSlider {
text: @tr("nv_temp_target" => "dGPU temperature max"); text: @tr("nv_temp_target" => "dGPU temperature max");
minimum: 75; minimum: SystemPageData.nv_temp_target.min;
maximum: 87; maximum: SystemPageData.nv_temp_target.max;
value <=> SystemPageData.nv_temp_target; value: SystemPageData.nv_temp_target.val;
released => { released => {
SystemPageData.set_nv_temp_target(Math.round(SystemPageData.nv_temp_target)) SystemPageData.nv_temp_target.val = self.value;
SystemPageData.cb_nv_temp_target(Math.round(self.value))
} }
} }
} }
@@ -298,7 +317,7 @@ export component PageSystem inherits Rectangle {
text: @tr("Change EPP based on Throttle Policy"); text: @tr("Change EPP based on Throttle Policy");
checked <=> SystemPageData.throttle_policy_linked_epp; checked <=> SystemPageData.throttle_policy_linked_epp;
toggled => { toggled => {
SystemPageData.set_throttle_policy_linked_epp(SystemPageData.throttle_policy_linked_epp) SystemPageData.cb_throttle_policy_linked_epp(SystemPageData.throttle_policy_linked_epp)
} }
} }
@@ -308,7 +327,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_balanced_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_balanced_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.set_throttle_balanced_epp(SystemPageData.throttle_balanced_epp) SystemPageData.cb_throttle_balanced_epp(SystemPageData.throttle_balanced_epp)
} }
} }
@@ -318,7 +337,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_performance_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_performance_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.set_throttle_performance_epp(SystemPageData.throttle_performance_epp) SystemPageData.cb_throttle_performance_epp(SystemPageData.throttle_performance_epp)
} }
} }
@@ -328,7 +347,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_quiet_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_quiet_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.set_throttle_quiet_epp(SystemPageData.throttle_quiet_epp) SystemPageData.cb_throttle_quiet_epp(SystemPageData.throttle_quiet_epp)
} }
} }
} }
@@ -352,7 +371,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_battery]; current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_battery];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.throttle_policy_choices;
selected => { selected => {
SystemPageData.set_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery) SystemPageData.cb_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery)
} }
} }
@@ -360,7 +379,7 @@ export component PageSystem inherits Rectangle {
text: @tr("Enabled"); text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_battery; checked <=> SystemPageData.change_throttle_policy_on_battery;
toggled => { toggled => {
SystemPageData.set_change_throttle_policy_on_battery(SystemPageData.change_throttle_policy_on_battery); SystemPageData.cb_change_throttle_policy_on_battery(SystemPageData.change_throttle_policy_on_battery);
} }
} }
} }
@@ -373,7 +392,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_ac]; current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_ac];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.throttle_policy_choices;
selected => { selected => {
SystemPageData.set_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac) SystemPageData.cb_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac)
} }
} }
@@ -381,7 +400,7 @@ export component PageSystem inherits Rectangle {
text: @tr("Enabled"); text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_ac; checked <=> SystemPageData.change_throttle_policy_on_ac;
toggled => { toggled => {
SystemPageData.set_change_throttle_policy_on_ac(SystemPageData.change_throttle_policy_on_ac); SystemPageData.cb_change_throttle_policy_on_ac(SystemPageData.change_throttle_policy_on_ac);
} }
} }
} }

View File

@@ -15,30 +15,42 @@ export component SystemSlider inherits RogItem {
in-out property <float> minimum; in-out property <float> minimum;
in-out property <float> maximum; in-out property <float> maximum;
callback released(int); callback released(int);
HorizontalLayout { HorizontalLayout {
HorizontalLayout { HorizontalLayout {
width: 50%; width: 50%;
alignment: LayoutAlignment.space-between; alignment: LayoutAlignment.stretch;
padding-left: 10px; padding-left: 10px;
Text { TouchArea {
font-size: 16px; clicked => {
vertical-alignment: TextVerticalAlignment.center; slider.value += 1;
color: Palette.control-foreground; if slider.value > slider.maximum {
text <=> root.text; slider.value = slider.minimum;
} }
}
Text { HorizontalLayout {
font-size: 16px; spacing: 6px;
vertical-alignment: TextVerticalAlignment.center; Text {
color: Palette.control-foreground; font-size: 16px;
text: "\{Math.round(root.value)}"; vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
Text {
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.right;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text: "\{Math.round(root.value)}";
}
}
} }
} }
HorizontalBox { HorizontalBox {
// alignment: LayoutAlignment.end; // alignment: LayoutAlignment.end;
padding-right: 20px; padding-right: 20px;
Slider { slider := Slider {
maximum: root.maximum; maximum: root.maximum;
minimum: root.minimum; minimum: root.minimum;
value <=> root.value; value <=> root.value;
@@ -80,6 +92,38 @@ export component SystemToggle inherits RogItem {
} }
} }
export component SystemToggleInt inherits RogItem {
in property <string> text;
// in-out property <bool> checked;
in-out property <int> checked_int;
callback toggled(int);
HorizontalLayout {
spacing: 6px;
HorizontalLayout {
alignment: LayoutAlignment.start;
padding-left: 10px;
Text {
font-size: 16px;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
}
HorizontalLayout {
alignment: LayoutAlignment.end;
padding-right: 20px;
Switch {
checked: root.checked_int != 0;
toggled => {
root.checked_int = self.checked ? 1 : 0;
root.toggled(root.checked_int);
}
}
}
}
}
export component SystemToggleVert inherits RogItem { export component SystemToggleVert inherits RogItem {
in property <string> text; in property <string> text;
in-out property <bool> checked; in-out property <bool> checked;

Some files were not shown because too many files have changed in this diff Show More