Skip to content

Commit

Permalink
Merge pull request #16 from lucasmln/fix_shift_lock_and_unpress
Browse files Browse the repository at this point in the history
Use match rather than if/else and fix shift_lock
  • Loading branch information
lucasmln authored Dec 13, 2023
2 parents 6f4c1b8 + dc71627 commit e847432
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/keyboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,13 @@ fn key_unpress(knbr: u8) {

match state.lang[state.lang_id].map.get(unpressed_knbr as usize) {
Some(_key) => {
if unpressed_knbr == fr::Kvalue::Ctrl as u8 {
state.lctrl = false;
} else if unpressed_knbr == fr::Kvalue::LShift as u8 {
state.lshift = false;
} else if unpressed_knbr == fr::Kvalue::Rshift as u8 {
state.rshift = false;
} else if unpressed_knbr == fr::Kvalue::Option as u8 {
// loption and roption have the same value in macos keyboard
state.loption = false;
} else {
state.pressed_key.push(knbr);
let kvalue = fr::get_kvalue(unpressed_knbr);
match kvalue {
fr::Kvalue::Ctrl => { state.lctrl = false; }
fr::Kvalue::LShift => { state.lshift = false; }
fr::Kvalue::Rshift => { state.rshift = false; }
fr::Kvalue::Option => { state.loption = false; }
_ => { state.pressed_key.push(knbr); }
}
state.active_key.pop();
}
Expand Down Expand Up @@ -179,7 +175,7 @@ fn key_press(knbr: u8) {
state.loption = true;
}
fr::Kvalue::ShiftLock => {
state.caps_lock = true;
state.caps_lock = !state.caps_lock;
}
fr::Kvalue::Del => {
shell::read(&[127]);
Expand Down

0 comments on commit e847432

Please sign in to comment.