mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Clippy run
This commit is contained in:
@@ -9,7 +9,9 @@ stages:
|
|||||||
|
|
||||||
test:
|
test:
|
||||||
script:
|
script:
|
||||||
- cargo check #+nightly check --features "clippy"
|
- rustup component add clippy
|
||||||
|
- cargo check
|
||||||
|
- cargo clippy
|
||||||
- cargo test
|
- cargo test
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
|||||||
34
Cargo.lock
generated
34
Cargo.lock
generated
@@ -86,7 +86,7 @@ dependencies = [
|
|||||||
"rog_profiles",
|
"rog_profiles",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"smol",
|
"smol",
|
||||||
"zbus 3.1.0",
|
"zbus 3.2.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -584,7 +584,7 @@ dependencies = [
|
|||||||
"sysfs-class",
|
"sysfs-class",
|
||||||
"tokio",
|
"tokio",
|
||||||
"toml",
|
"toml",
|
||||||
"zbus 3.1.0",
|
"zbus 3.2.0",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -601,7 +601,7 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"smol",
|
"smol",
|
||||||
"zbus 3.1.0",
|
"zbus 3.2.0",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
"zvariant_derive",
|
"zvariant_derive",
|
||||||
]
|
]
|
||||||
@@ -1394,7 +1394,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "1c2bd5667a34b046e66f21ac2c016b1f4b41318423f9282b4e04f755ad947817"
|
checksum = "1c2bd5667a34b046e66f21ac2c016b1f4b41318423f9282b4e04f755ad947817"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"zbus 3.1.0",
|
"zbus 3.2.0",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2032,7 +2032,7 @@ dependencies = [
|
|||||||
"smol",
|
"smol",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"toml",
|
"toml",
|
||||||
"zbus 3.1.0",
|
"zbus 3.2.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2047,7 +2047,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"sysfs-class",
|
"sysfs-class",
|
||||||
"zbus 3.1.0",
|
"zbus 3.2.0",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2070,8 +2070,8 @@ dependencies = [
|
|||||||
"rog_aura",
|
"rog_aura",
|
||||||
"rog_platform",
|
"rog_platform",
|
||||||
"rog_profiles",
|
"rog_profiles",
|
||||||
"zbus 3.1.0",
|
"zbus 3.2.0",
|
||||||
"zbus_macros 2.3.2",
|
"zbus_macros 3.2.0",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3148,9 +3148,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zbus"
|
name = "zbus"
|
||||||
version = "3.1.0"
|
version = "3.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d37e0d34b881934b987b72a91fdc1daba9ebc90c1f91b7944c680991c4443fc6"
|
checksum = "be2db10dd0354816a3615c72deff837f983d5c8ad9a0312727d0f89a5a9e9145"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-broadcast",
|
"async-broadcast",
|
||||||
"async-channel",
|
"async-channel",
|
||||||
@@ -3180,7 +3180,7 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
"uds_windows",
|
"uds_windows",
|
||||||
"winapi",
|
"winapi",
|
||||||
"zbus_macros 3.1.0",
|
"zbus_macros 3.2.0",
|
||||||
"zbus_names",
|
"zbus_names",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
]
|
]
|
||||||
@@ -3200,9 +3200,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zbus_macros"
|
name = "zbus_macros"
|
||||||
version = "3.1.0"
|
version = "3.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ba7905f7c665ea41828bd69112902daa131191a85131fef0f60f7cc3bc2fbec4"
|
checksum = "7d03f1a5fb482cc0d97f3d3de9fe2e942f436a635a5fb6c12c9f03f21eb03075"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -3224,9 +3224,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zvariant"
|
name = "zvariant"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1bd68e4e6432ef19df47d7e90e2e72b5e7e3d778e0ae3baddf12b951265cc758"
|
checksum = "a7b1e052202eb9cc010ad11f556edc81508e1dd08e215188c236c81cd169d83d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"enumflags2",
|
"enumflags2",
|
||||||
@@ -3238,9 +3238,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zvariant_derive"
|
name = "zvariant_derive"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08e977eaa3af652f63d479ce50d924254ad76722a6289ec1a1eac3231ca30430"
|
checksum = "63331f3cf9f98b3bfbc1410ef55ec07f966beea5c0c8797c7003511c0642a2aa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ concat-idents = "1.1.3"
|
|||||||
dirs = "^4.0"
|
dirs = "^4.0"
|
||||||
smol = "^1.2"
|
smol = "^1.2"
|
||||||
|
|
||||||
zbus = "^3.1.0"
|
zbus = "^3.2"
|
||||||
zbus_macros = "^2.0"
|
zbus_macros = "^3.2"
|
||||||
zvariant = "^3.2"
|
zvariant = "^3.2"
|
||||||
zvariant_derive = "^3.2"
|
zvariant_derive = "^3.2"
|
||||||
logind-zbus = { version = "^3.0" } #, default-features = false, features = ["non_blocking"] }
|
logind-zbus = { version = "^3.0" } #, default-features = false, features = ["non_blocking"] }
|
||||||
|
|||||||
5
Makefile
5
Makefile
@@ -114,5 +114,10 @@ ifeq ($(VENDORED),1)
|
|||||||
tar pxf vendor_asusctl_$(VERSION).tar.xz
|
tar pxf vendor_asusctl_$(VERSION).tar.xz
|
||||||
endif
|
endif
|
||||||
cargo build $(ARGS)
|
cargo build $(ARGS)
|
||||||
|
strip -s ./target/release/$(BIN_C)
|
||||||
|
strip -s ./target/release/$(BIN_D)
|
||||||
|
strip -s ./target/release/$(BIN_U)
|
||||||
|
strip -s ./target/release/$(BIN_N)
|
||||||
|
strip -s ./target/release/$(BIN_ROG)
|
||||||
|
|
||||||
.PHONY: all clean distclean install uninstall update build
|
.PHONY: all clean distclean install uninstall update build
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
p.for_each(|e| {
|
p.for_each(|e| {
|
||||||
if let Ok(out) = e.args() {
|
if let Ok(out) = e.args() {
|
||||||
if let Ok(ref mut lock) = x.try_lock() {
|
if let Ok(ref mut lock) = x.try_lock() {
|
||||||
notify!(do_post_sound_notif, lock, &out.on());
|
notify!(do_post_sound_notif, lock, out.on());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
future::ready(())
|
future::ready(())
|
||||||
|
|||||||
@@ -29,23 +29,22 @@ mod profiles_cli;
|
|||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let args: Vec<String> = args().skip(1).collect();
|
let args: Vec<String> = args().skip(1).collect();
|
||||||
|
|
||||||
let parsed: CliStart;
|
|
||||||
let missing_argument_k = gumdrop::Error::missing_argument(Opt::Short('k'));
|
let missing_argument_k = gumdrop::Error::missing_argument(Opt::Short('k'));
|
||||||
match CliStart::parse_args_default(&args) {
|
let parsed = match CliStart::parse_args_default(&args) {
|
||||||
Ok(p) => {
|
Ok(p) => {
|
||||||
parsed = p;
|
p
|
||||||
}
|
}
|
||||||
Err(err) if err.to_string() == missing_argument_k.to_string() => {
|
Err(err) if err.to_string() == missing_argument_k.to_string() => {
|
||||||
parsed = CliStart {
|
CliStart {
|
||||||
kbd_bright: Some(LedBrightness::new(None)),
|
kbd_bright: Some(LedBrightness::new(None)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("source {}", err);
|
eprintln!("source {}", err);
|
||||||
std::process::exit(2);
|
std::process::exit(2);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
let (dbus, _) = RogDbusClientBlocking::new()
|
let (dbus, _) = RogDbusClientBlocking::new()
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
@@ -376,7 +375,7 @@ fn handle_anime(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn verify_brightness(brightness: f32) {
|
fn verify_brightness(brightness: f32) {
|
||||||
if brightness < 0.0 || brightness > 1.0 {
|
if !(0.0..=1.0).contains(&brightness) {
|
||||||
println!(
|
println!(
|
||||||
"Image and global brightness must be between 0.0 and 1.0 (inclusive), was {}",
|
"Image and global brightness must be between 0.0 and 1.0 (inclusive), was {}",
|
||||||
brightness
|
brightness
|
||||||
@@ -474,7 +473,7 @@ fn handle_led_power1(
|
|||||||
}
|
}
|
||||||
|
|
||||||
println!("These options are for keyboards of product ID 0x1866 or TUF only");
|
println!("These options are for keyboards of product ID 0x1866 or TUF only");
|
||||||
return Ok(());
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_led_power_1_do_1866(
|
fn handle_led_power_1_do_1866(
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
println!("{BOARD_NAME}, {e}");
|
println!("{BOARD_NAME}, {e}");
|
||||||
})
|
})
|
||||||
.unwrap_or(KeyLayout::ga401_layout());
|
.unwrap_or_else(|_| KeyLayout::ga401_layout());
|
||||||
|
|
||||||
executor
|
executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ pub trait ConfigLoadSave<T: DeserializeOwned + serde::Serialize> {
|
|||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
create_dir(path.clone())?;
|
create_dir(path.clone())?;
|
||||||
}
|
}
|
||||||
let name = self.name().clone();
|
let name = self.name();
|
||||||
path.push(name + ".cfg");
|
path.push(name + ".cfg");
|
||||||
|
|
||||||
let mut file = OpenOptions::new()
|
let mut file = OpenOptions::new()
|
||||||
@@ -230,7 +230,7 @@ impl Default for UserAuraConfig {
|
|||||||
80,
|
80,
|
||||||
40,
|
40,
|
||||||
));
|
));
|
||||||
seq.push(key.clone());
|
seq.push(key);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
name: "default".to_string(),
|
name: "default".to_string(),
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ impl CtrlAnime {
|
|||||||
.ok();
|
.ok();
|
||||||
false // Don't exit yet
|
false // Don't exit yet
|
||||||
})
|
})
|
||||||
.map(|r| Ok(r))
|
.map(Ok)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
warn!("rog_anime::run_animation:callback failed");
|
warn!("rog_anime::run_animation:callback failed");
|
||||||
Err(AnimeError::NoFrames)
|
Err(AnimeError::NoFrames)
|
||||||
|
|||||||
@@ -123,14 +123,14 @@ impl CtrlAnimeZbus {
|
|||||||
#[dbus_interface(property)]
|
#[dbus_interface(property)]
|
||||||
async fn awake_enabled(&self) -> bool {
|
async fn awake_enabled(&self) -> bool {
|
||||||
let lock = self.0.lock().await;
|
let lock = self.0.lock().await;
|
||||||
return lock.config.awake_enabled;
|
lock.config.awake_enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the status of if factory system-status animations are enabled
|
/// Get the status of if factory system-status animations are enabled
|
||||||
#[dbus_interface(property)]
|
#[dbus_interface(property)]
|
||||||
async fn boot_enabled(&self) -> bool {
|
async fn boot_enabled(&self) -> bool {
|
||||||
let lock = self.0.lock().await;
|
let lock = self.0.lock().await;
|
||||||
return lock.config.boot_anim_enabled;
|
lock.config.boot_anim_enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Notify listeners of the status of AniMe LED power and factory system-status animations
|
/// Notify listeners of the status of AniMe LED power and factory system-status animations
|
||||||
@@ -152,10 +152,10 @@ impl crate::CtrlTask for CtrlAnimeZbus {
|
|||||||
|start: bool, lock: MutexGuard<CtrlAnime>, inner: Arc<Mutex<CtrlAnime>>| {
|
|start: bool, lock: MutexGuard<CtrlAnime>, inner: Arc<Mutex<CtrlAnime>>| {
|
||||||
if start {
|
if start {
|
||||||
info!("CtrlAnimeTask running sleep animation");
|
info!("CtrlAnimeTask running sleep animation");
|
||||||
CtrlAnime::run_thread(inner.clone(), lock.cache.shutdown.clone(), true);
|
CtrlAnime::run_thread(inner, lock.cache.shutdown.clone(), true);
|
||||||
} else {
|
} else {
|
||||||
info!("CtrlAnimeTask running wake animation");
|
info!("CtrlAnimeTask running wake animation");
|
||||||
CtrlAnime::run_thread(inner.clone(), lock.cache.wake.clone(), true);
|
CtrlAnime::run_thread(inner, lock.cache.wake.clone(), true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ impl AuraPowerConfig {
|
|||||||
match control {
|
match control {
|
||||||
AuraPowerConfig::AuraDevTuf(_) => [0, 0, 0],
|
AuraPowerConfig::AuraDevTuf(_) => [0, 0, 0],
|
||||||
AuraPowerConfig::AuraDev1866(c) => {
|
AuraPowerConfig::AuraDev1866(c) => {
|
||||||
let c: Vec<AuraDev1866> = c.iter().map(|v| *v).collect();
|
let c: Vec<AuraDev1866> = c.iter().copied().collect();
|
||||||
AuraDev1866::to_bytes(&c)
|
AuraDev1866::to_bytes(&c)
|
||||||
}
|
}
|
||||||
AuraPowerConfig::AuraDev19b6(c) => {
|
AuraPowerConfig::AuraDev19b6(c) => {
|
||||||
let c: Vec<AuraDev19b6> = c.iter().map(|v| *v).collect();
|
let c: Vec<AuraDev19b6> = c.iter().copied().collect();
|
||||||
AuraDev19b6::to_bytes(&c)
|
AuraDev19b6::to_bytes(&c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,19 +95,19 @@ impl From<&AuraPowerConfig> for AuraPowerDev {
|
|||||||
fn from(config: &AuraPowerConfig) -> Self {
|
fn from(config: &AuraPowerConfig) -> Self {
|
||||||
match config {
|
match config {
|
||||||
AuraPowerConfig::AuraDevTuf(d) => AuraPowerDev {
|
AuraPowerConfig::AuraDevTuf(d) => AuraPowerDev {
|
||||||
tuf: d.iter().map(|o| *o).collect(),
|
tuf: d.iter().copied().collect(),
|
||||||
x1866: vec![],
|
x1866: vec![],
|
||||||
x19b6: vec![],
|
x19b6: vec![],
|
||||||
},
|
},
|
||||||
AuraPowerConfig::AuraDev1866(d) => AuraPowerDev {
|
AuraPowerConfig::AuraDev1866(d) => AuraPowerDev {
|
||||||
tuf: vec![],
|
tuf: vec![],
|
||||||
x1866: d.iter().map(|o| *o).collect(),
|
x1866: d.iter().copied().collect(),
|
||||||
x19b6: vec![],
|
x19b6: vec![],
|
||||||
},
|
},
|
||||||
AuraPowerConfig::AuraDev19b6(d) => AuraPowerDev {
|
AuraPowerConfig::AuraDev19b6(d) => AuraPowerDev {
|
||||||
tuf: vec![],
|
tuf: vec![],
|
||||||
x1866: vec![],
|
x1866: vec![],
|
||||||
x19b6: d.iter().map(|o| *o).collect(),
|
x19b6: d.iter().copied().collect(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ impl Default for AuraConfig {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let mut prod_id = AuraDevice::Unknown;
|
let mut prod_id = AuraDevice::Unknown;
|
||||||
for prod in ASUS_KEYBOARD_DEVICES.iter() {
|
for prod in ASUS_KEYBOARD_DEVICES.iter() {
|
||||||
if let Ok(_) = HidRaw::new(prod) {
|
if HidRaw::new(prod).is_ok() {
|
||||||
prod_id = AuraDevice::from(*prod);
|
prod_id = AuraDevice::from(*prod);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -335,26 +335,34 @@ mod tests {
|
|||||||
fn set_multizone_4key_config() {
|
fn set_multizone_4key_config() {
|
||||||
let mut config = AuraConfig::default();
|
let mut config = AuraConfig::default();
|
||||||
|
|
||||||
let mut effect = AuraEffect::default();
|
let effect = AuraEffect {
|
||||||
effect.colour1 = Colour(0xff, 0x00, 0xff);
|
colour1: Colour(0xff, 0x00, 0xff),
|
||||||
effect.zone = AuraZone::Key1;
|
zone: AuraZone::Key1,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
config.set_builtin(effect);
|
config.set_builtin(effect);
|
||||||
|
|
||||||
assert!(config.multizone.is_some());
|
assert!(config.multizone.is_some());
|
||||||
|
|
||||||
let mut effect = AuraEffect::default();
|
let effect = AuraEffect {
|
||||||
effect.colour1 = Colour(0x00, 0xff, 0xff);
|
colour1: Colour(0x00, 0xff, 0xff),
|
||||||
effect.zone = AuraZone::Key2;
|
zone: AuraZone::Key2,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
config.set_builtin(effect);
|
config.set_builtin(effect);
|
||||||
|
|
||||||
let mut effect = AuraEffect::default();
|
let effect = AuraEffect {
|
||||||
effect.colour1 = Colour(0xff, 0xff, 0x00);
|
colour1: Colour(0xff, 0xff, 0x00),
|
||||||
effect.zone = AuraZone::Key3;
|
zone: AuraZone::Key3,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
config.set_builtin(effect);
|
config.set_builtin(effect);
|
||||||
|
|
||||||
let mut effect = AuraEffect::default();
|
let effect = AuraEffect {
|
||||||
effect.colour1 = Colour(0x00, 0xff, 0x00);
|
colour1: Colour(0x00, 0xff, 0x00),
|
||||||
effect.zone = AuraZone::Key4;
|
zone: AuraZone::Key4,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
let effect_clone = effect.clone();
|
let effect_clone = effect.clone();
|
||||||
config.set_builtin(effect);
|
config.set_builtin(effect);
|
||||||
// This should replace existing
|
// This should replace existing
|
||||||
@@ -373,25 +381,33 @@ mod tests {
|
|||||||
fn set_multizone_multimode_config() {
|
fn set_multizone_multimode_config() {
|
||||||
let mut config = AuraConfig::default();
|
let mut config = AuraConfig::default();
|
||||||
|
|
||||||
let mut effect = AuraEffect::default();
|
let effect = AuraEffect {
|
||||||
effect.zone = AuraZone::Key1;
|
zone: AuraZone::Key1,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
config.set_builtin(effect);
|
config.set_builtin(effect);
|
||||||
|
|
||||||
assert!(config.multizone.is_some());
|
assert!(config.multizone.is_some());
|
||||||
|
|
||||||
let mut effect = AuraEffect::default();
|
let effect = AuraEffect {
|
||||||
effect.zone = AuraZone::Key2;
|
zone: AuraZone::Key2,
|
||||||
effect.mode = AuraModeNum::Breathe;
|
mode: AuraModeNum::Breathe,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
config.set_builtin(effect);
|
config.set_builtin(effect);
|
||||||
|
|
||||||
let mut effect = AuraEffect::default();
|
let effect = AuraEffect {
|
||||||
effect.zone = AuraZone::Key3;
|
zone: AuraZone::Key3,
|
||||||
effect.mode = AuraModeNum::Comet;
|
mode: AuraModeNum::Comet,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
config.set_builtin(effect);
|
config.set_builtin(effect);
|
||||||
|
|
||||||
let mut effect = AuraEffect::default();
|
let effect = AuraEffect {
|
||||||
effect.zone = AuraZone::Key4;
|
zone: AuraZone::Key4,
|
||||||
effect.mode = AuraModeNum::Pulse;
|
mode: AuraModeNum::Pulse,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
config.set_builtin(effect);
|
config.set_builtin(effect);
|
||||||
|
|
||||||
let res = config.multizone.unwrap();
|
let res = config.multizone.unwrap();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ impl GetSupported for CtrlKbdLed {
|
|||||||
|
|
||||||
let mut prod_id = AuraDevice::Unknown;
|
let mut prod_id = AuraDevice::Unknown;
|
||||||
for prod in ASUS_KEYBOARD_DEVICES.iter() {
|
for prod in ASUS_KEYBOARD_DEVICES.iter() {
|
||||||
if let Ok(_) = HidRaw::new(prod) {
|
if HidRaw::new(prod).is_ok() {
|
||||||
prod_id = AuraDevice::from(*prod);
|
prod_id = AuraDevice::from(*prod);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ impl GetSupported for CtrlKbdLed {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, PartialOrd)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd)]
|
||||||
pub enum LEDNode {
|
pub enum LEDNode {
|
||||||
KbdLed(KeyboardLed),
|
KbdLed(KeyboardLed),
|
||||||
Rog(HidRaw),
|
Rog(HidRaw),
|
||||||
@@ -121,13 +121,13 @@ impl CtrlKbdLed {
|
|||||||
pub(super) fn get_brightness(&self) -> Result<u8, RogError> {
|
pub(super) fn get_brightness(&self) -> Result<u8, RogError> {
|
||||||
self.kd_brightness
|
self.kd_brightness
|
||||||
.get_brightness()
|
.get_brightness()
|
||||||
.map_err(|e| RogError::Platform(e))
|
.map_err(RogError::Platform)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn set_brightness(&self, brightness: LedBrightness) -> Result<(), RogError> {
|
pub(super) fn set_brightness(&self, brightness: LedBrightness) -> Result<(), RogError> {
|
||||||
self.kd_brightness
|
self.kd_brightness
|
||||||
.set_brightness(brightness as u8)
|
.set_brightness(brightness as u8)
|
||||||
.map_err(|e| RogError::Platform(e))
|
.map_err(RogError::Platform)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_brightness(&mut self) -> Result<(), RogError> {
|
pub fn next_brightness(&mut self) -> Result<(), RogError> {
|
||||||
@@ -176,10 +176,9 @@ impl CtrlKbdLed {
|
|||||||
/// On success the aura config file is read to refresh cached values, then the effect is
|
/// On success the aura config file is read to refresh cached values, then the effect is
|
||||||
/// stored and config written to disk.
|
/// stored and config written to disk.
|
||||||
pub(crate) fn set_effect(&mut self, effect: AuraEffect) -> Result<(), RogError> {
|
pub(crate) fn set_effect(&mut self, effect: AuraEffect) -> Result<(), RogError> {
|
||||||
if !self.supported_modes.standard.contains(&effect.mode) {
|
if !self.supported_modes.standard.contains(&effect.mode)
|
||||||
return Err(RogError::AuraEffectNotSupported);
|
|| effect.zone != AuraZone::None
|
||||||
} else if effect.zone != AuraZone::None
|
&& !self.supported_modes.multizone.contains(&effect.zone)
|
||||||
&& !self.supported_modes.multizone.contains(&effect.zone)
|
|
||||||
{
|
{
|
||||||
return Err(RogError::AuraEffectNotSupported);
|
return Err(RogError::AuraEffectNotSupported);
|
||||||
}
|
}
|
||||||
@@ -387,9 +386,11 @@ mod tests {
|
|||||||
config,
|
config,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut effect = AuraEffect::default();
|
let mut effect = AuraEffect {
|
||||||
effect.colour1 = Colour(0xff, 0x00, 0xff);
|
colour1: Colour(0xff, 0x00, 0xff),
|
||||||
effect.zone = AuraZone::None;
|
zone: AuraZone::None,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
// This error comes from write_bytes because we don't have a keyboard node stored
|
// This error comes from write_bytes because we don't have a keyboard node stored
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -422,7 +423,7 @@ mod tests {
|
|||||||
controller.supported_modes.multizone.push(AuraZone::Key2);
|
controller.supported_modes.multizone.push(AuraZone::Key2);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
controller
|
controller
|
||||||
.set_effect(effect.clone())
|
.set_effect(effect)
|
||||||
.unwrap_err()
|
.unwrap_err()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
"No supported Aura keyboard"
|
"No supported Aura keyboard"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ impl CtrlKbdLedZbus {
|
|||||||
lock.config.read();
|
lock.config.read();
|
||||||
lock.config.brightness = (bright as u32).into();
|
lock.config.brightness = (bright as u32).into();
|
||||||
lock.config.write();
|
lock.config.write();
|
||||||
return Ok(());
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,19 +192,19 @@ impl CtrlKbdLedZbus {
|
|||||||
// #[dbus_interface(property)]
|
// #[dbus_interface(property)]
|
||||||
async fn leds_enabled(&self) -> AuraPowerDev {
|
async fn leds_enabled(&self) -> AuraPowerDev {
|
||||||
let ctrl = self.0.lock().await;
|
let ctrl = self.0.lock().await;
|
||||||
return AuraPowerDev::from(&ctrl.config.enabled);
|
AuraPowerDev::from(&ctrl.config.enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the current mode data
|
/// Return the current mode data
|
||||||
async fn led_mode(&self) -> AuraModeNum {
|
async fn led_mode(&self) -> AuraModeNum {
|
||||||
let ctrl = self.0.lock().await;
|
let ctrl = self.0.lock().await;
|
||||||
return ctrl.config.current_mode;
|
ctrl.config.current_mode
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a list of available modes
|
/// Return a list of available modes
|
||||||
async fn led_modes(&self) -> BTreeMap<AuraModeNum, AuraEffect> {
|
async fn led_modes(&self) -> BTreeMap<AuraModeNum, AuraEffect> {
|
||||||
let ctrl = self.0.lock().await;
|
let ctrl = self.0.lock().await;
|
||||||
return ctrl.config.builtins.clone();
|
ctrl.config.builtins.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn per_key_raw(&self, data: PerKeyRaw) -> zbus::fdo::Result<()> {
|
async fn per_key_raw(&self, data: PerKeyRaw) -> zbus::fdo::Result<()> {
|
||||||
|
|||||||
@@ -202,21 +202,16 @@ impl CtrlPlatform {
|
|||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
overdrive: bool,
|
overdrive: bool,
|
||||||
) {
|
) {
|
||||||
if self
|
match self.platform.set_panel_od(overdrive) {
|
||||||
.platform
|
Ok(_) => {
|
||||||
.set_panel_od(overdrive)
|
if let Some(mut lock) = self.config.try_lock() {
|
||||||
.map_err(|err| {
|
lock.panel_od = overdrive;
|
||||||
warn!("CtrlRogBios: set_panel_overdrive {}", err);
|
lock.write();
|
||||||
err
|
}
|
||||||
})
|
Self::notify_panel_od(&ctxt, overdrive).await.ok();
|
||||||
.is_ok()
|
|
||||||
{
|
|
||||||
if let Some(mut lock) = self.config.try_lock() {
|
|
||||||
lock.panel_od = overdrive;
|
|
||||||
lock.write();
|
|
||||||
}
|
}
|
||||||
Self::notify_panel_od(&ctxt, overdrive).await.ok();
|
Err(err) => warn!("CtrlRogBios: set_panel_overdrive {}", err),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the `panel_od` value from platform. Updates the stored value in internal config also.
|
/// Get the `panel_od` value from platform. Updates the stored value in internal config also.
|
||||||
@@ -245,17 +240,12 @@ impl CtrlPlatform {
|
|||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
disable: bool,
|
disable: bool,
|
||||||
) {
|
) {
|
||||||
if self
|
match self.platform.set_dgpu_disable(disable) {
|
||||||
.platform
|
Ok(_) => {
|
||||||
.set_dgpu_disable(disable)
|
Self::notify_dgpu_disable(&ctxt, disable).await.ok();
|
||||||
.map_err(|err| {
|
}
|
||||||
warn!("CtrlRogBios: set_dgpu_disable {}", err);
|
Err(err) => warn!("CtrlRogBios: set_dgpu_disable {}", err),
|
||||||
err
|
};
|
||||||
})
|
|
||||||
.is_ok()
|
|
||||||
{
|
|
||||||
Self::notify_dgpu_disable(&ctxt, disable).await.ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dgpu_disable(&self) -> bool {
|
fn dgpu_disable(&self) -> bool {
|
||||||
@@ -280,17 +270,12 @@ impl CtrlPlatform {
|
|||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
enable: bool,
|
enable: bool,
|
||||||
) {
|
) {
|
||||||
if self
|
match self.platform.set_egpu_enable(enable) {
|
||||||
.platform
|
Ok(_) => {
|
||||||
.set_egpu_enable(enable)
|
Self::notify_egpu_enable(&ctxt, enable).await.ok();
|
||||||
.map_err(|err| {
|
}
|
||||||
warn!("CtrlRogBios: set_egpu_enable {}", err);
|
Err(err) => warn!("CtrlRogBios: set_egpu_enable {}", err),
|
||||||
err
|
};
|
||||||
})
|
|
||||||
.is_ok()
|
|
||||||
{
|
|
||||||
Self::notify_egpu_enable(&ctxt, enable).await.ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn egpu_enable(&self) -> bool {
|
fn egpu_enable(&self) -> bool {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ impl ProfileZbus {
|
|||||||
if let Some(curves) = &ctrl.config.fan_curves {
|
if let Some(curves) = &ctrl.config.fan_curves {
|
||||||
return Ok(curves.get_enabled_curve_profiles().to_vec());
|
return Ok(curves.get_enabled_curve_profiles().to_vec());
|
||||||
}
|
}
|
||||||
return Err(Error::Failed(UNSUPPORTED_MSG.to_string()));
|
Err(Error::Failed(UNSUPPORTED_MSG.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a profile fan curve enabled status. Will also activate a fan curve if in the
|
/// Set a profile fan curve enabled status. Will also activate a fan curve if in the
|
||||||
@@ -99,7 +99,7 @@ impl ProfileZbus {
|
|||||||
) -> zbus::fdo::Result<()> {
|
) -> zbus::fdo::Result<()> {
|
||||||
let mut ctrl = self.0.lock().await;
|
let mut ctrl = self.0.lock().await;
|
||||||
ctrl.config.read();
|
ctrl.config.read();
|
||||||
return if let Some(curves) = &mut ctrl.config.fan_curves {
|
if let Some(curves) = &mut ctrl.config.fan_curves {
|
||||||
curves.set_profile_curve_enabled(profile, enabled);
|
curves.set_profile_curve_enabled(profile, enabled);
|
||||||
|
|
||||||
ctrl.write_profile_curve_to_platform()
|
ctrl.write_profile_curve_to_platform()
|
||||||
@@ -110,7 +110,7 @@ impl ProfileZbus {
|
|||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(Error::Failed(UNSUPPORTED_MSG.to_string()))
|
Err(Error::Failed(UNSUPPORTED_MSG.to_string()))
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the fan-curve data for the currently active Profile
|
/// Get the fan-curve data for the currently active Profile
|
||||||
@@ -121,7 +121,7 @@ impl ProfileZbus {
|
|||||||
let curve = curves.get_fan_curves_for(profile);
|
let curve = curves.get_fan_curves_for(profile);
|
||||||
return Ok(curve.clone());
|
return Ok(curve.clone());
|
||||||
}
|
}
|
||||||
return Err(Error::Failed(UNSUPPORTED_MSG.to_string()));
|
Err(Error::Failed(UNSUPPORTED_MSG.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the fan curve for the specified profile.
|
/// Set the fan curve for the specified profile.
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ where
|
|||||||
.unwrap_or_else(|err| warn!("Controller error: {}", err));
|
.unwrap_or_else(|err| warn!("Controller error: {}", err));
|
||||||
zbus.add_to_server(connection).await;
|
zbus.add_to_server(connection).await;
|
||||||
|
|
||||||
task.create_tasks(CtrlKbdLedZbus::signal_context(&connection)?)
|
task.create_tasks(CtrlKbdLedZbus::signal_context(connection)?)
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const USB_PREFIX2: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02];
|
|||||||
const USB_PREFIX3: [u8; 7] = [0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02];
|
const USB_PREFIX3: [u8; 7] = [0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02];
|
||||||
|
|
||||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||||
#[derive(Debug, PartialEq, Copy, Clone, Deserialize, Serialize)]
|
#[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
|
||||||
pub struct AnimePowerStates {
|
pub struct AnimePowerStates {
|
||||||
pub brightness: u8,
|
pub brightness: u8,
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
|
|||||||
@@ -131,14 +131,14 @@ impl AnimeDiagonal {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_data_buffer(&self, anime_type: AnimeType) -> Result<AnimeDataBuffer> {
|
pub fn into_data_buffer(&self, anime_type: AnimeType) -> Result<AnimeDataBuffer> {
|
||||||
match anime_type {
|
match anime_type {
|
||||||
AnimeType::GA401 => self.into_ga401_packets(),
|
AnimeType::GA401 => self.to_ga401_packets(),
|
||||||
AnimeType::GA402 => self.into_ga402_packets(),
|
AnimeType::GA402 => self.to_ga402_packets(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do conversion from the nested Vec in AnimeMatrix to the two required
|
/// Do conversion from the nested Vec in AnimeMatrix to the two required
|
||||||
/// packets suitable for sending over USB
|
/// packets suitable for sending over USB
|
||||||
fn into_ga401_packets(&self) -> Result<AnimeDataBuffer> {
|
fn to_ga401_packets(&self) -> Result<AnimeDataBuffer> {
|
||||||
let mut buf = vec![0u8; AnimeType::GA401.data_length()];
|
let mut buf = vec![0u8; AnimeType::GA401.data_length()];
|
||||||
|
|
||||||
buf[1..=32].copy_from_slice(&self.get_row(0, 3, 32));
|
buf[1..=32].copy_from_slice(&self.get_row(0, 3, 32));
|
||||||
@@ -200,12 +200,12 @@ impl AnimeDiagonal {
|
|||||||
AnimeDataBuffer::from_vec(crate::AnimeType::GA401, buf)
|
AnimeDataBuffer::from_vec(crate::AnimeType::GA401, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn into_ga402_packets(&self) -> Result<AnimeDataBuffer> {
|
fn to_ga402_packets(&self) -> Result<AnimeDataBuffer> {
|
||||||
let mut buf = vec![0u8; AnimeType::GA402.data_length()];
|
let mut buf = vec![0u8; AnimeType::GA402.data_length()];
|
||||||
let mut start_index: usize = 0;
|
let mut start_index: usize = 0;
|
||||||
|
|
||||||
fn copy_slice(
|
fn copy_slice(
|
||||||
buf: &mut Vec<u8>,
|
buf: &mut [u8],
|
||||||
anime: &AnimeDiagonal,
|
anime: &AnimeDiagonal,
|
||||||
x: usize,
|
x: usize,
|
||||||
y: usize,
|
y: usize,
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ impl AnimeImage {
|
|||||||
width: u32,
|
width: u32,
|
||||||
anime_type: AnimeType,
|
anime_type: AnimeType,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
if bright < 0.0 || bright > 1.0 {
|
if !(0.0..=1.0).contains(&bright) {
|
||||||
return Err(AnimeError::InvalidBrightness(bright));
|
return Err(AnimeError::InvalidBrightness(bright));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ pub fn get_anime_type() -> Result<AnimeType, AnimeError> {
|
|||||||
let dmi = sysfs_class::DmiId::default();
|
let dmi = sysfs_class::DmiId::default();
|
||||||
let board_name = dmi.board_name()?;
|
let board_name = dmi.board_name()?;
|
||||||
|
|
||||||
if board_name.contains("GA401I") {
|
if board_name.contains("GA401I") || board_name.contains("GA401Q") {
|
||||||
return Ok(AnimeType::GA401);
|
|
||||||
} else if board_name.contains("GA401Q") {
|
|
||||||
return Ok(AnimeType::GA401);
|
return Ok(AnimeType::GA401);
|
||||||
} else if board_name.contains("GA402R") {
|
} else if board_name.contains("GA402R") {
|
||||||
return Ok(AnimeType::GA402);
|
return Ok(AnimeType::GA402);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use zvariant::Type;
|
|||||||
use crate::{error::Error, LED_MSG_LEN};
|
use crate::{error::Error, LED_MSG_LEN};
|
||||||
|
|
||||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Deserialize, Serialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
pub enum LedBrightness {
|
pub enum LedBrightness {
|
||||||
Off,
|
Off,
|
||||||
Low,
|
Low,
|
||||||
@@ -33,7 +33,7 @@ impl From<u32> for LedBrightness {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Copy, Deserialize, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Copy, Deserialize, Serialize)]
|
||||||
pub struct Colour(pub u8, pub u8, pub u8);
|
pub struct Colour(pub u8, pub u8, pub u8);
|
||||||
|
|
||||||
impl Default for Colour {
|
impl Default for Colour {
|
||||||
@@ -85,7 +85,7 @@ impl From<Colour> for [u8; 3] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Deserialize, Serialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
pub enum Speed {
|
pub enum Speed {
|
||||||
Low = 0xe1,
|
Low = 0xe1,
|
||||||
Med = 0xeb,
|
Med = 0xeb,
|
||||||
@@ -123,7 +123,7 @@ impl From<Speed> for u8 {
|
|||||||
///
|
///
|
||||||
/// Enum corresponds to the required integer value
|
/// Enum corresponds to the required integer value
|
||||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Deserialize, Serialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
pub enum Direction {
|
pub enum Direction {
|
||||||
Right,
|
Right,
|
||||||
Left,
|
Left,
|
||||||
@@ -251,7 +251,7 @@ impl From<u8> for AuraModeNum {
|
|||||||
|
|
||||||
/// Base effects have no zoning, while multizone is 1-4
|
/// Base effects have no zoning, while multizone is 1-4
|
||||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||||
#[derive(Debug, Default, Copy, Clone, PartialEq, Deserialize, Serialize)]
|
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
pub enum AuraZone {
|
pub enum AuraZone {
|
||||||
/// Used if keyboard has no zones, or if setting all
|
/// Used if keyboard has no zones, or if setting all
|
||||||
#[default]
|
#[default]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq, Copy, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
|
||||||
pub enum Key {
|
pub enum Key {
|
||||||
VolUp,
|
VolUp,
|
||||||
VolDown,
|
VolDown,
|
||||||
@@ -235,51 +235,44 @@ impl KeyShape {
|
|||||||
/// A blank is used to space keys out in GUI's and can be used or ignored
|
/// A blank is used to space keys out in GUI's and can be used or ignored
|
||||||
/// depednign on the per-key effect
|
/// depednign on the per-key effect
|
||||||
pub const fn is_blank(&self) -> bool {
|
pub const fn is_blank(&self) -> bool {
|
||||||
match self {
|
matches!(
|
||||||
|
self,
|
||||||
Self::NormalBlank
|
Self::NormalBlank
|
||||||
| Self::FuncBlank
|
| Self::FuncBlank
|
||||||
| Self::ArrowBlank
|
| Self::ArrowBlank
|
||||||
| Self::ArrowSplitBlank
|
| Self::ArrowSplitBlank
|
||||||
| Self::ArrowRegularBlank => true,
|
| Self::ArrowRegularBlank
|
||||||
_ => false,
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A spacer is used to space keys out in GUI's, but ignored in per-key effects
|
/// A spacer is used to space keys out in GUI's, but ignored in per-key effects
|
||||||
pub const fn is_spacer(&self) -> bool {
|
pub const fn is_spacer(&self) -> bool {
|
||||||
match self {
|
matches!(
|
||||||
|
self,
|
||||||
Self::FuncSpacer
|
Self::FuncSpacer
|
||||||
| Self::NormalSpacer
|
| Self::NormalSpacer
|
||||||
| Self::ArrowSpacer
|
| Self::ArrowSpacer
|
||||||
| Self::ArrowSplitSpacer
|
| Self::ArrowSplitSpacer
|
||||||
| Self::ArrowRegularSpacer => true,
|
| Self::ArrowRegularSpacer
|
||||||
_ => false,
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All keys with a postfix of some number
|
/// All keys with a postfix of some number
|
||||||
pub const fn is_group(&self) -> bool {
|
pub const fn is_group(&self) -> bool {
|
||||||
match self {
|
matches!(
|
||||||
Self::LShift3 | Self::RShift3 => true,
|
self,
|
||||||
Self::Return3 | Self::Space5 | Self::Backspace3 => true,
|
Self::LShift3 | Self::RShift3 | Self::Return3 | Self::Space5 | Self::Backspace3
|
||||||
_ => false,
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mostly intended as a helper for signalling when to draw a
|
/// Mostly intended as a helper for signalling when to draw a
|
||||||
/// split/compact arrow cluster
|
/// split/compact arrow cluster
|
||||||
pub const fn is_arrow_cluster(&self) -> bool {
|
pub const fn is_arrow_cluster(&self) -> bool {
|
||||||
match self {
|
matches!(self, Self::Arrow | Self::ArrowBlank | Self::ArrowSpacer)
|
||||||
Self::Arrow | Self::ArrowBlank | Self::ArrowSpacer => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn is_arrow_splits(&self) -> bool {
|
pub const fn is_arrow_splits(&self) -> bool {
|
||||||
match self {
|
matches!(self, Self::Arrow | Self::ArrowBlank | Self::ArrowSpacer)
|
||||||
Self::ArrowSplit | Self::ArrowSplitBlank | Self::ArrowSplitSpacer => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ impl KeyLayout {
|
|||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
let read_len = file.read_to_string(&mut buf)?;
|
let read_len = file.read_to_string(&mut buf)?;
|
||||||
if read_len == 0 {
|
if read_len == 0 {
|
||||||
return Err(Error::Io(std::io::ErrorKind::InvalidData.into()));
|
Err(Error::Io(std::io::ErrorKind::InvalidData.into()))
|
||||||
} else {
|
} else {
|
||||||
return Ok(toml::from_str::<Self>(&buf)?);
|
Ok(toml::from_str::<Self>(&buf)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,16 +138,15 @@ impl EffectState for Breathe {
|
|||||||
|
|
||||||
let speed = 4 - <u8>::from(*speed);
|
let speed = 4 - <u8>::from(*speed);
|
||||||
|
|
||||||
let colour: &mut Colour;
|
|
||||||
if *colour_actual == Colour(0, 0, 0) {
|
if *colour_actual == Colour(0, 0, 0) {
|
||||||
*use_colour1 = !*use_colour1;
|
*use_colour1 = !*use_colour1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*use_colour1 {
|
let colour = if !*use_colour1 {
|
||||||
colour = colour2;
|
colour2
|
||||||
} else {
|
} else {
|
||||||
colour = colour1;
|
colour1
|
||||||
}
|
};
|
||||||
|
|
||||||
let r1_scale = colour.0 / speed / 2;
|
let r1_scale = colour.0 / speed / 2;
|
||||||
let g1_scale = colour.1 / speed / 2;
|
let g1_scale = colour.1 / speed / 2;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub const fn aura_brightness_bytes(brightness: u8) -> [u8; 17] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize, Default)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Serialize, Deserialize, Default)]
|
||||||
pub enum AuraDevice {
|
pub enum AuraDevice {
|
||||||
Tuf,
|
Tuf,
|
||||||
X1854,
|
X1854,
|
||||||
@@ -127,7 +127,7 @@ impl BitOr<AuraDev1866> for AuraDev1866 {
|
|||||||
type Output = u32;
|
type Output = u32;
|
||||||
|
|
||||||
fn bitor(self, rhs: AuraDev1866) -> Self::Output {
|
fn bitor(self, rhs: AuraDev1866) -> Self::Output {
|
||||||
return self as u32 | rhs as u32;
|
self as u32 | rhs as u32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ impl BitAnd<AuraDev1866> for AuraDev1866 {
|
|||||||
type Output = u32;
|
type Output = u32;
|
||||||
|
|
||||||
fn bitand(self, rhs: AuraDev1866) -> Self::Output {
|
fn bitand(self, rhs: AuraDev1866) -> Self::Output {
|
||||||
return self as u32 & rhs as u32;
|
self as u32 & rhs as u32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,14 +178,14 @@ pub enum AuraDev19b6 {
|
|||||||
SleepKeyb = 1 << 5,
|
SleepKeyb = 1 << 5,
|
||||||
ShutdownLogo = 1 << 6,
|
ShutdownLogo = 1 << 6,
|
||||||
ShutdownKeyb = 1 << 7,
|
ShutdownKeyb = 1 << 7,
|
||||||
BootBar = 1 << 7 + 2,
|
BootBar = 1 << (7 + 2),
|
||||||
AwakeBar = 1 << 7 + 3,
|
AwakeBar = 1 << (7 + 3),
|
||||||
SleepBar = 1 << 7 + 4,
|
SleepBar = 1 << (7 + 4),
|
||||||
ShutdownBar = 1 << 7 + 5,
|
ShutdownBar = 1 << (7 + 5),
|
||||||
BootLid = 1 << 15 + 1,
|
BootLid = 1 << (15 + 1),
|
||||||
AwakeLid = 1 << 15 + 2,
|
AwakeLid = 1 << (15 + 2),
|
||||||
SleepLid = 1 << 15 + 3,
|
SleepLid = 1 << (15 + 3),
|
||||||
ShutdownLid = 1 << 15 + 4,
|
ShutdownLid = 1 << (15 + 4),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AuraDev19b6> for u32 {
|
impl From<AuraDev19b6> for u32 {
|
||||||
@@ -216,7 +216,7 @@ impl BitOr<AuraDev19b6> for AuraDev19b6 {
|
|||||||
type Output = u16;
|
type Output = u16;
|
||||||
|
|
||||||
fn bitor(self, rhs: AuraDev19b6) -> Self::Output {
|
fn bitor(self, rhs: AuraDev19b6) -> Self::Output {
|
||||||
return self as u16 | rhs as u16;
|
self as u16 | rhs as u16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ impl BitAnd<AuraDev19b6> for AuraDev19b6 {
|
|||||||
type Output = u16;
|
type Output = u16;
|
||||||
|
|
||||||
fn bitand(self, rhs: AuraDev19b6) -> Self::Output {
|
fn bitand(self, rhs: AuraDev19b6) -> Self::Output {
|
||||||
return self as u16 & rhs as u16;
|
self as u16 & rhs as u16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ pub fn print_versions() {
|
|||||||
pub const SHOWING_GUI: u8 = 1;
|
pub const SHOWING_GUI: u8 = 1;
|
||||||
pub const SHOW_GUI: u8 = 2;
|
pub const SHOW_GUI: u8 = 2;
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Copy)]
|
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum Page {
|
pub enum Page {
|
||||||
System,
|
System,
|
||||||
AuraEffects,
|
AuraEffects,
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
println!("{BOARD_NAME}, {e}");
|
println!("{BOARD_NAME}, {e}");
|
||||||
})
|
})
|
||||||
.unwrap_or(KeyLayout::ga401_layout());
|
.unwrap_or_else(|_| KeyLayout::ga401_layout());
|
||||||
|
|
||||||
// Cheap method to alert to notifications rather than spinning a thread for each
|
// Cheap method to alert to notifications rather than spinning a thread for each
|
||||||
// This is quite different when done in a retained mode app
|
// This is quite different when done in a retained mode app
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ pub fn start_notifications(
|
|||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
let bios_notified1 = bios_notified.clone();
|
let bios_notified1 = bios_notified;
|
||||||
executor
|
executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
let conn = zbus::Connection::system().await.unwrap();
|
||||||
@@ -181,9 +181,9 @@ pub fn start_notifications(
|
|||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
// LED notif
|
// LED notif
|
||||||
let last_notif = last_notification.clone();
|
let last_notif = last_notification;
|
||||||
let aura_notif = aura_notified.clone();
|
let aura_notif = aura_notified.clone();
|
||||||
let notifs_enabled1 = notifs_enabled.clone();
|
let notifs_enabled1 = notifs_enabled;
|
||||||
executor
|
executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
let conn = zbus::Connection::system().await.unwrap();
|
||||||
|
|||||||
@@ -262,6 +262,7 @@ pub struct PageDataStates {
|
|||||||
pub error: Option<String>,
|
pub error: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
impl PageDataStates {
|
impl PageDataStates {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
keyboard_layout: KeyLayout,
|
keyboard_layout: KeyLayout,
|
||||||
|
|||||||
@@ -73,10 +73,10 @@ fn aura_power1(
|
|||||||
if ui.toggle_value(&mut keyboard, "Keyboard").changed() {
|
if ui.toggle_value(&mut keyboard, "Keyboard").changed() {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if !supported.keyboard_led.multizone_led_mode.is_empty() {
|
if !supported.keyboard_led.multizone_led_mode.is_empty()
|
||||||
if ui.toggle_value(&mut lightbar, "Lightbar").changed() {
|
&& ui.toggle_value(&mut lightbar, "Lightbar").changed()
|
||||||
changed = true;
|
{
|
||||||
}
|
changed = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.horizontal_wrapped(|ui| {
|
ui.horizontal_wrapped(|ui| {
|
||||||
|
|||||||
@@ -54,40 +54,38 @@ pub fn rog_bios_group(
|
|||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
if supported.rog_bios_ctrl.post_sound {
|
if supported.rog_bios_ctrl.post_sound
|
||||||
if ui
|
&& ui
|
||||||
.add(egui::Checkbox::new(
|
.add(egui::Checkbox::new(
|
||||||
&mut states.bios.post_sound,
|
&mut states.bios.post_sound,
|
||||||
"POST sound",
|
"POST sound",
|
||||||
))
|
))
|
||||||
.changed()
|
.changed()
|
||||||
{
|
{
|
||||||
dbus.proxies()
|
dbus.proxies()
|
||||||
.rog_bios()
|
.rog_bios()
|
||||||
.set_post_boot_sound(states.bios.post_sound)
|
.set_post_boot_sound(states.bios.post_sound)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
states.error = Some(err.to_string());
|
states.error = Some(err.to_string());
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if supported.rog_bios_ctrl.post_sound {
|
if supported.rog_bios_ctrl.post_sound
|
||||||
if ui
|
&& ui
|
||||||
.add(egui::Checkbox::new(
|
.add(egui::Checkbox::new(
|
||||||
&mut states.bios.panel_overdrive,
|
&mut states.bios.panel_overdrive,
|
||||||
"Panel overdrive",
|
"Panel overdrive",
|
||||||
))
|
))
|
||||||
.changed()
|
.changed()
|
||||||
{
|
{
|
||||||
dbus.proxies()
|
dbus.proxies()
|
||||||
.rog_bios()
|
.rog_bios()
|
||||||
.set_panel_od(states.bios.panel_overdrive)
|
.set_panel_od(states.bios.panel_overdrive)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
states.error = Some(err.to_string());
|
states.error = Some(err.to_string());
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if supported.rog_bios_ctrl.gpu_mux {
|
if supported.rog_bios_ctrl.gpu_mux {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use log::{info, warn};
|
|||||||
|
|
||||||
use crate::error::{PlatformError, Result};
|
use crate::error::{PlatformError, Result};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, PartialOrd, Clone)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
|
||||||
pub struct HidRaw(PathBuf);
|
pub struct HidRaw(PathBuf);
|
||||||
|
|
||||||
impl HidRaw {
|
impl HidRaw {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::{
|
|||||||
has_attr, set_attr_u8_array, to_device,
|
has_attr, set_attr_u8_array, to_device,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq, PartialOrd, Clone)]
|
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Clone)]
|
||||||
pub struct KeyboardLed {
|
pub struct KeyboardLed {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
}
|
}
|
||||||
@@ -32,10 +32,12 @@ impl KeyboardLed {
|
|||||||
PlatformError::Udev("match_subsystem failed".into(), err)
|
PlatformError::Udev("match_subsystem failed".into(), err)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
for device in enumerator.scan_devices().map_err(|err| {
|
if let Some(device) = (enumerator.scan_devices().map_err(|err| {
|
||||||
warn!("{}", err);
|
warn!("{}", err);
|
||||||
PlatformError::Udev("scan_devices failed".into(), err)
|
PlatformError::Udev("scan_devices failed".into(), err)
|
||||||
})? {
|
})?)
|
||||||
|
.next()
|
||||||
|
{
|
||||||
info!("Found keyboard LED controls at {:?}", device.sysname());
|
info!("Found keyboard LED controls at {:?}", device.sysname());
|
||||||
return Ok(Self {
|
return Ok(Self {
|
||||||
path: device.syspath().to_owned(),
|
path: device.syspath().to_owned(),
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ pub fn write_attr_bool(device: &mut Device, attr: &str, value: bool) -> Result<(
|
|||||||
pub fn read_attr_u8(device: &Device, attr_name: &str) -> Result<u8> {
|
pub fn read_attr_u8(device: &Device, attr_name: &str) -> Result<u8> {
|
||||||
if let Some(value) = device.attribute_value(attr_name) {
|
if let Some(value) = device.attribute_value(attr_name) {
|
||||||
let tmp = value.to_string_lossy();
|
let tmp = value.to_string_lossy();
|
||||||
return Ok(tmp.parse::<u8>().map_err(|_| PlatformError::ParseNum)?);
|
return tmp.parse::<u8>().map_err(|_| PlatformError::ParseNum);
|
||||||
}
|
}
|
||||||
Err(PlatformError::AttrNotFound(attr_name.to_string()))
|
Err(PlatformError::AttrNotFound(attr_name.to_string()))
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ pub fn read_attr_u8_array(device: &Device, attr_name: &str) -> Result<Vec<u8>> {
|
|||||||
let tmp = value.to_string_lossy();
|
let tmp = value.to_string_lossy();
|
||||||
let tmp = tmp
|
let tmp = tmp
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.map(|v| u8::from_str_radix(v, 10).unwrap_or(0))
|
.map(|v| v.parse::<u8>().unwrap_or(0))
|
||||||
.collect();
|
.collect();
|
||||||
return Ok(tmp);
|
return Ok(tmp);
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ mod tests {
|
|||||||
|
|
||||||
let tmp: Vec<u8> = tmp
|
let tmp: Vec<u8> = tmp
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.map(|v| u8::from_str_radix(v, 10).unwrap_or(0))
|
.map(|v| v.parse::<u8>().unwrap_or(0))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(tmp, &[1, 2, 3, 4, 5]);
|
assert_eq!(tmp, &[1, 2, 3, 4, 5]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ macro_rules! has_attr {
|
|||||||
$(#[$doc_comment])*
|
$(#[$doc_comment])*
|
||||||
pub fn fn_name(&self) -> bool {
|
pub fn fn_name(&self) -> bool {
|
||||||
match to_device(&self.$item) {
|
match to_device(&self.$item) {
|
||||||
Ok(p) => crate::has_attr(&p, $attr_name),
|
Ok(p) => $crate::has_attr(&p, $attr_name),
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ macro_rules! get_attr_bool {
|
|||||||
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$doc_comment])*
|
||||||
pub fn fn_name(&self) -> Result<bool> {
|
pub fn fn_name(&self) -> Result<bool> {
|
||||||
crate::read_attr_bool(&to_device(&self.$item)?, $attr_name)
|
$crate::read_attr_bool(&to_device(&self.$item)?, $attr_name)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -57,7 +57,7 @@ macro_rules! set_attr_bool {
|
|||||||
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$doc_comment])*
|
||||||
pub fn fn_name(&self, value: bool) -> Result<()> {
|
pub fn fn_name(&self, value: bool) -> Result<()> {
|
||||||
crate::write_attr_bool(&mut to_device(&self.$item)?, $attr_name, value)
|
$crate::write_attr_bool(&mut to_device(&self.$item)?, $attr_name, value)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -66,10 +66,10 @@ macro_rules! set_attr_bool {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! attr_bool {
|
macro_rules! attr_bool {
|
||||||
($attr_name:literal, $item:ident) => {
|
($attr_name:literal, $item:ident) => {
|
||||||
crate::has_attr!($attr_name $item);
|
$crate::has_attr!($attr_name $item);
|
||||||
crate::get_attr_bool!( $attr_name $item);
|
$crate::get_attr_bool!( $attr_name $item);
|
||||||
crate::set_attr_bool!($attr_name $item);
|
$crate::set_attr_bool!($attr_name $item);
|
||||||
crate::watch_attr!($attr_name $item);
|
$crate::watch_attr!($attr_name $item);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ macro_rules! get_attr_u8 {
|
|||||||
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$doc_comment])*
|
||||||
pub fn fn_name(&self) -> Result<u8> {
|
pub fn fn_name(&self) -> Result<u8> {
|
||||||
crate::read_attr_u8(&to_device(&self.$item)?, $attr_name)
|
$crate::read_attr_u8(&to_device(&self.$item)?, $attr_name)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -91,7 +91,7 @@ macro_rules! set_attr_u8 {
|
|||||||
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$doc_comment])*
|
||||||
pub fn fn_name(&self, value: u8) -> Result<()> {
|
pub fn fn_name(&self, value: u8) -> Result<()> {
|
||||||
crate::write_attr_u8(&mut to_device(&self.$item)?, $attr_name, value)
|
$crate::write_attr_u8(&mut to_device(&self.$item)?, $attr_name, value)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -100,10 +100,10 @@ macro_rules! set_attr_u8 {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! attr_u8 {
|
macro_rules! attr_u8 {
|
||||||
($attr_name:literal, $item:ident) => {
|
($attr_name:literal, $item:ident) => {
|
||||||
crate::has_attr!($attr_name $item);
|
$crate::has_attr!($attr_name $item);
|
||||||
crate::get_attr_u8!($attr_name $item);
|
$crate::get_attr_u8!($attr_name $item);
|
||||||
crate::set_attr_u8!($attr_name $item);
|
$crate::set_attr_u8!($attr_name $item);
|
||||||
crate::watch_attr!($attr_name $item);
|
$crate::watch_attr!($attr_name $item);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ macro_rules! get_attr_u8_array {
|
|||||||
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$doc_comment])*
|
||||||
pub fn fn_name(&self) -> Result<Vec<u8>> {
|
pub fn fn_name(&self) -> Result<Vec<u8>> {
|
||||||
crate::read_attr_u8_array(&to_device(&self.$item)?, $attr_name)
|
$crate::read_attr_u8_array(&to_device(&self.$item)?, $attr_name)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -125,7 +125,7 @@ macro_rules! set_attr_u8_array {
|
|||||||
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$doc_comment])*
|
||||||
pub fn fn_name(&self, values: &[u8]) -> Result<()> {
|
pub fn fn_name(&self, values: &[u8]) -> Result<()> {
|
||||||
crate::write_attr_u8_array(&mut to_device(&self.$item)?, $attr_name, values)
|
$crate::write_attr_u8_array(&mut to_device(&self.$item)?, $attr_name, values)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -134,9 +134,9 @@ macro_rules! set_attr_u8_array {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! attr_u8_array {
|
macro_rules! attr_u8_array {
|
||||||
($attr_name:literal, $item:ident) => {
|
($attr_name:literal, $item:ident) => {
|
||||||
crate::has_attr!($attr_name $item);
|
$crate::has_attr!($attr_name $item);
|
||||||
crate::get_attr_u8_array!($attr_name $item);
|
$crate::get_attr_u8_array!($attr_name $item);
|
||||||
crate::set_attr_u8_array!($attr_name $item);
|
$crate::set_attr_u8_array!($attr_name $item);
|
||||||
crate::watch_attr!($attr_name $item);
|
$crate::watch_attr!($attr_name $item);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use crate::{
|
|||||||
/// - gpu_mux
|
/// - gpu_mux
|
||||||
/// - keyboard_mode, set keyboard RGB mode and speed
|
/// - keyboard_mode, set keyboard RGB mode and speed
|
||||||
/// - keyboard_state, set keyboard power states
|
/// - keyboard_state, set keyboard power states
|
||||||
#[derive(Debug, PartialEq, PartialOrd, Clone)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
|
||||||
pub struct AsusPlatform {
|
pub struct AsusPlatform {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
pp_path: PathBuf,
|
pp_path: PathBuf,
|
||||||
@@ -38,10 +38,12 @@ impl AsusPlatform {
|
|||||||
PlatformError::Udev("match_subsystem failed".into(), err)
|
PlatformError::Udev("match_subsystem failed".into(), err)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
for device in enumerator.scan_devices().map_err(|err| {
|
if let Some(device) = (enumerator.scan_devices().map_err(|err| {
|
||||||
warn!("{}", err);
|
warn!("{}", err);
|
||||||
PlatformError::Udev("scan_devices failed".into(), err)
|
PlatformError::Udev("scan_devices failed".into(), err)
|
||||||
})? {
|
})?)
|
||||||
|
.next()
|
||||||
|
{
|
||||||
info!("Found platform support at {:?}", device.sysname());
|
info!("Found platform support at {:?}", device.sysname());
|
||||||
return Ok(Self {
|
return Ok(Self {
|
||||||
path: device.syspath().to_owned(),
|
path: device.syspath().to_owned(),
|
||||||
@@ -63,7 +65,7 @@ impl AsusPlatform {
|
|||||||
attr_u8!("platform_profile", pp_path);
|
attr_u8!("platform_profile", pp_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Type, Debug, PartialEq, Clone, Copy)]
|
#[derive(Serialize, Deserialize, Type, Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum GpuMode {
|
pub enum GpuMode {
|
||||||
Discrete,
|
Discrete,
|
||||||
Optimus,
|
Optimus,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use crate::{
|
|||||||
/// - gpu_mux
|
/// - gpu_mux
|
||||||
/// - keyboard_mode, set keyboard RGB mode and speed
|
/// - keyboard_mode, set keyboard RGB mode and speed
|
||||||
/// - keyboard_state, set keyboard power states
|
/// - keyboard_state, set keyboard power states
|
||||||
#[derive(Debug, PartialEq, PartialOrd, Clone)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
|
||||||
pub struct AsusPower {
|
pub struct AsusPower {
|
||||||
mains: PathBuf,
|
mains: PathBuf,
|
||||||
battery: PathBuf,
|
battery: PathBuf,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use crate::error::{PlatformError, Result};
|
use crate::error::{PlatformError, Result};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct USBRaw(DeviceHandle<rusb::GlobalContext>);
|
pub struct USBRaw(DeviceHandle<rusb::GlobalContext>);
|
||||||
|
|
||||||
impl USBRaw {
|
impl USBRaw {
|
||||||
@@ -43,6 +43,6 @@ impl USBRaw {
|
|||||||
message,
|
message,
|
||||||
Duration::from_millis(200),
|
Duration::from_millis(200),
|
||||||
)
|
)
|
||||||
.map_err(|e| PlatformError::USB(e))
|
.map_err(PlatformError::USB)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ impl std::str::FromStr for Profile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||||
#[derive(Deserialize, Serialize, Debug, PartialEq, Clone, Copy)]
|
#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum FanCurvePU {
|
pub enum FanCurvePU {
|
||||||
CPU,
|
CPU,
|
||||||
GPU,
|
GPU,
|
||||||
|
|||||||
Reference in New Issue
Block a user