Skip to content

演奏模式 ​

热键 ​

services/hotkey.rs 在演奏模式下注册 F1 / F2;听歌模式不保持脚本热键。RootView 根据 PlayMode 同步注册状态。事件进入 MainTask::Hotkey,由 ClxState::handle_hotkey 处理。

按键条件与行为
F1PlayMode::Script、已选曲、未在演奏弹窗中 → start_script_playback
F2将 script_continue 置 false

回放线程 ​

start_script_playback:

  1. script_continue = true,打开演奏中弹窗标志
  2. thread::spawn
  3. 在线程内 clx_core::new_shared_enigo()(Windows 上跨线程创建 Enigo 会导致模拟失效)
  4. api::get_music_notation
  5. run_script_notation
  6. MainTask::ScriptFinished

谱面语义 ​

与 Tauri player.play 相同:

rust
for v in notation {
    if !flag.load(Ordering::SeqCst) { break; }
    if let Some(ms) = v.as_f64() { /* 亦处理 u64/i64 */
        thread::sleep(Duration::from_millis(ms as u64));
    } else if let Some(s) = v.as_str() {
        for ch in s.chars() {
            clx_core::click(&mut *enigo.lock().unwrap(), &ch.to_string())?;
        }
    }
}

按键原语在 crates/clx-core。F 键是否需 fn 的提示文案见 core / fkey_hint。