Skip to content

Commit

Permalink
fix(clafrica): Shift key can't be used for special function (#78)
Browse files Browse the repository at this point in the history
The holding of the Shift key don't permit to use his normal function
(capitalization by example.).
  • Loading branch information
pythonbrad committed Aug 30, 2023
1 parent bf1f506 commit aa2942b
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions clafrica/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ pub fn run(
idle = match event.event_type {
EventType::KeyPress(E_Key::Pause) => true,
EventType::KeyRelease(E_Key::Pause) => false,
EventType::KeyPress(E_Key::ShiftLeft) => idle,
EventType::KeyRelease(E_Key::ShiftLeft) => {
EventType::KeyPress(E_Key::ControlLeft) => idle,
EventType::KeyRelease(E_Key::ControlLeft) => {
pause_counter += 1;

if pause_counter != 0 && pause_counter % 2 == 0 {
Expand Down Expand Up @@ -76,20 +76,20 @@ pub fn run(
EventType::MouseMove { x, y } => {
frontend.update_position((x, y));
}
EventType::KeyPress(E_Key::ShiftLeft) => {
EventType::KeyPress(E_Key::ControlLeft) => {
is_special_pressed = true;
}
EventType::KeyRelease(E_Key::ShiftLeft) => {
EventType::KeyRelease(E_Key::ControlLeft) => {
is_special_pressed = false;
}
EventType::KeyRelease(E_Key::ControlRight) if is_special_pressed => {
EventType::KeyRelease(E_Key::ShiftRight) if is_special_pressed => {
frontend.next_predicate()
}
EventType::KeyRelease(E_Key::ControlLeft) if is_special_pressed => {
EventType::KeyRelease(E_Key::ShiftLeft) if is_special_pressed => {
frontend.previous_predicate()
}
EventType::KeyRelease(E_Key::ShiftRight) if is_special_pressed => {
rdev::simulate(&EventType::KeyRelease(E_Key::ShiftLeft))
EventType::KeyRelease(E_Key::ControlRight) if is_special_pressed => {
rdev::simulate(&EventType::KeyRelease(E_Key::ControlLeft))
.expect("We couldn't cancel the special function");
is_special_pressed = false;

Expand Down Expand Up @@ -233,9 +233,9 @@ mod tests {
output!(textfield, LIMIT);

// We verify that the pause/resume works as expected
input!(ShiftLeft ShiftLeft, typing_speed_ms);
input!(ControlLeft ControlLeft, typing_speed_ms);
input!(KeyU KeyU, typing_speed_ms);
input!(ShiftLeft ShiftLeft, typing_speed_ms);
input!(ControlLeft ControlLeft, typing_speed_ms);
input!(KeyA KeyF, typing_speed_ms);
output!(textfield, format!("{LIMIT}uuɑ"));

Expand Down Expand Up @@ -263,15 +263,15 @@ mod tests {

// We verify that the predicate selection work as expected
input!(KeyH KeyE, typing_speed_ms);
rdev::simulate(&KeyPress(ShiftLeft)).unwrap();
input!(ControlLeft, typing_speed_ms);
input!(ControlRight, typing_speed_ms);
rdev::simulate(&KeyRelease(ShiftLeft)).unwrap();
rdev::simulate(&KeyPress(ControlLeft)).unwrap();
input!(ShiftLeft, typing_speed_ms);
input!(ShiftRight, typing_speed_ms);
rdev::simulate(&KeyRelease(ControlLeft)).unwrap();

input!(KeyL KeyL, typing_speed_ms);
rdev::simulate(&KeyPress(ShiftLeft)).unwrap();
input!(ShiftRight, typing_speed_ms);
rdev::simulate(&KeyRelease(ShiftLeft)).unwrap();
rdev::simulate(&KeyPress(ControlLeft)).unwrap();
input!(ControlRight, typing_speed_ms);
rdev::simulate(&KeyRelease(ControlLeft)).unwrap();
output!(textfield, format!("{LIMIT}hi"));
}
}

0 comments on commit aa2942b

Please sign in to comment.