aboutsummaryrefslogtreecommitdiffstats
path: root/src/sdl_keyboard.erl
blob: 325c7278404add86861c00349d125377b1c440db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
%% Copyright (c) 2015-2018, Loïc Hoguin <[email protected]>
%%
%% Permission to use, copy, modify, and/or distribute this software for any
%% purpose with or without fee is hereby granted, provided that the above
%% copyright notice and this permission notice appear in all copies.
%%
%% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
%% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
%% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
%% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
%% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

-module(sdl_keyboard).

-export([get_key_from_name/1]).
-export([get_key_from_scancode/1]).
-export([get_key_name/1]).
-export([get_mod_state/0]).
-export([get_scancode_from_key/1]).
-export([get_scancode_from_name/1]).
-export([get_scancode_name/1]).
-export([is_text_input_active/0]).
-export([set_mod_state/1]).
-export([start_text_input/0]).
-export([stop_text_input/0]).

-spec get_key_from_name(binary()) -> non_neg_integer() | undefined.
get_key_from_name(Name) ->
	esdl2:get_key_from_name(Name).

-spec get_key_from_scancode(non_neg_integer()) -> non_neg_integer() | undefined.
get_key_from_scancode(Scancode) ->
	esdl2:get_key_from_scancode(Scancode).

-spec get_key_name(non_neg_integer()) -> binary().
get_key_name(Key) ->
	esdl2:get_key_name(Key),
	receive {'_nif_thread_ret_', Ret} -> Ret end.

-spec get_mod_state() -> [sdl_keycode:keymod()].
get_mod_state() ->
	esdl2:get_mod_state(),
	receive {'_nif_thread_ret_', Ret} -> Ret end.

-spec get_scancode_from_key(non_neg_integer()) -> non_neg_integer() | undefined.
get_scancode_from_key(Key) ->
	esdl2:get_scancode_from_key(Key).

-spec get_scancode_from_name(binary()) -> non_neg_integer() | undefined.
get_scancode_from_name(Name) ->
	esdl2:get_scancode_from_name(Name).

-spec get_scancode_name(non_neg_integer()) -> binary().
get_scancode_name(Scancode) ->
	esdl2:get_scancode_name(Scancode).

-spec is_text_input_active() -> boolean().
is_text_input_active() ->
	esdl2:is_text_input_active(),
	receive {'_nif_thread_ret_', Ret} -> Ret end.

-spec set_mod_state([sdl_keycode:keymod()]) -> ok.
set_mod_state(Mod) ->
	esdl2:set_mod_state(Mod).

-spec start_text_input() -> ok.
start_text_input() ->
	esdl2:start_text_input().

-spec stop_text_input() -> ok.
stop_text_input() ->
	esdl2:stop_text_input().