mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
fix: LEDs managfement in rogcc
This commit is contained in:
@@ -187,12 +187,18 @@ async fn main() -> Result<()> {
|
|||||||
slint::init_translations!(concat!(env!("CARGO_MANIFEST_DIR"), "/translations/"));
|
slint::init_translations!(concat!(env!("CARGO_MANIFEST_DIR"), "/translations/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prefetch supported Aura modes once at startup and move into the
|
||||||
|
// spawned UI thread so the UI uses a stable, immutable list.
|
||||||
|
let prefetched_supported: std::sync::Arc<Option<Vec<i32>>> = std::sync::Arc::new(
|
||||||
|
rog_control_center::ui::setup_aura::prefetch_supported_basic_modes().await,
|
||||||
|
);
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let mut state = AppState::StartingUp;
|
let mut state = AppState::StartingUp;
|
||||||
loop {
|
loop {
|
||||||
if is_rog_ally {
|
if is_rog_ally {
|
||||||
let config_copy_2 = config.clone();
|
let config_copy_2 = config.clone();
|
||||||
let newui = setup_window(config.clone());
|
let newui = setup_window(config.clone(), prefetched_supported.clone());
|
||||||
newui.window().on_close_requested(move || {
|
newui.window().on_close_requested(move || {
|
||||||
exit(0);
|
exit(0);
|
||||||
});
|
});
|
||||||
@@ -233,6 +239,9 @@ async fn main() -> Result<()> {
|
|||||||
|
|
||||||
let config_copy = config.clone();
|
let config_copy = config.clone();
|
||||||
let app_state_copy = app_state.clone();
|
let app_state_copy = app_state.clone();
|
||||||
|
// Avoid moving the original `prefetched_supported` into the
|
||||||
|
// closure — clone an Arc for the closure to capture.
|
||||||
|
let pref_for_invoke = prefetched_supported.clone();
|
||||||
slint::invoke_from_event_loop(move || {
|
slint::invoke_from_event_loop(move || {
|
||||||
UI.with(|ui| {
|
UI.with(|ui| {
|
||||||
let app_state_copy = app_state_copy.clone();
|
let app_state_copy = app_state_copy.clone();
|
||||||
@@ -247,7 +256,7 @@ async fn main() -> Result<()> {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let config_copy_2 = config_copy.clone();
|
let config_copy_2 = config_copy.clone();
|
||||||
let newui = setup_window(config_copy);
|
let newui = setup_window(config_copy, pref_for_invoke.clone());
|
||||||
newui.window().on_close_requested(move || {
|
newui.window().on_close_requested(move || {
|
||||||
if let Ok(mut app_state) = app_state_copy.lock() {
|
if let Ok(mut app_state) = app_state_copy.lock() {
|
||||||
*app_state = AppState::MainWindowClosed;
|
*app_state = AppState::MainWindowClosed;
|
||||||
|
|||||||
@@ -82,7 +82,10 @@ pub fn show_toast(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
|
pub fn setup_window(
|
||||||
|
config: Arc<Mutex<Config>>,
|
||||||
|
prefetched_supported: std::sync::Arc<Option<Vec<i32>>>,
|
||||||
|
) -> MainWindow {
|
||||||
slint::set_xdg_app_id("rog-control-center")
|
slint::set_xdg_app_id("rog-control-center")
|
||||||
.map_err(|e| warn!("Couldn't set application ID: {e:?}"))
|
.map_err(|e| warn!("Couldn't set application ID: {e:?}"))
|
||||||
.ok();
|
.ok();
|
||||||
@@ -119,7 +122,7 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
|
|||||||
setup_system_page_callbacks(&ui, config.clone());
|
setup_system_page_callbacks(&ui, config.clone());
|
||||||
}
|
}
|
||||||
if available.contains(&"xyz.ljones.Aura".to_string()) {
|
if available.contains(&"xyz.ljones.Aura".to_string()) {
|
||||||
setup_aura_page(&ui, config.clone());
|
setup_aura_page(&ui, config.clone(), prefetched_supported.as_ref().clone());
|
||||||
}
|
}
|
||||||
if available.contains(&"xyz.ljones.Anime".to_string()) {
|
if available.contains(&"xyz.ljones.Anime".to_string()) {
|
||||||
setup_anime_page(&ui, config.clone());
|
setup_anime_page(&ui, config.clone());
|
||||||
|
|||||||
@@ -34,63 +34,108 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the first available Aura interface
|
|
||||||
// TODO: return all
|
|
||||||
async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Error>> {
|
async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Error>> {
|
||||||
let conn = zbus::Connection::system().await?;
|
let conn = zbus::Connection::system().await?;
|
||||||
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").await?;
|
let mgr = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").await?;
|
||||||
let interfaces = f.get_managed_objects().await?;
|
let objs = mgr.get_managed_objects().await?;
|
||||||
let mut aura_paths = Vec::new();
|
let mut paths: Vec<zbus::zvariant::OwnedObjectPath> = objs
|
||||||
for v in interfaces.iter() {
|
.iter()
|
||||||
for k in v.1.keys() {
|
.filter(|(_, ifaces)| ifaces.keys().any(|k| k.as_str() == "xyz.ljones.Aura"))
|
||||||
if k.as_str() == "xyz.ljones.Aura" {
|
.map(|(p, _)| p.clone())
|
||||||
println!("Found aura device at {}, {}", v.0, k);
|
.collect();
|
||||||
aura_paths.push(v.0.clone());
|
if paths.len() > 1 {
|
||||||
}
|
log::debug!("Multiple aura devices: {paths:?}");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if aura_paths.len() > 1 {
|
let path = paths.pop().ok_or("No Aura interface")?;
|
||||||
println!("Multiple aura devices found: {aura_paths:?}");
|
AuraProxy::builder(&conn)
|
||||||
println!("TODO: enable selection");
|
.path(path)?
|
||||||
}
|
.destination("xyz.ljones.Asusd")?
|
||||||
if let Some(path) = aura_paths.first() {
|
.build()
|
||||||
return Ok(AuraProxy::builder(&conn)
|
.await
|
||||||
.path(path.clone())?
|
.map_err(Into::into)
|
||||||
.destination("xyz.ljones.Asusd")?
|
|
||||||
.build()
|
|
||||||
.await?);
|
|
||||||
}
|
|
||||||
|
|
||||||
Err("No Aura interface".into())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
pub async fn prefetch_supported_basic_modes() -> Option<Vec<i32>> {
|
||||||
ui.global::<AuraPageData>().on_cb_hex_from_colour(|c| {
|
let proxy = find_aura_iface().await.ok()?;
|
||||||
|
let modes = proxy.supported_basic_modes().await.ok()?;
|
||||||
|
Some(modes.iter().map(|n| (*n).into()).collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn setup_aura_page(
|
||||||
|
ui: &MainWindow,
|
||||||
|
_states: Arc<Mutex<Config>>,
|
||||||
|
prefetched_supported: Option<Vec<i32>>,
|
||||||
|
) {
|
||||||
|
let g = ui.global::<AuraPageData>();
|
||||||
|
g.on_cb_hex_from_colour(|c| {
|
||||||
format!("#{:02X}{:02X}{:02X}", c.red(), c.green(), c.blue()).into()
|
format!("#{:02X}{:02X}{:02X}", c.red(), c.green(), c.blue()).into()
|
||||||
});
|
});
|
||||||
|
g.on_cb_hex_to_colour(|s| decode_hex(s.as_str()).into());
|
||||||
ui.global::<AuraPageData>()
|
|
||||||
.on_cb_hex_to_colour(|s| decode_hex(s.as_str()).into());
|
|
||||||
|
|
||||||
let handle = ui.as_weak();
|
let handle = ui.as_weak();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let Ok(aura) = find_aura_iface().await else {
|
let Ok(aura) = find_aura_iface().await else {
|
||||||
info!("This device appears to have no aura interfaces");
|
info!("No aura interfaces");
|
||||||
return Ok::<(), zbus::Error>(());
|
return Ok::<(), zbus::Error>(());
|
||||||
};
|
};
|
||||||
|
|
||||||
set_ui_props_async!(handle, aura, AuraPageData, brightness);
|
set_ui_props_async!(handle, aura, AuraPageData, brightness);
|
||||||
set_ui_props_async!(handle, aura, AuraPageData, led_mode);
|
|
||||||
set_ui_props_async!(handle, aura, AuraPageData, led_mode_data);
|
|
||||||
set_ui_props_async!(handle, aura, AuraPageData, led_power);
|
set_ui_props_async!(handle, aura, AuraPageData, led_power);
|
||||||
set_ui_props_async!(handle, aura, AuraPageData, device_type);
|
set_ui_props_async!(handle, aura, AuraPageData, device_type);
|
||||||
|
|
||||||
|
if let Ok(data) = aura.led_mode_data().await {
|
||||||
|
let d = data.into();
|
||||||
|
handle
|
||||||
|
.upgrade_in_event_loop(move |h| {
|
||||||
|
h.global::<AuraPageData>().invoke_update_led_mode_data(d);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
let modes_vec: Vec<i32> = match prefetched_supported {
|
||||||
|
Some(p) => p,
|
||||||
|
None => aura
|
||||||
|
.supported_basic_modes()
|
||||||
|
.await
|
||||||
|
.ok()
|
||||||
|
.map(|m| m.iter().map(|n| (*n).into()).collect())
|
||||||
|
.unwrap_or_default(),
|
||||||
|
};
|
||||||
|
let current_mode: Option<i32> = aura.led_mode().await.ok().map(|m| m.into());
|
||||||
|
|
||||||
|
handle
|
||||||
|
.upgrade_in_event_loop(move |handle| {
|
||||||
|
let names = handle.global::<AuraPageData>().get_mode_names();
|
||||||
|
let mut raws = Vec::new();
|
||||||
|
let mut mode_names = Vec::new();
|
||||||
|
for (i, name) in names.iter().enumerate() {
|
||||||
|
let raw = i as i32;
|
||||||
|
if modes_vec.contains(&raw) && i != 9 {
|
||||||
|
raws.push(raw);
|
||||||
|
mode_names.push(name.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handle
|
||||||
|
.global::<AuraPageData>()
|
||||||
|
.set_supported_basic_modes(raws.as_slice().into());
|
||||||
|
handle
|
||||||
|
.global::<AuraPageData>()
|
||||||
|
.set_available_mode_names(mode_names.as_slice().into());
|
||||||
|
if let Some(cm) = current_mode {
|
||||||
|
let idx = raws.iter().position(|&r| r == cm).unwrap_or(0) as i32;
|
||||||
|
handle
|
||||||
|
.global::<AuraPageData>()
|
||||||
|
.set_current_available_mode(idx);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map_err(|e| error!("{e}"))
|
||||||
|
.ok();
|
||||||
|
|
||||||
if let Ok(mut pow3r) = aura.supported_power_zones().await {
|
if let Ok(mut pow3r) = aura.supported_power_zones().await {
|
||||||
let dev_type = aura
|
let dev = aura
|
||||||
.device_type()
|
.device_type()
|
||||||
.await
|
.await
|
||||||
.unwrap_or(AuraDeviceType::LaptopKeyboard2021);
|
.unwrap_or(AuraDeviceType::LaptopKeyboard2021);
|
||||||
log::debug!("Available LED power modes {pow3r:?}");
|
|
||||||
handle
|
handle
|
||||||
.upgrade_in_event_loop(move |handle| {
|
.upgrade_in_event_loop(move |handle| {
|
||||||
let names: Vec<SharedString> = handle
|
let names: Vec<SharedString> = handle
|
||||||
@@ -98,135 +143,103 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
|||||||
.get_power_zone_names()
|
.get_power_zone_names()
|
||||||
.iter()
|
.iter()
|
||||||
.collect();
|
.collect();
|
||||||
|
if dev.is_old_laptop() {
|
||||||
if dev_type.is_old_laptop() {
|
|
||||||
// Need to add the specific KeyboardAndLightbar
|
|
||||||
if pow3r.contains(&PowerZones::Keyboard)
|
if pow3r.contains(&PowerZones::Keyboard)
|
||||||
&& pow3r.contains(&PowerZones::Lightbar)
|
&& pow3r.contains(&PowerZones::Lightbar)
|
||||||
{
|
{
|
||||||
pow3r.push(PowerZones::KeyboardAndLightbar);
|
pow3r.push(PowerZones::KeyboardAndLightbar);
|
||||||
}
|
}
|
||||||
let names: Vec<SharedString> =
|
let n: Vec<SharedString> =
|
||||||
pow3r.iter().map(|n| names[(*n) as usize].clone()).collect();
|
pow3r.iter().map(|z| names[(*z) as usize].clone()).collect();
|
||||||
handle
|
handle
|
||||||
.global::<AuraPageData>()
|
.global::<AuraPageData>()
|
||||||
.set_power_zone_names_old(names.as_slice().into());
|
.set_power_zone_names_old(n.as_slice().into());
|
||||||
} else {
|
} else {
|
||||||
let power: Vec<SlintPowerZones> =
|
let p: Vec<SlintPowerZones> = pow3r.iter().map(|z| (*z).into()).collect();
|
||||||
pow3r.iter().map(|p| (*p).into()).collect();
|
|
||||||
|
|
||||||
handle
|
handle
|
||||||
.global::<AuraPageData>()
|
.global::<AuraPageData>()
|
||||||
.set_supported_power_zones(power.as_slice().into());
|
.set_supported_power_zones(p.as_slice().into());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(modes) = aura.supported_basic_modes().await {
|
let proxy = aura.clone();
|
||||||
log::debug!("Available LED modes {modes:?}");
|
let weak = handle.clone();
|
||||||
handle
|
|
||||||
.upgrade_in_event_loop(move |handle| {
|
|
||||||
let m: Vec<i32> = modes.iter().map(|n| (*n).into()).collect();
|
|
||||||
handle
|
|
||||||
.global::<AuraPageData>()
|
|
||||||
.set_supported_basic_modes(m.as_slice().into());
|
|
||||||
// Get the translated names
|
|
||||||
let names = handle.global::<AuraPageData>().get_mode_names();
|
|
||||||
|
|
||||||
let res: Vec<SharedString> = names
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.filter(|(n, _)| modes.contains(&(*n as i32).into()) && *n != 9)
|
|
||||||
.map(|(_, i)| i)
|
|
||||||
.collect();
|
|
||||||
handle
|
|
||||||
.global::<AuraPageData>()
|
|
||||||
.set_available_mode_names(res.as_slice().into());
|
|
||||||
})
|
|
||||||
.map_err(|e| error!("{e:}"))
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
let proxy_copy = aura.clone();
|
|
||||||
handle
|
handle
|
||||||
.upgrade_in_event_loop(move |handle| {
|
.upgrade_in_event_loop(move |h| {
|
||||||
set_ui_callbacks!(handle,
|
set_ui_callbacks!(h,
|
||||||
AuraPageData(.into()),
|
AuraPageData(.into()),
|
||||||
proxy_copy.brightness(.into()),
|
proxy.brightness(.into()),
|
||||||
"Keyboard LED brightness successfully set to {}",
|
"Brightness set to {}",
|
||||||
"Setting keyboard LED brightness failed"
|
"Brightness failed"
|
||||||
);
|
);
|
||||||
|
|
||||||
set_ui_callbacks!(handle,
|
let p = proxy.clone();
|
||||||
AuraPageData(.into()),
|
let w = weak.clone();
|
||||||
proxy_copy.led_mode(.into()),
|
h.global::<AuraPageData>().on_apply_led_mode_data(move || {
|
||||||
"Keyboard LED mode successfully set to {}",
|
let Some(ui) = w.upgrade() else { return };
|
||||||
"Setting keyboard LEDmode failed"
|
let slint_effect = ui.global::<AuraPageData>().get_led_mode_data();
|
||||||
);
|
let raw: rog_aura::AuraEffect = slint_effect.into();
|
||||||
|
let pp = p.clone();
|
||||||
set_ui_callbacks!(handle,
|
let t = w.clone();
|
||||||
AuraPageData(.into()),
|
tokio::spawn(async move {
|
||||||
proxy_copy.led_mode_data(.into()),
|
let r = pp.set_led_mode_data(raw).await;
|
||||||
"Keyboard LED mode set to {:?}",
|
show_toast("LED mode applied".into(), "LED mode failed".into(), t, r);
|
||||||
"Setting keyboard LED mode failed"
|
|
||||||
);
|
|
||||||
|
|
||||||
// set_ui_callbacks!(handle,
|
|
||||||
// AuraPageData(.clone().into()),
|
|
||||||
// proxy_copy.led_power(.into()),
|
|
||||||
// "Keyboard LED power successfully set to {:?}",
|
|
||||||
// "Setting keyboard power failed"
|
|
||||||
// );
|
|
||||||
|
|
||||||
handle.invoke_external_colour_change();
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
|
|
||||||
let handle_copy = handle.clone();
|
|
||||||
let proxy_copy = aura.clone();
|
|
||||||
handle
|
|
||||||
.upgrade_in_event_loop(|handle| {
|
|
||||||
handle
|
|
||||||
.global::<AuraPageData>()
|
|
||||||
.on_cb_led_power(move |power| {
|
|
||||||
let handle_copy = handle_copy.clone();
|
|
||||||
let proxy_copy = aura.clone();
|
|
||||||
let power: LaptopAuraPower = power.into();
|
|
||||||
tokio::spawn(async move {
|
|
||||||
show_toast(
|
|
||||||
"Aura power settings changed".into(),
|
|
||||||
"Failed to set Aura power settings".into(),
|
|
||||||
handle_copy,
|
|
||||||
proxy_copy.set_led_power(power).await,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
h.invoke_external_colour_change();
|
||||||
})
|
})
|
||||||
.map_err(|e| error!("{e:}"))
|
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
// Need to update the UI if the mode changes
|
let weak_power = handle.clone();
|
||||||
let handle_copy = handle.clone();
|
let proxy_power = aura.clone();
|
||||||
// spawn required since the while let never exits
|
handle
|
||||||
|
.upgrade_in_event_loop(|h| {
|
||||||
|
h.global::<AuraPageData>().on_cb_led_power(move |power| {
|
||||||
|
let w = weak_power.clone();
|
||||||
|
let p = proxy_power.clone();
|
||||||
|
let pw: LaptopAuraPower = power.into();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
show_toast(
|
||||||
|
"Aura power updated".into(),
|
||||||
|
"Aura power failed".into(),
|
||||||
|
w,
|
||||||
|
p.set_led_power(pw).await,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.map_err(|e| error!("{e}"))
|
||||||
|
.ok();
|
||||||
|
|
||||||
|
let stream_handle = handle.clone();
|
||||||
|
let aura_stream = aura.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let mut x = proxy_copy.receive_led_mode_data_changed().await;
|
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
while let Some(e) = x.next().await {
|
let mut stream = aura_stream.receive_led_mode_data_changed().await;
|
||||||
|
while let Some(e) = stream.next().await {
|
||||||
if let Ok(out) = e.get().await {
|
if let Ok(out) = e.get().await {
|
||||||
handle_copy
|
let raw: i32 = out.mode.into();
|
||||||
.upgrade_in_event_loop(move |handle| {
|
let data = out.into();
|
||||||
handle
|
stream_handle
|
||||||
|
.upgrade_in_event_loop(move |h| {
|
||||||
|
h.global::<AuraPageData>().invoke_update_led_mode_data(data);
|
||||||
|
let supported: Vec<i32> = h
|
||||||
.global::<AuraPageData>()
|
.global::<AuraPageData>()
|
||||||
.invoke_update_led_mode_data(out.into());
|
.get_supported_basic_modes()
|
||||||
handle.invoke_external_colour_change();
|
.iter()
|
||||||
|
.collect();
|
||||||
|
let idx = supported.iter().position(|&x| x == raw).unwrap_or(0) as i32;
|
||||||
|
h.global::<AuraPageData>().set_current_available_mode(idx);
|
||||||
|
h.invoke_external_colour_change();
|
||||||
})
|
})
|
||||||
.map_err(|e| error!("{e:}"))
|
.map_err(|e| error!("{e}"))
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
debug!("Aura setup tasks complete");
|
debug!("Aura setup done");
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,14 @@ export component PageAura inherits Rectangle {
|
|||||||
current_value: AuraPageData.available_mode_names[self.current-index];
|
current_value: AuraPageData.available_mode_names[self.current-index];
|
||||||
model <=> AuraPageData.available_mode_names;
|
model <=> AuraPageData.available_mode_names;
|
||||||
selected => {
|
selected => {
|
||||||
AuraPageData.led_mode_data.mode = AuraPageData.led_mode;
|
AuraPageData.apply_effect({
|
||||||
AuraPageData.led_mode_data.mode = AuraPageData.current_available_mode;
|
mode: AuraPageData.supported_basic_modes[self.current-index],
|
||||||
self.current_value = AuraPageData.available_mode_names[self.current-index];
|
zone: AuraPageData.led_mode_data.zone,
|
||||||
AuraPageData.cb_led_mode(AuraPageData.current_available_mode);
|
colour1: AuraPageData.led_mode_data.colour1,
|
||||||
|
colour2: AuraPageData.led_mode_data.colour2,
|
||||||
|
speed: AuraPageData.led_mode_data.speed,
|
||||||
|
direction: AuraPageData.led_mode_data.direction,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,47 +66,44 @@ export component PageAura inherits Rectangle {
|
|||||||
vertical-alignment: TextVerticalAlignment.center;
|
vertical-alignment: TextVerticalAlignment.center;
|
||||||
horizontal-alignment: TextHorizontalAlignment.center;
|
horizontal-alignment: TextHorizontalAlignment.center;
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalBox {
|
HorizontalBox {
|
||||||
c1 := ColourSlider {
|
c1 := ColourSlider {
|
||||||
enabled: AuraPageData.led_mode == 0 || AuraPageData.led_mode == 1 || AuraPageData.led_mode == 4 || AuraPageData.led_mode == 6 || AuraPageData.led_mode == 7 || AuraPageData.led_mode == 8 || AuraPageData.led_mode == 10 || AuraPageData.led_mode == 11 || AuraPageData.led_mode == 12;
|
enabled: AuraPageData.colour1_enabled;
|
||||||
final_colour <=> AuraPageData.color1;
|
final_colour <=> AuraPageData.color1;
|
||||||
colourbox <=> AuraPageData.colorbox1;
|
colourbox <=> AuraPageData.colorbox1;
|
||||||
set_hex_from_colour(c1) => {
|
set_hex_from_colour(c) => { return AuraPageData.cb_hex_from_colour(c); }
|
||||||
return AuraPageData.cb_hex_from_colour(c1);
|
hex_to_colour(s) => { return AuraPageData.cb_hex_to_colour(s); }
|
||||||
}
|
|
||||||
hex_to_colour(s) => {
|
|
||||||
return AuraPageData.cb_hex_to_colour(s);
|
|
||||||
}
|
|
||||||
released => {
|
released => {
|
||||||
AuraPageData.led_mode_data.colour1 = AuraPageData.color1;
|
AuraPageData.apply_effect({
|
||||||
AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
|
mode: AuraPageData.led_mode_data.mode,
|
||||||
|
zone: AuraPageData.led_mode_data.zone,
|
||||||
|
colour1: AuraPageData.color1,
|
||||||
|
colour2: AuraPageData.led_mode_data.colour2,
|
||||||
|
speed: AuraPageData.led_mode_data.speed,
|
||||||
|
direction: AuraPageData.led_mode_data.direction,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VerticalBox {
|
VerticalBox {
|
||||||
Text {
|
Text { text: @tr("Colour 2"); vertical-alignment: TextVerticalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center; }
|
||||||
text: @tr("Colour 2");
|
|
||||||
vertical-alignment: TextVerticalAlignment.center;
|
|
||||||
horizontal-alignment: TextHorizontalAlignment.center;
|
|
||||||
}
|
|
||||||
|
|
||||||
HorizontalBox {
|
HorizontalBox {
|
||||||
c2 := ColourSlider {
|
c2 := ColourSlider {
|
||||||
enabled: AuraPageData.led_mode == 1 || AuraPageData.led_mode == 4;
|
enabled: AuraPageData.colour2_enabled;
|
||||||
final_colour <=> AuraPageData.color2;
|
final_colour <=> AuraPageData.color2;
|
||||||
colourbox <=> AuraPageData.colorbox2;
|
colourbox <=> AuraPageData.colorbox2;
|
||||||
set_hex_from_colour(c1) => {
|
set_hex_from_colour(c) => { return AuraPageData.cb_hex_from_colour(c); }
|
||||||
return AuraPageData.cb_hex_from_colour(c1);
|
hex_to_colour(s) => { return AuraPageData.cb_hex_to_colour(s); }
|
||||||
}
|
|
||||||
hex_to_colour(s) => {
|
|
||||||
return AuraPageData.cb_hex_to_colour(s);
|
|
||||||
}
|
|
||||||
released => {
|
released => {
|
||||||
AuraPageData.led_mode_data.colour2 = AuraPageData.color2;
|
AuraPageData.apply_effect({
|
||||||
AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
|
mode: AuraPageData.led_mode_data.mode,
|
||||||
|
zone: AuraPageData.led_mode_data.zone,
|
||||||
|
colour1: AuraPageData.led_mode_data.colour1,
|
||||||
|
colour2: AuraPageData.color2,
|
||||||
|
speed: AuraPageData.led_mode_data.speed,
|
||||||
|
direction: AuraPageData.led_mode_data.direction,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,63 +117,63 @@ export component PageAura inherits Rectangle {
|
|||||||
max-height: 90px;
|
max-height: 90px;
|
||||||
RogItem {
|
RogItem {
|
||||||
VerticalBox {
|
VerticalBox {
|
||||||
Text {
|
Text { text: @tr("Zone"); vertical-alignment: TextVerticalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center; }
|
||||||
text: @tr("Zone");
|
|
||||||
vertical-alignment: TextVerticalAlignment.center;
|
|
||||||
horizontal-alignment: TextHorizontalAlignment.center;
|
|
||||||
}
|
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
// enabled: AuraPageData.led_mode == ;
|
enabled: false;
|
||||||
enabled: false;
|
|
||||||
current_index <=> AuraPageData.zone;
|
current_index <=> AuraPageData.zone;
|
||||||
current_value: AuraPageData.zone_names[self.current-index];
|
current_value: AuraPageData.zone_names[self.current-index];
|
||||||
model <=> AuraPageData.zone_names;
|
model <=> AuraPageData.zone_names;
|
||||||
selected => {
|
selected => {
|
||||||
AuraPageData.led_mode_data.zone = self.current-index;
|
AuraPageData.apply_effect({
|
||||||
AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
|
mode: AuraPageData.led_mode_data.mode,
|
||||||
|
zone: self.current-index,
|
||||||
|
colour1: AuraPageData.led_mode_data.colour1,
|
||||||
|
colour2: AuraPageData.led_mode_data.colour2,
|
||||||
|
speed: AuraPageData.led_mode_data.speed,
|
||||||
|
direction: AuraPageData.led_mode_data.direction,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RogItem {
|
RogItem {
|
||||||
VerticalBox {
|
VerticalBox {
|
||||||
Text {
|
Text { text: @tr("Direction"); vertical-alignment: TextVerticalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center; }
|
||||||
text: @tr("Direction");
|
|
||||||
vertical-alignment: TextVerticalAlignment.center;
|
|
||||||
horizontal-alignment: TextHorizontalAlignment.center;
|
|
||||||
}
|
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
enabled: AuraPageData.led_mode == 3;
|
enabled: AuraPageData.direction_enabled;
|
||||||
current_index <=> AuraPageData.direction;
|
current_index <=> AuraPageData.direction;
|
||||||
current_value: AuraPageData.direction_names[self.current-index];
|
current_value: AuraPageData.direction_names[self.current-index];
|
||||||
model <=> AuraPageData.direction_names;
|
model <=> AuraPageData.direction_names;
|
||||||
selected => {
|
selected => {
|
||||||
AuraPageData.led_mode_data.direction = self.current-index;
|
AuraPageData.apply_effect({
|
||||||
AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
|
mode: AuraPageData.led_mode_data.mode,
|
||||||
|
zone: AuraPageData.led_mode_data.zone,
|
||||||
|
colour1: AuraPageData.led_mode_data.colour1,
|
||||||
|
colour2: AuraPageData.led_mode_data.colour2,
|
||||||
|
speed: AuraPageData.led_mode_data.speed,
|
||||||
|
direction: self.current-index,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RogItem {
|
RogItem {
|
||||||
VerticalBox {
|
VerticalBox {
|
||||||
Text {
|
Text { text: @tr("Speed"); vertical-alignment: TextVerticalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center; }
|
||||||
text: @tr("Speed");
|
|
||||||
vertical-alignment: TextVerticalAlignment.center;
|
|
||||||
horizontal-alignment: TextHorizontalAlignment.center;
|
|
||||||
}
|
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
enabled: AuraPageData.led_mode == 1 || AuraPageData.led_mode == 2 || AuraPageData.led_mode == 3 || AuraPageData.led_mode == 4 || AuraPageData.led_mode == 5 || AuraPageData.led_mode == 6 || AuraPageData.led_mode == 7 || AuraPageData.led_mode == 8;
|
enabled: AuraPageData.speed_enabled;
|
||||||
current_index <=> AuraPageData.speed;
|
current_index <=> AuraPageData.speed;
|
||||||
current_value: AuraPageData.speed_names[self.current-index];
|
current_value: AuraPageData.speed_names[self.current-index];
|
||||||
model <=> AuraPageData.speed_names;
|
model <=> AuraPageData.speed_names;
|
||||||
selected => {
|
selected => {
|
||||||
AuraPageData.led_mode_data.speed = self.current-index;
|
AuraPageData.apply_effect({
|
||||||
AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
|
mode: AuraPageData.led_mode_data.mode,
|
||||||
|
zone: AuraPageData.led_mode_data.zone,
|
||||||
|
colour1: AuraPageData.led_mode_data.colour1,
|
||||||
|
colour2: AuraPageData.led_mode_data.colour2,
|
||||||
|
speed: self.current-index,
|
||||||
|
direction: AuraPageData.led_mode_data.direction,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,10 @@ export struct LaptopAuraPower {
|
|||||||
states: [AuraPowerState],
|
states: [AuraPowerState],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Modes with colour1: Static,Breathe,Star,Rain,Highlight,Laser,Ripple,Pulse,Comet,Flash (excl. Strobe,Rainbow,Nothing)
|
||||||
|
// Modes with colour2: Breathe, Star only.
|
||||||
|
// Speed: Breathe,Strobe,Rainbow,Star,Rain,Highlight,Laser,Ripple. Direction: Rainbow only.
|
||||||
export global AuraPageData {
|
export global AuraPageData {
|
||||||
// The ordering must match the rog-aura crate
|
|
||||||
in-out property <[string]> power_zone_names: [
|
in-out property <[string]> power_zone_names: [
|
||||||
@tr("Aura power zone" => "Logo"),
|
@tr("Aura power zone" => "Logo"),
|
||||||
@tr("Aura power zone" => "Keyboard"),
|
@tr("Aura power zone" => "Keyboard"),
|
||||||
@@ -87,15 +89,9 @@ export global AuraPageData {
|
|||||||
@tr("Basic aura mode" => "Comet"),
|
@tr("Basic aura mode" => "Comet"),
|
||||||
@tr("Basic aura mode" => "Flash"),
|
@tr("Basic aura mode" => "Flash"),
|
||||||
];
|
];
|
||||||
in-out property <[string]> available_mode_names: [
|
in-out property <[string]> available_mode_names: [ @tr("Basic aura mode" => "Static"), @tr("Basic aura mode" => "Breathe"), @tr("Basic aura mode" => "Strobe") ];
|
||||||
@tr("Basic aura mode" => "Static"),
|
|
||||||
@tr("Basic aura mode" => "Breathe"),
|
|
||||||
@tr("Basic aura mode" => "Strobe"),
|
|
||||||
];
|
|
||||||
in-out property <int> current_available_mode: 0;
|
in-out property <int> current_available_mode: 0;
|
||||||
in-out property <[int]> supported_basic_modes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12];
|
in-out property <[int]> supported_basic_modes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12];
|
||||||
in-out property <int> led_mode;
|
|
||||||
callback cb_led_mode(int);
|
|
||||||
in-out property <[string]> zone_names: [
|
in-out property <[string]> zone_names: [
|
||||||
@tr("Aura zone" => "None"),
|
@tr("Aura zone" => "None"),
|
||||||
@tr("Aura zone" => "Key1"),
|
@tr("Aura zone" => "Key1"),
|
||||||
@@ -106,51 +102,57 @@ export global AuraPageData {
|
|||||||
@tr("Aura zone" => "Lightbar Left"),
|
@tr("Aura zone" => "Lightbar Left"),
|
||||||
@tr("Aura zone" => "Lightbar Right"),
|
@tr("Aura zone" => "Lightbar Right"),
|
||||||
];
|
];
|
||||||
in-out property <int> zone;
|
|
||||||
in-out property <[string]> direction_names: [
|
in-out property <[string]> direction_names: [
|
||||||
@tr("Aura direction" => "Right"),
|
@tr("Aura direction" => "Right"),
|
||||||
@tr("Aura direction" => "Left"),
|
@tr("Aura direction" => "Left"),
|
||||||
@tr("Aura direction" => "Up"),
|
@tr("Aura direction" => "Up"),
|
||||||
@tr("Aura direction" => "Down"),
|
@tr("Aura direction" => "Down"),
|
||||||
];
|
];
|
||||||
in-out property <int> direction;
|
|
||||||
in-out property <[string]> speed_names: [
|
in-out property <[string]> speed_names: [
|
||||||
@tr("Aura speed" => "Low"),
|
@tr("Aura speed" => "Low"),
|
||||||
@tr("Aura speed" => "Medium"),
|
@tr("Aura speed" => "Medium"),
|
||||||
@tr("Aura speed" => "High"),
|
@tr("Aura speed" => "High"),
|
||||||
];
|
];
|
||||||
in-out property <int> speed;
|
|
||||||
in-out property <AuraEffect> led_mode_data: {
|
in-out property <AuraEffect> led_mode_data: {
|
||||||
mode: 0,
|
mode: 0,
|
||||||
zone: 0,
|
zone: 0,
|
||||||
colour1: Colors.aquamarine,
|
colour1: Colors.aquamarine,
|
||||||
colourbox1: Colors.aquamarine,
|
|
||||||
colour2: Colors.hotpink,
|
colour2: Colors.hotpink,
|
||||||
colourbox2: Colors.hotpink,
|
|
||||||
speed: 0,
|
speed: 0,
|
||||||
direction: 0,
|
direction: 0,
|
||||||
};
|
};
|
||||||
callback cb_led_mode_data(AuraEffect);
|
|
||||||
in-out property <color> color1;
|
in-out property <color> color1;
|
||||||
in-out property <brush> colorbox1;
|
in-out property <brush> colorbox1;
|
||||||
in-out property <color> color2;
|
in-out property <color> color2;
|
||||||
in-out property <brush> colorbox2;
|
in-out property <brush> colorbox2;
|
||||||
|
|
||||||
|
out property <bool> colour1_enabled: led_mode_data.mode == 0 || led_mode_data.mode == 1 || led_mode_data.mode == 4 || led_mode_data.mode == 6 || led_mode_data.mode == 7 || led_mode_data.mode == 8 || led_mode_data.mode == 10 || led_mode_data.mode == 11 || led_mode_data.mode == 12;
|
||||||
|
out property <bool> colour2_enabled: led_mode_data.mode == 1 || led_mode_data.mode == 4;
|
||||||
|
out property <bool> speed_enabled: led_mode_data.mode == 1 || led_mode_data.mode == 2 || led_mode_data.mode == 3 || led_mode_data.mode == 4 || led_mode_data.mode == 5 || led_mode_data.mode == 6 || led_mode_data.mode == 7 || led_mode_data.mode == 8;
|
||||||
|
out property <bool> direction_enabled: led_mode_data.mode == 3;
|
||||||
|
|
||||||
|
callback apply_led_mode_data();
|
||||||
|
callback apply_effect(AuraEffect);
|
||||||
|
apply_effect(e) => { led_mode_data = e; apply_led_mode_data(); }
|
||||||
|
in-out property <int> zone;
|
||||||
|
in-out property <int> speed;
|
||||||
|
in-out property <int> direction;
|
||||||
|
|
||||||
callback update_led_mode_data(AuraEffect);
|
callback update_led_mode_data(AuraEffect);
|
||||||
update_led_mode_data(data) => {
|
update_led_mode_data(d) => {
|
||||||
led_mode_data = data;
|
led_mode_data = d;
|
||||||
current_available_mode = data.mode;
|
zone = d.zone;
|
||||||
zone = data.zone;
|
speed = d.speed;
|
||||||
speed = data.speed;
|
direction = d.direction;
|
||||||
direction = data.direction;
|
color1 = d.colour1;
|
||||||
color1 = data.colour1;
|
color2 = d.colour2;
|
||||||
color2 = data.colour2;
|
colorbox1 = d.colour1;
|
||||||
colorbox1 = data.colour1;
|
colorbox2 = d.colour2;
|
||||||
colorbox2 = data.colour2;
|
|
||||||
}
|
}
|
||||||
callback cb_hex_from_colour(color) -> string;
|
callback cb_hex_from_colour(color) -> string;
|
||||||
callback cb_hex_to_colour(string) -> color;
|
callback cb_hex_to_colour(string) -> color;
|
||||||
in-out property <AuraDevType> device_type: AuraDevType.Old;
|
in-out property <AuraDevType> device_type: AuraDevType.Old;
|
||||||
// List of indexes to power_zone_names. Must correspond to rog-aura crate
|
|
||||||
in-out property <[PowerZones]> supported_power_zones: [
|
in-out property <[PowerZones]> supported_power_zones: [
|
||||||
PowerZones.Keyboard,
|
PowerZones.Keyboard,
|
||||||
PowerZones.Lightbar,
|
PowerZones.Lightbar,
|
||||||
|
|||||||
Reference in New Issue
Block a user