Skip to content

Commit

Permalink
Check if the 'key' field contains the special key.
Browse files Browse the repository at this point in the history
  • Loading branch information
WeirdConstructor committed Dec 18, 2020
1 parent 1460402 commit 54b7b7b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,10 @@ impl Key {

impl From<p::PuglEventKey> for KeyVal {
fn from(ke: p::PuglEventKey) -> KeyVal {
match ke.key {
0 => KeyVal::Special (SpecialKey::from(ke.keycode)),
_ => KeyVal::Character (char::from_u32(ke.key).unwrap())
let special_key = SpecialKey::from(ke.key);
match special_key {
SpecialKey::None => KeyVal::Character (char::from_u32(ke.key).unwrap()),
_ => KeyVal::Special (special_key),
}
}
}
Expand Down Expand Up @@ -739,8 +740,8 @@ mod test {
xRoot: 123.0,
yRoot: 142.0,
state: p::PuglMod_PUGL_MOD_CTRL | p::PuglMod_PUGL_MOD_ALT,
keycode: p::PuglKey_PUGL_KEY_F1,
key: 0, // 'A'
keycode: 0,
key: p::PuglKey_PUGL_KEY_F1,
}
}

Expand Down

0 comments on commit 54b7b7b

Please sign in to comment.