Skip to content

Commit

Permalink
Monitor input only sends key on press now, not on release
Browse files Browse the repository at this point in the history
  • Loading branch information
LelouBil committed Aug 7, 2024
1 parent 2334907 commit c95ebd4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Downgrade crossterm and update time crates (#659)
- Monitor now only sends key presses on key down events

### Changed

Expand Down
25 changes: 14 additions & 11 deletions espflash/src/cli/monitor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use std::{
time::Duration,
};

use crossterm::event::KeyEventKind;
use crossterm::{
event::{poll, read, Event, KeyCode, KeyEvent, KeyModifiers},
terminal::{disable_raw_mode, enable_raw_mode},
Expand Down Expand Up @@ -116,20 +117,22 @@ pub fn monitor(

if interactive_mode && poll(Duration::from_secs(0)).into_diagnostic()? {
if let Event::Key(key) = read().into_diagnostic()? {
if key.modifiers.contains(KeyModifiers::CONTROL) {
match key.code {
KeyCode::Char('c') => break,
KeyCode::Char('r') => {
reset_after_flash(&mut serial, pid).into_diagnostic()?;
continue;
if key.kind == KeyEventKind::Press {
if key.modifiers.contains(KeyModifiers::CONTROL) {
match key.code {
KeyCode::Char('c') => break,
KeyCode::Char('r') => {
reset_after_flash(&mut serial, pid).into_diagnostic()?;
continue;
}
_ => {}
}
_ => {}
}
}

if let Some(bytes) = handle_key_event(key) {
serial.write_all(&bytes).into_diagnostic()?;
serial.flush().into_diagnostic()?;
if let Some(bytes) = handle_key_event(key) {
serial.write_all(&bytes).into_diagnostic()?;
serial.flush().into_diagnostic()?;
}
}
}
}
Expand Down

0 comments on commit c95ebd4

Please sign in to comment.