Support for key events in windows works.

This commit is contained in:
Clement Tsang 2019-09-25 00:37:17 -04:00 committed by ClementTsang
parent bc3169a4df
commit 9df0b2e4e2
2 changed files with 17 additions and 17 deletions

View File

@ -40,7 +40,6 @@ pub async fn get_temperature_data(sys : &System, temp_type : &TemperatureType) -
} }
else if cfg!(target_os = "windows") { else if cfg!(target_os = "windows") {
let sensor_data = sys.get_components_list(); let sensor_data = sys.get_components_list();
debug!("TEMPS: {:?}", sensor_data);
for component in sensor_data { for component in sensor_data {
temperature_vec.push(TempData { temperature_vec.push(TempData {
component_name : Box::from(component.get_label()), component_name : Box::from(component.get_label()),

View File

@ -93,8 +93,8 @@ fn main() -> error::Result<()> {
if cfg!(target_os = "windows") { if cfg!(target_os = "windows") {
screen.to_main()?; screen.to_main()?;
crossterm::RawScreen::into_raw_mode()?;
queue!(stdout, crossterm::Clear(crossterm::ClearType::All), crossterm::BlinkOff)?; queue!(stdout, crossterm::Clear(crossterm::ClearType::All), crossterm::BlinkOff)?;
stdout.flush()?; stdout.flush()?;
} }
@ -110,25 +110,26 @@ fn main() -> error::Result<()> {
let tx = tx.clone(); let tx = tx.clone();
thread::spawn(move || { thread::spawn(move || {
let input = input(); let input = input();
// TODO: Temp! input.enable_mouse_mode().unwrap(); // TODO: I think this is broken on windows...
if !(cfg!(target_os = "windows")) {
input.enable_mouse_mode().unwrap(); // TODO: I think this is broken on windows... let mut reader = input.read_async();
} loop {
let reader = input.read_sync(); if let Some(event) = reader.next() {
for event in reader { match event {
match event { InputEvent::Keyboard(key) => {
InputEvent::Keyboard(key) => { if tx.send(Event::KeyInput(key.clone())).is_err() {
if tx.send(Event::KeyInput(key.clone())).is_err() { return;
return; }
} }
} InputEvent::Mouse(mouse) => {
InputEvent::Mouse(mouse) => { if tx.send(Event::MouseInput(mouse)).is_err() {
if tx.send(Event::MouseInput(mouse)).is_err() { return;
return; }
} }
_ => {}
} }
_ => {}
} }
thread::sleep(Duration::from_millis(50));
} }
}); });
} }