1 /*  RetroArch - A frontend for libretro.
2  *  Copyright (C) 2010-2014 - Hans-Kristian Arntzen
3  *  Copyright (C) 2011-2017 - Daniel De Matteis
4  *
5  *  RetroArch is free software: you can redistribute it and/or modify it under the terms
6  *  of the GNU General Public License as published by the Free Software Found-
7  *  ation, either version 3 of the License, or (at your option) any later version.
8  *
9  *  RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  *  PURPOSE.  See the GNU General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License along with RetroArch.
14  *  If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef INPUT_KEYMAPS_H__
18 #define INPUT_KEYMAPS_H__
19 
20 #include <stdint.h>
21 
22 #include <retro_common_api.h>
23 #include <libretro.h>
24 
25 RETRO_BEGIN_DECLS
26 
27 struct rarch_key_map
28 {
29    unsigned sym;
30    enum retro_key rk;
31 };
32 
33 struct input_key_map
34 {
35    const char *str;
36    enum retro_key key;
37 };
38 
39 #define RARCH_KEY_MAP_RWEBINPUT_SIZE 111
40 
41 extern const struct input_key_map input_config_key_map[];
42 
43 extern const struct rarch_key_map rarch_key_map_x11[];
44 extern const struct rarch_key_map rarch_key_map_sdl[];
45 extern const struct rarch_key_map rarch_key_map_sdl2[];
46 extern const struct rarch_key_map rarch_key_map_dinput[];
47 
48  /* is generated at runtime so can't be const */
49 extern struct rarch_key_map rarch_key_map_rwebinput[RARCH_KEY_MAP_RWEBINPUT_SIZE];
50 
51 extern const struct rarch_key_map rarch_key_map_linux[];
52 extern const struct rarch_key_map rarch_key_map_apple_hid[];
53 extern const struct rarch_key_map rarch_key_map_android[];
54 extern const struct rarch_key_map rarch_key_map_qnx[];
55 extern const struct rarch_key_map rarch_key_map_dos[];
56 extern const struct rarch_key_map rarch_key_map_wiiu[];
57 extern const struct rarch_key_map rarch_key_map_winraw[];
58 #ifdef HAVE_LIBNX
59 extern const struct rarch_key_map rarch_key_map_switch[];
60 #endif
61 #ifdef VITA
62 extern const struct rarch_key_map rarch_key_map_vita[];
63 #endif
64 
65 /**
66  * input_keymaps_init_keyboard_lut:
67  * @map                   : Keyboard map.
68  *
69  * Initializes and sets the keyboard layout to a keyboard map (@map).
70  **/
71 void input_keymaps_init_keyboard_lut(const struct rarch_key_map *map);
72 
73 /**
74  * input_keymaps_translate_keysym_to_rk:
75  * @sym                   : Key symbol.
76  *
77  * Translates a key symbol from the keyboard layout table
78  * to an associated retro key identifier.
79  *
80  * Returns: Retro key identifier.
81  **/
82 enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym);
83 
84 /**
85  * input_keymaps_translate_rk_to_str:
86  * @key                   : Retro key identifier.
87  * @buf                   : Buffer.
88  * @size                  : Size of @buf.
89  *
90  * Translates a retro key identifier to a human-readable
91  * identifier string.
92  **/
93 void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size);
94 
95 extern enum retro_key rarch_keysym_lut[RETROK_LAST];
96 
97 RETRO_END_DECLS
98 
99 #endif
100