Skip to content

feat: add left and right Control key support for hotkeys#14

Merged
missuo merged 1 commit into
missuo:mainfrom
nmvr2600:feat/control-key-hotkeys
Mar 26, 2026
Merged

feat: add left and right Control key support for hotkeys#14
missuo merged 1 commit into
missuo:mainfrom
nmvr2600:feat/control-key-hotkeys

Conversation

@nmvr2600

Copy link
Copy Markdown
Contributor

Summary

Add left and right Control key options for trigger/cancel hotkeys.

Changes

  • UI: Add "Left Control (⌃)" and "Right Control (⌃)" to hotkey dropdowns
  • Config: Add keyCode mappings (left_control=59, right_control=62)
  • Validation: Update normalizedHotkeyValue() and default_cancel_key_for_trigger()
  • Status bar: Update displayNameForHotkeyValue() for menu display

Tested

  • Left Control works as trigger key
  • Right Control works as cancel key
  • Config saves correctly
  • Menu bar displays correctly

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds left/right Control as selectable trigger/cancel hotkeys across the Rust core config, setup wizard UI, and status bar display so users can bind Control keys in addition to Fn/Option/Command.

Changes:

  • Extend hotkey normalization/defaulting and add keycode/modifier-flag mappings for left_control / right_control in the Rust config layer.
  • Update Setup Wizard hotkey dropdowns and validation/default-cancel logic to include the new values.
  • Update Status Bar hotkey display names to render the new values in the menu.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
koe-core/src/config.rs Adds left_control/right_control to normalization, defaults, and keycode/modifier mapping; updates default config comment.
KoeApp/Koe/StatusBar/SPStatusBarManager.m Adds human-readable display names for the new hotkey values in the status bar menu.
KoeApp/Koe/SetupWizard/SPSetupWizardWindowController.m Adds new hotkey options to dropdowns and extends normalization/default-cancel logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread koe-core/src/config.rs Outdated
# 触发键:fn | left_option | right_option | left_command | right_command
# 触发键:fn | left_option | right_option | left_command | right_command | left_control | right_control
trigger_key: "fn"
# 取消键:不能与触发键重复

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the default config YAML snippet, the trigger-key comment was updated to list left_control/right_control, but the cancel-key comment below still doesn’t list the allowed values. Consider updating the cancel-key comment to include the same option list (and/or mention that it must differ from the trigger key) so users editing the YAML have a complete reference.

Suggested change
# 取消键:不能与触发键重复
# 取消键:fn | left_option | right_option | left_command | right_command | left_control | right_control (不能与触发键相同)

Copilot uses AI. Check for mistakes.
Comment thread koe-core/src/config.rs Outdated
Comment on lines +218 to +219
// Note: Some keyboards don't set NX_DEVICERCTLKEYMASK, use LCTL mask
modifier_flag: 0x00000001, // NX_DEVICELCTLKEYMASK

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right_control is currently configured with modifier_flag: 0x00000001 (NX_DEVICELCTLKEYMASK). In the native hotkey monitor, flags-changed detection uses keyCode == cancelKeyCode/targetKeyCode and (flags & modifierFlag) != 0; if the OS reports Right Control with NX_DEVICERCTLKEYMASK (distinct from LCTL), this mapping would prevent Right Control from being detected. Use the proper right-control mask (and/or consider OR-ing left+right control masks for compatibility) so Right Control works reliably across keyboards.

Suggested change
// Note: Some keyboards don't set NX_DEVICERCTLKEYMASK, use LCTL mask
modifier_flag: 0x00000001, // NX_DEVICELCTLKEYMASK
// Use both left and right control masks so Right Control is detected reliably
// NX_DEVICELCTLKEYMASK (0x00000001) | NX_DEVICERCTLKEYMASK (0x00000002)
modifier_flag: 0x00000003,

Copilot uses AI. Check for mistakes.
Comment thread koe-core/src/config.rs
"right_control" => "fn",
_ => "left_option",
}
}

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hotkey defaulting behavior was extended (right_command -> left_control -> right_control -> fn), but the tests in this file only cover the left_option case. Add unit tests covering the new control-key branches to prevent regressions in normalization/backfilling (e.g., trigger right_command, left_control, right_control).

Suggested change
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_cancel_key_for_trigger_cycles_through_modifier_keys() {
assert_eq!(default_cancel_key_for_trigger("fn"), "left_option");
assert_eq!(default_cancel_key_for_trigger("left_option"), "right_option");
assert_eq!(default_cancel_key_for_trigger("right_option"), "left_command");
assert_eq!(default_cancel_key_for_trigger("left_command"), "right_command");
assert_eq!(default_cancel_key_for_trigger("right_command"), "left_control");
assert_eq!(default_cancel_key_for_trigger("left_control"), "right_control");
assert_eq!(default_cancel_key_for_trigger("right_control"), "fn");
}
#[test]
fn default_cancel_key_for_trigger_falls_back_to_left_option_for_unknown_keys() {
assert_eq!(default_cancel_key_for_trigger("unknown_key"), "left_option");
}
}

Copilot uses AI. Check for mistakes.
@nmvr2600 nmvr2600 force-pushed the feat/control-key-hotkeys branch 2 times, most recently from e8dba15 to 96bb7d0 Compare March 26, 2026 13:09
- Add left_control (⌃) and right_control (⌃) options to trigger/cancel key dropdowns
- Add keyCode mappings: left_control=59, right_control=62
- Update valid hotkey values in normalizedHotkeyValue()
- Update default_cancel_key_for_trigger() to cycle through all keys
- Sync Rust config validation with UI options

Changes:
- SPSetupWizardWindowController.m: UI dropdowns and validation
- koe-core/src/config.rs: Config parsing and key resolution
@nmvr2600 nmvr2600 force-pushed the feat/control-key-hotkeys branch from 96bb7d0 to 2b6dc4a Compare March 26, 2026 13:22
@missuo missuo merged commit edc6d21 into missuo:main Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants