mirror of
https://github.com/IllusionMan1212/predator-ng.git
synced 2026-10-24 02:12:30 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83f23d23ae
|
||
|
|
b0e65427e2
|
||
|
|
2fa43cd4ce
|
||
|
|
cf24dc48cd
|
Generated
+100
-25
@@ -23,6 +23,10 @@ name = "accesskit"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76eb1adf08c5bcaa8490b9851fd53cca27fa9880076f178ea9d29f05196728a8"
|
||||
dependencies = [
|
||||
"enumn",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "accesskit_consumer"
|
||||
@@ -101,6 +105,7 @@ checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
@@ -294,12 +299,6 @@ version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3"
|
||||
|
||||
[[package]]
|
||||
name = "atomic_refcell"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "112ef6b3f6cb3cb6fc5b6b494ef7a848492cff1ab0ef4de10b0f7d572861c905"
|
||||
|
||||
[[package]]
|
||||
name = "atspi"
|
||||
version = "0.10.1"
|
||||
@@ -723,18 +722,19 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||
|
||||
[[package]]
|
||||
name = "ecolor"
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e479a7fa3f23d4e794f8b2f8b3568dd4e47886ad1b12c9c095e141cb591eb63"
|
||||
checksum = "cfdf4e52dbbb615cfd30cf5a5265335c217b5fd8d669593cea74a517d9c605af"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "eframe"
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf4596583a2c680c55b6feaa748f74890c4f9cb9c7cb69d6117110444cb65b2f"
|
||||
checksum = "26d9efede6c8905d3fc51a5ec9a506d4da4011bbcae0253d0304580fe40af3f5"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cocoa",
|
||||
@@ -748,8 +748,10 @@ dependencies = [
|
||||
"js-sys",
|
||||
"log",
|
||||
"objc",
|
||||
"parking_lot",
|
||||
"percent-encoding",
|
||||
"raw-window-handle",
|
||||
"static_assertions",
|
||||
"thiserror",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
@@ -760,41 +762,45 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "egui"
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3aef8ec3ae1b772f340170c65bf27d5b8c28f543a0116c844d2ac08d01123e7"
|
||||
checksum = "8bd69fed5fcf4fbb8225b24e80ea6193b61e17a625db105ef0c4d71dde6eb8b7"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"ahash",
|
||||
"epaint",
|
||||
"log",
|
||||
"nohash-hasher",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "egui-winit"
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a49155fd4a0a4fb21224407a91de0030847972ef90fc64edb63621caea61cb2"
|
||||
checksum = "c15479a96d9fadccf5dac690bdc6373b97b8e1c0dd28367058f25a5298da0195"
|
||||
dependencies = [
|
||||
"accesskit_winit",
|
||||
"arboard",
|
||||
"egui",
|
||||
"instant",
|
||||
"log",
|
||||
"raw-window-handle",
|
||||
"smithay-clipboard",
|
||||
"web-time",
|
||||
"webbrowser",
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "egui_extras"
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9278f4337b526f0d57e5375e5a7340a311fa6ee8f9fcc75721ac50af13face02"
|
||||
checksum = "68ffe3fe5c00295f91c2a61a74ee271c32f74049c94ba0b1cea8f26eb478bc07"
|
||||
dependencies = [
|
||||
"egui",
|
||||
"enum-map",
|
||||
"log",
|
||||
"mime_guess",
|
||||
"resvg",
|
||||
"serde",
|
||||
"tiny-skia",
|
||||
@@ -803,9 +809,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "egui_glow"
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f8c2752cdf1b0ef5fcda59a898cacabad974d4f5880e92a420b2c917022da64"
|
||||
checksum = "ce6726c08798822280038bbad2e32f4fc3cbed800cd51c6e34e99cd2d60cc1bc"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"egui",
|
||||
@@ -818,11 +824,33 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "emath"
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3857d743a6e0741cdd60b622a74c7a36ea75f5f8f11b793b41d905d2c9721a4b"
|
||||
checksum = "1ef2b29de53074e575c18b694167ccbe6e5191f7b25fe65175a0d905a32eeec0"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enum-map"
|
||||
version = "2.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c188012f8542dee7b3996e44dd89461d64aa471b0a7c71a1ae2f595d259e96e5"
|
||||
dependencies = [
|
||||
"enum-map-derive",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enum-map-derive"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04d0b288e3bb1d861c4403c1774a6f7a798781dfc519b3647df2a3dd4ae95f25"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.37",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -847,20 +875,31 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "epaint"
|
||||
version = "0.22.0"
|
||||
name = "enumn"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09333964d4d57f40a85338ba3ca5ed4716070ab184dcfed966b35491c5c64f3b"
|
||||
checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.37",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "epaint"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58067b840d009143934d91d8dcb8ded054d8301d7c11a517ace0a99bb1e1595e"
|
||||
dependencies = [
|
||||
"ab_glyph",
|
||||
"ahash",
|
||||
"atomic_refcell",
|
||||
"bytemuck",
|
||||
"ecolor",
|
||||
"emath",
|
||||
"log",
|
||||
"nohash-hasher",
|
||||
"parking_lot",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1390,6 +1429,22 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mime"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
|
||||
dependencies = [
|
||||
"mime",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
@@ -2346,6 +2401,15 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.13"
|
||||
@@ -2593,6 +2657,17 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-time"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19353897b48e2c4d849a2d73cb0aeb16dc2be4e00c565abfc11eb65a806e47de"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webbrowser"
|
||||
version = "0.8.11"
|
||||
|
||||
+3
-3
@@ -6,8 +6,8 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
eframe = "0.22.0"
|
||||
egui = "0.22.0"
|
||||
eframe = "0.23.0"
|
||||
egui = "0.23.0"
|
||||
|
||||
[dependencies.confy]
|
||||
version = "0.5.1"
|
||||
@@ -19,5 +19,5 @@ version = "1.0.188"
|
||||
features = ["derive"]
|
||||
|
||||
[dependencies.egui_extras]
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
features = ["svg"]
|
||||
|
||||
@@ -3,5 +3,12 @@ A GUI client to interact with my (private for now) fork of the 3rd party linux [
|
||||
|
||||
The client mainly supports controlling the keyboard RGB for now, but there's plans for fan control as well (maybe. depends on how busy I am and how complicated this gets)
|
||||
|
||||
## Screenshots
|
||||
Dynamic lighting control
|
||||

|
||||
|
||||
Static lighting control
|
||||

|
||||
|
||||
## Disclaimer
|
||||
This client is primarily made for use with my PT314-52s and custom changes of the kernel module and is not guaranteed to work with other models. Use at your own risk.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
+106
-39
@@ -105,7 +105,7 @@ fn update_dynamic(dynamic_dev: &mut File, cfg: Config) {
|
||||
dynamic_data[7] = cfg.kb.color[2];
|
||||
dynamic_data[9] = 1;
|
||||
|
||||
dynamic_dev.write(&dynamic_data).expect("Failed to write to dynamic device");
|
||||
dynamic_dev.write_all(&dynamic_data).expect("Failed to write to dynamic device");
|
||||
}
|
||||
|
||||
fn change_brightness(dynamic_dev: &mut File, cfg: Config) {
|
||||
@@ -119,7 +119,7 @@ fn change_brightness(dynamic_dev: &mut File, cfg: Config) {
|
||||
dynamic_data[7] = if cfg.kb.mode == KBLightMode::Static {0} else {cfg.kb.color[2]};
|
||||
dynamic_data[9] = 1;
|
||||
|
||||
dynamic_dev.write(&dynamic_data).expect("Failed to write to dynamic device");
|
||||
dynamic_dev.write_all(&dynamic_data).expect("Failed to write to dynamic device");
|
||||
}
|
||||
|
||||
fn switch_to_static(static_dev: &mut File, dynamic_dev: &mut File, cfg: Config) {
|
||||
@@ -130,7 +130,7 @@ fn switch_to_static(static_dev: &mut File, dynamic_dev: &mut File, cfg: Config)
|
||||
dynamic_data[2] = cfg.kb.brightness;
|
||||
dynamic_data[9] = 1; // This is needed for PT314-52s and possibly other models
|
||||
|
||||
dynamic_dev.write(&dynamic_data).expect("Failed to write to static device");
|
||||
dynamic_dev.write_all(&dynamic_data).expect("Failed to write to static device");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ fn write_to_static_dev(static_dev: &mut File, cfg: Config, zone: usize) {
|
||||
cfg.kb.zones[1].enabled as u8,
|
||||
cfg.kb.zones[2].enabled as u8
|
||||
];
|
||||
static_dev.write(&static_data).expect("Failed to write to static device");
|
||||
static_dev.write_all(&static_data).expect("Failed to write to static device");
|
||||
}
|
||||
|
||||
fn toggle_zone(static_dev: &mut File, cfg: Config, zone_num: usize) {
|
||||
@@ -165,7 +165,7 @@ fn toggle_zone(static_dev: &mut File, cfg: Config, zone_num: usize) {
|
||||
cfg.kb.zones[2].enabled as u8 // Zone 3 enabled
|
||||
];
|
||||
|
||||
static_dev.write(&static_data).expect("Failed to write to static device");
|
||||
static_dev.write_all(&static_data).expect("Failed to write to static device");
|
||||
}
|
||||
|
||||
fn show_dynamic_kb_lighting_pane(ui: &mut egui::Ui, dynamic_dev: &mut File, cfg: &mut Config, config_path: PathBuf) {
|
||||
@@ -259,13 +259,37 @@ fn show_dynamic_kb_lighting_pane(ui: &mut egui::Ui, dynamic_dev: &mut File, cfg:
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
});
|
||||
ui.vertical(|ui| {
|
||||
ui.label("Custom Color");
|
||||
if ui.color_edit_button_srgb(&mut cfg.kb.color).changed() {
|
||||
update_dynamic(dynamic_dev, *cfg);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
let r = ui.label("R");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.color[0])).labelled_by(r.id).changed() {
|
||||
update_dynamic(dynamic_dev, *cfg);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
let g = ui.label("G");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.color[1])).labelled_by(g.id).changed() {
|
||||
update_dynamic(dynamic_dev, *cfg);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
let b = ui.label("B");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.color[2])).labelled_by(b.id).changed() {
|
||||
update_dynamic(dynamic_dev, *cfg);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn show_static_kb_lighting_pane(ui: &mut egui::Ui, static_dev: &mut File, cfg: &mut Config, config_path: PathBuf, prohibit_tex: TextureHandle) {
|
||||
ui.horizontal(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.label("Zone 1");
|
||||
ui.horizontal(|ui| {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
let mut picker_rect = ui.available_rect_before_wrap();
|
||||
|
||||
if ui.add(toggle(&mut cfg.kb.zones[0].enabled)).changed() {
|
||||
@@ -282,29 +306,34 @@ fn show_static_kb_lighting_pane(ui: &mut egui::Ui, static_dev: &mut File, cfg: &
|
||||
});
|
||||
if !cfg.kb.zones[0].enabled {
|
||||
let pos = [egui::pos2(picker_rect.max.x - 2.0, picker_rect.max.y - 7.0)];
|
||||
ui.put(egui::Rect::from_points(&pos), egui::Image::new(prohibit_tex.id(), egui::vec2(10.0, 10.0)));
|
||||
ui.put(egui::Rect::from_points(&pos), egui::Image::new(&prohibit_tex).max_size(egui::Vec2::new(14.0, 14.0)));
|
||||
}
|
||||
});
|
||||
ui.add_space(10.0);
|
||||
ui.add_enabled_ui(cfg.kb.zones[0].enabled, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[0].color[0])).changed() {
|
||||
let r = ui.label("R");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[0].color[0])).labelled_by(r.id).changed() {
|
||||
write_to_static_dev(static_dev, *cfg, 1);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[0].color[1])).changed() {
|
||||
let g = ui.label("G");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[0].color[1])).labelled_by(g.id).changed() {
|
||||
write_to_static_dev(static_dev, *cfg, 1);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[0].color[2])).changed() {
|
||||
let b = ui.label("B");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[0].color[2])).labelled_by(b.id).changed() {
|
||||
write_to_static_dev(static_dev, *cfg, 1);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
ui.separator();
|
||||
ui.vertical(|ui| {
|
||||
ui.label("Zone 2");
|
||||
ui.horizontal(|ui| {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
let mut picker_rect = ui.available_rect_before_wrap();
|
||||
|
||||
if ui.add(toggle(&mut cfg.kb.zones[1].enabled)).changed() {
|
||||
@@ -321,29 +350,34 @@ fn show_static_kb_lighting_pane(ui: &mut egui::Ui, static_dev: &mut File, cfg: &
|
||||
});
|
||||
if !cfg.kb.zones[1].enabled {
|
||||
let pos = [egui::pos2(picker_rect.max.x - 2.0, picker_rect.max.y - 7.0)];
|
||||
ui.put(egui::Rect::from_points(&pos), egui::Image::new(prohibit_tex.id(), egui::vec2(10.0, 10.0)));
|
||||
ui.put(egui::Rect::from_points(&pos), egui::Image::new(&prohibit_tex).max_size(egui::Vec2::new(14.0, 14.0)));
|
||||
}
|
||||
});
|
||||
ui.add_space(10.0);
|
||||
ui.add_enabled_ui(cfg.kb.zones[1].enabled, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[1].color[0])).changed() {
|
||||
let r = ui.label("R");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[1].color[0])).labelled_by(r.id).changed() {
|
||||
write_to_static_dev(static_dev, *cfg, 2);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[1].color[1])).changed() {
|
||||
let g = ui.label("G");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[1].color[1])).labelled_by(g.id).changed() {
|
||||
write_to_static_dev(static_dev, *cfg, 2);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[1].color[2])).changed() {
|
||||
let b = ui.label("B");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[1].color[2])).labelled_by(b.id).changed() {
|
||||
write_to_static_dev(static_dev, *cfg, 2);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
ui.vertical(|ui| {
|
||||
ui.label("Zone 3");
|
||||
ui.horizontal(|ui| {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
let mut picker_rect = ui.available_rect_before_wrap();
|
||||
|
||||
if ui.add(toggle(&mut cfg.kb.zones[2].enabled)).changed() {
|
||||
@@ -360,26 +394,65 @@ fn show_static_kb_lighting_pane(ui: &mut egui::Ui, static_dev: &mut File, cfg: &
|
||||
});
|
||||
if !cfg.kb.zones[2].enabled {
|
||||
let pos = [egui::pos2(picker_rect.max.x - 2.0, picker_rect.max.y - 7.0)];
|
||||
ui.put(egui::Rect::from_points(&pos), egui::Image::new(prohibit_tex.id(), egui::vec2(10.0, 10.0)));
|
||||
ui.put(egui::Rect::from_points(&pos), egui::Image::new(&prohibit_tex).max_size(egui::Vec2::new(10.0, 10.0)));
|
||||
}
|
||||
});
|
||||
ui.add_space(10.0);
|
||||
ui.add_enabled_ui(cfg.kb.zones[2].enabled, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[2].color[0])).changed() {
|
||||
let r = ui.label("R");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[2].color[0])).labelled_by(r.id).changed() {
|
||||
write_to_static_dev(static_dev, *cfg, 3);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[2].color[1])).changed() {
|
||||
let g = ui.label("G");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[2].color[1])).labelled_by(g.id).changed() {
|
||||
write_to_static_dev(static_dev, *cfg, 3);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[2].color[2])).changed() {
|
||||
let b = ui.label("B");
|
||||
if ui.add(egui::DragValue::new(&mut cfg.kb.zones[2].color[2])).labelled_by(b.id).changed() {
|
||||
write_to_static_dev(static_dev, *cfg, 3);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn check_devices(options: &eframe::NativeOptions) -> Result<(File, File), String> {
|
||||
let static_dev = OpenOptions::new()
|
||||
.write(true)
|
||||
.create(false)
|
||||
.open("/dev/acer-gkbbl-static-0");
|
||||
|
||||
let dynamic_dev = OpenOptions::new()
|
||||
.write(true)
|
||||
.create(false)
|
||||
.open("/dev/acer-gkbbl-0");
|
||||
|
||||
match static_dev.is_err() || dynamic_dev.is_err() {
|
||||
true => {
|
||||
eprintln!("[ERROR]: Could not open device files");
|
||||
|
||||
let _ = eframe::run_simple_native("Predator-ng", options.clone(), move |ctx, _frame| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.colored_label(egui::Color32::RED, egui::RichText::new("Error: could not open device files").heading());
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label("Please make sure you have the kernel module loaded, and that both");
|
||||
ui.label(egui::RichText::new("/dev/acer-gkbbl-0").code());
|
||||
ui.label("and");
|
||||
ui.label(egui::RichText::new("/dev/acer-gkbbl-static-0").code());
|
||||
ui.label("exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Err("Could not open device files".to_string())
|
||||
}
|
||||
false => Ok((static_dev.unwrap(), dynamic_dev.unwrap())),
|
||||
}
|
||||
}
|
||||
|
||||
fn initial_load(config_path: PathBuf, static_dev: &mut File, dynamic_dev: &mut File) -> Result<Config, confy::ConfyError> {
|
||||
@@ -395,29 +468,20 @@ fn initial_load(config_path: PathBuf, static_dev: &mut File, dynamic_dev: &mut F
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut static_dev = OpenOptions::new()
|
||||
.write(true)
|
||||
.create(false)
|
||||
.open("/dev/acer-gkbbl-static-0")
|
||||
.expect("No static device found. Please make sure the kernel module is loaded first.");
|
||||
|
||||
let mut dynamic_dev = OpenOptions::new()
|
||||
.write(true)
|
||||
.create(false)
|
||||
.open("/dev/acer-gkbbl-0")
|
||||
.expect("No dynamic device found. Please make sure the kernel module is loaded first.");
|
||||
let options = eframe::NativeOptions {
|
||||
initial_window_size: Some(egui::vec2(640.0, 480.0)),
|
||||
//min_window_size: Some(egui::vec2(620.0, 400.0)),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
match check_devices(&options) {
|
||||
Ok((mut static_dev, mut dynamic_dev)) => {
|
||||
let config_home = var("XDG_CONFIG_HOME")
|
||||
.or_else(|_| var("HOME").map(|home|format!("{}/.config", home))).unwrap();
|
||||
|
||||
let config_path = Path::new(&config_home).join("predator-ng").to_path_buf();
|
||||
let mut cfg = initial_load(config_path.clone(), &mut static_dev, &mut dynamic_dev)?;
|
||||
|
||||
let options = eframe::NativeOptions {
|
||||
initial_window_size: Some(egui::vec2(640.0, 480.0)),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let prohibit_svg_bytes = include_bytes!("../assets/prohibit.svg");
|
||||
|
||||
let _ = eframe::run_simple_native("Predator-ng", options, move |ctx, _frame| {
|
||||
@@ -429,16 +493,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
ui.label("Keyboard Lighting Mode: ");
|
||||
if ui.radio_value(&mut cfg.kb.mode, KBLightMode::Static, "Static").clicked() {
|
||||
switch_to_static(&mut static_dev, &mut dynamic_dev, cfg);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
let _ = confy::store_path(config_path.clone(), cfg);
|
||||
}
|
||||
if ui.radio_value(&mut cfg.kb.mode, KBLightMode::Dynamic, "Dynamic").clicked() {
|
||||
update_dynamic(&mut dynamic_dev, cfg);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
let _ = confy::store_path(config_path.clone(), cfg);
|
||||
}
|
||||
ui.label("Keyboard Brightness: ");
|
||||
if ui.add(egui::Slider::new(&mut cfg.kb.brightness, 0..=100).show_value(false).step_by(25.0)).changed() {
|
||||
change_brightness(&mut dynamic_dev, cfg);
|
||||
let _ = confy::store_path(config_path.clone(), &cfg);
|
||||
let _ = confy::store_path(config_path.clone(), cfg);
|
||||
}
|
||||
});
|
||||
ui.add_space(15.0);
|
||||
@@ -457,3 +521,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Err(_) => Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user