Skip to content

Commit

Permalink
Fix #252 on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
federico-terzi committed May 2, 2020
1 parent 65aeb93 commit 5305fbd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/context/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ extern fn keypress_callback(_self: *mut c_void, raw_buffer: *const u16, len: i32
return;
}

if is_key_down != 0 { // KEY DOWN EVENT
if event_type == 0 { // Char event
if event_type == 0 { // Char event
if is_key_down != 0 { // KEY DOWN EVENT
// Convert the received buffer to a string
let buffer = std::slice::from_raw_parts(raw_buffer, len as usize);
let c_string = U16CStr::from_slice_with_nul(buffer);
Expand All @@ -143,15 +143,15 @@ extern fn keypress_callback(_self: *mut c_void, raw_buffer: *const u16, len: i32
(*_self).send_channel.send(event).unwrap();
},
Err(e) => {
error!("Unable to receive char: {}",e);
error!("Unable to receive char: {}", e);
},
}
}else{
} else {
error!("unable to decode widechar");
}
}
}else{ // KEY UP event
if event_type == 1 { // Modifier event
}else if event_type == 1 { // Modifier event
if is_key_down == 1 { // Keyup event
let modifier: Option<KeyModifier> = match (key_code, variant) {
(0x5B, _) => Some(LEFT_META),
(0x5C, _) => Some(RIGHT_META),
Expand All @@ -172,11 +172,11 @@ extern fn keypress_callback(_self: *mut c_void, raw_buffer: *const u16, len: i32
let event = Event::Key(KeyEvent::Other);
(*_self).send_channel.send(event).unwrap();
}
}else{
// Other type of event
let event = Event::Key(KeyEvent::Other);
(*_self).send_channel.send(event).unwrap();
}
}else{
// Other type of event
let event = Event::Key(KeyEvent::Other);
(*_self).send_channel.send(event).unwrap();
}
}
}
Expand Down

0 comments on commit 5305fbd

Please sign in to comment.