1 /+
2 +            Copyright 2022 – 2024 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;
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 	FnBind[] ret = [
28 		{q{SDL_Window*}, q{SDL_GetKeyboardFocus}, q{}},
29 		{q{ubyte*}, q{SDL_GetKeyboardState}, q{int* numKeys}},
30 		{q{SDL_Keymod}, q{SDL_GetModState}, q{}},
31 		{q{void}, q{SDL_SetModState}, q{SDL_Keymod modState}},
32 		{q{SDL_KeyCode}, q{SDL_GetKeyFromScancode}, q{SDL_Scancode scancode}},
33 		{q{SDL_Scancode}, q{SDL_GetScancodeFromKey}, q{SDL_KeyCode key}},
34 		{q{const(char)*}, q{SDL_GetScancodeName}, q{SDL_Scancode scancode}},
35 		{q{SDL_Scancode}, q{SDL_GetScancodeFromName}, q{const(char)* name}},
36 		{q{const(char)*}, q{SDL_GetKeyName}, q{SDL_KeyCode key}},
37 		{q{SDL_KeyCode}, q{SDL_GetKeyFromName}, q{const(char)* name}},
38 		{q{void}, q{SDL_StartTextInput}, q{}},
39 		{q{SDL_bool}, q{SDL_IsTextInputActive}, q{}},
40 		{q{void}, q{SDL_StopTextInput}, q{}},
41 		{q{SDL_bool}, q{SDL_HasScreenKeyboardSupport}, q{}},
42 		{q{SDL_bool}, q{SDL_IsScreenKeyboardShown}, q{SDL_Window* window}},
43 	];
44 	if(sdlSupport >= SDLSupport.v2_0_22){
45 		FnBind[] add = [
46 			{q{void}, q{SDL_ClearComposition}, q{}},
47 			{q{SDL_bool}, q{SDL_IsTextInputShown}, q{}},
48 		];
49 		ret ~= add;
50 	}
51 	if(sdlSupport >= SDLSupport.v2_24){
52 		FnBind[] add = [
53 			{q{void}, q{SDL_SetTextInputRect}, q{const(SDL_Rect)* rect}},
54 			{q{void}, q{SDL_ResetKeyboard}, q{}},
55 		];
56 		ret ~= add;
57 	}else{
58 		FnBind[] add = [
59 			{q{void}, q{SDL_SetTextInputRect}, q{SDL_Rect* rect}}, //`rect` was non-const before 2.24
60 		];
61 		ret ~= add;
62 	}
63 	return ret;
64 }()));