mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
rog-control-center: ensure brightness slider works correctly
This commit is contained in:
@@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Support for G513RW LED modes
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- rog-control-center: ensure brightness slider works correctly
|
||||||
|
- Update `smithay-client-toolkit` for fix to issue #407
|
||||||
|
|
||||||
## [v4.7.2]
|
## [v4.7.2]
|
||||||
### Added
|
### Added
|
||||||
- Support for G733PZ LED modes
|
- Support for G733PZ LED modes
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ use std::time::SystemTime;
|
|||||||
|
|
||||||
use egui::Vec2;
|
use egui::Vec2;
|
||||||
use log::error;
|
use log::error;
|
||||||
use rog_anime::usb::Brightness;
|
use rog_anime::{Animations, DeviceState};
|
||||||
use rog_anime::Animations;
|
|
||||||
use rog_aura::layouts::KeyLayout;
|
use rog_aura::layouts::KeyLayout;
|
||||||
use rog_aura::usb::AuraPowerDev;
|
use rog_aura::usb::AuraPowerDev;
|
||||||
use rog_aura::{AuraEffect, AuraModeNum};
|
use rog_aura::{AuraEffect, AuraModeNum};
|
||||||
@@ -193,7 +192,7 @@ impl AuraState {
|
|||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct AnimeState {
|
pub struct AnimeState {
|
||||||
pub display_enabled: bool,
|
pub display_enabled: bool,
|
||||||
pub display_brightness: Brightness,
|
pub display_brightness: u8,
|
||||||
pub builtin_anims_enabled: bool,
|
pub builtin_anims_enabled: bool,
|
||||||
pub builtin_anims: Animations,
|
pub builtin_anims: Animations,
|
||||||
}
|
}
|
||||||
@@ -204,7 +203,7 @@ impl AnimeState {
|
|||||||
let device_state = dbus.proxies().anime().device_state()?;
|
let device_state = dbus.proxies().anime().device_state()?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
display_enabled: device_state.display_enabled,
|
display_enabled: device_state.display_enabled,
|
||||||
display_brightness: device_state.display_brightness,
|
display_brightness: device_state.display_brightness as u8,
|
||||||
builtin_anims_enabled: device_state.builtin_anims_enabled,
|
builtin_anims_enabled: device_state.builtin_anims_enabled,
|
||||||
builtin_anims: device_state.builtin_anims,
|
builtin_anims: device_state.builtin_anims,
|
||||||
})
|
})
|
||||||
@@ -214,6 +213,17 @@ impl AnimeState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<DeviceState> for AnimeState {
|
||||||
|
fn from(dev: DeviceState) -> Self {
|
||||||
|
Self {
|
||||||
|
display_enabled: dev.display_enabled,
|
||||||
|
display_brightness: dev.display_brightness as u8,
|
||||||
|
builtin_anims_enabled: dev.builtin_anims_enabled,
|
||||||
|
builtin_anims: dev.builtin_anims,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct GfxState {
|
pub struct GfxState {
|
||||||
pub has_supergfx: bool,
|
pub has_supergfx: bool,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use supergfxctl::actions::UserActionRequired as GfxUserAction;
|
|||||||
use supergfxctl::pci_device::{GfxMode, GfxPower};
|
use supergfxctl::pci_device::{GfxMode, GfxPower};
|
||||||
use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy;
|
use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use zbus::export::futures_util::{future, StreamExt};
|
use zbus::export::futures_util::StreamExt;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
@@ -314,15 +314,15 @@ pub fn start_notifications(
|
|||||||
e
|
e
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if let Ok(p) = proxy.receive_device_state().await {
|
if let Ok(mut p) = proxy.receive_device_state().await {
|
||||||
info!("Started zbus signal thread: receive_device_state");
|
info!("Started zbus signal thread: receive_device_state");
|
||||||
p.for_each(|_| {
|
while let Some(e) = p.next().await {
|
||||||
if let Ok(_lock) = page_states1.lock() {
|
if let Ok(out) = e.args() {
|
||||||
// TODO: lock.anime.
|
if let Ok(mut lock) = page_states1.lock() {
|
||||||
|
lock.anime = out.data.into();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
future::ready(())
|
}
|
||||||
})
|
|
||||||
.await;
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ pub fn anime_power_group(_supported: &SupportedFunctions, states: &mut SystemSta
|
|||||||
ui.heading("AniMe Matrix Settings");
|
ui.heading("AniMe Matrix Settings");
|
||||||
ui.label("Options are incomplete. Awake + Boot should work");
|
ui.label("Options are incomplete. Awake + Boot should work");
|
||||||
|
|
||||||
let mut brightness = states.anime.display_brightness as u8;
|
|
||||||
|
|
||||||
ui.horizontal_wrapped(|ui| {
|
ui.horizontal_wrapped(|ui| {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
let h = 16.0;
|
let h = 16.0;
|
||||||
@@ -30,12 +28,14 @@ pub fn anime_power_group(_supported: &SupportedFunctions, states: &mut SystemSta
|
|||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.set_row_height(22.0);
|
ui.set_row_height(22.0);
|
||||||
ui.horizontal_wrapped(|ui| {
|
ui.horizontal_wrapped(|ui| {
|
||||||
if ui.add(egui::Slider::new(&mut brightness, 0..=3)).changed() {
|
let slider =
|
||||||
|
egui::Slider::new(&mut states.anime.display_brightness, 0..=3).step_by(1.0);
|
||||||
|
if ui.add(slider).drag_released() {
|
||||||
states
|
states
|
||||||
.asus_dbus
|
.asus_dbus
|
||||||
.proxies()
|
.proxies()
|
||||||
.anime()
|
.anime()
|
||||||
.set_brightness(Brightness::from(brightness))
|
.set_brightness(Brightness::from(states.anime.display_brightness))
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
states.error = Some(err.to_string());
|
states.error = Some(err.to_string());
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -75,11 +75,14 @@ pub fn read_attr_u8_array(device: &Device, attr_name: &str) -> Result<Vec<u8>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_attr_u8_array(device: &mut Device, attr: &str, values: &[u8]) -> Result<()> {
|
pub fn write_attr_u8_array(device: &mut Device, attr: &str, values: &[u8]) -> Result<()> {
|
||||||
#[allow(clippy::format_collect)]
|
let mut tmp = String::new();
|
||||||
let tmp: String = values.iter().map(|v| format!("{} ", v)).collect();
|
for n in values {
|
||||||
let tmp = tmp.trim();
|
tmp.push_str(&n.to_string());
|
||||||
|
tmp.push(' '); // space padding required
|
||||||
|
}
|
||||||
|
tmp.pop();
|
||||||
device
|
device
|
||||||
.set_attribute_value(attr, tmp)
|
.set_attribute_value(attr, tmp.trim())
|
||||||
.map_err(|e| PlatformError::IoPath(attr.into(), e))
|
.map_err(|e| PlatformError::IoPath(attr.into(), e))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,9 +106,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn check() {
|
fn check() {
|
||||||
let data = [1, 2, 3, 4, 5];
|
let data = [1, 2, 3, 4, 5];
|
||||||
#[allow(clippy::format_collect)]
|
let mut tmp = String::new();
|
||||||
let tmp: String = data.iter().map(|v| format!("{} ", v)).collect();
|
for n in data {
|
||||||
let tmp = tmp.trim();
|
tmp.push_str(&n.to_string());
|
||||||
|
tmp.push(' '); // space padding required
|
||||||
|
}
|
||||||
|
tmp.pop();
|
||||||
assert_eq!(tmp, "1 2 3 4 5");
|
assert_eq!(tmp, "1 2 3 4 5");
|
||||||
|
|
||||||
let tmp: Vec<u8> = tmp
|
let tmp: Vec<u8> = tmp
|
||||||
|
|||||||
Reference in New Issue
Block a user