Skip to content

Commit 5a32976

Browse files
ThinkofnameCobrand
authored andcommitted
Add missing #[repr(C)] to SDL_Keysym
This also reverts the change in 9604e85 which just hid the issue.
1 parent a6d6718 commit 5a32976

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

sdl2-sys/src/keyboard.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use sdl::SDL_bool;
88

99
// SDL_keyboard.h
1010
#[derive(Copy, Clone)]
11+
#[repr(C)]
1112
pub struct SDL_Keysym {
1213
pub scancode: SDL_Scancode,
1314
pub sym: SDL_Keycode,

src/sdl2/event.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ impl Event {
12981298
window_id: event.windowID,
12991299
keycode: Keycode::from_i32(event.keysym.sym as i32),
13001300
scancode: Scancode::from_i32(event.keysym.scancode as i32),
1301-
keymod: keyboard::Mod::from_bits_truncate(event.keysym._mod as SDL_Keymod),
1301+
keymod: keyboard::Mod::from_bits(event.keysym._mod as SDL_Keymod).unwrap(),
13021302
repeat: event.repeat != 0
13031303
}
13041304
}
@@ -1310,7 +1310,7 @@ impl Event {
13101310
window_id: event.windowID,
13111311
keycode: Keycode::from_i32(event.keysym.sym as i32),
13121312
scancode: Scancode::from_i32(event.keysym.scancode as i32),
1313-
keymod: keyboard::Mod::from_bits_truncate(event.keysym._mod as SDL_Keymod),
1313+
keymod: keyboard::Mod::from_bits(event.keysym._mod as SDL_Keymod).unwrap(),
13141314
repeat: event.repeat != 0
13151315
}
13161316
}

0 commit comments

Comments
 (0)