Use backup hidraw brightness write if read-back value fails

This commit is contained in:
Luke D. Jones
2024-05-13 16:18:00 +12:00
parent 6c7e1a6467
commit f2f090a88f
11 changed files with 412 additions and 226 deletions

View File

@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Add a config option to set if throttle policy is changed on ac/bat change (UI only)
- Allow X11 GUI. This is *not* supported.
- Fixes to some GUI widget layouts and sizing
- Do a backup HID raw write fro brightness if the read-back value does not match. This is a temporary solve for some G14 and G16 until the kernel patch is ready.
## [v6.0.6]

181
Cargo.lock generated
View File

@@ -115,6 +115,12 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "as-raw-xcb-connection"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b"
[[package]]
name = "asusctl"
version = "6.0.7"
@@ -726,7 +732,7 @@ checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1"
dependencies = [
"glob",
"libc",
"libloading",
"libloading 0.8.3",
]
[[package]]
@@ -872,6 +878,7 @@ dependencies = [
"objc-foundation",
"objc_id",
"smithay-clipboard",
"x11-clipboard",
]
[[package]]
@@ -1010,6 +1017,16 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "ctor"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad291aa74992b9b7a7e88c38acbbf6ad7e107f1d90ee8775b7bc1fc3394f485c"
dependencies = [
"quote",
"syn 2.0.61",
]
[[package]]
name = "cursor-icon"
version = "1.1.0"
@@ -1129,7 +1146,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
dependencies = [
"libloading",
"libloading 0.8.3",
]
[[package]]
@@ -1396,7 +1413,7 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
dependencies = [
"memoffset",
"memoffset 0.9.1",
"rustc_version",
]
@@ -1615,6 +1632,26 @@ dependencies = [
"version_check",
]
[[package]]
name = "gethostname"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "gethostname"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818"
dependencies = [
"libc",
"windows-targets 0.48.5",
]
[[package]]
name = "getrandom"
version = "0.2.15"
@@ -1724,14 +1761,16 @@ dependencies = [
"core-foundation",
"dispatch",
"glutin_egl_sys",
"glutin_glx_sys",
"glutin_wgl_sys",
"icrate 0.0.4",
"libloading",
"libloading 0.8.3",
"objc2 0.4.1",
"once_cell",
"raw-window-handle 0.5.2",
"wayland-sys",
"windows-sys 0.48.0",
"x11-dl",
]
[[package]]
@@ -1756,6 +1795,16 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "glutin_glx_sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a165fd686c10dcc2d45380b35796e577eacfd43d4660ee741ec8ebe2201b3b4f"
dependencies = [
"gl_generator",
"x11-dl",
]
[[package]]
name = "glutin_wgl_sys"
version = "0.5.0"
@@ -1908,7 +1957,7 @@ dependencies = [
"cfg-if",
"derive_more",
"fontdb",
"libloading",
"libloading 0.8.3",
]
[[package]]
@@ -2342,6 +2391,16 @@ version = "0.2.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
[[package]]
name = "libloading"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"winapi",
]
[[package]]
name = "libloading"
version = "0.8.3"
@@ -2580,6 +2639,15 @@ dependencies = [
"libc",
]
[[package]]
name = "memoffset"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
dependencies = [
"autocfg",
]
[[package]]
name = "memoffset"
version = "0.9.1"
@@ -2690,6 +2758,7 @@ dependencies = [
"bitflags 1.3.2",
"cfg-if",
"libc",
"memoffset 0.7.1",
]
[[package]]
@@ -2713,7 +2782,7 @@ dependencies = [
"cfg-if",
"cfg_aliases 0.1.1",
"libc",
"memoffset",
"memoffset 0.9.1",
]
[[package]]
@@ -3455,7 +3524,7 @@ checksum = "32a58fa8a7ccff2aec4f39cc45bf5f985cec7125ab271cf681c279fd00192b49"
dependencies = [
"countme",
"hashbrown",
"memoffset",
"memoffset 0.9.1",
"rustc-hash",
"text-size",
]
@@ -3898,6 +3967,7 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f266ce2aa23eaaaa4e758ed44495d505d00fb79f359d46f6c1900cb053123b62"
dependencies = [
"as-raw-xcb-connection",
"bytemuck",
"cfg_aliases 0.1.1",
"cocoa",
@@ -3911,12 +3981,14 @@ dependencies = [
"raw-window-handle 0.5.2",
"redox_syscall 0.4.1",
"rustix 0.38.34",
"tiny-xlib",
"wasm-bindgen",
"wayland-backend",
"wayland-client",
"wayland-sys",
"web-sys",
"windows-sys 0.48.0",
"x11rb 0.12.0",
]
[[package]]
@@ -4157,6 +4229,18 @@ dependencies = [
"strict-num",
]
[[package]]
name = "tiny-xlib"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4098d49269baa034a8d1eae9bd63e9fa532148d772121dace3bcd6a6c98eb6d"
dependencies = [
"as-raw-xcb-connection",
"ctor",
"libloading 0.8.3",
"tracing",
]
[[package]]
name = "tinyvec"
version = "1.6.0"
@@ -4339,7 +4423,7 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9"
dependencies = [
"memoffset",
"memoffset 0.9.1",
"tempfile",
"winapi",
]
@@ -4784,6 +4868,15 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "winapi-wsapoll"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1eafc5f679c576995526e81635d0cf9695841736712b4e892f87abbe6fed3f28"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
@@ -5106,6 +5199,7 @@ dependencies = [
"android-activity",
"atomic-waker",
"bitflags 2.5.0",
"bytemuck",
"calloop",
"cfg_aliases 0.1.1",
"core-foundation",
@@ -5121,6 +5215,7 @@ dependencies = [
"objc2 0.4.1",
"once_cell",
"orbclient",
"percent-encoding",
"raw-window-handle 0.5.2",
"redox_syscall 0.3.5",
"rustix 0.38.34",
@@ -5137,6 +5232,8 @@ dependencies = [
"web-sys",
"web-time 0.2.4",
"windows-sys 0.48.0",
"x11-dl",
"x11rb 0.13.0",
"xkbcommon-dl",
]
@@ -5167,6 +5264,74 @@ dependencies = [
"winapi",
]
[[package]]
name = "x11-clipboard"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98785a09322d7446e28a13203d2cae1059a0dd3dfb32cb06d0a225f023d8286"
dependencies = [
"libc",
"x11rb 0.13.0",
]
[[package]]
name = "x11-dl"
version = "2.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f"
dependencies = [
"libc",
"once_cell",
"pkg-config",
]
[[package]]
name = "x11rb"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a"
dependencies = [
"as-raw-xcb-connection",
"gethostname 0.3.0",
"libc",
"libloading 0.7.4",
"nix 0.26.4",
"once_cell",
"winapi",
"winapi-wsapoll",
"x11rb-protocol 0.12.0",
]
[[package]]
name = "x11rb"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8f25ead8c7e4cba123243a6367da5d3990e0d3affa708ea19dce96356bd9f1a"
dependencies = [
"as-raw-xcb-connection",
"gethostname 0.4.3",
"libc",
"libloading 0.8.3",
"once_cell",
"rustix 0.38.34",
"x11rb-protocol 0.13.0",
]
[[package]]
name = "x11rb-protocol"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc"
dependencies = [
"nix 0.26.4",
]
[[package]]
name = "x11rb-protocol"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e63e71c4b8bd9ffec2c963173a4dc4cbde9ee96961d4fcb4429db9929b606c34"
[[package]]
name = "xattr"
version = "1.3.1"

View File

@@ -23,10 +23,10 @@ STRIP_BINARIES ?= 0
DEBUG ?= 0
ifeq ($(DEBUG),0)
ARGS += --release
ARGS += --release --features "rog-control-center/x11"
TARGET = release
else
ARGS += --profile dev
ARGS += --profile dev --features "rog-control-center/x11"
TARGET = debug
endif

View File

@@ -35,11 +35,20 @@ impl LEDNode {
pub fn set_brightness(&self, value: u8) -> Result<(), RogError> {
match self {
LEDNode::KbdLed(k) => k.set_brightness(value)?,
LEDNode::Rog(k, _) => {
LEDNode::Rog(k, r) => {
if let Some(k) = k {
k.set_brightness(value)?
k.set_brightness(value)?;
let x = k.get_brightness()?;
if x != value {
debug!(
"Kernel brightness control didn't read back correct value, setting \
with raw hid"
);
r.write_bytes(&[0x5a, 0xba, 0xc5, 0xc4, value])?;
}
} else {
debug!("No brightness control found");
debug!("No brightness control found, trying raw write");
r.write_bytes(&[0x5a, 0xba, 0xc5, 0xc4, value])?;
}
}
}

View File

@@ -11,6 +11,7 @@ edition.workspace = true
[features]
#default = ["mocking"]
#mocking = []
x11 = ["slint/backend-winit-x11"]
[dependencies]
nix = { version = "^0.28.0", features = ["fs"] }

View File

@@ -22,9 +22,6 @@ export component PageAppSettings inherits VerticalLayout {
mainview := VerticalLayout {
padding: 10px;
spacing: 10px;
HorizontalLayout {
spacing: 10px;
max-height: 32px;
SystemToggle {
text: @tr("Run in background after closing");
checked <=> AppSettingsPageData.run_in_background;
@@ -34,18 +31,13 @@ export component PageAppSettings inherits VerticalLayout {
}
SystemToggle {
width: parent.width * 1px / 2px;
text: @tr("Start app in background (UI closed)");
checked <=> AppSettingsPageData.startup_in_background;
toggled => {
AppSettingsPageData.set_startup_in_background(AppSettingsPageData.startup_in_background)
}
}
}
HorizontalLayout {
max-height: 32px;
spacing: 10px;
SystemToggle {
text: @tr("Enable system tray icon");
checked <=> AppSettingsPageData.enable_tray_icon;
@@ -55,14 +47,12 @@ export component PageAppSettings inherits VerticalLayout {
}
SystemToggle {
width: parent.width * 1px / 2px;
text: @tr("Enable dGPU notifications");
checked <=> AppSettingsPageData.enable_dgpu_notifications;
toggled => {
AppSettingsPageData.set_enable_dgpu_notifications(AppSettingsPageData.enable_dgpu_notifications)
}
}
}
Text {
text: "WIP: some features like notifications are not complete";

View File

@@ -17,6 +17,7 @@ export component PageAura inherits Rectangle {
c2.final_colour = AuraPageData.led_mode_data.colour2;
c2.external_colour_change();
}
ScrollView {
VerticalLayout {
padding: 10px;
spacing: 10px;
@@ -34,7 +35,7 @@ export component PageAura inherits Rectangle {
}
SystemDropdown {
width: parent.width * 1px / 2px;
width: root.width * 1px / 2px;
text: @tr("Aura mode");
current_index <=> AuraPageData.current_available_mode;
current_value: AuraPageData.available_mode_names[self.current-index];
@@ -49,6 +50,8 @@ export component PageAura inherits Rectangle {
}
RogItem {
min-height: 220px;
max-height: 400px;
HorizontalLayout {
spacing: 10px;
VerticalBox {
@@ -107,6 +110,8 @@ export component PageAura inherits Rectangle {
HorizontalLayout {
spacing: 10px;
min-height: 80px;
max-height: 90px;
RogItem {
padding: 0px;
VerticalBox {
@@ -175,7 +180,7 @@ export component PageAura inherits Rectangle {
}
}
HorizontalBox {
HorizontalLayout {
Button {
text: @tr("Power Settings");
clicked => {
@@ -196,6 +201,7 @@ export component PageAura inherits Rectangle {
width: 100%;
}
}
}
if root.show_aura_power && AuraPageData.aura_type == AuraDevType.New: Rectangle {
width: 100%;
@@ -206,6 +212,7 @@ export component PageAura inherits Rectangle {
padding: 30px;
padding-top: 10px;
spacing: 10px;
alignment: LayoutAlignment.start;
for state[idx] in AuraPageData.led_power.states: zone := AuraPowerGroup {
group-title: AuraPageData.power_zone_names[state.zone_name_idx];

View File

@@ -19,7 +19,6 @@ component FanTab inherits Rectangle {
HorizontalLayout {
if root.tab_enabled: Graph {
nodes <=> root.nodes;
}
if !root.tab_enabled: Rectangle {
Text {

View File

@@ -81,7 +81,7 @@ export component ColourSlider inherits VerticalLayout {
hsv(base_colour.to-hsv().hue, 1, 0),
];
function set_base_colour(){
function set_base_colour() {
root.base_colour = hsv(c1.value / base_colours.length * 360, 1, 1);
root.final_colour = hsv(base_colour.to-hsv().hue, ((base_saturation.length - c2.value) / base_saturation.length), ((base_value.length - c3.value) / base_value.length));
root.colourbox = root.final_colour;

View File

@@ -197,7 +197,7 @@ export component PopupNotification {
}
}
public function show(){
public function show() {
_p.show();
}
}

View File

@@ -26,16 +26,20 @@ export component Graph inherits Rectangle {
y: root.graph_padding;
function scale_x_to_graph(x: length) -> length {
((x - node_min.x) / (node_max.x - node_min.x)) * graph.width
}//
}
//
function scale_y_to_graph(y: length) -> length {
((y - node_min.y) / (node_max.y - node_min.y)) * graph.height
}//
}
//
function scale_x_to_node(x: length) -> length {
(x / graph.width) * (node_max.x - node_min.x)
}//
}
//
function scale_y_to_node(y: length) -> length {
(y / graph.height) * (node_max.y - node_min.y)
}//
}
//
for n in 11: Path {
viewbox-width: self.width / 1px;
@@ -43,21 +47,23 @@ export component Graph inherits Rectangle {
stroke: Palette.alternate-foreground.darker(200%);
stroke-width: 1px;
MoveTo {
x: scale_x_to_graph(n*10px) / 1px;
y: 0; // scale_y_to_graph(n*1px) / 1px;
x: scale_x_to_graph(n * 10px) / 1px;
y: 0;
// scale_y_to_graph(n*1px) / 1px;
}
LineTo {
x: scale_x_to_graph(n*10px) / 1px;
y: graph.height / 1px; //scale_y_to_graph(n*1px) / 1px;
x: scale_x_to_graph(n * 10px) / 1px;
y: graph.height / 1px;
//scale_y_to_graph(n*1px) / 1px;
}
}
for n in 11: Text {
color: Palette.accent-background;
font-size <=> root.axis_font_size;
text: "\{n*10}c";
x: scale_x_to_graph(n*10px) - self.width / 3;
text: "\{n * 10}c";
x: scale_x_to_graph(n * 10px) - self.width / 3;
y: graph.height + 2px;
}
@@ -67,22 +73,24 @@ export component Graph inherits Rectangle {
stroke: Palette.alternate-foreground.darker(200%);
stroke-width: 1px;
MoveTo {
x: 0; //scale_x_to_graph(n*10px) / 1px;
y: scale_y_to_graph(n*25.5px) / 1px;
x: 0;
//scale_x_to_graph(n*10px) / 1px;
y: scale_y_to_graph(n * 25.5px) / 1px;
}
LineTo {
x: graph.width / 1px; //scale_x_to_graph(n*10px) / 1px;
y: scale_y_to_graph(n*25.5px) / 1px;
x: graph.width / 1px;
//scale_x_to_graph(n*10px) / 1px;
y: scale_y_to_graph(n * 25.5px) / 1px;
}
}
for n in 11: Text {
color: Palette.accent-background;
font-size <=> root.axis_font_size;
text: "\{n*10}%";
text: "\{n * 10}%";
x: - self.width;
y: graph.height - scale_y_to_graph(n*25.5px) - self.height / 2;
y: graph.height - scale_y_to_graph(n * 25.5px) - self.height / 2;
}
for l[idx] in nodes: path := Rectangle {
@@ -115,7 +123,8 @@ export component Graph inherits Rectangle {
tip.background: Palette.accent-background;
tip.opacity: 1.0;
}
]//
]
//
point := Rectangle {
background: Palette.control-foreground;
x: scale_x_to_graph(n.x) - self.width / 2;
@@ -133,7 +142,6 @@ export component Graph inherits Rectangle {
} else if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) < nodes[idx - 1].x {
n.x = nodes[idx - 1].x + pad;
}
if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) > nodes[idx + 1].y {
n.y = nodes[idx + 1].y - pad;
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) < nodes[idx - 1].y {
@@ -145,7 +153,6 @@ export component Graph inherits Rectangle {
} else if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) > nodes[idx + 1].x {
n.x = nodes[idx + 1].x - pad;
}
if n.y - scale_y_to_node(self.mouse-y - self.pressed-y) < 0.0 {
n.y = 1px;
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) > nodes[idx + 1].y {
@@ -157,14 +164,14 @@ export component Graph inherits Rectangle {
} else if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) < nodes[idx - 1].x {
n.x = nodes[idx - 1].x + pad;
}
if n.y - scale_y_to_node(self.mouse-y - self.pressed-y) > scale_y_to_node(graph.height) {
n.y = scale_y_to_node(graph.height - 1px);
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) < nodes[idx - 1].y {
n.y = nodes[idx - 1].y + pad;
}
}
}//
}
//
moved => {
if (self.pressed) {
n.x += scale_x_to_node(self.mouse-x - self.pressed-x);
@@ -190,27 +197,32 @@ export component Graph inherits Rectangle {
height: label.preferred-height;
function x_pos() -> length {
scale_x_to_graph(n.x) - label.preferred-width - 8px
}//
}
//
function final_x_pos() -> length {
if x_pos() > 0 {
x_pos()
} else {
x_pos() + label.preferred-width
}
}//
}
//
function y_pos() -> length {
graph.height - scale_y_to_graph(n.y) - self.height - 4px
}//
}
//
function final_y_pos() -> length {
if y_pos() > 0 {
y_pos()
} else {
y_pos() + label.preferred-height
}
}//
}
//
function fan_pct() -> int {
Math.floor(n.y / 1px) / 255 * 100
}//
}
//
label := Text {
color: Palette.accent-foreground;
font-size: 16px;