summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClement Tsang <clementjhtsang@gmail.com>2019-09-25 00:37:17 -0400
committerClementTsang <clementjhtsang@gmail.com>2019-09-25 01:59:58 -0400
commit9df0b2e4e202ffb225a3616bdf1dbe3cd830fe84 (patch)
tree4f72d8430e3e7fc99d149f2883927436e859afa8 /src
parentbc3169a4df3c0749f6ea08fbca7b235cce3f77d7 (diff)
Support for key events in windows works.
Diffstat (limited to 'src')
-rw-r--r--src/app/data_collection/temperature.rs1
-rw-r--r--src/main.rs33
2 files changed, 17 insertions, 17 deletions
diff --git a/src/app/data_collection/temperature.rs b/src/app/data_collection/temperature.rs
index 8c05a5f6..274e4175 100644
--- a/src/app/data_collection/temperature.rs
+++ b/src/app/data_collection/temperature.rs
@@ -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()),
diff --git a/src/main.rs b/src/main.rs
index 19fe5493..f6067f2f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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));
}
});
}