Skip to content

Commit

Permalink
fix(zippy): release ralt/altgr correctly (#1385)
Browse files Browse the repository at this point in the history
  • Loading branch information
nightscape authored Nov 26, 2024
1 parent 89235ac commit 5b25f3c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/kanata/output_logic/zippychord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ impl ZchState {
OsCode::KEY_RIGHTSHIFT => {
self.zchd.zchd_is_rsft_active = false;
}
OsCode::KEY_RIGHTALT => {
self.zchd.zchd_is_altgr_active = false;
}
_ => {}
}
if osc.is_zippy_ignored() {
Expand Down
49 changes: 49 additions & 0 deletions src/tests/sim_tests/zippychord_sim_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,55 @@ fn sim_zippychord_rsft() {
);
}

#[test]
fn sim_zippychord_ralt() {
// test ralt behaviour while pressed
let result = simulate_with_zippy_file_content(
ZIPPY_CFG,
"d:ralt t:10 d:d t:10 d:y t:10",
ZIPPY_FILE_CONTENT,
)
.to_ascii();
assert_eq!(
"dn:RAlt t:10ms dn:D t:10ms dn:BSpace up:BSpace up:RAlt up:D dn:D dn:A up:A up:Y dn:Y dn:RAlt",
result
);
let result = simulate_with_zippy_file_content(
ZIPPY_CFG,
"d:ralt t:10 d:x t:10 d:y t:10",
ZIPPY_FILE_CONTENT,
)
.to_ascii();
assert_eq!(
"dn:RAlt t:10ms dn:X t:10ms dn:BSpace up:BSpace \
up:RAlt dn:LShift dn:W up:W up:LShift up:X dn:X dn:LShift up:Y dn:Y up:LShift dn:Z up:Z dn:RAlt",
result
);

// ensure rsft-held behaviour goes away when released
let result = simulate_with_zippy_file_content(
ZIPPY_CFG,
"d:ralt t:10 d:d u:ralt t:10 d:y t:10",
ZIPPY_FILE_CONTENT,
)
.to_ascii();
assert_eq!(
"dn:RAlt t:10ms dn:D t:1ms up:RAlt t:9ms dn:BSpace up:BSpace up:D dn:D dn:A up:A up:Y dn:Y",
result
);
let result = simulate_with_zippy_file_content(
ZIPPY_CFG,
"d:ralt t:10 d:x u:ralt t:10 d:y t:10",
ZIPPY_FILE_CONTENT,
)
.to_ascii();
assert_eq!(
"dn:RAlt t:10ms dn:X t:1ms up:RAlt t:9ms dn:BSpace up:BSpace \
dn:LShift dn:W up:W up:LShift up:X dn:X dn:LShift up:Y dn:Y up:LShift dn:Z up:Z",
result
);
}

#[test]
fn sim_zippychord_caps_word() {
let result = simulate_with_zippy_file_content(
Expand Down

0 comments on commit 5b25f3c

Please sign in to comment.