only bring in as many sdl things as are strictly necessary
[tangerine.git] / arch / all-hosted / hidd / sdl / keymap.c
blob524afd9face555edb9a776456186300e881c3bc5
1 /*
2 * sdl.hidd - SDL graphics/sound/keyboard for AROS hosted
3 * Copyright (c) 2007 Robert Norris. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the same terms as AROS itself.
7 */
9 #include <exec/types.h>
11 #include <devices/rawkeycodes.h>
13 #include <aros/symbolsets.h>
15 #include "sdl_intern.h"
17 #include LC_LIBDEFS_FILE
19 #define DEBUG 0
20 #include <aros/debug.h>
22 struct keymap {
23 SDLKey sdl;
24 UBYTE aros;
27 /* the SDLK_* names are taken from SDL/SDL_keysym.h. I've only included the
28 * ones that actually have an equal in AROS. If you have a keyboard with a key
29 * that isn't covered here, find its SDL key name in SDL/SDL_keysym.h, choose
30 * an appropriate AROS key to map it to from devices/rawkeycodes.h, and add a
31 * row to the table. The SDL "checkkeys" test program can help you to choose a
32 * SDL key */
34 static const struct keymap keymap[] = {
35 { SDLK_BACKSPACE, RAWKEY_BACKSPACE },
36 { SDLK_TAB, RAWKEY_TAB },
37 { SDLK_RETURN, RAWKEY_RETURN },
38 { SDLK_PAUSE, RAWKEY_PAUSE },
39 { SDLK_ESCAPE, RAWKEY_ESCAPE },
40 { SDLK_SPACE, RAWKEY_SPACE },
41 { SDLK_COMMA, RAWKEY_COMMA },
42 { SDLK_MINUS, RAWKEY_MINUS },
43 { SDLK_PERIOD, RAWKEY_PERIOD },
44 { SDLK_SLASH, RAWKEY_SLASH },
45 { SDLK_0, RAWKEY_0 },
46 { SDLK_1, RAWKEY_1 },
47 { SDLK_2, RAWKEY_2 },
48 { SDLK_3, RAWKEY_3 },
49 { SDLK_4, RAWKEY_4 },
50 { SDLK_5, RAWKEY_5 },
51 { SDLK_6, RAWKEY_6 },
52 { SDLK_7, RAWKEY_7 },
53 { SDLK_8, RAWKEY_8 },
54 { SDLK_9, RAWKEY_9 },
55 { SDLK_SEMICOLON, RAWKEY_SEMICOLON },
56 { SDLK_EQUALS, RAWKEY_EQUAL },
57 { SDLK_BACKSLASH, RAWKEY_BACKSLASH },
58 { SDLK_BACKQUOTE, RAWKEY_TILDE },
59 { SDLK_a, RAWKEY_A },
60 { SDLK_b, RAWKEY_B },
61 { SDLK_c, RAWKEY_C },
62 { SDLK_d, RAWKEY_D },
63 { SDLK_e, RAWKEY_E },
64 { SDLK_f, RAWKEY_F },
65 { SDLK_g, RAWKEY_G },
66 { SDLK_h, RAWKEY_H },
67 { SDLK_i, RAWKEY_I },
68 { SDLK_j, RAWKEY_J },
69 { SDLK_k, RAWKEY_K },
70 { SDLK_l, RAWKEY_L },
71 { SDLK_m, RAWKEY_M },
72 { SDLK_n, RAWKEY_N },
73 { SDLK_o, RAWKEY_O },
74 { SDLK_p, RAWKEY_P },
75 { SDLK_q, RAWKEY_Q },
76 { SDLK_r, RAWKEY_R },
77 { SDLK_s, RAWKEY_S },
78 { SDLK_t, RAWKEY_T },
79 { SDLK_u, RAWKEY_U },
80 { SDLK_v, RAWKEY_V },
81 { SDLK_w, RAWKEY_W },
82 { SDLK_x, RAWKEY_X },
83 { SDLK_y, RAWKEY_Y },
84 { SDLK_z, RAWKEY_Z },
85 { SDLK_DELETE, RAWKEY_DELETE },
86 { SDLK_KP0, RAWKEY_KP_0 },
87 { SDLK_KP1, RAWKEY_KP_1 },
88 { SDLK_KP2, RAWKEY_KP_2 },
89 { SDLK_KP3, RAWKEY_KP_3 },
90 { SDLK_KP4, RAWKEY_KP_4 },
91 { SDLK_KP5, RAWKEY_KP_5 },
92 { SDLK_KP6, RAWKEY_KP_6 },
93 { SDLK_KP7, RAWKEY_KP_7 },
94 { SDLK_KP8, RAWKEY_KP_8 },
95 { SDLK_KP9, RAWKEY_KP_9 },
96 { SDLK_KP_PERIOD, RAWKEY_KP_DECIMAL},
97 { SDLK_KP_PLUS, RAWKEY_KP_PLUS },
98 { SDLK_KP_ENTER, RAWKEY_KP_ENTER },
99 { SDLK_UP, RAWKEY_UP },
100 { SDLK_DOWN, RAWKEY_DOWN },
101 { SDLK_RIGHT, RAWKEY_RIGHT },
102 { SDLK_LEFT, RAWKEY_LEFT },
103 { SDLK_INSERT, RAWKEY_INSERT },
104 { SDLK_HOME, RAWKEY_HOME },
105 { SDLK_END, RAWKEY_END },
106 { SDLK_PAGEUP, RAWKEY_PAGEUP },
107 { SDLK_PAGEDOWN, RAWKEY_PAGEDOWN },
108 { SDLK_F1, RAWKEY_F1 },
109 { SDLK_F2, RAWKEY_F2 },
110 { SDLK_F3, RAWKEY_F3 },
111 { SDLK_F4, RAWKEY_F4 },
112 { SDLK_F5, RAWKEY_F5 },
113 { SDLK_F6, RAWKEY_F6 },
114 { SDLK_F7, RAWKEY_F7 },
115 { SDLK_F8, RAWKEY_F8 },
116 { SDLK_F9, RAWKEY_F9 },
117 { SDLK_F10, RAWKEY_F10 },
118 { SDLK_F11, RAWKEY_F11 },
119 { SDLK_F12, RAWKEY_F12 },
120 { SDLK_CAPSLOCK, RAWKEY_CAPSLOCK },
121 { SDLK_RSHIFT, RAWKEY_RSHIFT },
122 { SDLK_LSHIFT, RAWKEY_LSHIFT },
123 { SDLK_RCTRL, RAWKEY_CONTROL },
124 { SDLK_LCTRL, RAWKEY_LCONTROL },
125 { SDLK_RALT, RAWKEY_RALT },
126 { SDLK_LALT, RAWKEY_LALT },
127 { SDLK_RMETA, RAWKEY_RAMIGA },
128 { SDLK_LMETA, RAWKEY_LAMIGA },
129 { SDLK_LSUPER, RAWKEY_LAMIGA },
130 { SDLK_RSUPER, RAWKEY_RAMIGA },
131 { SDLK_HELP, RAWKEY_HELP },
132 { 0xff, 0xff }
135 static int sdl_keymap_init(LIBBASETYPEPTR LIBBASE) {
136 int i;
137 struct keymap *pair;
139 D(bug("[sdl] sdl_keymap_init\n"));
141 for (i = 0; i < SDLK_LAST; i++)
142 LIBBASE->keycode[i] = 0xff;
144 for (pair = keymap; pair->sdl != 0xff && pair->aros != 0xff; pair++)
145 LIBBASE->keycode[pair->sdl] = pair->aros;
147 return TRUE;
150 ADD2INITLIB(sdl_keymap_init, 0)