comparison src/video/directfb/SDL_DirectFB_events.c @ 382:74bdcae44bf5

Date: Wed, 29 May 2002 17:37:19 +0200 From: Denis Oliver Kropp <dok@directfb.org> Subject: DirectFB 0.9.11 Hi, we had some API enhancements in keyboard handling. We support full unicode now and have support for keyboard mappings. I've attached a patch to have SDL compile with the upcoming (monday?) DirectFB 0.9.11.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 29 May 2002 20:47:19 +0000
parents f6ffac90895c
children 276d0d7ba96c
comparison
equal deleted inserted replaced
381:bc1401311390 382:74bdcae44bf5
98 98
99 /* Initialize the DirectFB key translation table */ 99 /* Initialize the DirectFB key translation table */
100 for (i=0; i<SDL_TABLESIZE(keymap); ++i) 100 for (i=0; i<SDL_TABLESIZE(keymap); ++i)
101 keymap[i] = SDLK_UNKNOWN; 101 keymap[i] = SDLK_UNKNOWN;
102 102
103 keymap[DIKC_A] = SDLK_a; 103 keymap[DIKI_A] = SDLK_a;
104 keymap[DIKC_B] = SDLK_b; 104 keymap[DIKI_B] = SDLK_b;
105 keymap[DIKC_C] = SDLK_c; 105 keymap[DIKI_C] = SDLK_c;
106 keymap[DIKC_D] = SDLK_d; 106 keymap[DIKI_D] = SDLK_d;
107 keymap[DIKC_E] = SDLK_e; 107 keymap[DIKI_E] = SDLK_e;
108 keymap[DIKC_F] = SDLK_f; 108 keymap[DIKI_F] = SDLK_f;
109 keymap[DIKC_G] = SDLK_g; 109 keymap[DIKI_G] = SDLK_g;
110 keymap[DIKC_H] = SDLK_h; 110 keymap[DIKI_H] = SDLK_h;
111 keymap[DIKC_I] = SDLK_i; 111 keymap[DIKI_I] = SDLK_i;
112 keymap[DIKC_J] = SDLK_j; 112 keymap[DIKI_J] = SDLK_j;
113 keymap[DIKC_K] = SDLK_k; 113 keymap[DIKI_K] = SDLK_k;
114 keymap[DIKC_L] = SDLK_l; 114 keymap[DIKI_L] = SDLK_l;
115 keymap[DIKC_M] = SDLK_m; 115 keymap[DIKI_M] = SDLK_m;
116 keymap[DIKC_N] = SDLK_n; 116 keymap[DIKI_N] = SDLK_n;
117 keymap[DIKC_O] = SDLK_o; 117 keymap[DIKI_O] = SDLK_o;
118 keymap[DIKC_P] = SDLK_p; 118 keymap[DIKI_P] = SDLK_p;
119 keymap[DIKC_Q] = SDLK_q; 119 keymap[DIKI_Q] = SDLK_q;
120 keymap[DIKC_R] = SDLK_r; 120 keymap[DIKI_R] = SDLK_r;
121 keymap[DIKC_S] = SDLK_s; 121 keymap[DIKI_S] = SDLK_s;
122 keymap[DIKC_T] = SDLK_t; 122 keymap[DIKI_T] = SDLK_t;
123 keymap[DIKC_U] = SDLK_u; 123 keymap[DIKI_U] = SDLK_u;
124 keymap[DIKC_V] = SDLK_v; 124 keymap[DIKI_V] = SDLK_v;
125 keymap[DIKC_W] = SDLK_w; 125 keymap[DIKI_W] = SDLK_w;
126 keymap[DIKC_X] = SDLK_x; 126 keymap[DIKI_X] = SDLK_x;
127 keymap[DIKC_Y] = SDLK_y; 127 keymap[DIKI_Y] = SDLK_y;
128 keymap[DIKC_Z] = SDLK_z; 128 keymap[DIKI_Z] = SDLK_z;
129 129
130 keymap[DIKC_0] = SDLK_0; 130 keymap[DIKI_0] = SDLK_0;
131 keymap[DIKC_1] = SDLK_1; 131 keymap[DIKI_1] = SDLK_1;
132 keymap[DIKC_2] = SDLK_2; 132 keymap[DIKI_2] = SDLK_2;
133 keymap[DIKC_3] = SDLK_3; 133 keymap[DIKI_3] = SDLK_3;
134 keymap[DIKC_4] = SDLK_4; 134 keymap[DIKI_4] = SDLK_4;
135 keymap[DIKC_5] = SDLK_5; 135 keymap[DIKI_5] = SDLK_5;
136 keymap[DIKC_6] = SDLK_6; 136 keymap[DIKI_6] = SDLK_6;
137 keymap[DIKC_7] = SDLK_7; 137 keymap[DIKI_7] = SDLK_7;
138 keymap[DIKC_8] = SDLK_8; 138 keymap[DIKI_8] = SDLK_8;
139 keymap[DIKC_9] = SDLK_9; 139 keymap[DIKI_9] = SDLK_9;
140 140
141 keymap[DIKC_F1] = SDLK_F1; 141 keymap[DIKI_F1] = SDLK_F1;
142 keymap[DIKC_F2] = SDLK_F2; 142 keymap[DIKI_F2] = SDLK_F2;
143 keymap[DIKC_F3] = SDLK_F3; 143 keymap[DIKI_F3] = SDLK_F3;
144 keymap[DIKC_F4] = SDLK_F4; 144 keymap[DIKI_F4] = SDLK_F4;
145 keymap[DIKC_F5] = SDLK_F5; 145 keymap[DIKI_F5] = SDLK_F5;
146 keymap[DIKC_F6] = SDLK_F6; 146 keymap[DIKI_F6] = SDLK_F6;
147 keymap[DIKC_F7] = SDLK_F7; 147 keymap[DIKI_F7] = SDLK_F7;
148 keymap[DIKC_F8] = SDLK_F8; 148 keymap[DIKI_F8] = SDLK_F8;
149 keymap[DIKC_F9] = SDLK_F9; 149 keymap[DIKI_F9] = SDLK_F9;
150 keymap[DIKC_F10] = SDLK_F10; 150 keymap[DIKI_F10] = SDLK_F10;
151 keymap[DIKC_F11] = SDLK_F11; 151 keymap[DIKI_F11] = SDLK_F11;
152 keymap[DIKC_F12] = SDLK_F12; 152 keymap[DIKI_F12] = SDLK_F12;
153 153
154 keymap[DIKC_ESCAPE] = SDLK_ESCAPE; 154 keymap[DIKI_ESCAPE] = SDLK_ESCAPE;
155 keymap[DIKC_LEFT] = SDLK_LEFT; 155 keymap[DIKI_LEFT] = SDLK_LEFT;
156 keymap[DIKC_RIGHT] = SDLK_RIGHT; 156 keymap[DIKI_RIGHT] = SDLK_RIGHT;
157 keymap[DIKC_UP] = SDLK_UP; 157 keymap[DIKI_UP] = SDLK_UP;
158 keymap[DIKC_DOWN] = SDLK_DOWN; 158 keymap[DIKI_DOWN] = SDLK_DOWN;
159 keymap[DIKC_CTRL] = SDLK_LCTRL; 159 keymap[DIKI_CTRL] = SDLK_LCTRL;
160 keymap[DIKC_SHIFT] = SDLK_LSHIFT; 160 keymap[DIKI_SHIFT] = SDLK_LSHIFT;
161 keymap[DIKC_ALT] = SDLK_LALT; 161 keymap[DIKI_ALT] = SDLK_LALT;
162 keymap[DIKC_ALTGR] = SDLK_RALT; 162 keymap[DIKI_ALTGR] = SDLK_RALT;
163 keymap[DIKC_TAB] = SDLK_TAB; 163 keymap[DIKI_TAB] = SDLK_TAB;
164 keymap[DIKC_ENTER] = SDLK_RETURN; 164 keymap[DIKI_ENTER] = SDLK_RETURN;
165 keymap[DIKC_SPACE] = SDLK_SPACE; 165 keymap[DIKI_SPACE] = SDLK_SPACE;
166 keymap[DIKC_BACKSPACE] = SDLK_BACKSPACE; 166 keymap[DIKI_BACKSPACE] = SDLK_BACKSPACE;
167 keymap[DIKC_INSERT] = SDLK_INSERT; 167 keymap[DIKI_INSERT] = SDLK_INSERT;
168 keymap[DIKC_DELETE] = SDLK_DELETE; 168 keymap[DIKI_DELETE] = SDLK_DELETE;
169 keymap[DIKC_HOME] = SDLK_HOME; 169 keymap[DIKI_HOME] = SDLK_HOME;
170 keymap[DIKC_END] = SDLK_END; 170 keymap[DIKI_END] = SDLK_END;
171 keymap[DIKC_PAGEUP] = SDLK_PAGEUP; 171 keymap[DIKI_PAGE_UP] = SDLK_PAGEUP;
172 keymap[DIKC_PAGEDOWN] = SDLK_PAGEDOWN; 172 keymap[DIKI_PAGE_DOWN] = SDLK_PAGEDOWN;
173 keymap[DIKC_CAPSLOCK] = SDLK_CAPSLOCK; 173 keymap[DIKI_CAPSLOCK] = SDLK_CAPSLOCK;
174 keymap[DIKC_NUMLOCK] = SDLK_NUMLOCK; 174 keymap[DIKI_NUMLOCK] = SDLK_NUMLOCK;
175 keymap[DIKC_SCRLOCK] = SDLK_SCROLLOCK; 175 keymap[DIKI_SCRLOCK] = SDLK_SCROLLOCK;
176 keymap[DIKC_PRINT] = SDLK_PRINT; 176 keymap[DIKI_PRINT] = SDLK_PRINT;
177 keymap[DIKC_PAUSE] = SDLK_PAUSE; 177 keymap[DIKI_PAUSE] = SDLK_PAUSE;
178 keymap[DIKC_KP_DIV] = SDLK_KP_DIVIDE; 178 keymap[DIKI_KP_DIV] = SDLK_KP_DIVIDE;
179 keymap[DIKC_KP_MULT] = SDLK_KP_MULTIPLY; 179 keymap[DIKI_KP_MULT] = SDLK_KP_MULTIPLY;
180 keymap[DIKC_KP_MINUS] = SDLK_KP_MINUS; 180 keymap[DIKI_KP_MINUS] = SDLK_KP_MINUS;
181 keymap[DIKC_KP_PLUS] = SDLK_KP_PLUS; 181 keymap[DIKI_KP_PLUS] = SDLK_KP_PLUS;
182 keymap[DIKC_KP_ENTER] = SDLK_KP_ENTER; 182 keymap[DIKI_KP_ENTER] = SDLK_KP_ENTER;
183
184 keymap[DIKC_OK] = SDLK_RETURN;
185 keymap[DIKC_CANCEL] = SDLK_BREAK;
186 keymap[DIKC_CLEAR] = SDLK_DELETE;
187 keymap[DIKC_POWER] = SDLK_POWER;
188 keymap[DIKC_POWER2] = SDLK_POWER;
189 keymap[DIKC_MENU] = SDLK_MENU;
190 keymap[DIKC_HELP] = SDLK_HELP;
191 keymap[DIKC_BACK] = SDLK_ESCAPE;
192 } 183 }
193 184
194 185
195 static SDL_keysym *DirectFB_TranslateKey (DFBInputEvent *ev, SDL_keysym *keysym) 186 static SDL_keysym *DirectFB_TranslateKey (DFBInputEvent *ev, SDL_keysym *keysym)
196 { 187 {
197 /* Set the keysym information */ 188 /* Set the keysym information */
198 keysym->scancode = ev->keycode; 189 keysym->scancode = ev->key_id;
199 keysym->mod = KMOD_NONE; 190 keysym->mod = KMOD_NONE; /* FIXME */
200 keysym->unicode = 0; 191 keysym->unicode = (DFB_KEY_TYPE (ev->key_symbol) == DIKT_UNICODE) ? ev->key_symbol : 0;
201 192
202 if (ev->key_ascii > 0 && ev->key_ascii < 128) 193 if (ev->key_symbol > 0 && ev->key_symbol < 128)
203 keysym->sym = ev->key_ascii; 194 keysym->sym = ev->key_symbol;
204 else 195 else
205 keysym->sym = keymap[ev->keycode]; 196 keysym->sym = keymap[ev->key_id];
206 197
207 return keysym; 198 return keysym;
208 } 199 }
209 200
210 static int DirectFB_TranslateButton (DFBInputEvent *ev) 201 static int DirectFB_TranslateButton (DFBInputEvent *ev)