1 2 // Copyright 2018 - 2021 Michael D. Parker 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.config; 10 import bindbc.sdl.bind.sdlkeycode : SDL_Keycode, SDL_Keymod; 11 import bindbc.sdl.bind.sdlrect : SDL_Rect; 12 import bindbc.sdl.bind.sdlscancode : SDL_Scancode; 13 import bindbc.sdl.bind.sdlstdinc : SDL_bool; 14 import bindbc.sdl.bind.sdlvideo : SDL_Window; 15 16 struct SDL_Keysym { 17 SDL_Scancode scancode; 18 SDL_Keycode sym; 19 ushort mod; 20 uint unused; 21 } 22 23 static if(staticBinding) { 24 extern(C) @nogc nothrow { 25 SDL_Window* SDL_GetKeyboardFocus(); 26 ubyte* SDL_GetKeyboardState(int* numkeys); 27 SDL_Keymod SDL_GetModState(); 28 void SDL_SetModState(SDL_Keymod modstate); 29 SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode); 30 SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key); 31 const(char)* SDL_GetScancodeName(SDL_Scancode scancode); 32 SDL_Scancode SDL_GetScancodeFromName(const(char)* name); 33 const(char)* SDL_GetKeyName(SDL_Keycode key); 34 SDL_Keycode SDL_GetKeyFromName(const(char)* name); 35 void SDL_StartTextInput(); 36 SDL_bool SDL_IsTextInputActive(); 37 void SDL_StopTextInput(); 38 void SDL_SetTextInputRect(SDL_Rect*); 39 SDL_bool SDL_HasScreenKeyboardSupport(); 40 SDL_bool SDL_IsScreenKeyboardShown(SDL_Window* window); 41 } 42 } 43 else { 44 extern(C) @nogc nothrow { 45 alias pSDL_GetKeyboardFocus = SDL_Window* function(); 46 alias pSDL_GetKeyboardState = ubyte* function(int* numkeys); 47 alias pSDL_GetModState = SDL_Keymod function(); 48 alias pSDL_SetModState = void function(SDL_Keymod modstate); 49 alias pSDL_GetKeyFromScancode = SDL_Keycode function(SDL_Scancode scancode); 50 alias pSDL_GetScancodeFromKey = SDL_Scancode function(SDL_Keycode key); 51 alias pSDL_GetScancodeName = const(char)* function(SDL_Scancode scancode); 52 alias pSDL_GetScancodeFromName = SDL_Scancode function(const(char)* name); 53 alias pSDL_GetKeyName = const(char)* function(SDL_Keycode key); 54 alias pSDL_GetKeyFromName = SDL_Keycode function(const(char)* name); 55 alias pSDL_StartTextInput = void function(); 56 alias pSDL_IsTextInputActive = SDL_bool function(); 57 alias pSDL_StopTextInput = void function(); 58 alias pSDL_SetTextInputRect = void function(SDL_Rect*); 59 alias pSDL_HasScreenKeyboardSupport = SDL_bool function(); 60 alias pSDL_IsScreenKeyboardShown = SDL_bool function(SDL_Window* window); 61 } 62 63 __gshared { 64 pSDL_GetKeyboardFocus SDL_GetKeyboardFocus; 65 pSDL_GetKeyboardState SDL_GetKeyboardState; 66 pSDL_GetModState SDL_GetModState; 67 pSDL_SetModState SDL_SetModState; 68 pSDL_GetKeyFromScancode SDL_GetKeyFromScancode; 69 pSDL_GetScancodeFromKey SDL_GetScancodeFromKey; 70 pSDL_GetScancodeName SDL_GetScancodeName; 71 pSDL_GetScancodeFromName SDL_GetScancodeFromName; 72 pSDL_GetKeyName SDL_GetKeyName; 73 pSDL_GetKeyFromName SDL_GetKeyFromName; 74 pSDL_StartTextInput SDL_StartTextInput; 75 pSDL_IsTextInputActive SDL_IsTextInputActive; 76 pSDL_StopTextInput SDL_StopTextInput; 77 pSDL_SetTextInputRect SDL_SetTextInputRect; 78 pSDL_HasScreenKeyboardSupport SDL_HasScreenKeyboardSupport; 79 pSDL_IsScreenKeyboardShown SDL_IsScreenKeyboardShown; 80 } 81 }