Skip to content

Commit 45a00ca

Browse files
committed
Ignore extra SDL_Keymod bits instead of defaulting to "no mods"
1 parent aefd78d commit 45a00ca

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
In this file will be listed the changes, especially the breaking ones that one should be careful of
22
when upgrading from a version of rust-sdl2 to another.
33

4+
### v0.32.3 (unreleased)
5+
6+
[PR #882](https://github.com/Rust-SDL2/rust-sdl2/pull/882)
7+
Ignore unknown bits in `SDL_Keysym`'s `mod` field (key modifiers) when constructing `Event::KeyDown` and `Event::KeyUp`. Deprecate `sdl2::event::Event::unwrap_keymod`, which had been made public accidentally.
8+
49
### v0.32.1
510

611
[PR #868](https://github.com/Rust-SDL2/rust-sdl2/pull/868):

src/sdl2/event.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ impl Event {
12781278
window_id: event.windowID,
12791279
keycode: Keycode::from_i32(event.keysym.sym as i32),
12801280
scancode: Scancode::from_i32(event.keysym.scancode as i32),
1281-
keymod: Event::unwrap_keymod(keyboard::Mod::from_bits(event.keysym.mod_)),
1281+
keymod: keyboard::Mod::from_bits_truncate(event.keysym.mod_),
12821282
repeat: event.repeat != 0
12831283
}
12841284
}
@@ -1290,7 +1290,7 @@ impl Event {
12901290
window_id: event.windowID,
12911291
keycode: Keycode::from_i32(event.keysym.sym as i32),
12921292
scancode: Scancode::from_i32(event.keysym.scancode as i32),
1293-
keymod: keyboard::Mod::from_bits(event.keysym.mod_).unwrap(),
1293+
keymod: keyboard::Mod::from_bits_truncate(event.keysym.mod_),
12941294
repeat: event.repeat != 0
12951295
}
12961296
}
@@ -1619,6 +1619,7 @@ impl Event {
16191619
}} // close unsafe & match
16201620
}
16211621

1622+
#[deprecated(since = "0.32.3", note = "This method has been made public accidentally")]
16221623
pub fn unwrap_keymod(keymod_option: Option<keyboard::Mod>) -> keyboard::Mod {
16231624
match keymod_option {
16241625
None => keyboard::Mod::empty(),

0 commit comments

Comments
 (0)