#![allow(unreachable_patterns)]
use std::ffi::{CString, CStr};
use libc::c_char;
use std::mem::transmute;
use crate::sys;
#[repr(i32)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub enum Scancode {
A = sys::SDL_Scancode::SDL_SCANCODE_A as i32,
B = sys::SDL_Scancode::SDL_SCANCODE_B as i32,
C = sys::SDL_Scancode::SDL_SCANCODE_C as i32,
D = sys::SDL_Scancode::SDL_SCANCODE_D as i32,
E = sys::SDL_Scancode::SDL_SCANCODE_E as i32,
F = sys::SDL_Scancode::SDL_SCANCODE_F as i32,
G = sys::SDL_Scancode::SDL_SCANCODE_G as i32,
H = sys::SDL_Scancode::SDL_SCANCODE_H as i32,
I = sys::SDL_Scancode::SDL_SCANCODE_I as i32,
J = sys::SDL_Scancode::SDL_SCANCODE_J as i32,
K = sys::SDL_Scancode::SDL_SCANCODE_K as i32,
L = sys::SDL_Scancode::SDL_SCANCODE_L as i32,
M = sys::SDL_Scancode::SDL_SCANCODE_M as i32,
N = sys::SDL_Scancode::SDL_SCANCODE_N as i32,
O = sys::SDL_Scancode::SDL_SCANCODE_O as i32,
P = sys::SDL_Scancode::SDL_SCANCODE_P as i32,
Q = sys::SDL_Scancode::SDL_SCANCODE_Q as i32,
R = sys::SDL_Scancode::SDL_SCANCODE_R as i32,
S = sys::SDL_Scancode::SDL_SCANCODE_S as i32,
T = sys::SDL_Scancode::SDL_SCANCODE_T as i32,
U = sys::SDL_Scancode::SDL_SCANCODE_U as i32,
V = sys::SDL_Scancode::SDL_SCANCODE_V as i32,
W = sys::SDL_Scancode::SDL_SCANCODE_W as i32,
X = sys::SDL_Scancode::SDL_SCANCODE_X as i32,
Y = sys::SDL_Scancode::SDL_SCANCODE_Y as i32,
Z = sys::SDL_Scancode::SDL_SCANCODE_Z as i32,
Num1 = sys::SDL_Scancode::SDL_SCANCODE_1 as i32,
Num2 = sys::SDL_Scancode::SDL_SCANCODE_2 as i32,
Num3 = sys::SDL_Scancode::SDL_SCANCODE_3 as i32,
Num4 = sys::SDL_Scancode::SDL_SCANCODE_4 as i32,
Num5 = sys::SDL_Scancode::SDL_SCANCODE_5 as i32,
Num6 = sys::SDL_Scancode::SDL_SCANCODE_6 as i32,
Num7 = sys::SDL_Scancode::SDL_SCANCODE_7 as i32,
Num8 = sys::SDL_Scancode::SDL_SCANCODE_8 as i32,
Num9 = sys::SDL_Scancode::SDL_SCANCODE_9 as i32,
Num0 = sys::SDL_Scancode::SDL_SCANCODE_0 as i32,
Return = sys::SDL_Scancode::SDL_SCANCODE_RETURN as i32,
Escape = sys::SDL_Scancode::SDL_SCANCODE_ESCAPE as i32,
Backspace = sys::SDL_Scancode::SDL_SCANCODE_BACKSPACE as i32,
Tab = sys::SDL_Scancode::SDL_SCANCODE_TAB as i32,
Space = sys::SDL_Scancode::SDL_SCANCODE_SPACE as i32,
Minus = sys::SDL_Scancode::SDL_SCANCODE_MINUS as i32,
Equals = sys::SDL_Scancode::SDL_SCANCODE_EQUALS as i32,
LeftBracket = sys::SDL_Scancode::SDL_SCANCODE_LEFTBRACKET as i32,
RightBracket = sys::SDL_Scancode::SDL_SCANCODE_RIGHTBRACKET as i32,
Backslash = sys::SDL_Scancode::SDL_SCANCODE_BACKSLASH as i32,
NonUsHash = sys::SDL_Scancode::SDL_SCANCODE_NONUSHASH as i32,
Semicolon = sys::SDL_Scancode::SDL_SCANCODE_SEMICOLON as i32,
Apostrophe = sys::SDL_Scancode::SDL_SCANCODE_APOSTROPHE as i32,
Grave = sys::SDL_Scancode::SDL_SCANCODE_GRAVE as i32,
Comma = sys::SDL_Scancode::SDL_SCANCODE_COMMA as i32,
Period = sys::SDL_Scancode::SDL_SCANCODE_PERIOD as i32,
Slash = sys::SDL_Scancode::SDL_SCANCODE_SLASH as i32,
CapsLock = sys::SDL_Scancode::SDL_SCANCODE_CAPSLOCK as i32,
F1 = sys::SDL_Scancode::SDL_SCANCODE_F1 as i32,
F2 = sys::SDL_Scancode::SDL_SCANCODE_F2 as i32,
F3 = sys::SDL_Scancode::SDL_SCANCODE_F3 as i32,
F4 = sys::SDL_Scancode::SDL_SCANCODE_F4 as i32,
F5 = sys::SDL_Scancode::SDL_SCANCODE_F5 as i32,
F6 = sys::SDL_Scancode::SDL_SCANCODE_F6 as i32,
F7 = sys::SDL_Scancode::SDL_SCANCODE_F7 as i32,
F8 = sys::SDL_Scancode::SDL_SCANCODE_F8 as i32,
F9 = sys::SDL_Scancode::SDL_SCANCODE_F9 as i32,
F10 = sys::SDL_Scancode::SDL_SCANCODE_F10 as i32,
F11 = sys::SDL_Scancode::SDL_SCANCODE_F11 as i32,
F12 = sys::SDL_Scancode::SDL_SCANCODE_F12 as i32,
PrintScreen = sys::SDL_Scancode::SDL_SCANCODE_PRINTSCREEN as i32,
ScrollLock = sys::SDL_Scancode::SDL_SCANCODE_SCROLLLOCK as i32,
Pause = sys::SDL_Scancode::SDL_SCANCODE_PAUSE as i32,
Insert = sys::SDL_Scancode::SDL_SCANCODE_INSERT as i32,
Home = sys::SDL_Scancode::SDL_SCANCODE_HOME as i32,
PageUp = sys::SDL_Scancode::SDL_SCANCODE_PAGEUP as i32,
Delete = sys::SDL_Scancode::SDL_SCANCODE_DELETE as i32,
End = sys::SDL_Scancode::SDL_SCANCODE_END as i32,
PageDown = sys::SDL_Scancode::SDL_SCANCODE_PAGEDOWN as i32,
Right = sys::SDL_Scancode::SDL_SCANCODE_RIGHT as i32,
Left = sys::SDL_Scancode::SDL_SCANCODE_LEFT as i32,
Down = sys::SDL_Scancode::SDL_SCANCODE_DOWN as i32,
Up = sys::SDL_Scancode::SDL_SCANCODE_UP as i32,
NumLockClear = sys::SDL_Scancode::SDL_SCANCODE_NUMLOCKCLEAR as i32,
KpDivide = sys::SDL_Scancode::SDL_SCANCODE_KP_DIVIDE as i32,
KpMultiply = sys::SDL_Scancode::SDL_SCANCODE_KP_MULTIPLY as i32,
KpMinus = sys::SDL_Scancode::SDL_SCANCODE_KP_MINUS as i32,
KpPlus = sys::SDL_Scancode::SDL_SCANCODE_KP_PLUS as i32,
KpEnter = sys::SDL_Scancode::SDL_SCANCODE_KP_ENTER as i32,
Kp1 = sys::SDL_Scancode::SDL_SCANCODE_KP_1 as i32,
Kp2 = sys::SDL_Scancode::SDL_SCANCODE_KP_2 as i32,
Kp3 = sys::SDL_Scancode::SDL_SCANCODE_KP_3 as i32,
Kp4 = sys::SDL_Scancode::SDL_SCANCODE_KP_4 as i32,
Kp5 = sys::SDL_Scancode::SDL_SCANCODE_KP_5 as i32,
Kp6 = sys::SDL_Scancode::SDL_SCANCODE_KP_6 as i32,
Kp7 = sys::SDL_Scancode::SDL_SCANCODE_KP_7 as i32,
Kp8 = sys::SDL_Scancode::SDL_SCANCODE_KP_8 as i32,
Kp9 = sys::SDL_Scancode::SDL_SCANCODE_KP_9 as i32,
Kp0 = sys::SDL_Scancode::SDL_SCANCODE_KP_0 as i32,
KpPeriod = sys::SDL_Scancode::SDL_SCANCODE_KP_PERIOD as i32,
NonUsBackslash = sys::SDL_Scancode::SDL_SCANCODE_NONUSBACKSLASH as i32,
Application = sys::SDL_Scancode::SDL_SCANCODE_APPLICATION as i32,
Power = sys::SDL_Scancode::SDL_SCANCODE_POWER as i32,
KpEquals = sys::SDL_Scancode::SDL_SCANCODE_KP_EQUALS as i32,
F13 = sys::SDL_Scancode::SDL_SCANCODE_F13 as i32,
F14 = sys::SDL_Scancode::SDL_SCANCODE_F14 as i32,
F15 = sys::SDL_Scancode::SDL_SCANCODE_F15 as i32,
F16 = sys::SDL_Scancode::SDL_SCANCODE_F16 as i32,
F17 = sys::SDL_Scancode::SDL_SCANCODE_F17 as i32,
F18 = sys::SDL_Scancode::SDL_SCANCODE_F18 as i32,
F19 = sys::SDL_Scancode::SDL_SCANCODE_F19 as i32,
F20 = sys::SDL_Scancode::SDL_SCANCODE_F20 as i32,
F21 = sys::SDL_Scancode::SDL_SCANCODE_F21 as i32,
F22 = sys::SDL_Scancode::SDL_SCANCODE_F22 as i32,
F23 = sys::SDL_Scancode::SDL_SCANCODE_F23 as i32,
F24 = sys::SDL_Scancode::SDL_SCANCODE_F24 as i32,
Execute = sys::SDL_Scancode::SDL_SCANCODE_EXECUTE as i32,
Help = sys::SDL_Scancode::SDL_SCANCODE_HELP as i32,
Menu = sys::SDL_Scancode::SDL_SCANCODE_MENU as i32,
Select = sys::SDL_Scancode::SDL_SCANCODE_SELECT as i32,
Stop = sys::SDL_Scancode::SDL_SCANCODE_STOP as i32,
Again = sys::SDL_Scancode::SDL_SCANCODE_AGAIN as i32,
Undo = sys::SDL_Scancode::SDL_SCANCODE_UNDO as i32,
Cut = sys::SDL_Scancode::SDL_SCANCODE_CUT as i32,
Copy = sys::SDL_Scancode::SDL_SCANCODE_COPY as i32,
Paste = sys::SDL_Scancode::SDL_SCANCODE_PASTE as i32,
Find = sys::SDL_Scancode::SDL_SCANCODE_FIND as i32,
Mute = sys::SDL_Scancode::SDL_SCANCODE_MUTE as i32,
VolumeUp = sys::SDL_Scancode::SDL_SCANCODE_VOLUMEUP as i32,
VolumeDown = sys::SDL_Scancode::SDL_SCANCODE_VOLUMEDOWN as i32,
KpComma = sys::SDL_Scancode::SDL_SCANCODE_KP_COMMA as i32,
KpEqualsAS400 = sys::SDL_Scancode::SDL_SCANCODE_KP_EQUALSAS400 as i32,
International1 = sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL1 as i32,
International2 = sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL2 as i32,
International3 = sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL3 as i32,
International4 = sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL4 as i32,
International5 = sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL5 as i32,
International6 = sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL6 as i32,
International7 = sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL7 as i32,
International8 = sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL8 as i32,
International9 = sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL9 as i32,
Lang1 = sys::SDL_Scancode::SDL_SCANCODE_LANG1 as i32,
Lang2 = sys::SDL_Scancode::SDL_SCANCODE_LANG2 as i32,
Lang3 = sys::SDL_Scancode::SDL_SCANCODE_LANG3 as i32,
Lang4 = sys::SDL_Scancode::SDL_SCANCODE_LANG4 as i32,
Lang5 = sys::SDL_Scancode::SDL_SCANCODE_LANG5 as i32,
Lang6 = sys::SDL_Scancode::SDL_SCANCODE_LANG6 as i32,
Lang7 = sys::SDL_Scancode::SDL_SCANCODE_LANG7 as i32,
Lang8 = sys::SDL_Scancode::SDL_SCANCODE_LANG8 as i32,
Lang9 = sys::SDL_Scancode::SDL_SCANCODE_LANG9 as i32,
AltErase = sys::SDL_Scancode::SDL_SCANCODE_ALTERASE as i32,
SysReq = sys::SDL_Scancode::SDL_SCANCODE_SYSREQ as i32,
Cancel = sys::SDL_Scancode::SDL_SCANCODE_CANCEL as i32,
Clear = sys::SDL_Scancode::SDL_SCANCODE_CLEAR as i32,
Prior = sys::SDL_Scancode::SDL_SCANCODE_PRIOR as i32,
Return2 = sys::SDL_Scancode::SDL_SCANCODE_RETURN2 as i32,
Separator = sys::SDL_Scancode::SDL_SCANCODE_SEPARATOR as i32,
Out = sys::SDL_Scancode::SDL_SCANCODE_OUT as i32,
Oper = sys::SDL_Scancode::SDL_SCANCODE_OPER as i32,
ClearAgain = sys::SDL_Scancode::SDL_SCANCODE_CLEARAGAIN as i32,
CrSel = sys::SDL_Scancode::SDL_SCANCODE_CRSEL as i32,
ExSel = sys::SDL_Scancode::SDL_SCANCODE_EXSEL as i32,
Kp00 = sys::SDL_Scancode::SDL_SCANCODE_KP_00 as i32,
Kp000 = sys::SDL_Scancode::SDL_SCANCODE_KP_000 as i32,
ThousandsSeparator = sys::SDL_Scancode::SDL_SCANCODE_THOUSANDSSEPARATOR as i32,
DecimalSeparator = sys::SDL_Scancode::SDL_SCANCODE_DECIMALSEPARATOR as i32,
CurrencyUnit = sys::SDL_Scancode::SDL_SCANCODE_CURRENCYUNIT as i32,
CurrencySubUnit = sys::SDL_Scancode::SDL_SCANCODE_CURRENCYSUBUNIT as i32,
KpLeftParen = sys::SDL_Scancode::SDL_SCANCODE_KP_LEFTPAREN as i32,
KpRightParen = sys::SDL_Scancode::SDL_SCANCODE_KP_RIGHTPAREN as i32,
KpLeftBrace = sys::SDL_Scancode::SDL_SCANCODE_KP_LEFTBRACE as i32,
KpRightBrace = sys::SDL_Scancode::SDL_SCANCODE_KP_RIGHTBRACE as i32,
KpTab = sys::SDL_Scancode::SDL_SCANCODE_KP_TAB as i32,
KpBackspace = sys::SDL_Scancode::SDL_SCANCODE_KP_BACKSPACE as i32,
KpA = sys::SDL_Scancode::SDL_SCANCODE_KP_A as i32,
KpB = sys::SDL_Scancode::SDL_SCANCODE_KP_B as i32,
KpC = sys::SDL_Scancode::SDL_SCANCODE_KP_C as i32,
KpD = sys::SDL_Scancode::SDL_SCANCODE_KP_D as i32,
KpE = sys::SDL_Scancode::SDL_SCANCODE_KP_E as i32,
KpF = sys::SDL_Scancode::SDL_SCANCODE_KP_F as i32,
KpXor = sys::SDL_Scancode::SDL_SCANCODE_KP_XOR as i32,
KpPower = sys::SDL_Scancode::SDL_SCANCODE_KP_POWER as i32,
KpPercent = sys::SDL_Scancode::SDL_SCANCODE_KP_PERCENT as i32,
KpLess = sys::SDL_Scancode::SDL_SCANCODE_KP_LESS as i32,
KpGreater = sys::SDL_Scancode::SDL_SCANCODE_KP_GREATER as i32,
KpAmpersand = sys::SDL_Scancode::SDL_SCANCODE_KP_AMPERSAND as i32,
KpDblAmpersand = sys::SDL_Scancode::SDL_SCANCODE_KP_DBLAMPERSAND as i32,
KpVerticalBar = sys::SDL_Scancode::SDL_SCANCODE_KP_VERTICALBAR as i32,
KpDblVerticalBar = sys::SDL_Scancode::SDL_SCANCODE_KP_DBLVERTICALBAR as i32,
KpColon = sys::SDL_Scancode::SDL_SCANCODE_KP_COLON as i32,
KpHash = sys::SDL_Scancode::SDL_SCANCODE_KP_HASH as i32,
KpSpace = sys::SDL_Scancode::SDL_SCANCODE_KP_SPACE as i32,
KpAt = sys::SDL_Scancode::SDL_SCANCODE_KP_AT as i32,
KpExclam = sys::SDL_Scancode::SDL_SCANCODE_KP_EXCLAM as i32,
KpMemStore = sys::SDL_Scancode::SDL_SCANCODE_KP_MEMSTORE as i32,
KpMemRecall = sys::SDL_Scancode::SDL_SCANCODE_KP_MEMRECALL as i32,
KpMemClear = sys::SDL_Scancode::SDL_SCANCODE_KP_MEMCLEAR as i32,
KpMemAdd = sys::SDL_Scancode::SDL_SCANCODE_KP_MEMADD as i32,
KpMemSubtract = sys::SDL_Scancode::SDL_SCANCODE_KP_MEMSUBTRACT as i32,
KpMemMultiply = sys::SDL_Scancode::SDL_SCANCODE_KP_MEMMULTIPLY as i32,
KpMemDivide = sys::SDL_Scancode::SDL_SCANCODE_KP_MEMDIVIDE as i32,
KpPlusMinus = sys::SDL_Scancode::SDL_SCANCODE_KP_PLUSMINUS as i32,
KpClear = sys::SDL_Scancode::SDL_SCANCODE_KP_CLEAR as i32,
KpClearEntry = sys::SDL_Scancode::SDL_SCANCODE_KP_CLEARENTRY as i32,
KpBinary = sys::SDL_Scancode::SDL_SCANCODE_KP_BINARY as i32,
KpOctal = sys::SDL_Scancode::SDL_SCANCODE_KP_OCTAL as i32,
KpDecimal = sys::SDL_Scancode::SDL_SCANCODE_KP_DECIMAL as i32,
KpHexadecimal = sys::SDL_Scancode::SDL_SCANCODE_KP_HEXADECIMAL as i32,
LCtrl = sys::SDL_Scancode::SDL_SCANCODE_LCTRL as i32,
LShift = sys::SDL_Scancode::SDL_SCANCODE_LSHIFT as i32,
LAlt = sys::SDL_Scancode::SDL_SCANCODE_LALT as i32,
LGui = sys::SDL_Scancode::SDL_SCANCODE_LGUI as i32,
RCtrl = sys::SDL_Scancode::SDL_SCANCODE_RCTRL as i32,
RShift = sys::SDL_Scancode::SDL_SCANCODE_RSHIFT as i32,
RAlt = sys::SDL_Scancode::SDL_SCANCODE_RALT as i32,
RGui = sys::SDL_Scancode::SDL_SCANCODE_RGUI as i32,
Mode = sys::SDL_Scancode::SDL_SCANCODE_MODE as i32,
AudioNext = sys::SDL_Scancode::SDL_SCANCODE_AUDIONEXT as i32,
AudioPrev = sys::SDL_Scancode::SDL_SCANCODE_AUDIOPREV as i32,
AudioStop = sys::SDL_Scancode::SDL_SCANCODE_AUDIOSTOP as i32,
AudioPlay = sys::SDL_Scancode::SDL_SCANCODE_AUDIOPLAY as i32,
AudioMute = sys::SDL_Scancode::SDL_SCANCODE_AUDIOMUTE as i32,
MediaSelect = sys::SDL_Scancode::SDL_SCANCODE_MEDIASELECT as i32,
Www = sys::SDL_Scancode::SDL_SCANCODE_WWW as i32,
Mail = sys::SDL_Scancode::SDL_SCANCODE_MAIL as i32,
Calculator = sys::SDL_Scancode::SDL_SCANCODE_CALCULATOR as i32,
Computer = sys::SDL_Scancode::SDL_SCANCODE_COMPUTER as i32,
AcSearch = sys::SDL_Scancode::SDL_SCANCODE_AC_SEARCH as i32,
AcHome = sys::SDL_Scancode::SDL_SCANCODE_AC_HOME as i32,
AcBack = sys::SDL_Scancode::SDL_SCANCODE_AC_BACK as i32,
AcForward = sys::SDL_Scancode::SDL_SCANCODE_AC_FORWARD as i32,
AcStop = sys::SDL_Scancode::SDL_SCANCODE_AC_STOP as i32,
AcRefresh = sys::SDL_Scancode::SDL_SCANCODE_AC_REFRESH as i32,
AcBookmarks = sys::SDL_Scancode::SDL_SCANCODE_AC_BOOKMARKS as i32,
BrightnessDown = sys::SDL_Scancode::SDL_SCANCODE_BRIGHTNESSDOWN as i32,
BrightnessUp = sys::SDL_Scancode::SDL_SCANCODE_BRIGHTNESSUP as i32,
DisplaySwitch = sys::SDL_Scancode::SDL_SCANCODE_DISPLAYSWITCH as i32,
KbdIllumToggle = sys::SDL_Scancode::SDL_SCANCODE_KBDILLUMTOGGLE as i32,
KbdIllumDown = sys::SDL_Scancode::SDL_SCANCODE_KBDILLUMDOWN as i32,
KbdIllumUp = sys::SDL_Scancode::SDL_SCANCODE_KBDILLUMUP as i32,
Eject = sys::SDL_Scancode::SDL_SCANCODE_EJECT as i32,
Sleep = sys::SDL_Scancode::SDL_SCANCODE_SLEEP as i32,
App1 = sys::SDL_Scancode::SDL_SCANCODE_APP1 as i32,
App2 = sys::SDL_Scancode::SDL_SCANCODE_APP2 as i32,
Num = sys::SDL_Scancode::SDL_NUM_SCANCODES as i32,
}
impl Scancode {
pub fn from_i32(n: i32) -> Option<Scancode> {
use self::Scancode::*;
let n = n as u32;
Some( match unsafe { transmute::<u32, sys::SDL_Scancode>(n) } {
sys::SDL_Scancode::SDL_SCANCODE_A => A,
sys::SDL_Scancode::SDL_SCANCODE_B => B,
sys::SDL_Scancode::SDL_SCANCODE_C => C,
sys::SDL_Scancode::SDL_SCANCODE_D => D,
sys::SDL_Scancode::SDL_SCANCODE_E => E,
sys::SDL_Scancode::SDL_SCANCODE_F => F,
sys::SDL_Scancode::SDL_SCANCODE_G => G,
sys::SDL_Scancode::SDL_SCANCODE_H => H,
sys::SDL_Scancode::SDL_SCANCODE_I => I,
sys::SDL_Scancode::SDL_SCANCODE_J => J,
sys::SDL_Scancode::SDL_SCANCODE_K => K,
sys::SDL_Scancode::SDL_SCANCODE_L => L,
sys::SDL_Scancode::SDL_SCANCODE_M => M,
sys::SDL_Scancode::SDL_SCANCODE_N => N,
sys::SDL_Scancode::SDL_SCANCODE_O => O,
sys::SDL_Scancode::SDL_SCANCODE_P => P,
sys::SDL_Scancode::SDL_SCANCODE_Q => Q,
sys::SDL_Scancode::SDL_SCANCODE_R => R,
sys::SDL_Scancode::SDL_SCANCODE_S => S,
sys::SDL_Scancode::SDL_SCANCODE_T => T,
sys::SDL_Scancode::SDL_SCANCODE_U => U,
sys::SDL_Scancode::SDL_SCANCODE_V => V,
sys::SDL_Scancode::SDL_SCANCODE_W => W,
sys::SDL_Scancode::SDL_SCANCODE_X => X,
sys::SDL_Scancode::SDL_SCANCODE_Y => Y,
sys::SDL_Scancode::SDL_SCANCODE_Z => Z,
sys::SDL_Scancode::SDL_SCANCODE_1 => Num1,
sys::SDL_Scancode::SDL_SCANCODE_2 => Num2,
sys::SDL_Scancode::SDL_SCANCODE_3 => Num3,
sys::SDL_Scancode::SDL_SCANCODE_4 => Num4,
sys::SDL_Scancode::SDL_SCANCODE_5 => Num5,
sys::SDL_Scancode::SDL_SCANCODE_6 => Num6,
sys::SDL_Scancode::SDL_SCANCODE_7 => Num7,
sys::SDL_Scancode::SDL_SCANCODE_8 => Num8,
sys::SDL_Scancode::SDL_SCANCODE_9 => Num9,
sys::SDL_Scancode::SDL_SCANCODE_0 => Num0,
sys::SDL_Scancode::SDL_SCANCODE_RETURN => Return,
sys::SDL_Scancode::SDL_SCANCODE_ESCAPE => Escape,
sys::SDL_Scancode::SDL_SCANCODE_BACKSPACE => Backspace,
sys::SDL_Scancode::SDL_SCANCODE_TAB => Tab,
sys::SDL_Scancode::SDL_SCANCODE_SPACE => Space,
sys::SDL_Scancode::SDL_SCANCODE_MINUS => Minus,
sys::SDL_Scancode::SDL_SCANCODE_EQUALS => Equals,
sys::SDL_Scancode::SDL_SCANCODE_LEFTBRACKET => LeftBracket,
sys::SDL_Scancode::SDL_SCANCODE_RIGHTBRACKET => RightBracket,
sys::SDL_Scancode::SDL_SCANCODE_BACKSLASH => Backslash,
sys::SDL_Scancode::SDL_SCANCODE_NONUSHASH => NonUsHash,
sys::SDL_Scancode::SDL_SCANCODE_SEMICOLON => Semicolon,
sys::SDL_Scancode::SDL_SCANCODE_APOSTROPHE => Apostrophe,
sys::SDL_Scancode::SDL_SCANCODE_GRAVE => Grave,
sys::SDL_Scancode::SDL_SCANCODE_COMMA => Comma,
sys::SDL_Scancode::SDL_SCANCODE_PERIOD => Period,
sys::SDL_Scancode::SDL_SCANCODE_SLASH => Slash,
sys::SDL_Scancode::SDL_SCANCODE_CAPSLOCK => CapsLock,
sys::SDL_Scancode::SDL_SCANCODE_F1 => F1,
sys::SDL_Scancode::SDL_SCANCODE_F2 => F2,
sys::SDL_Scancode::SDL_SCANCODE_F3 => F3,
sys::SDL_Scancode::SDL_SCANCODE_F4 => F4,
sys::SDL_Scancode::SDL_SCANCODE_F5 => F5,
sys::SDL_Scancode::SDL_SCANCODE_F6 => F6,
sys::SDL_Scancode::SDL_SCANCODE_F7 => F7,
sys::SDL_Scancode::SDL_SCANCODE_F8 => F8,
sys::SDL_Scancode::SDL_SCANCODE_F9 => F9,
sys::SDL_Scancode::SDL_SCANCODE_F10 => F10,
sys::SDL_Scancode::SDL_SCANCODE_F11 => F11,
sys::SDL_Scancode::SDL_SCANCODE_F12 => F12,
sys::SDL_Scancode::SDL_SCANCODE_PRINTSCREEN => PrintScreen,
sys::SDL_Scancode::SDL_SCANCODE_SCROLLLOCK => ScrollLock,
sys::SDL_Scancode::SDL_SCANCODE_PAUSE => Pause,
sys::SDL_Scancode::SDL_SCANCODE_INSERT => Insert,
sys::SDL_Scancode::SDL_SCANCODE_HOME => Home,
sys::SDL_Scancode::SDL_SCANCODE_PAGEUP => PageUp,
sys::SDL_Scancode::SDL_SCANCODE_DELETE => Delete,
sys::SDL_Scancode::SDL_SCANCODE_END => End,
sys::SDL_Scancode::SDL_SCANCODE_PAGEDOWN => PageDown,
sys::SDL_Scancode::SDL_SCANCODE_RIGHT => Right,
sys::SDL_Scancode::SDL_SCANCODE_LEFT => Left,
sys::SDL_Scancode::SDL_SCANCODE_DOWN => Down,
sys::SDL_Scancode::SDL_SCANCODE_UP => Up,
sys::SDL_Scancode::SDL_SCANCODE_NUMLOCKCLEAR => NumLockClear,
sys::SDL_Scancode::SDL_SCANCODE_KP_DIVIDE => KpDivide,
sys::SDL_Scancode::SDL_SCANCODE_KP_MULTIPLY => KpMultiply,
sys::SDL_Scancode::SDL_SCANCODE_KP_MINUS => KpMinus,
sys::SDL_Scancode::SDL_SCANCODE_KP_PLUS => KpPlus,
sys::SDL_Scancode::SDL_SCANCODE_KP_ENTER => KpEnter,
sys::SDL_Scancode::SDL_SCANCODE_KP_1 => Kp1,
sys::SDL_Scancode::SDL_SCANCODE_KP_2 => Kp2,
sys::SDL_Scancode::SDL_SCANCODE_KP_3 => Kp3,
sys::SDL_Scancode::SDL_SCANCODE_KP_4 => Kp4,
sys::SDL_Scancode::SDL_SCANCODE_KP_5 => Kp5,
sys::SDL_Scancode::SDL_SCANCODE_KP_6 => Kp6,
sys::SDL_Scancode::SDL_SCANCODE_KP_7 => Kp7,
sys::SDL_Scancode::SDL_SCANCODE_KP_8 => Kp8,
sys::SDL_Scancode::SDL_SCANCODE_KP_9 => Kp9,
sys::SDL_Scancode::SDL_SCANCODE_KP_0 => Kp0,
sys::SDL_Scancode::SDL_SCANCODE_KP_PERIOD => KpPeriod,
sys::SDL_Scancode::SDL_SCANCODE_NONUSBACKSLASH => NonUsBackslash,
sys::SDL_Scancode::SDL_SCANCODE_APPLICATION => Application,
sys::SDL_Scancode::SDL_SCANCODE_POWER => Power,
sys::SDL_Scancode::SDL_SCANCODE_KP_EQUALS => KpEquals,
sys::SDL_Scancode::SDL_SCANCODE_F13 => F13,
sys::SDL_Scancode::SDL_SCANCODE_F14 => F14,
sys::SDL_Scancode::SDL_SCANCODE_F15 => F15,
sys::SDL_Scancode::SDL_SCANCODE_F16 => F16,
sys::SDL_Scancode::SDL_SCANCODE_F17 => F17,
sys::SDL_Scancode::SDL_SCANCODE_F18 => F18,
sys::SDL_Scancode::SDL_SCANCODE_F19 => F19,
sys::SDL_Scancode::SDL_SCANCODE_F20 => F20,
sys::SDL_Scancode::SDL_SCANCODE_F21 => F21,
sys::SDL_Scancode::SDL_SCANCODE_F22 => F22,
sys::SDL_Scancode::SDL_SCANCODE_F23 => F23,
sys::SDL_Scancode::SDL_SCANCODE_F24 => F24,
sys::SDL_Scancode::SDL_SCANCODE_EXECUTE => Execute,
sys::SDL_Scancode::SDL_SCANCODE_HELP => Help,
sys::SDL_Scancode::SDL_SCANCODE_MENU => Menu,
sys::SDL_Scancode::SDL_SCANCODE_SELECT => Select,
sys::SDL_Scancode::SDL_SCANCODE_STOP => Stop,
sys::SDL_Scancode::SDL_SCANCODE_AGAIN => Again,
sys::SDL_Scancode::SDL_SCANCODE_UNDO => Undo,
sys::SDL_Scancode::SDL_SCANCODE_CUT => Cut,
sys::SDL_Scancode::SDL_SCANCODE_COPY => Copy,
sys::SDL_Scancode::SDL_SCANCODE_PASTE => Paste,
sys::SDL_Scancode::SDL_SCANCODE_FIND => Find,
sys::SDL_Scancode::SDL_SCANCODE_MUTE => Mute,
sys::SDL_Scancode::SDL_SCANCODE_VOLUMEUP => VolumeUp,
sys::SDL_Scancode::SDL_SCANCODE_VOLUMEDOWN => VolumeDown,
sys::SDL_Scancode::SDL_SCANCODE_KP_COMMA => KpComma,
sys::SDL_Scancode::SDL_SCANCODE_KP_EQUALSAS400 => KpEqualsAS400,
sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL1 => International1,
sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL2 => International2,
sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL3 => International3,
sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL4 => International4,
sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL5 => International5,
sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL6 => International6,
sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL7 => International7,
sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL8 => International8,
sys::SDL_Scancode::SDL_SCANCODE_INTERNATIONAL9 => International9,
sys::SDL_Scancode::SDL_SCANCODE_LANG1 => Lang1,
sys::SDL_Scancode::SDL_SCANCODE_LANG2 => Lang2,
sys::SDL_Scancode::SDL_SCANCODE_LANG3 => Lang3,
sys::SDL_Scancode::SDL_SCANCODE_LANG4 => Lang4,
sys::SDL_Scancode::SDL_SCANCODE_LANG5 => Lang5,
sys::SDL_Scancode::SDL_SCANCODE_LANG6 => Lang6,
sys::SDL_Scancode::SDL_SCANCODE_LANG7 => Lang7,
sys::SDL_Scancode::SDL_SCANCODE_LANG8 => Lang8,
sys::SDL_Scancode::SDL_SCANCODE_LANG9 => Lang9,
sys::SDL_Scancode::SDL_SCANCODE_ALTERASE => AltErase,
sys::SDL_Scancode::SDL_SCANCODE_SYSREQ => SysReq,
sys::SDL_Scancode::SDL_SCANCODE_CANCEL => Cancel,
sys::SDL_Scancode::SDL_SCANCODE_CLEAR => Clear,
sys::SDL_Scancode::SDL_SCANCODE_PRIOR => Prior,
sys::SDL_Scancode::SDL_SCANCODE_RETURN2 => Return2,
sys::SDL_Scancode::SDL_SCANCODE_SEPARATOR => Separator,
sys::SDL_Scancode::SDL_SCANCODE_OUT => Out,
sys::SDL_Scancode::SDL_SCANCODE_OPER => Oper,
sys::SDL_Scancode::SDL_SCANCODE_CLEARAGAIN => ClearAgain,
sys::SDL_Scancode::SDL_SCANCODE_CRSEL => CrSel,
sys::SDL_Scancode::SDL_SCANCODE_EXSEL => ExSel,
sys::SDL_Scancode::SDL_SCANCODE_KP_00 => Kp00,
sys::SDL_Scancode::SDL_SCANCODE_KP_000 => Kp000,
sys::SDL_Scancode::SDL_SCANCODE_THOUSANDSSEPARATOR => ThousandsSeparator,
sys::SDL_Scancode::SDL_SCANCODE_DECIMALSEPARATOR => DecimalSeparator,
sys::SDL_Scancode::SDL_SCANCODE_CURRENCYUNIT => CurrencyUnit,
sys::SDL_Scancode::SDL_SCANCODE_CURRENCYSUBUNIT => CurrencySubUnit,
sys::SDL_Scancode::SDL_SCANCODE_KP_LEFTPAREN => KpLeftParen,
sys::SDL_Scancode::SDL_SCANCODE_KP_RIGHTPAREN => KpRightParen,
sys::SDL_Scancode::SDL_SCANCODE_KP_LEFTBRACE => KpLeftBrace,
sys::SDL_Scancode::SDL_SCANCODE_KP_RIGHTBRACE => KpRightBrace,
sys::SDL_Scancode::SDL_SCANCODE_KP_TAB => KpTab,
sys::SDL_Scancode::SDL_SCANCODE_KP_BACKSPACE => KpBackspace,
sys::SDL_Scancode::SDL_SCANCODE_KP_A => KpA,
sys::SDL_Scancode::SDL_SCANCODE_KP_B => KpB,
sys::SDL_Scancode::SDL_SCANCODE_KP_C => KpC,
sys::SDL_Scancode::SDL_SCANCODE_KP_D => KpD,
sys::SDL_Scancode::SDL_SCANCODE_KP_E => KpE,
sys::SDL_Scancode::SDL_SCANCODE_KP_F => KpF,
sys::SDL_Scancode::SDL_SCANCODE_KP_XOR => KpXor,
sys::SDL_Scancode::SDL_SCANCODE_KP_POWER => KpPower,
sys::SDL_Scancode::SDL_SCANCODE_KP_PERCENT => KpPercent,
sys::SDL_Scancode::SDL_SCANCODE_KP_LESS => KpLess,
sys::SDL_Scancode::SDL_SCANCODE_KP_GREATER => KpGreater,
sys::SDL_Scancode::SDL_SCANCODE_KP_AMPERSAND => KpAmpersand,
sys::SDL_Scancode::SDL_SCANCODE_KP_DBLAMPERSAND => KpDblAmpersand,
sys::SDL_Scancode::SDL_SCANCODE_KP_VERTICALBAR => KpVerticalBar,
sys::SDL_Scancode::SDL_SCANCODE_KP_DBLVERTICALBAR => KpDblVerticalBar,
sys::SDL_Scancode::SDL_SCANCODE_KP_COLON => KpColon,
sys::SDL_Scancode::SDL_SCANCODE_KP_HASH => KpHash,
sys::SDL_Scancode::SDL_SCANCODE_KP_SPACE => KpSpace,
sys::SDL_Scancode::SDL_SCANCODE_KP_AT => KpAt,
sys::SDL_Scancode::SDL_SCANCODE_KP_EXCLAM => KpExclam,
sys::SDL_Scancode::SDL_SCANCODE_KP_MEMSTORE => KpMemStore,
sys::SDL_Scancode::SDL_SCANCODE_KP_MEMRECALL => KpMemRecall,
sys::SDL_Scancode::SDL_SCANCODE_KP_MEMCLEAR => KpMemClear,
sys::SDL_Scancode::SDL_SCANCODE_KP_MEMADD => KpMemAdd,
sys::SDL_Scancode::SDL_SCANCODE_KP_MEMSUBTRACT => KpMemSubtract,
sys::SDL_Scancode::SDL_SCANCODE_KP_MEMMULTIPLY => KpMemMultiply,
sys::SDL_Scancode::SDL_SCANCODE_KP_MEMDIVIDE => KpMemDivide,
sys::SDL_Scancode::SDL_SCANCODE_KP_PLUSMINUS => KpPlusMinus,
sys::SDL_Scancode::SDL_SCANCODE_KP_CLEAR => KpClear,
sys::SDL_Scancode::SDL_SCANCODE_KP_CLEARENTRY => KpClearEntry,
sys::SDL_Scancode::SDL_SCANCODE_KP_BINARY => KpBinary,
sys::SDL_Scancode::SDL_SCANCODE_KP_OCTAL => KpOctal,
sys::SDL_Scancode::SDL_SCANCODE_KP_DECIMAL => KpDecimal,
sys::SDL_Scancode::SDL_SCANCODE_KP_HEXADECIMAL => KpHexadecimal,
sys::SDL_Scancode::SDL_SCANCODE_LCTRL => LCtrl,
sys::SDL_Scancode::SDL_SCANCODE_LSHIFT => LShift,
sys::SDL_Scancode::SDL_SCANCODE_LALT => LAlt,
sys::SDL_Scancode::SDL_SCANCODE_LGUI => LGui,
sys::SDL_Scancode::SDL_SCANCODE_RCTRL => RCtrl,
sys::SDL_Scancode::SDL_SCANCODE_RSHIFT => RShift,
sys::SDL_Scancode::SDL_SCANCODE_RALT => RAlt,
sys::SDL_Scancode::SDL_SCANCODE_RGUI => RGui,
sys::SDL_Scancode::SDL_SCANCODE_MODE => Mode,
sys::SDL_Scancode::SDL_SCANCODE_AUDIONEXT => AudioNext,
sys::SDL_Scancode::SDL_SCANCODE_AUDIOPREV => AudioPrev,
sys::SDL_Scancode::SDL_SCANCODE_AUDIOSTOP => AudioStop,
sys::SDL_Scancode::SDL_SCANCODE_AUDIOPLAY => AudioPlay,
sys::SDL_Scancode::SDL_SCANCODE_AUDIOMUTE => AudioMute,
sys::SDL_Scancode::SDL_SCANCODE_MEDIASELECT => MediaSelect,
sys::SDL_Scancode::SDL_SCANCODE_WWW => Www,
sys::SDL_Scancode::SDL_SCANCODE_MAIL => Mail,
sys::SDL_Scancode::SDL_SCANCODE_CALCULATOR => Calculator,
sys::SDL_Scancode::SDL_SCANCODE_COMPUTER => Computer,
sys::SDL_Scancode::SDL_SCANCODE_AC_SEARCH => AcSearch,
sys::SDL_Scancode::SDL_SCANCODE_AC_HOME => AcHome,
sys::SDL_Scancode::SDL_SCANCODE_AC_BACK => AcBack,
sys::SDL_Scancode::SDL_SCANCODE_AC_FORWARD => AcForward,
sys::SDL_Scancode::SDL_SCANCODE_AC_STOP => AcStop,
sys::SDL_Scancode::SDL_SCANCODE_AC_REFRESH => AcRefresh,
sys::SDL_Scancode::SDL_SCANCODE_AC_BOOKMARKS => AcBookmarks,
sys::SDL_Scancode::SDL_SCANCODE_BRIGHTNESSDOWN => BrightnessDown,
sys::SDL_Scancode::SDL_SCANCODE_BRIGHTNESSUP => BrightnessUp,
sys::SDL_Scancode::SDL_SCANCODE_DISPLAYSWITCH => DisplaySwitch,
sys::SDL_Scancode::SDL_SCANCODE_KBDILLUMTOGGLE => KbdIllumToggle,
sys::SDL_Scancode::SDL_SCANCODE_KBDILLUMDOWN => KbdIllumDown,
sys::SDL_Scancode::SDL_SCANCODE_KBDILLUMUP => KbdIllumUp,
sys::SDL_Scancode::SDL_SCANCODE_EJECT => Eject,
sys::SDL_Scancode::SDL_SCANCODE_SLEEP => Sleep,
sys::SDL_Scancode::SDL_SCANCODE_APP1 => App1,
sys::SDL_Scancode::SDL_SCANCODE_APP2 => App2,
sys::SDL_Scancode::SDL_NUM_SCANCODES => Num,
_ => return None,
})
}
}
use std::fmt;
impl fmt::Display for Scancode {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "{}", self.name())
}
}
use crate::keyboard::Keycode;
impl Scancode {
pub fn from_keycode(keycode: Keycode) -> Option<Scancode> {
unsafe {
match sys::SDL_GetScancodeFromKey(keycode as i32) {
sys::SDL_Scancode::SDL_SCANCODE_UNKNOWN => None,
scancode_id => Scancode::from_i32(scancode_id as i32)
}
}
}
pub fn from_name(name: &str) -> Option<Scancode> {
unsafe {
match CString::new(name) {
Ok(name) => match sys::SDL_GetScancodeFromName(name.as_ptr() as *const c_char) {
sys::SDL_Scancode::SDL_SCANCODE_UNKNOWN => None,
scancode_id => Some(Scancode::from_i32(scancode_id as i32).unwrap())
},
Err(_) => None
}
}
}
pub fn name(self) -> &'static str {
unsafe {
let buf = sys::SDL_GetScancodeName(transmute::<u32, sys::SDL_Scancode>(self as u32));
::std::str::from_utf8(CStr::from_ptr(buf as *const _).to_bytes()).unwrap()
}
}
}