diff --git a/README.adoc b/README.adoc index 463a0a1..183c4c0 100644 --- a/README.adoc +++ b/README.adoc @@ -3,7 +3,7 @@ :sokol-rs: https://github.com/code-disaster/sokol-rs[sokol-rs] :bindgen: https://github.com/rust-lang/rust-bindgen[bindgen] -Wrapper of {sokol}, the C libraries for game development +Wrapper of {sokol}, the C libraries for games == API diff --git a/src/app.rs b/src/app.rs index 09ab8b9..d977d5c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -26,130 +26,130 @@ pub enum SAppEventType { QuitRequested, } -#[repr(C)] #[derive(Copy, Clone, PartialEq, Debug)] -pub enum SAppKeycode { - KeyInvalid = 0, - KeySpace = 32, - KeyApostrophe = 39, - KeyComma = 44, - KeyMinus = 45, - KeyPeriod = 46, - KeySlash = 47, - Key0 = 48, - Key1 = 49, - Key2 = 50, - Key3 = 51, - Key4 = 52, - Key5 = 53, - Key6 = 54, - Key7 = 55, - Key8 = 56, - Key9 = 57, - KeySemicolon = 59, - KeyEqual = 61, - KeyA = 65, - KeyB = 66, - KeyC = 67, - KeyD = 68, - KeyE = 69, - KeyF = 70, - KeyG = 71, - KeyH = 72, - KeyI = 73, - KeyJ = 74, - KeyK = 75, - KeyL = 76, - KeyM = 77, - KeyN = 78, - KeyO = 79, - KeyP = 80, - KeyQ = 81, - KeyR = 82, - KeyS = 83, - KeyT = 84, - KeyU = 85, - KeyV = 86, - KeyW = 87, - KeyX = 88, - KeyY = 89, - KeyZ = 90, - KeyLeftBracket = 91, - KeyBackslash = 92, - KeyRightBracket = 93, - KeyGraveAccent = 96, - KeyWorld1 = 161, - KeyWorld2 = 162, - KeyEscape = 256, - KeyEnter = 257, - KeyTab = 258, - KeyBackspace = 259, - KeyInsert = 260, - KeyDelete = 261, - KeyRight = 262, - KeyLeft = 263, - KeyDown = 264, - KeyUp = 265, - KeyPageUp = 266, - KeyPageDown = 267, - KeyHome = 268, - KeyEnd = 269, - KeyCapsLock = 280, - KeyScrollLock = 281, - KeyNumLock = 282, - KeyPrintScreen = 283, - KeyPause = 284, - KeyF1 = 290, - KeyF2 = 291, - KeyF3 = 292, - KeyF4 = 293, - KeyF5 = 294, - KeyF6 = 295, - KeyF7 = 296, - KeyF8 = 297, - KeyF9 = 298, - KeyF10 = 299, - KeyF11 = 300, - KeyF12 = 301, - KeyF13 = 302, - KeyF14 = 303, - KeyF15 = 304, - KeyF16 = 305, - KeyF17 = 306, - KeyF18 = 307, - KeyF19 = 308, - KeyF20 = 309, - KeyF21 = 310, - KeyF22 = 311, - KeyF23 = 312, - KeyF24 = 313, - KeyF25 = 314, - KeyKP0 = 320, - KeyKP1 = 321, - KeyKP2 = 322, - KeyKP3 = 323, - KeyKP4 = 324, - KeyKP5 = 325, - KeyKP6 = 326, - KeyKP7 = 327, - KeyKP8 = 328, - KeyKP9 = 329, - KeyKPDecimal = 330, - KeyKPDivide = 331, - KeyKPMultiply = 332, - KeyKPSubtract = 333, - KeyKPAdd = 334, - KeyKPEnter = 335, - KeyKPEqual = 336, - KeyLeftShift = 340, - KeyLeftControl = 341, - KeyLeftAlt = 342, - KeyLeftSuper = 343, - KeyRightShift = 344, - KeyRightControl = 345, - KeyRightAlt = 346, - KeyRightSuper = 347, - KeyMenu = 348, +#[repr(u32)] +pub enum Key { + Invalid = ffi::sapp_keycode_SAPP_KEYCODE_INVALID, + Space = ffi::sapp_keycode_SAPP_KEYCODE_SPACE, + Apostrophe = ffi::sapp_keycode_SAPP_KEYCODE_APOSTROPHE, + Comma = ffi::sapp_keycode_SAPP_KEYCODE_COMMA, + Minus = ffi::sapp_keycode_SAPP_KEYCODE_MINUS, + Period = ffi::sapp_keycode_SAPP_KEYCODE_PERIOD, + Slash = ffi::sapp_keycode_SAPP_KEYCODE_SLASH, + Kbd0 = ffi::sapp_keycode_SAPP_KEYCODE_0, + Kbd1 = ffi::sapp_keycode_SAPP_KEYCODE_1, + Kbd2 = ffi::sapp_keycode_SAPP_KEYCODE_2, + Kbd3 = ffi::sapp_keycode_SAPP_KEYCODE_3, + Kbd4 = ffi::sapp_keycode_SAPP_KEYCODE_4, + Kbd5 = ffi::sapp_keycode_SAPP_KEYCODE_5, + Kbd6 = ffi::sapp_keycode_SAPP_KEYCODE_6, + Kbd7 = ffi::sapp_keycode_SAPP_KEYCODE_7, + Kbd8 = ffi::sapp_keycode_SAPP_KEYCODE_8, + Kbd9 = ffi::sapp_keycode_SAPP_KEYCODE_9, + Semicolon = ffi::sapp_keycode_SAPP_KEYCODE_SEMICOLON, + Equal = ffi::sapp_keycode_SAPP_KEYCODE_EQUAL, + A = ffi::sapp_keycode_SAPP_KEYCODE_A, + B = ffi::sapp_keycode_SAPP_KEYCODE_B, + C = ffi::sapp_keycode_SAPP_KEYCODE_C, + D = ffi::sapp_keycode_SAPP_KEYCODE_D, + E = ffi::sapp_keycode_SAPP_KEYCODE_E, + F = ffi::sapp_keycode_SAPP_KEYCODE_F, + G = ffi::sapp_keycode_SAPP_KEYCODE_G, + H = ffi::sapp_keycode_SAPP_KEYCODE_H, + I = ffi::sapp_keycode_SAPP_KEYCODE_I, + J = ffi::sapp_keycode_SAPP_KEYCODE_J, + K = ffi::sapp_keycode_SAPP_KEYCODE_K, + L = ffi::sapp_keycode_SAPP_KEYCODE_L, + M = ffi::sapp_keycode_SAPP_KEYCODE_M, + N = ffi::sapp_keycode_SAPP_KEYCODE_N, + O = ffi::sapp_keycode_SAPP_KEYCODE_O, + P = ffi::sapp_keycode_SAPP_KEYCODE_P, + Q = ffi::sapp_keycode_SAPP_KEYCODE_Q, + R = ffi::sapp_keycode_SAPP_KEYCODE_R, + S = ffi::sapp_keycode_SAPP_KEYCODE_S, + T = ffi::sapp_keycode_SAPP_KEYCODE_T, + U = ffi::sapp_keycode_SAPP_KEYCODE_U, + V = ffi::sapp_keycode_SAPP_KEYCODE_V, + W = ffi::sapp_keycode_SAPP_KEYCODE_W, + X = ffi::sapp_keycode_SAPP_KEYCODE_X, + Y = ffi::sapp_keycode_SAPP_KEYCODE_Y, + Z = ffi::sapp_keycode_SAPP_KEYCODE_Z, + LeftBracket = ffi::sapp_keycode_SAPP_KEYCODE_LEFT_BRACKET, + Backslash = ffi::sapp_keycode_SAPP_KEYCODE_BACKSLASH, + RightBracket = ffi::sapp_keycode_SAPP_KEYCODE_RIGHT_BRACKET, + GraveAccent = ffi::sapp_keycode_SAPP_KEYCODE_GRAVE_ACCENT, + World1 = ffi::sapp_keycode_SAPP_KEYCODE_WORLD_1, + World2 = ffi::sapp_keycode_SAPP_KEYCODE_WORLD_2, + Escape = ffi::sapp_keycode_SAPP_KEYCODE_ESCAPE, + Enter = ffi::sapp_keycode_SAPP_KEYCODE_ENTER, + Tab = ffi::sapp_keycode_SAPP_KEYCODE_TAB, + Backspace = ffi::sapp_keycode_SAPP_KEYCODE_BACKSPACE, + Insert = ffi::sapp_keycode_SAPP_KEYCODE_INSERT, + Delete = ffi::sapp_keycode_SAPP_KEYCODE_DELETE, + Right = ffi::sapp_keycode_SAPP_KEYCODE_RIGHT, + Left = ffi::sapp_keycode_SAPP_KEYCODE_LEFT, + Down = ffi::sapp_keycode_SAPP_KEYCODE_DOWN, + Up = ffi::sapp_keycode_SAPP_KEYCODE_UP, + PageUp = ffi::sapp_keycode_SAPP_KEYCODE_PAGE_UP, + PageDown = ffi::sapp_keycode_SAPP_KEYCODE_PAGE_DOWN, + Home = ffi::sapp_keycode_SAPP_KEYCODE_HOME, + End = ffi::sapp_keycode_SAPP_KEYCODE_END, + CapsLock = ffi::sapp_keycode_SAPP_KEYCODE_CAPS_LOCK, + ScrollLock = ffi::sapp_keycode_SAPP_KEYCODE_SCROLL_LOCK, + NumLock = ffi::sapp_keycode_SAPP_KEYCODE_NUM_LOCK, + PrintScreen = ffi::sapp_keycode_SAPP_KEYCODE_PRINT_SCREEN, + Pause = ffi::sapp_keycode_SAPP_KEYCODE_PAUSE, + F1 = ffi::sapp_keycode_SAPP_KEYCODE_F1, + F2 = ffi::sapp_keycode_SAPP_KEYCODE_F2, + F3 = ffi::sapp_keycode_SAPP_KEYCODE_F3, + F4 = ffi::sapp_keycode_SAPP_KEYCODE_F4, + F5 = ffi::sapp_keycode_SAPP_KEYCODE_F5, + F6 = ffi::sapp_keycode_SAPP_KEYCODE_F6, + F7 = ffi::sapp_keycode_SAPP_KEYCODE_F7, + F8 = ffi::sapp_keycode_SAPP_KEYCODE_F8, + F9 = ffi::sapp_keycode_SAPP_KEYCODE_F9, + F10 = ffi::sapp_keycode_SAPP_KEYCODE_F10, + F11 = ffi::sapp_keycode_SAPP_KEYCODE_F11, + F12 = ffi::sapp_keycode_SAPP_KEYCODE_F12, + F13 = ffi::sapp_keycode_SAPP_KEYCODE_F13, + F14 = ffi::sapp_keycode_SAPP_KEYCODE_F14, + F15 = ffi::sapp_keycode_SAPP_KEYCODE_F15, + F16 = ffi::sapp_keycode_SAPP_KEYCODE_F16, + F17 = ffi::sapp_keycode_SAPP_KEYCODE_F17, + F18 = ffi::sapp_keycode_SAPP_KEYCODE_F18, + F19 = ffi::sapp_keycode_SAPP_KEYCODE_F19, + F20 = ffi::sapp_keycode_SAPP_KEYCODE_F20, + F21 = ffi::sapp_keycode_SAPP_KEYCODE_F21, + F22 = ffi::sapp_keycode_SAPP_KEYCODE_F22, + F23 = ffi::sapp_keycode_SAPP_KEYCODE_F23, + F24 = ffi::sapp_keycode_SAPP_KEYCODE_F24, + F25 = ffi::sapp_keycode_SAPP_KEYCODE_F25, + KP0 = ffi::sapp_keycode_SAPP_KEYCODE_KP_0, + KP1 = ffi::sapp_keycode_SAPP_KEYCODE_KP_1, + KP2 = ffi::sapp_keycode_SAPP_KEYCODE_KP_2, + KP3 = ffi::sapp_keycode_SAPP_KEYCODE_KP_3, + KP4 = ffi::sapp_keycode_SAPP_KEYCODE_KP_4, + KP5 = ffi::sapp_keycode_SAPP_KEYCODE_KP_5, + KP6 = ffi::sapp_keycode_SAPP_KEYCODE_KP_6, + KP7 = ffi::sapp_keycode_SAPP_KEYCODE_KP_7, + KP8 = ffi::sapp_keycode_SAPP_KEYCODE_KP_8, + KP9 = ffi::sapp_keycode_SAPP_KEYCODE_KP_9, + KPDecimal = ffi::sapp_keycode_SAPP_KEYCODE_KP_DECIMAL, + KPDivide = ffi::sapp_keycode_SAPP_KEYCODE_KP_DIVIDE, + KPMultiply = ffi::sapp_keycode_SAPP_KEYCODE_KP_MULTIPLY, + KPSubtract = ffi::sapp_keycode_SAPP_KEYCODE_KP_SUBTRACT, + KPAdd = ffi::sapp_keycode_SAPP_KEYCODE_KP_ADD, + KPEnter = ffi::sapp_keycode_SAPP_KEYCODE_KP_ENTER, + KPEqual = ffi::sapp_keycode_SAPP_KEYCODE_KP_EQUAL, + LeftShift = ffi::sapp_keycode_SAPP_KEYCODE_LEFT_SHIFT, + LeftControl = ffi::sapp_keycode_SAPP_KEYCODE_LEFT_CONTROL, + LeftAlt = ffi::sapp_keycode_SAPP_KEYCODE_LEFT_ALT, + LeftSuper = ffi::sapp_keycode_SAPP_KEYCODE_LEFT_SUPER, + RightShift = ffi::sapp_keycode_SAPP_KEYCODE_RIGHT_SHIFT, + RightControl = ffi::sapp_keycode_SAPP_KEYCODE_RIGHT_CONTROL, + RightAlt = ffi::sapp_keycode_SAPP_KEYCODE_RIGHT_ALT, + RightSuper = ffi::sapp_keycode_SAPP_KEYCODE_RIGHT_SUPER, + Menu = ffi::sapp_keycode_SAPP_KEYCODE_MENU, } #[repr(C)] @@ -184,7 +184,7 @@ pub struct SAppTouchPoint { pub struct SAppEvent { pub frame_count: u64, pub event_type: SAppEventType, - pub key_code: SAppKeycode, + pub key_code: Key, pub char_code: u32, pub key_repeat: bool, pub modifiers: SAppModifier,