From 0120793fd180c40db9a21131ce50fbae42eb0b89 Mon Sep 17 00:00:00 2001 From: Thinkofname Date: Thu, 22 Dec 2016 11:52:13 +0000 Subject: [PATCH] Add missing `#[repr(C)]` to SDL_Keysym This also reverts the change in 9604e85f3db1881654c2d23924fc0b08f7948b94 which just hid the issue. --- sdl2-sys/src/keyboard.rs | 1 + src/sdl2/event.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdl2-sys/src/keyboard.rs b/sdl2-sys/src/keyboard.rs index a0d7090de13..7a36e922126 100644 --- a/sdl2-sys/src/keyboard.rs +++ b/sdl2-sys/src/keyboard.rs @@ -8,6 +8,7 @@ use sdl::SDL_bool; // SDL_keyboard.h #[derive(Copy, Clone)] +#[repr(C)] pub struct SDL_Keysym { pub scancode: SDL_Scancode, pub sym: SDL_Keycode, diff --git a/src/sdl2/event.rs b/src/sdl2/event.rs index 7d6373eca4e..7a0c3fa2982 100644 --- a/src/sdl2/event.rs +++ b/src/sdl2/event.rs @@ -1298,7 +1298,7 @@ impl Event { window_id: event.windowID, keycode: Keycode::from_i32(event.keysym.sym as i32), scancode: Scancode::from_i32(event.keysym.scancode as i32), - keymod: keyboard::Mod::from_bits_truncate(event.keysym._mod as SDL_Keymod), + keymod: keyboard::Mod::from_bits(event.keysym._mod as SDL_Keymod).unwrap(), repeat: event.repeat != 0 } } @@ -1310,7 +1310,7 @@ impl Event { window_id: event.windowID, keycode: Keycode::from_i32(event.keysym.sym as i32), scancode: Scancode::from_i32(event.keysym.scancode as i32), - keymod: keyboard::Mod::from_bits_truncate(event.keysym._mod as SDL_Keymod), + keymod: keyboard::Mod::from_bits(event.keysym._mod as SDL_Keymod).unwrap(), repeat: event.repeat != 0 } }