mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
rename keyboard led power dbus methods
This commit is contained in:
@@ -507,14 +507,14 @@ fn handle_led_power_1_do_1866(
|
|||||||
x19b6: vec![],
|
x19b6: vec![],
|
||||||
tuf: vec![],
|
tuf: vec![],
|
||||||
};
|
};
|
||||||
dbus.proxies().led().set_leds_power(data, true)?;
|
dbus.proxies().led().set_led_power(data, true)?;
|
||||||
|
|
||||||
let data = AuraPowerDev {
|
let data = AuraPowerDev {
|
||||||
x1866: disabled,
|
x1866: disabled,
|
||||||
x19b6: vec![],
|
x19b6: vec![],
|
||||||
tuf: vec![],
|
tuf: vec![],
|
||||||
};
|
};
|
||||||
dbus.proxies().led().set_leds_power(data, false)?;
|
dbus.proxies().led().set_led_power(data, false)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -546,14 +546,14 @@ fn handle_led_power_1_do_tuf(
|
|||||||
x19b6: vec![],
|
x19b6: vec![],
|
||||||
tuf: enabled,
|
tuf: enabled,
|
||||||
};
|
};
|
||||||
dbus.proxies().led().set_leds_power(data, true)?;
|
dbus.proxies().led().set_led_power(data, true)?;
|
||||||
|
|
||||||
let data = AuraPowerDev {
|
let data = AuraPowerDev {
|
||||||
x1866: vec![],
|
x1866: vec![],
|
||||||
x19b6: vec![],
|
x19b6: vec![],
|
||||||
tuf: disabled,
|
tuf: disabled,
|
||||||
};
|
};
|
||||||
dbus.proxies().led().set_leds_power(data, false)?;
|
dbus.proxies().led().set_led_power(data, false)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -640,7 +640,7 @@ fn handle_led_power2(
|
|||||||
x1866: vec![],
|
x1866: vec![],
|
||||||
x19b6: enabled,
|
x19b6: enabled,
|
||||||
};
|
};
|
||||||
dbus.proxies().led().set_leds_power(data, true)?;
|
dbus.proxies().led().set_led_power(data, true)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !disabled.is_empty() {
|
if !disabled.is_empty() {
|
||||||
@@ -649,7 +649,7 @@ fn handle_led_power2(
|
|||||||
x1866: vec![],
|
x1866: vec![],
|
||||||
x19b6: disabled,
|
x19b6: disabled,
|
||||||
};
|
};
|
||||||
dbus.proxies().led().set_leds_power(data, false)?;
|
dbus.proxies().led().set_led_power(data, false)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ impl CtrlKbdLedZbus {
|
|||||||
/// ShutdownRearGlow = 1 << (23 + 4),
|
/// ShutdownRearGlow = 1 << (23 + 4),
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
async fn set_leds_power(
|
async fn set_led_power(
|
||||||
&mut self,
|
&mut self,
|
||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
options: AuraPowerDev,
|
options: AuraPowerDev,
|
||||||
@@ -210,7 +210,7 @@ impl CtrlKbdLedZbus {
|
|||||||
|
|
||||||
// As property doesn't work for AuraPowerDev (complexity of serialization?)
|
// As property doesn't work for AuraPowerDev (complexity of serialization?)
|
||||||
// #[dbus_interface(property)]
|
// #[dbus_interface(property)]
|
||||||
async fn leds_enabled(&self) -> AuraPowerDev {
|
async fn led_power(&self) -> AuraPowerDev {
|
||||||
let ctrl = self.0.lock().await;
|
let ctrl = self.0.lock().await;
|
||||||
AuraPowerDev::from(&ctrl.config.enabled)
|
AuraPowerDev::from(&ctrl.config.enabled)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
-->
|
-->
|
||||||
<method name="SetLedsPower">
|
<method name="SetLedPower">
|
||||||
<arg name="options" type="(asasas)" direction="in"/>
|
<arg name="options" type="(asasas)" direction="in"/>
|
||||||
<arg name="enabled" type="b" direction="in"/>
|
<arg name="enabled" type="b" direction="in"/>
|
||||||
</method>
|
</method>
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
</method>
|
</method>
|
||||||
<method name="PrevLedBrightness">
|
<method name="PrevLedBrightness">
|
||||||
</method>
|
</method>
|
||||||
<method name="LedsEnabled">
|
<method name="LedPower">
|
||||||
<arg type="(asasas)" direction="out"/>
|
<arg type="(asasas)" direction="out"/>
|
||||||
</method>
|
</method>
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -1,19 +1,38 @@
|
|||||||
import { AuraEffect, AuraModeNum, AuraZone, Direction, Speed } from "../../bindings/aura";
|
import { AuraEffect, AuraModeNum, AuraPowerDev, AuraZone, Direction, Speed } from "../../bindings/aura";
|
||||||
import { DbusBase } from "./base";
|
import { DbusBase } from "./base";
|
||||||
|
|
||||||
export class AuraDbus extends DbusBase {
|
export class AuraDbus extends DbusBase {
|
||||||
public aura_modes: Map<string, AuraEffect> = new Map;
|
public current_aura_mode: AuraModeNum = AuraModeNum.Static;
|
||||||
|
public aura_modes: Map<AuraModeNum, AuraEffect> = new Map;
|
||||||
|
public leds_powered: AuraPowerDev = {
|
||||||
|
tuf: [],
|
||||||
|
x1866: [],
|
||||||
|
x19b6: []
|
||||||
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("org-asuslinux-aura-4", "/org/asuslinux/Aura");
|
super("org-asuslinux-aura-4", "/org/asuslinux/Aura");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getLedPower() {
|
||||||
|
if (this.isRunning()) {
|
||||||
|
try {
|
||||||
|
const data = this.dbus_proxy.LedPowerSync();
|
||||||
|
//@ts-ignore
|
||||||
|
log("Current LED mode:", data);
|
||||||
|
} catch (e) {
|
||||||
|
//@ts-ignore
|
||||||
|
log("Failed to fetch supported functionalities", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public getLedMode() {
|
public getLedMode() {
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
try {
|
try {
|
||||||
const _data = this.dbus_proxy.LedModeSync();
|
this.current_aura_mode = AuraModeNum[this.dbus_proxy.LedModeSync() as AuraModeNum];
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log("Led Mode:", _data);
|
log("Current LED mode:", this.current_aura_mode);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log("Failed to fetch supported functionalities", e);
|
log("Failed to fetch supported functionalities", e);
|
||||||
@@ -25,14 +44,6 @@ export class AuraDbus extends DbusBase {
|
|||||||
public getLedModes() {
|
public getLedModes() {
|
||||||
// {'Breathe': ('Breathe', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
// {'Breathe': ('Breathe', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
||||||
// 'Comet': ('Comet', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
// 'Comet': ('Comet', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
||||||
// 'Flash': ('Flash', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
|
||||||
// 'Highlight': ('Highlight', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
|
||||||
// 'Laser': ('Laser', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
|
||||||
// 'Pulse': ('Pulse', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
|
||||||
// 'Rain': ('Rain', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
|
||||||
// 'Rainbow': ('Rainbow', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
|
||||||
// 'Ripple': ('Ripple', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
|
||||||
// 'Star': ('Star', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
|
||||||
// 'Static': ('Static', 'None', (78, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
// 'Static': ('Static', 'None', (78, 0, 0), (0, 0, 0), 'Med', 'Right'),
|
||||||
// 'Strobe': ('Strobe', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right')}
|
// 'Strobe': ('Strobe', 'None', (166, 0, 0), (0, 0, 0), 'Med', 'Right')}
|
||||||
if (this.isRunning()) {
|
if (this.isRunning()) {
|
||||||
@@ -56,12 +67,12 @@ export class AuraDbus extends DbusBase {
|
|||||||
speed: Speed[value[4] as Speed],
|
speed: Speed[value[4] as Speed],
|
||||||
direction: Direction[value[5] as Direction],
|
direction: Direction[value[5] as Direction],
|
||||||
};
|
};
|
||||||
this.aura_modes.set(key, aura);
|
this.aura_modes.set(AuraModeNum[key as AuraModeNum], aura);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [key, value] of this.aura_modes) {
|
for (const [key, value] of this.aura_modes) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log(key + " = ", value.zone, value.colour1, value.speed, value.direction);
|
log(key, value.zone, value.colour1.r, value.speed, value.direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -74,6 +85,7 @@ export class AuraDbus extends DbusBase {
|
|||||||
async start() {
|
async start() {
|
||||||
try {
|
try {
|
||||||
await super.start();
|
await super.start();
|
||||||
|
this.getLedPower();
|
||||||
this.getLedMode();
|
this.getLedMode();
|
||||||
this.getLedModes();
|
this.getLedModes();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ impl Led {
|
|||||||
Ok(1)
|
Ok(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn leds_enabled(&self) -> Result<AuraPowerDev> {
|
pub fn led_powered(&self) -> Result<AuraPowerDev> {
|
||||||
Ok(AuraPowerDev {
|
Ok(AuraPowerDev {
|
||||||
tuf: vec![],
|
tuf: vec![],
|
||||||
x1866: vec![],
|
x1866: vec![],
|
||||||
@@ -200,7 +200,7 @@ impl Led {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_leds_power(&self, _a: AuraPowerDev, _b: bool) -> Result<()> {
|
pub fn set_led_power(&self, _a: AuraPowerDev, _b: bool) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ impl AuraState {
|
|||||||
} else {
|
} else {
|
||||||
BTreeMap::new()
|
BTreeMap::new()
|
||||||
},
|
},
|
||||||
enabled: dbus.proxies().led().leds_enabled().unwrap_or_default(),
|
enabled: dbus.proxies().led().led_powered().unwrap_or_default(),
|
||||||
bright: dbus.proxies().led().led_brightness().unwrap_or_default(),
|
bright: dbus.proxies().led().led_brightness().unwrap_or_default(),
|
||||||
wave_red: [0u8; 22],
|
wave_red: [0u8; 22],
|
||||||
wave_green: [0u8; 22],
|
wave_green: [0u8; 22],
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
|
|||||||
.asus_dbus
|
.asus_dbus
|
||||||
.proxies()
|
.proxies()
|
||||||
.led()
|
.led()
|
||||||
.set_leds_power(options, enable)
|
.set_led_power(options, enable)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
states.error = Some(err.to_string());
|
states.error = Some(err.to_string());
|
||||||
})
|
})
|
||||||
@@ -189,7 +189,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
|
|||||||
.asus_dbus
|
.asus_dbus
|
||||||
.proxies()
|
.proxies()
|
||||||
.led()
|
.led()
|
||||||
.set_leds_power(options, enable)
|
.set_led_power(options, enable)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
states.error = Some(err.to_string());
|
states.error = Some(err.to_string());
|
||||||
})
|
})
|
||||||
@@ -317,7 +317,7 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
|
|||||||
.asus_dbus
|
.asus_dbus
|
||||||
.proxies()
|
.proxies()
|
||||||
.led()
|
.led()
|
||||||
.set_leds_power(options, enable)
|
.set_led_power(options, enable)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
states.error = Some(err.to_string());
|
states.error = Some(err.to_string());
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ trait Led {
|
|||||||
/// SetLedMode method
|
/// SetLedMode method
|
||||||
fn set_led_mode(&self, effect: &AuraEffect) -> zbus::Result<()>;
|
fn set_led_mode(&self, effect: &AuraEffect) -> zbus::Result<()>;
|
||||||
|
|
||||||
fn set_leds_power(&self, options: AuraPowerDev, enabled: bool) -> zbus::Result<()>;
|
fn set_led_power(&self, options: AuraPowerDev, enabled: bool) -> zbus::Result<()>;
|
||||||
|
|
||||||
/// On machine that have some form of either per-key keyboard or per-zone
|
/// On machine that have some form of either per-key keyboard or per-zone
|
||||||
/// this can be used to write custom effects over dbus. The input is a
|
/// this can be used to write custom effects over dbus. The input is a
|
||||||
@@ -79,7 +79,7 @@ trait Led {
|
|||||||
|
|
||||||
// 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)]
|
||||||
fn leds_enabled(&self) -> zbus::Result<AuraPowerDev>;
|
fn led_powered(&self) -> zbus::Result<AuraPowerDev>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LedProxyPerkey<'a>(LedProxyBlocking<'a>);
|
pub struct LedProxyPerkey<'a>(LedProxyBlocking<'a>);
|
||||||
|
|||||||
Reference in New Issue
Block a user