fix: Auto-slot macros + heatmap auto-load on toggle
- Macro slot auto-assigned from macros.len() (no manual slot selection) - Heatmap toggle auto-loads KEYSTATS? from firmware - Debug logs for macro save/refresh Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d69b421590
commit
0813e8531f
4 changed files with 26 additions and 9 deletions
21
src/main.rs
21
src/main.rs
|
|
@ -489,6 +489,23 @@ fn main() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Heatmap toggle: auto-load data ---
|
||||||
|
{
|
||||||
|
let serial = serial.clone();
|
||||||
|
let tx = bg_tx.clone();
|
||||||
|
|
||||||
|
keymap_bridge.on_toggle_heatmap(move || {
|
||||||
|
let serial = serial.clone();
|
||||||
|
let tx = tx.clone();
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
|
let lines = ser.query_command("KEYSTATS?").unwrap_or_default();
|
||||||
|
let (data, max) = logic::parsers::parse_heatmap_lines(&lines);
|
||||||
|
let _ = tx.send(BgMsg::HeatmapData(data, max));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// --- Connect/Disconnect callbacks ---
|
// --- Connect/Disconnect callbacks ---
|
||||||
{
|
{
|
||||||
let serial_c = serial.clone();
|
let serial_c = serial.clone();
|
||||||
|
|
@ -1203,7 +1220,7 @@ fn main() {
|
||||||
window.global::<MacroBridge>().on_save_macro(move || {
|
window.global::<MacroBridge>().on_save_macro(move || {
|
||||||
let Some(w) = window_weak.upgrade() else { return };
|
let Some(w) = window_weak.upgrade() else { return };
|
||||||
let mb = w.global::<MacroBridge>();
|
let mb = w.global::<MacroBridge>();
|
||||||
let slot_num = mb.get_new_slot_idx() as u8;
|
let slot_num = mb.get_macros().row_count() as u8;
|
||||||
let name = mb.get_new_name().to_string();
|
let name = mb.get_new_name().to_string();
|
||||||
let steps = macro_steps.borrow();
|
let steps = macro_steps.borrow();
|
||||||
let steps_str: Vec<String> = steps.iter().map(|&(kc, md)| {
|
let steps_str: Vec<String> = steps.iter().map(|&(kc, md)| {
|
||||||
|
|
@ -1213,6 +1230,7 @@ fn main() {
|
||||||
let steps_text = steps_str.join(",");
|
let steps_text = steps_str.join(",");
|
||||||
drop(steps);
|
drop(steps);
|
||||||
let cmd = logic::protocol::cmd_macroseq(slot_num, &name, &steps_text);
|
let cmd = logic::protocol::cmd_macroseq(slot_num, &name, &steps_text);
|
||||||
|
eprintln!("MACRO SAVE: {}", cmd);
|
||||||
let serial = serial.clone();
|
let serial = serial.clone();
|
||||||
let tx = tx.clone();
|
let tx = tx.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
|
|
@ -1606,6 +1624,7 @@ fn main() {
|
||||||
window.global::<AdvancedBridge>().set_bt_status(SharedString::from(bt_text));
|
window.global::<AdvancedBridge>().set_bt_status(SharedString::from(bt_text));
|
||||||
}
|
}
|
||||||
"macros" => {
|
"macros" => {
|
||||||
|
eprintln!("MACRO raw lines: {:?}", lines);
|
||||||
let macro_data = logic::parsers::parse_macro_lines(&lines);
|
let macro_data = logic::parsers::parse_macro_lines(&lines);
|
||||||
let model: Vec<MacroData> = macro_data.iter().map(|m| {
|
let model: Vec<MacroData> = macro_data.iter().map(|m| {
|
||||||
let steps_str: Vec<String> = m.steps.iter().map(|s| {
|
let steps_str: Vec<String> = m.steps.iter().map(|s| {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,8 @@ export global KeymapBridge {
|
||||||
in-out property <string> selector-target: "keymap";
|
in-out property <string> selector-target: "keymap";
|
||||||
callback select-key(int);
|
callback select-key(int);
|
||||||
callback switch-layer(int);
|
callback switch-layer(int);
|
||||||
callback change-key(int, int); // key-index, new-keycode
|
callback change-key(int, int);
|
||||||
|
callback toggle-heatmap();
|
||||||
callback rename-layer(int, string); // layer-index, new-name
|
callback rename-layer(int, string); // layer-index, new-name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,10 @@ export component TabKeymap inherits VerticalLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
TouchArea {
|
TouchArea {
|
||||||
clicked => { KeymapBridge.heatmap-enabled = !KeymapBridge.heatmap-enabled; }
|
clicked => {
|
||||||
|
KeymapBridge.heatmap-enabled = !KeymapBridge.heatmap-enabled;
|
||||||
|
if KeymapBridge.heatmap-enabled { KeymapBridge.toggle-heatmap(); }
|
||||||
|
}
|
||||||
mouse-cursor: pointer;
|
mouse-cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,6 @@ export component TabMacros inherits Rectangle {
|
||||||
spacing: 8px;
|
spacing: 8px;
|
||||||
alignment: start;
|
alignment: start;
|
||||||
|
|
||||||
Text { text: "Slot:"; color: Theme.fg-secondary; font-size: 12px; vertical-alignment: center; }
|
|
||||||
DarkComboBox {
|
|
||||||
width: 60px;
|
|
||||||
model: ["0","1","2","3","4","5","6","7","8","9"];
|
|
||||||
current-index <=> MacroBridge.new-slot-idx;
|
|
||||||
}
|
|
||||||
Text { text: "Name:"; color: Theme.fg-secondary; font-size: 12px; vertical-alignment: center; }
|
Text { text: "Name:"; color: Theme.fg-secondary; font-size: 12px; vertical-alignment: center; }
|
||||||
DarkLineEdit {
|
DarkLineEdit {
|
||||||
horizontal-stretch: 1;
|
horizontal-stretch: 1;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue