1 2 // Copyright Michael D. Parker 2018. 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 module bindbc.sdl.bind.sdlkeyboard; 8 9 import bindbc.sdl.bind.sdlkeycode : SDL_Keycode, SDL_Keymod; 10 import bindbc.sdl.bind.sdlrect : SDL_Rect; 11 import bindbc.sdl.bind.sdlscancode : SDL_Scancode; 12 import bindbc.sdl.bind.sdlstdinc : SDL_bool; 13 import bindbc.sdl.bind.sdlvideo : SDL_Window; 14 15 struct SDL_Keysym { 16 SDL_Scancode scancode; 17 SDL_Keycode sym; 18 ushort mod; 19 uint unused; 20 } 21 22 version(BindSDL_Static) { 23 extern(C) @nogc nothrow { 24 SDL_Window* SDL_GetKeyboardFocus(); 25 ubyte* SDL_GetKeyboardState(int*); 26 SDL_Keymod SDL_GetModState(); 27 void SDL_SetModState(SDL_Keymod); 28 SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode); 29 SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode); 30 const(char)* SDL_GetScancodeName(SDL_Scancode); 31 SDL_Scancode SDL_GetScancodeFromName(const(char)*); 32 const(char)* SDL_GetKeyName(SDL_Keycode); 33 SDL_Keycode SDL_GetKeyFromName(const(char)*); 34 void SDL_StartTextInput(); 35 SDL_bool SDL_IsTextInputActive(); 36 void SDL_StopTextInput(); 37 void SDL_SetTextInputRect(SDL_Rect*); 38 SDL_bool SDL_HasScreenKeyboardSupport(); 39 SDL_bool SDL_IsScreenKeyboardShown(SDL_Window*); 40 } 41 } 42 else { 43 extern(C) @nogc nothrow { 44 alias pSDL_GetKeyboardFocus = SDL_Window* function(); 45 alias pSDL_GetKeyboardState = ubyte* function(int*); 46 alias pSDL_GetModState = SDL_Keymod function(); 47 alias pSDL_SetModState = void function(SDL_Keymod); 48 alias pSDL_GetKeyFromScancode = SDL_Keycode function(SDL_Scancode); 49 alias pSDL_GetScancodeFromKey = SDL_Scancode function(SDL_Keycode); 50 alias pSDL_GetScancodeName = const(char)* function(SDL_Scancode); 51 alias pSDL_GetScancodeFromName = SDL_Scancode function(const(char)*); 52 alias pSDL_GetKeyName = const(char)* function(SDL_Keycode); 53 alias pSDL_GetKeyFromName = SDL_Keycode function(const(char)*); 54 alias pSDL_StartTextInput = void function(); 55 alias pSDL_IsTextInputActive = SDL_bool function(); 56 alias pSDL_StopTextInput = void function(); 57 alias pSDL_SetTextInputRect = void function(SDL_Rect*); 58 alias pSDL_HasScreenKeyboardSupport = SDL_bool function(); 59 alias pSDL_IsScreenKeyboardShown = SDL_bool function(SDL_Window*); 60 } 61 62 __gshared { 63 pSDL_GetKeyboardFocus SDL_GetKeyboardFocus; 64 pSDL_GetKeyboardState SDL_GetKeyboardState; 65 pSDL_GetModState SDL_GetModState; 66 pSDL_SetModState SDL_SetModState; 67 pSDL_GetKeyFromScancode SDL_GetKeyFromScancode; 68 pSDL_GetScancodeFromKey SDL_GetScancodeFromKey; 69 pSDL_GetScancodeName SDL_GetScancodeName; 70 pSDL_GetScancodeFromName SDL_GetScancodeFromName; 71 pSDL_GetKeyName SDL_GetKeyName; 72 pSDL_GetKeyFromName SDL_GetKeyFromName; 73 pSDL_StartTextInput SDL_StartTextInput; 74 pSDL_IsTextInputActive SDL_IsTextInputActive; 75 pSDL_StopTextInput SDL_StopTextInput; 76 pSDL_SetTextInputRect SDL_SetTextInputRect; 77 pSDL_HasScreenKeyboardSupport SDL_HasScreenKeyboardSupport; 78 pSDL_IsScreenKeyboardShown SDL_IsScreenKeyboardShown; 79 } 80 }