blob: d43da8831763f4dc29a567120d11dad488155d9f [file] [log] [blame]
bellard0f0b7262003-08-09 18:26:36 +00001/*
2 * QEMU SDL display driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
bellard67b915a2004-03-31 23:37:16 +000024#include "vl.h"
bellard0f0b7262003-08-09 18:26:36 +000025
26#include <SDL.h>
27
bellard67b915a2004-03-31 23:37:16 +000028#ifndef _WIN32
29#include <signal.h>
30#endif
bellard0f0b7262003-08-09 18:26:36 +000031
32static SDL_Surface *screen;
33static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
bellard8a7ddc32004-03-31 19:00:16 +000034static int last_vm_running;
bellard8e9c4af2004-04-28 19:33:40 +000035static int gui_saved_grab;
36static int gui_fullscreen;
37static int gui_key_modifier_pressed;
38static int gui_keysym;
bellardd63d3072004-10-03 13:29:03 +000039static int gui_fullscreen_initial_grab;
bellard32ff25b2004-10-03 14:33:54 +000040static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
41static uint8_t modifiers_state[256];
bellard0f0b7262003-08-09 18:26:36 +000042
43static void sdl_update(DisplayState *ds, int x, int y, int w, int h)
44{
bellard898712a2004-02-06 19:56:42 +000045 // printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h);
bellard0f0b7262003-08-09 18:26:36 +000046 SDL_UpdateRect(screen, x, y, w, h);
47}
48
49static void sdl_resize(DisplayState *ds, int w, int h)
50{
51 int flags;
52
53 // printf("resizing to %d %d\n", w, h);
54
55 flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
bellard8e9c4af2004-04-28 19:33:40 +000056 if (gui_fullscreen)
57 flags |= SDL_FULLSCREEN;
bellard0f0b7262003-08-09 18:26:36 +000058 screen = SDL_SetVideoMode(w, h, 0, flags);
59 if (!screen) {
60 fprintf(stderr, "Could not open SDL display\n");
61 exit(1);
62 }
63 ds->data = screen->pixels;
64 ds->linesize = screen->pitch;
65 ds->depth = screen->format->BitsPerPixel;
bellard457831f2004-07-14 17:22:33 +000066 ds->width = w;
67 ds->height = h;
bellard0f0b7262003-08-09 18:26:36 +000068}
69
bellard3d11d0e2004-12-12 16:56:30 +000070/* generic keyboard conversion */
bellarde58d12e2004-07-05 22:13:07 +000071
bellard3d11d0e2004-12-12 16:56:30 +000072#include "sdl_keysym.h"
73#include "keymaps.c"
bellarde58d12e2004-07-05 22:13:07 +000074
bellard3d11d0e2004-12-12 16:56:30 +000075static kbd_layout_t *kbd_layout = NULL;
bellarde58d12e2004-07-05 22:13:07 +000076
bellard3d11d0e2004-12-12 16:56:30 +000077static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev)
bellarde58d12e2004-07-05 22:13:07 +000078{
bellard3d11d0e2004-12-12 16:56:30 +000079 int keysym;
80 /* workaround for X11+SDL bug with AltGR */
81 keysym = ev->keysym.sym;
82 if (keysym == 0 && ev->keysym.scancode == 113)
83 keysym = SDLK_MODE;
84 return keysym2scancode(kbd_layout, keysym);
bellarde58d12e2004-07-05 22:13:07 +000085}
86
bellard3d11d0e2004-12-12 16:56:30 +000087/* specific keyboard conversions from scan codes */
88
89#if defined(_WIN32)
bellarde58d12e2004-07-05 22:13:07 +000090
91static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
92{
93 return ev->keysym.scancode;
94}
95
96#else
97
bellardde2200d2004-06-04 13:15:06 +000098static const uint8_t x_keycode_to_pc_keycode[61] = {
99 0xc7, /* 97 Home */
100 0xc8, /* 98 Up */
101 0xc9, /* 99 PgUp */
102 0xcb, /* 100 Left */
bellard0f0b7262003-08-09 18:26:36 +0000103 0x4c, /* 101 KP-5 */
bellardde2200d2004-06-04 13:15:06 +0000104 0xcd, /* 102 Right */
105 0xcf, /* 103 End */
106 0xd0, /* 104 Down */
107 0xd1, /* 105 PgDn */
108 0xd2, /* 106 Ins */
109 0xd3, /* 107 Del */
110 0x9c, /* 108 Enter */
111 0x9d, /* 109 Ctrl-R */
bellard22a56b82004-06-05 08:32:36 +0000112 0x0, /* 110 Pause */
bellardde2200d2004-06-04 13:15:06 +0000113 0xb7, /* 111 Print */
114 0xb5, /* 112 Divide */
115 0xb8, /* 113 Alt-R */
116 0xc6, /* 114 Break */
bellard0f0b7262003-08-09 18:26:36 +0000117 0x0, /* 115 */
118 0x0, /* 116 */
119 0x0, /* 117 */
120 0x0, /* 118 */
121 0x0, /* 119 */
bellardb71e95f2004-05-20 13:08:06 +0000122 0x70, /* 120 Hiragana_Katakana */
bellard0f0b7262003-08-09 18:26:36 +0000123 0x0, /* 121 */
124 0x0, /* 122 */
bellardb71e95f2004-05-20 13:08:06 +0000125 0x73, /* 123 backslash */
bellard0f0b7262003-08-09 18:26:36 +0000126 0x0, /* 124 */
127 0x0, /* 125 */
128 0x0, /* 126 */
129 0x0, /* 127 */
130 0x0, /* 128 */
bellardb71e95f2004-05-20 13:08:06 +0000131 0x79, /* 129 Henkan */
bellard0f0b7262003-08-09 18:26:36 +0000132 0x0, /* 130 */
bellardb71e95f2004-05-20 13:08:06 +0000133 0x7b, /* 131 Muhenkan */
bellard0f0b7262003-08-09 18:26:36 +0000134 0x0, /* 132 */
bellardb71e95f2004-05-20 13:08:06 +0000135 0x7d, /* 133 Yen */
bellard0f0b7262003-08-09 18:26:36 +0000136 0x0, /* 134 */
137 0x0, /* 135 */
138 0x47, /* 136 KP_7 */
139 0x48, /* 137 KP_8 */
140 0x49, /* 138 KP_9 */
141 0x4b, /* 139 KP_4 */
142 0x4c, /* 140 KP_5 */
143 0x4d, /* 141 KP_6 */
144 0x4f, /* 142 KP_1 */
145 0x50, /* 143 KP_2 */
146 0x51, /* 144 KP_3 */
147 0x52, /* 145 KP_0 */
148 0x53, /* 146 KP_. */
149 0x47, /* 147 KP_HOME */
150 0x48, /* 148 KP_UP */
151 0x49, /* 149 KP_PgUp */
152 0x4b, /* 150 KP_Left */
153 0x4c, /* 151 KP_ */
154 0x4d, /* 152 KP_Right */
155 0x4f, /* 153 KP_End */
156 0x50, /* 154 KP_Down */
157 0x51, /* 155 KP_PgDn */
158 0x52, /* 156 KP_Ins */
159 0x53, /* 157 KP_Del */
160};
161
bellarde58d12e2004-07-05 22:13:07 +0000162static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
163{
164 int keycode;
165
166 keycode = ev->keysym.scancode;
167
168 if (keycode < 9) {
169 keycode = 0;
170 } else if (keycode < 97) {
171 keycode -= 8; /* just an offset */
172 } else if (keycode < 158) {
173 /* use conversion table */
174 keycode = x_keycode_to_pc_keycode[keycode - 97];
175 } else {
176 keycode = 0;
177 }
178 return keycode;
179}
180
181#endif
182
bellard32ff25b2004-10-03 14:33:54 +0000183static void reset_keys(void)
184{
185 int i;
186 for(i = 0; i < 256; i++) {
187 if (modifiers_state[i]) {
188 if (i & 0x80)
189 kbd_put_keycode(0xe0);
190 kbd_put_keycode(i | 0x80);
191 modifiers_state[i] = 0;
192 }
193 }
194}
195
bellard0f0b7262003-08-09 18:26:36 +0000196static void sdl_process_key(SDL_KeyboardEvent *ev)
197{
bellard32ff25b2004-10-03 14:33:54 +0000198 int keycode, v;
bellardde2200d2004-06-04 13:15:06 +0000199
200 if (ev->keysym.sym == SDLK_PAUSE) {
201 /* specific case */
202 v = 0;
203 if (ev->type == SDL_KEYUP)
204 v |= 0x80;
205 kbd_put_keycode(0xe1);
206 kbd_put_keycode(0x1d | v);
207 kbd_put_keycode(0x45 | v);
208 return;
209 }
210
bellard3d11d0e2004-12-12 16:56:30 +0000211 if (kbd_layout) {
212 keycode = sdl_keyevent_to_keycode_generic(ev);
213 } else {
214 keycode = sdl_keyevent_to_keycode(ev);
215 }
bellardde2200d2004-06-04 13:15:06 +0000216
217 switch(keycode) {
218 case 0x00:
219 /* sent when leaving window: reset the modifiers state */
bellard32ff25b2004-10-03 14:33:54 +0000220 reset_keys();
bellardde2200d2004-06-04 13:15:06 +0000221 return;
222 case 0x2a: /* Left Shift */
223 case 0x36: /* Right Shift */
224 case 0x1d: /* Left CTRL */
225 case 0x9d: /* Right CTRL */
226 case 0x38: /* Left ALT */
227 case 0xb8: /* Right ALT */
bellard0f0b7262003-08-09 18:26:36 +0000228 if (ev->type == SDL_KEYUP)
bellardde2200d2004-06-04 13:15:06 +0000229 modifiers_state[keycode] = 0;
230 else
231 modifiers_state[keycode] = 1;
232 break;
233 case 0x45: /* num lock */
234 case 0x3a: /* caps lock */
235 /* SDL does not send the key up event, so we generate it */
236 kbd_put_keycode(keycode);
237 kbd_put_keycode(keycode | 0x80);
238 return;
bellard0f0b7262003-08-09 18:26:36 +0000239 }
bellardde2200d2004-06-04 13:15:06 +0000240
241 /* now send the key code */
242 if (keycode & 0x80)
243 kbd_put_keycode(0xe0);
244 if (ev->type == SDL_KEYUP)
245 kbd_put_keycode(keycode | 0x80);
246 else
247 kbd_put_keycode(keycode & 0x7f);
bellard0f0b7262003-08-09 18:26:36 +0000248}
249
bellard8a7ddc32004-03-31 19:00:16 +0000250static void sdl_update_caption(void)
251{
252 char buf[1024];
253 strcpy(buf, "QEMU");
254 if (!vm_running) {
255 strcat(buf, " [Stopped]");
256 }
257 if (gui_grab) {
bellard32ff25b2004-10-03 14:33:54 +0000258 strcat(buf, " - Press Ctrl-Alt to exit grab");
bellard8a7ddc32004-03-31 19:00:16 +0000259 }
260 SDL_WM_SetCaption(buf, "QEMU");
261}
262
bellard0f0b7262003-08-09 18:26:36 +0000263static void sdl_grab_start(void)
264{
bellard0f0b7262003-08-09 18:26:36 +0000265 SDL_ShowCursor(0);
266 SDL_WM_GrabInput(SDL_GRAB_ON);
267 /* dummy read to avoid moving the mouse */
268 SDL_GetRelativeMouseState(NULL, NULL);
269 gui_grab = 1;
bellard8a7ddc32004-03-31 19:00:16 +0000270 sdl_update_caption();
bellard0f0b7262003-08-09 18:26:36 +0000271}
272
273static void sdl_grab_end(void)
274{
bellard0f0b7262003-08-09 18:26:36 +0000275 SDL_WM_GrabInput(SDL_GRAB_OFF);
276 SDL_ShowCursor(1);
277 gui_grab = 0;
bellard8a7ddc32004-03-31 19:00:16 +0000278 sdl_update_caption();
bellard0f0b7262003-08-09 18:26:36 +0000279}
280
bellard18a6d282005-01-17 22:32:23 +0000281static void sdl_send_mouse_event(int dz)
bellard0f0b7262003-08-09 18:26:36 +0000282{
bellard18a6d282005-01-17 22:32:23 +0000283 int dx, dy, state, buttons;
bellard0f0b7262003-08-09 18:26:36 +0000284 state = SDL_GetRelativeMouseState(&dx, &dy);
285 buttons = 0;
286 if (state & SDL_BUTTON(SDL_BUTTON_LEFT))
287 buttons |= MOUSE_EVENT_LBUTTON;
288 if (state & SDL_BUTTON(SDL_BUTTON_RIGHT))
289 buttons |= MOUSE_EVENT_RBUTTON;
290 if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE))
291 buttons |= MOUSE_EVENT_MBUTTON;
bellard0f0b7262003-08-09 18:26:36 +0000292 kbd_mouse_event(dx, dy, dz, buttons);
293}
294
bellard8e9c4af2004-04-28 19:33:40 +0000295static void toggle_full_screen(DisplayState *ds)
296{
297 gui_fullscreen = !gui_fullscreen;
298 sdl_resize(ds, screen->w, screen->h);
299 if (gui_fullscreen) {
300 gui_saved_grab = gui_grab;
301 sdl_grab_start();
302 } else {
303 if (!gui_saved_grab)
304 sdl_grab_end();
305 }
bellardee38b4c2004-06-08 00:56:42 +0000306 vga_invalidate_display();
bellard8e9c4af2004-04-28 19:33:40 +0000307 vga_update_display();
bellard8e9c4af2004-04-28 19:33:40 +0000308}
309
bellard0f0b7262003-08-09 18:26:36 +0000310static void sdl_refresh(DisplayState *ds)
311{
312 SDL_Event ev1, *ev = &ev1;
bellard8e9c4af2004-04-28 19:33:40 +0000313 int mod_state;
314
bellard8a7ddc32004-03-31 19:00:16 +0000315 if (last_vm_running != vm_running) {
316 last_vm_running = vm_running;
317 sdl_update_caption();
318 }
319
bellard457831f2004-07-14 17:22:33 +0000320 if (is_active_console(vga_console))
321 vga_update_display();
322
bellard0f0b7262003-08-09 18:26:36 +0000323 while (SDL_PollEvent(ev)) {
324 switch (ev->type) {
325 case SDL_VIDEOEXPOSE:
326 sdl_update(ds, 0, 0, screen->w, screen->h);
327 break;
328 case SDL_KEYDOWN:
329 case SDL_KEYUP:
330 if (ev->type == SDL_KEYDOWN) {
bellard32ff25b2004-10-03 14:33:54 +0000331 mod_state = (SDL_GetModState() & gui_grab_code) ==
332 gui_grab_code;
bellard8e9c4af2004-04-28 19:33:40 +0000333 gui_key_modifier_pressed = mod_state;
bellard457831f2004-07-14 17:22:33 +0000334 if (gui_key_modifier_pressed) {
bellard32ff25b2004-10-03 14:33:54 +0000335 int keycode;
336 keycode = sdl_keyevent_to_keycode(&ev->key);
337 switch(keycode) {
338 case 0x21: /* 'f' key on US keyboard */
bellard457831f2004-07-14 17:22:33 +0000339 toggle_full_screen(ds);
340 gui_keysym = 1;
341 break;
bellard32ff25b2004-10-03 14:33:54 +0000342 case 0x02 ... 0x0a: /* '1' to '9' keys */
343 console_select(keycode - 0x02);
bellard457831f2004-07-14 17:22:33 +0000344 if (is_active_console(vga_console)) {
345 /* tell the vga console to redisplay itself */
346 vga_invalidate_display();
347 } else {
348 /* display grab if going to a text console */
349 if (gui_grab)
350 sdl_grab_end();
351 }
352 gui_keysym = 1;
353 break;
354 default:
355 break;
356 }
bellard32ff25b2004-10-03 14:33:54 +0000357 } else if (!is_active_console(vga_console)) {
bellard457831f2004-07-14 17:22:33 +0000358 int keysym;
359 keysym = 0;
360 if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
361 switch(ev->key.keysym.sym) {
362 case SDLK_UP: keysym = QEMU_KEY_CTRL_UP; break;
363 case SDLK_DOWN: keysym = QEMU_KEY_CTRL_DOWN; break;
364 case SDLK_LEFT: keysym = QEMU_KEY_CTRL_LEFT; break;
365 case SDLK_RIGHT: keysym = QEMU_KEY_CTRL_RIGHT; break;
366 case SDLK_HOME: keysym = QEMU_KEY_CTRL_HOME; break;
367 case SDLK_END: keysym = QEMU_KEY_CTRL_END; break;
368 case SDLK_PAGEUP: keysym = QEMU_KEY_CTRL_PAGEUP; break;
369 case SDLK_PAGEDOWN: keysym = QEMU_KEY_CTRL_PAGEDOWN; break;
370 default: break;
371 }
372 } else {
373 switch(ev->key.keysym.sym) {
374 case SDLK_UP: keysym = QEMU_KEY_UP; break;
375 case SDLK_DOWN: keysym = QEMU_KEY_DOWN; break;
376 case SDLK_LEFT: keysym = QEMU_KEY_LEFT; break;
377 case SDLK_RIGHT: keysym = QEMU_KEY_RIGHT; break;
378 case SDLK_HOME: keysym = QEMU_KEY_HOME; break;
379 case SDLK_END: keysym = QEMU_KEY_END; break;
380 case SDLK_PAGEUP: keysym = QEMU_KEY_PAGEUP; break;
381 case SDLK_PAGEDOWN: keysym = QEMU_KEY_PAGEDOWN; break;
382 case SDLK_BACKSPACE: keysym = QEMU_KEY_BACKSPACE; break; case SDLK_DELETE: keysym = QEMU_KEY_DELETE; break;
383 default: break;
384 }
385 }
386 if (keysym) {
387 kbd_put_keysym(keysym);
388 } else if (ev->key.keysym.unicode != 0) {
389 kbd_put_keysym(ev->key.keysym.unicode);
390 }
bellard8e9c4af2004-04-28 19:33:40 +0000391 }
392 } else if (ev->type == SDL_KEYUP) {
bellardbf2b84e2004-11-14 19:46:35 +0000393 mod_state = (ev->key.keysym.mod & gui_grab_code);
bellard8e9c4af2004-04-28 19:33:40 +0000394 if (!mod_state) {
395 if (gui_key_modifier_pressed) {
bellard457831f2004-07-14 17:22:33 +0000396 if (gui_keysym == 0) {
bellard32ff25b2004-10-03 14:33:54 +0000397 /* exit/enter grab if pressing Ctrl-Alt */
bellard8e9c4af2004-04-28 19:33:40 +0000398 if (!gui_grab)
399 sdl_grab_start();
400 else
401 sdl_grab_end();
bellard32ff25b2004-10-03 14:33:54 +0000402 /* SDL does not send back all the
403 modifiers key, so we must correct it */
404 reset_keys();
bellard8e9c4af2004-04-28 19:33:40 +0000405 break;
406 }
407 gui_key_modifier_pressed = 0;
408 gui_keysym = 0;
409 }
bellard0f0b7262003-08-09 18:26:36 +0000410 }
411 }
bellard457831f2004-07-14 17:22:33 +0000412 if (is_active_console(vga_console))
413 sdl_process_key(&ev->key);
bellard0f0b7262003-08-09 18:26:36 +0000414 break;
415 case SDL_QUIT:
bellard979a54f2004-06-20 12:36:04 +0000416 qemu_system_shutdown_request();
bellard0f0b7262003-08-09 18:26:36 +0000417 break;
418 case SDL_MOUSEMOTION:
419 if (gui_grab) {
bellard18a6d282005-01-17 22:32:23 +0000420 sdl_send_mouse_event(0);
bellard0f0b7262003-08-09 18:26:36 +0000421 }
422 break;
423 case SDL_MOUSEBUTTONDOWN:
424 case SDL_MOUSEBUTTONUP:
425 {
426 SDL_MouseButtonEvent *bev = &ev->button;
427 if (!gui_grab) {
428 if (ev->type == SDL_MOUSEBUTTONDOWN &&
429 (bev->state & SDL_BUTTON_LMASK)) {
430 /* start grabbing all events */
431 sdl_grab_start();
432 }
433 } else {
bellard18a6d282005-01-17 22:32:23 +0000434 int dz;
435 dz = 0;
436#ifdef SDL_BUTTON_WHEELUP
437 if (bev->button == SDL_BUTTON_WHEELUP) {
438 dz = -1;
439 } else if (bev->button == SDL_BUTTON_WHEELDOWN) {
440 dz = 1;
441 }
442#endif
443 sdl_send_mouse_event(dz);
bellard0f0b7262003-08-09 18:26:36 +0000444 }
445 }
446 break;
bellard0294ffb2004-04-29 22:15:15 +0000447 case SDL_ACTIVEEVENT:
bellardd63d3072004-10-03 13:29:03 +0000448 if (gui_grab && (ev->active.gain & SDL_ACTIVEEVENTMASK) == 0 &&
449 !gui_fullscreen_initial_grab) {
bellard0294ffb2004-04-29 22:15:15 +0000450 sdl_grab_end();
451 }
452 break;
bellard0f0b7262003-08-09 18:26:36 +0000453 default:
454 break;
455 }
456 }
457}
458
bellard898712a2004-02-06 19:56:42 +0000459static void sdl_cleanup(void)
460{
461 SDL_Quit();
462}
463
bellardd63d3072004-10-03 13:29:03 +0000464void sdl_display_init(DisplayState *ds, int full_screen)
bellard0f0b7262003-08-09 18:26:36 +0000465{
466 int flags;
467
bellard3d11d0e2004-12-12 16:56:30 +0000468#if defined(__APPLE__)
469 /* always use generic keymaps */
470 if (!keyboard_layout)
471 keyboard_layout = "en-us";
472#endif
473 if(keyboard_layout) {
474 kbd_layout = init_keyboard_layout(keyboard_layout);
475 if (!kbd_layout)
476 exit(1);
477 }
478
bellard0f0b7262003-08-09 18:26:36 +0000479 flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
480 if (SDL_Init (flags)) {
481 fprintf(stderr, "Could not initialize SDL - exiting\n");
482 exit(1);
483 }
bellard67b915a2004-03-31 23:37:16 +0000484#ifndef _WIN32
bellard0ae04d72003-09-30 21:09:16 +0000485 /* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */
486 signal(SIGINT, SIG_DFL);
487 signal(SIGQUIT, SIG_DFL);
bellard67b915a2004-03-31 23:37:16 +0000488#endif
bellard0ae04d72003-09-30 21:09:16 +0000489
bellard0f0b7262003-08-09 18:26:36 +0000490 ds->dpy_update = sdl_update;
491 ds->dpy_resize = sdl_resize;
492 ds->dpy_refresh = sdl_refresh;
493
494 sdl_resize(ds, 640, 400);
bellard8a7ddc32004-03-31 19:00:16 +0000495 sdl_update_caption();
bellard0f0b7262003-08-09 18:26:36 +0000496 SDL_EnableKeyRepeat(250, 50);
bellard457831f2004-07-14 17:22:33 +0000497 SDL_EnableUNICODE(1);
bellard0f0b7262003-08-09 18:26:36 +0000498 gui_grab = 0;
bellard898712a2004-02-06 19:56:42 +0000499
500 atexit(sdl_cleanup);
bellardd63d3072004-10-03 13:29:03 +0000501 if (full_screen) {
502 gui_fullscreen = 1;
503 gui_fullscreen_initial_grab = 1;
504 sdl_grab_start();
505 }
bellard0f0b7262003-08-09 18:26:36 +0000506}