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") {
let sensor_data = sys.get_components_list();
debug!("TEMPS: {:?}", sensor_data);
for component in sensor_data {
temperature_vec.push(TempData {
component_name : Box::from(component.get_label()),

View File

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