mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Trial BTreeMap<AuraModeNum, AuraEffect> return for led dbus
This commit is contained in:
@@ -418,8 +418,8 @@ impl CtrlKbdLed {
|
|||||||
|
|
||||||
self.config.read();
|
self.config.read();
|
||||||
// if self.config.builtins.contains_key(&next) {
|
// if self.config.builtins.contains_key(&next) {
|
||||||
self.config.current_mode = next;
|
self.config.current_mode = next;
|
||||||
self.write_current_config_mode()?;
|
self.write_current_config_mode()?;
|
||||||
// }
|
// }
|
||||||
self.config.write();
|
self.config.write();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use rog_aura::{usb::AuraPowerDev, AuraEffect, LedBrightness, AuraModeNum};
|
use rog_aura::{usb::AuraPowerDev, AuraEffect, AuraModeNum, LedBrightness};
|
||||||
use zbus::{dbus_interface, Connection, SignalContext};
|
use zbus::{dbus_interface, Connection, SignalContext};
|
||||||
|
|
||||||
use super::controller::CtrlKbdLedZbus;
|
use super::controller::CtrlKbdLedZbus;
|
||||||
@@ -183,15 +185,12 @@ impl CtrlKbdLedZbus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return a list of available modes
|
/// Return a list of available modes
|
||||||
#[dbus_interface(property)]
|
async fn led_modes(&self) -> BTreeMap<AuraModeNum, AuraEffect> {
|
||||||
async fn led_modes(&self) -> String {
|
loop {
|
||||||
if let Ok(ctrl) = self.0.try_lock() {
|
if let Ok(ctrl) = self.0.try_lock() {
|
||||||
if let Ok(json) = serde_json::to_string(&ctrl.config.builtins) {
|
return ctrl.config.builtins.clone();
|
||||||
return json;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
warn!("SetKeyBacklight could not deserialise");
|
|
||||||
"SetKeyBacklight could not serialise".to_string()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the current LED brightness
|
/// Return the current LED brightness
|
||||||
|
|||||||
@@ -19,10 +19,12 @@
|
|||||||
//!
|
//!
|
||||||
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
||||||
|
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use zbus::{blocking::Connection, Result};
|
use zbus::{blocking::Connection, Result};
|
||||||
use zbus_macros::dbus_proxy;
|
use zbus_macros::dbus_proxy;
|
||||||
|
|
||||||
use rog_aura::{usb::AuraPowerDev, AuraEffect, KeyColourArray, LedBrightness, AuraModeNum};
|
use rog_aura::{usb::AuraPowerDev, AuraEffect, AuraModeNum, KeyColourArray, LedBrightness};
|
||||||
|
|
||||||
const BLOCKING_TIME: u64 = 40; // 100ms = 10 FPS, max 50ms = 20 FPS, 40ms = 25 FPS
|
const BLOCKING_TIME: u64 = 40; // 100ms = 10 FPS, max 50ms = 20 FPS, 40ms = 25 FPS
|
||||||
|
|
||||||
@@ -66,8 +68,7 @@ trait Led {
|
|||||||
fn led_mode(&self) -> zbus::Result<AuraModeNum>;
|
fn led_mode(&self) -> zbus::Result<AuraModeNum>;
|
||||||
|
|
||||||
/// LedModes property
|
/// LedModes property
|
||||||
#[dbus_proxy(property)]
|
fn led_modes(&self) -> zbus::Result<BTreeMap<AuraModeNum, AuraEffect>>;
|
||||||
fn led_modes(&self) -> zbus::Result<String>;
|
|
||||||
|
|
||||||
// As property doesn't work for AuraPowerDev (complexity of serialization?)
|
// As property doesn't work for AuraPowerDev (complexity of serialization?)
|
||||||
// #[dbus_proxy(property)]
|
// #[dbus_proxy(property)]
|
||||||
|
|||||||
Reference in New Issue
Block a user