gex: parse led power from dbus

This commit is contained in:
Luke D. Jones
2023-07-04 12:31:10 +12:00
parent 823958492e
commit a09f7b5275
3 changed files with 44 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ use async_trait::async_trait;
use config_traits::StdConfig;
use log::{error, info, warn};
use rog_aura::advanced::UsbPackets;
use rog_aura::usb::AuraPowerDev;
use rog_aura::usb::{AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, LedBrightness};
use zbus::export::futures_util::lock::{Mutex, MutexGuard};
use zbus::export::futures_util::StreamExt;
@@ -208,6 +208,12 @@ impl CtrlKbdLedZbus {
Ok(())
}
/// Return the device type for this Aura keyboard
async fn device_type(&self) -> AuraDevice {
let ctrl = self.0.lock().await;
ctrl.led_prod
}
// As property doesn't work for AuraPowerDev (complexity of serialization?)
// #[dbus_interface(property)]
async fn led_power(&self) -> AuraPowerDev {

View File

@@ -69,8 +69,14 @@
</method>
<method name="PrevLedBrightness">
</method>
<!--
Return the device type for this Aura keyboard
-->
<method name="DeviceType">
<arg type="s" direction="out"/>
</method>
<method name="LedPower">
<arg type="(asasas)" direction="out"/>
<arg type="asasas" direction="out"/>
</method>
<!--
Return the current mode data

View File

@@ -1,7 +1,8 @@
import { AuraEffect, AuraModeNum, AuraPowerDev, AuraZone, Direction, Speed } from "../../bindings/aura";
import { AuraDevRog1, AuraDevRog2, AuraDevTuf, AuraDevice, AuraEffect, AuraModeNum, AuraPowerDev, AuraZone, Direction, Speed } from "../../bindings/aura";
import { DbusBase } from "./base";
export class AuraDbus extends DbusBase {
public device: AuraDevice = AuraDevice.Unknown;
public current_aura_mode: AuraModeNum = AuraModeNum.Static;
public aura_modes: Map<AuraModeNum, AuraEffect> = new Map;
public leds_powered: AuraPowerDev = {
@@ -14,12 +15,38 @@ export class AuraDbus extends DbusBase {
super("org-asuslinux-aura-4", "/org/asuslinux/Aura");
}
public getDevice() {
if (this.isRunning()) {
try {
this.device = AuraDevice[this.dbus_proxy.DeviceTypeSync() as AuraDevice];
//@ts-ignore
log("LED device: " + this.device);
} catch (e) {
//@ts-ignore
log("Failed to fetch supported functionalities", e);
}
}
}
public getLedPower() {
if (this.isRunning()) {
try {
const data = this.dbus_proxy.LedPowerSync();
this.leds_powered.tuf = data[0].map((value: string) => {
return AuraDevTuf[value as AuraDevTuf];
});
this.leds_powered.x1866 = data[1].map((value: string) => {
return AuraDevRog1[value as AuraDevRog1];
});
this.leds_powered.x19b6 = data[2].map((value: string) => {
return AuraDevRog2[value as AuraDevRog2];
});
//@ts-ignore
log("Current LED mode:", data);
log("LED power tuf: " + this.leds_powered.tuf);
//@ts-ignore
log("LED power x1866: " + this.leds_powered.x1866);
//@ts-ignore
log("LED power x19b6: " + this.leds_powered.x19b6);
} catch (e) {
//@ts-ignore
log("Failed to fetch supported functionalities", e);
@@ -85,6 +112,7 @@ export class AuraDbus extends DbusBase {
async start() {
try {
await super.start();
this.getDevice();
this.getLedPower();
this.getLedMode();
this.getLedModes();