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.
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
20 #include <aros/debug.h>
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
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
},
55 { SDLK_SEMICOLON
, RAWKEY_SEMICOLON
},
56 { SDLK_EQUALS
, RAWKEY_EQUAL
},
57 { SDLK_BACKSLASH
, RAWKEY_BACKSLASH
},
58 { SDLK_BACKQUOTE
, RAWKEY_TILDE
},
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
},
135 static int sdl_keymap_init(LIBBASETYPEPTR LIBBASE
) {
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
;
150 ADD2INITLIB(sdl_keymap_init
, 0)