1 /+ 2 + Copyright 2022 – 2023 Aya Partridge 3 + Copyright 2018 - 2022 Michael D. Parker 4 + Distributed under the Boost Software License, Version 1.0. 5 + (See accompanying file LICENSE_1_0.txt or copy at 6 + http://www.boost.org/LICENSE_1_0.txt) 7 +/ 8 module sdl.keyboard; 9 10 import bindbc.sdl.config; 11 import bindbc.sdl.codegen; 12 13 import sdl.keycode: SDL_KeyCode, SDL_Keymod; 14 import sdl.rect: SDL_Rect; 15 import sdl.scancode: SDL_Scancode; 16 import sdl.stdinc: SDL_bool; 17 import sdl.video: SDL_Window; 18 19 struct SDL_Keysym{ 20 SDL_Scancode scancode; 21 SDL_KeyCode sym; 22 ushort mod; 23 uint unused; 24 } 25 26 mixin(joinFnBinds((){ 27 string[][] ret; 28 ret ~= makeFnBinds([ 29 [q{SDL_Window*}, q{SDL_GetKeyboardFocus}, q{}], 30 [q{ubyte*}, q{SDL_GetKeyboardState}, q{int* numkeys}], 31 [q{SDL_Keymod}, q{SDL_GetModState}, q{}], 32 [q{void}, q{SDL_SetModState}, q{SDL_Keymod modstate}], 33 [q{SDL_KeyCode}, q{SDL_GetKeyFromScancode}, q{SDL_Scancode scancode}], 34 [q{SDL_Scancode}, q{SDL_GetScancodeFromKey}, q{SDL_KeyCode key}], 35 [q{const(char)*}, q{SDL_GetScancodeName}, q{SDL_Scancode scancode}], 36 [q{SDL_Scancode}, q{SDL_GetScancodeFromName}, q{const(char)* name}], 37 [q{const(char)*}, q{SDL_GetKeyName}, q{SDL_KeyCode key}], 38 [q{SDL_KeyCode}, q{SDL_GetKeyFromName}, q{const(char)* name}], 39 [q{void}, q{SDL_StartTextInput}, q{}], 40 [q{SDL_bool}, q{SDL_IsTextInputActive}, q{}], 41 [q{void}, q{SDL_StopTextInput}, q{}], 42 [q{SDL_bool}, q{SDL_HasScreenKeyboardSupport}, q{}], 43 [q{SDL_bool}, q{SDL_IsScreenKeyboardShown}, q{SDL_Window* window}], 44 ]); 45 static if(sdlSupport >= SDLSupport.v2_0_22){ 46 ret ~= makeFnBinds([ 47 [q{void}, q{SDL_ClearComposition}, q{}], 48 [q{SDL_bool}, q{SDL_IsTextInputShown}, q{}], 49 ]); 50 } 51 static if(sdlSupport >= SDLSupport.v2_24){ 52 ret ~= makeFnBinds([ 53 [q{void}, q{SDL_SetTextInputRect}, q{const(SDL_Rect)* rect}], 54 [q{void}, q{SDL_ResetKeyboard}, q{}], 55 ]); 56 }else{ 57 ret ~= makeFnBinds([ 58 [q{void}, q{SDL_SetTextInputRect}, q{SDL_Rect* rect}], //`rect` was non-const before 2.24 59 ]); 60 } 61 return ret; 62 }()));