]> git.proxmox.com Git - mirror_qemu.git/blame - sdl.c
Merge TCX and VGA pixel operations
[mirror_qemu.git] / sdl.c
CommitLineData
0f0b7264
FB
1/*
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 */
67b915a5 24#include "vl.h"
0f0b7264
FB
25
26#include <SDL.h>
27
67b915a5
FB
28#ifndef _WIN32
29#include <signal.h>
30#endif
0f0b7264
FB
31
32static SDL_Surface *screen;
33static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
8a7ddc38 34static int last_vm_running;
8e9c4afe
FB
35static int gui_saved_grab;
36static int gui_fullscreen;
43523e93 37static int gui_noframe;
8e9c4afe
FB
38static int gui_key_modifier_pressed;
39static int gui_keysym;
d63d307f 40static int gui_fullscreen_initial_grab;
32ff25bf
FB
41static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
42static uint8_t modifiers_state[256];
09b26c5e
FB
43static int width, height;
44static SDL_Cursor *sdl_cursor_normal;
45static SDL_Cursor *sdl_cursor_hidden;
46static int absolute_enabled = 0;
d34cab9f
TS
47static int guest_cursor = 0;
48static int guest_x, guest_y;
49static SDL_Cursor *guest_sprite = 0;
0f0b7264
FB
50
51static void sdl_update(DisplayState *ds, int x, int y, int w, int h)
52{
898712a8 53 // printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h);
0f0b7264
FB
54 SDL_UpdateRect(screen, x, y, w, h);
55}
56
57static void sdl_resize(DisplayState *ds, int w, int h)
58{
59 int flags;
60
61 // printf("resizing to %d %d\n", w, h);
62
63 flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
8e9c4afe
FB
64 if (gui_fullscreen)
65 flags |= SDL_FULLSCREEN;
43523e93
TS
66 if (gui_noframe)
67 flags |= SDL_NOFRAME;
9903da21 68
09b26c5e
FB
69 width = w;
70 height = h;
71
9903da21 72 again:
0f0b7264
FB
73 screen = SDL_SetVideoMode(w, h, 0, flags);
74 if (!screen) {
75 fprintf(stderr, "Could not open SDL display\n");
76 exit(1);
77 }
9903da21
FB
78 if (!screen->pixels && (flags & SDL_HWSURFACE) && (flags & SDL_FULLSCREEN)) {
79 flags &= ~SDL_HWSURFACE;
80 goto again;
81 }
82
83 if (!screen->pixels) {
84 fprintf(stderr, "Could not open SDL display\n");
85 exit(1);
86 }
0f0b7264
FB
87 ds->data = screen->pixels;
88 ds->linesize = screen->pitch;
89 ds->depth = screen->format->BitsPerPixel;
d3079cd2
FB
90 if (ds->depth == 32 && screen->format->Rshift == 0) {
91 ds->bgr = 1;
92 } else {
93 ds->bgr = 0;
94 }
457831f4
FB
95 ds->width = w;
96 ds->height = h;
0f0b7264
FB
97}
98
3d11d0eb 99/* generic keyboard conversion */
e58d12ed 100
3d11d0eb
FB
101#include "sdl_keysym.h"
102#include "keymaps.c"
103
104static kbd_layout_t *kbd_layout = NULL;
105
106static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev)
e58d12ed 107{
3d11d0eb
FB
108 int keysym;
109 /* workaround for X11+SDL bug with AltGR */
110 keysym = ev->keysym.sym;
111 if (keysym == 0 && ev->keysym.scancode == 113)
112 keysym = SDLK_MODE;
60659e3b
FB
113 /* For Japanese key '\' and '|' */
114 if (keysym == 92 && ev->keysym.scancode == 133) {
115 keysym = 0xa5;
116 }
3d11d0eb 117 return keysym2scancode(kbd_layout, keysym);
e58d12ed
FB
118}
119
3d11d0eb
FB
120/* specific keyboard conversions from scan codes */
121
122#if defined(_WIN32)
e58d12ed
FB
123
124static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
125{
126 return ev->keysym.scancode;
127}
128
129#else
130
e58d12ed
FB
131static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
132{
133 int keycode;
134
135 keycode = ev->keysym.scancode;
136
137 if (keycode < 9) {
138 keycode = 0;
139 } else if (keycode < 97) {
140 keycode -= 8; /* just an offset */
60659e3b 141 } else if (keycode < 212) {
e58d12ed 142 /* use conversion table */
6070dd07 143 keycode = _translate_keycode(keycode - 97);
e58d12ed
FB
144 } else {
145 keycode = 0;
146 }
147 return keycode;
148}
149
150#endif
151
32ff25bf
FB
152static void reset_keys(void)
153{
154 int i;
155 for(i = 0; i < 256; i++) {
156 if (modifiers_state[i]) {
157 if (i & 0x80)
158 kbd_put_keycode(0xe0);
159 kbd_put_keycode(i | 0x80);
160 modifiers_state[i] = 0;
161 }
162 }
163}
164
0f0b7264
FB
165static void sdl_process_key(SDL_KeyboardEvent *ev)
166{
32ff25bf 167 int keycode, v;
de2200d3
FB
168
169 if (ev->keysym.sym == SDLK_PAUSE) {
170 /* specific case */
171 v = 0;
172 if (ev->type == SDL_KEYUP)
173 v |= 0x80;
174 kbd_put_keycode(0xe1);
175 kbd_put_keycode(0x1d | v);
176 kbd_put_keycode(0x45 | v);
177 return;
178 }
179
3d11d0eb
FB
180 if (kbd_layout) {
181 keycode = sdl_keyevent_to_keycode_generic(ev);
182 } else {
183 keycode = sdl_keyevent_to_keycode(ev);
184 }
de2200d3
FB
185
186 switch(keycode) {
187 case 0x00:
188 /* sent when leaving window: reset the modifiers state */
32ff25bf 189 reset_keys();
de2200d3
FB
190 return;
191 case 0x2a: /* Left Shift */
192 case 0x36: /* Right Shift */
193 case 0x1d: /* Left CTRL */
194 case 0x9d: /* Right CTRL */
195 case 0x38: /* Left ALT */
196 case 0xb8: /* Right ALT */
0f0b7264 197 if (ev->type == SDL_KEYUP)
de2200d3
FB
198 modifiers_state[keycode] = 0;
199 else
200 modifiers_state[keycode] = 1;
201 break;
202 case 0x45: /* num lock */
203 case 0x3a: /* caps lock */
204 /* SDL does not send the key up event, so we generate it */
205 kbd_put_keycode(keycode);
206 kbd_put_keycode(keycode | 0x80);
207 return;
0f0b7264 208 }
de2200d3
FB
209
210 /* now send the key code */
211 if (keycode & 0x80)
212 kbd_put_keycode(0xe0);
213 if (ev->type == SDL_KEYUP)
214 kbd_put_keycode(keycode | 0x80);
215 else
216 kbd_put_keycode(keycode & 0x7f);
0f0b7264
FB
217}
218
8a7ddc38
FB
219static void sdl_update_caption(void)
220{
221 char buf[1024];
c35734b2
TS
222 const char *status = "";
223
224 if (!vm_running)
225 status = " [Stopped]";
226 else if (gui_grab)
227 status = " - Press Ctrl-Alt to exit grab";
228
229 if (qemu_name)
230 snprintf(buf, sizeof(buf), "QEMU (%s)%s", qemu_name, status);
231 else
232 snprintf(buf, sizeof(buf), "QEMU%s", status);
233
8a7ddc38
FB
234 SDL_WM_SetCaption(buf, "QEMU");
235}
236
09b26c5e
FB
237static void sdl_hide_cursor(void)
238{
9467cd46
AZ
239 if (!cursor_hide)
240 return;
241
8785a8dd
FB
242 if (kbd_mouse_is_absolute()) {
243 SDL_ShowCursor(1);
244 SDL_SetCursor(sdl_cursor_hidden);
245 } else {
246 SDL_ShowCursor(0);
247 }
09b26c5e
FB
248}
249
250static void sdl_show_cursor(void)
251{
9467cd46
AZ
252 if (!cursor_hide)
253 return;
254
09b26c5e 255 if (!kbd_mouse_is_absolute()) {
8785a8dd 256 SDL_ShowCursor(1);
d34cab9f
TS
257 if (guest_cursor &&
258 (gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
259 SDL_SetCursor(guest_sprite);
260 else
261 SDL_SetCursor(sdl_cursor_normal);
09b26c5e
FB
262 }
263}
264
0f0b7264
FB
265static void sdl_grab_start(void)
266{
d34cab9f
TS
267 if (guest_cursor) {
268 SDL_SetCursor(guest_sprite);
269 SDL_WarpMouse(guest_x, guest_y);
270 } else
271 sdl_hide_cursor();
0f0b7264
FB
272 SDL_WM_GrabInput(SDL_GRAB_ON);
273 /* dummy read to avoid moving the mouse */
274 SDL_GetRelativeMouseState(NULL, NULL);
275 gui_grab = 1;
8a7ddc38 276 sdl_update_caption();
0f0b7264
FB
277}
278
279static void sdl_grab_end(void)
280{
0f0b7264 281 SDL_WM_GrabInput(SDL_GRAB_OFF);
0f0b7264 282 gui_grab = 0;
d34cab9f 283 sdl_show_cursor();
8a7ddc38 284 sdl_update_caption();
0f0b7264
FB
285}
286
18a6d284 287static void sdl_send_mouse_event(int dz)
0f0b7264 288{
18a6d284 289 int dx, dy, state, buttons;
0f0b7264
FB
290 state = SDL_GetRelativeMouseState(&dx, &dy);
291 buttons = 0;
292 if (state & SDL_BUTTON(SDL_BUTTON_LEFT))
293 buttons |= MOUSE_EVENT_LBUTTON;
294 if (state & SDL_BUTTON(SDL_BUTTON_RIGHT))
295 buttons |= MOUSE_EVENT_RBUTTON;
296 if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE))
297 buttons |= MOUSE_EVENT_MBUTTON;
09b26c5e
FB
298
299 if (kbd_mouse_is_absolute()) {
300 if (!absolute_enabled) {
301 sdl_hide_cursor();
302 if (gui_grab) {
303 sdl_grab_end();
304 }
305 absolute_enabled = 1;
306 }
307
308 SDL_GetMouseState(&dx, &dy);
309 dx = dx * 0x7FFF / width;
310 dy = dy * 0x7FFF / height;
455204eb
TS
311 } else if (absolute_enabled) {
312 sdl_show_cursor();
313 absolute_enabled = 0;
d34cab9f
TS
314 } else if (guest_cursor) {
315 SDL_GetMouseState(&dx, &dy);
316 dx -= guest_x;
317 dy -= guest_y;
318 guest_x += dx;
319 guest_y += dy;
09b26c5e
FB
320 }
321
0f0b7264
FB
322 kbd_mouse_event(dx, dy, dz, buttons);
323}
324
8e9c4afe
FB
325static void toggle_full_screen(DisplayState *ds)
326{
327 gui_fullscreen = !gui_fullscreen;
328 sdl_resize(ds, screen->w, screen->h);
329 if (gui_fullscreen) {
330 gui_saved_grab = gui_grab;
331 sdl_grab_start();
332 } else {
333 if (!gui_saved_grab)
334 sdl_grab_end();
335 }
95219897
PB
336 vga_hw_invalidate();
337 vga_hw_update();
8e9c4afe
FB
338}
339
0f0b7264
FB
340static void sdl_refresh(DisplayState *ds)
341{
342 SDL_Event ev1, *ev = &ev1;
8e9c4afe
FB
343 int mod_state;
344
8a7ddc38
FB
345 if (last_vm_running != vm_running) {
346 last_vm_running = vm_running;
347 sdl_update_caption();
348 }
349
95219897 350 vga_hw_update();
457831f4 351
0f0b7264
FB
352 while (SDL_PollEvent(ev)) {
353 switch (ev->type) {
354 case SDL_VIDEOEXPOSE:
355 sdl_update(ds, 0, 0, screen->w, screen->h);
356 break;
357 case SDL_KEYDOWN:
358 case SDL_KEYUP:
359 if (ev->type == SDL_KEYDOWN) {
32ff25bf
FB
360 mod_state = (SDL_GetModState() & gui_grab_code) ==
361 gui_grab_code;
8e9c4afe 362 gui_key_modifier_pressed = mod_state;
457831f4 363 if (gui_key_modifier_pressed) {
32ff25bf
FB
364 int keycode;
365 keycode = sdl_keyevent_to_keycode(&ev->key);
366 switch(keycode) {
367 case 0x21: /* 'f' key on US keyboard */
457831f4
FB
368 toggle_full_screen(ds);
369 gui_keysym = 1;
370 break;
32ff25bf 371 case 0x02 ... 0x0a: /* '1' to '9' keys */
dfd92d3a
FB
372 /* Reset the modifiers sent to the current console */
373 reset_keys();
32ff25bf 374 console_select(keycode - 0x02);
95219897 375 if (!is_graphic_console()) {
457831f4
FB
376 /* display grab if going to a text console */
377 if (gui_grab)
378 sdl_grab_end();
379 }
380 gui_keysym = 1;
381 break;
382 default:
383 break;
384 }
95219897 385 } else if (!is_graphic_console()) {
457831f4
FB
386 int keysym;
387 keysym = 0;
388 if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
389 switch(ev->key.keysym.sym) {
390 case SDLK_UP: keysym = QEMU_KEY_CTRL_UP; break;
391 case SDLK_DOWN: keysym = QEMU_KEY_CTRL_DOWN; break;
392 case SDLK_LEFT: keysym = QEMU_KEY_CTRL_LEFT; break;
393 case SDLK_RIGHT: keysym = QEMU_KEY_CTRL_RIGHT; break;
394 case SDLK_HOME: keysym = QEMU_KEY_CTRL_HOME; break;
395 case SDLK_END: keysym = QEMU_KEY_CTRL_END; break;
396 case SDLK_PAGEUP: keysym = QEMU_KEY_CTRL_PAGEUP; break;
397 case SDLK_PAGEDOWN: keysym = QEMU_KEY_CTRL_PAGEDOWN; break;
398 default: break;
399 }
400 } else {
401 switch(ev->key.keysym.sym) {
402 case SDLK_UP: keysym = QEMU_KEY_UP; break;
403 case SDLK_DOWN: keysym = QEMU_KEY_DOWN; break;
404 case SDLK_LEFT: keysym = QEMU_KEY_LEFT; break;
405 case SDLK_RIGHT: keysym = QEMU_KEY_RIGHT; break;
406 case SDLK_HOME: keysym = QEMU_KEY_HOME; break;
407 case SDLK_END: keysym = QEMU_KEY_END; break;
408 case SDLK_PAGEUP: keysym = QEMU_KEY_PAGEUP; break;
409 case SDLK_PAGEDOWN: keysym = QEMU_KEY_PAGEDOWN; break;
e91c8a77
TS
410 case SDLK_BACKSPACE: keysym = QEMU_KEY_BACKSPACE; break;
411 case SDLK_DELETE: keysym = QEMU_KEY_DELETE; break;
457831f4
FB
412 default: break;
413 }
414 }
415 if (keysym) {
416 kbd_put_keysym(keysym);
417 } else if (ev->key.keysym.unicode != 0) {
418 kbd_put_keysym(ev->key.keysym.unicode);
419 }
8e9c4afe
FB
420 }
421 } else if (ev->type == SDL_KEYUP) {
bf2b84e4 422 mod_state = (ev->key.keysym.mod & gui_grab_code);
8e9c4afe
FB
423 if (!mod_state) {
424 if (gui_key_modifier_pressed) {
5b311878 425 gui_key_modifier_pressed = 0;
457831f4 426 if (gui_keysym == 0) {
32ff25bf 427 /* exit/enter grab if pressing Ctrl-Alt */
c66b0d4c
FB
428 if (!gui_grab) {
429 /* if the application is not active,
430 do not try to enter grab state. It
431 prevents
432 'SDL_WM_GrabInput(SDL_GRAB_ON)'
433 from blocking all the application
434 (SDL bug). */
435 if (SDL_GetAppState() & SDL_APPACTIVE)
436 sdl_grab_start();
437 } else {
8e9c4afe 438 sdl_grab_end();
c66b0d4c 439 }
32ff25bf
FB
440 /* SDL does not send back all the
441 modifiers key, so we must correct it */
442 reset_keys();
8e9c4afe
FB
443 break;
444 }
8e9c4afe
FB
445 gui_keysym = 0;
446 }
0f0b7264
FB
447 }
448 }
dfd92d3a 449 if (is_graphic_console() && !gui_keysym)
457831f4 450 sdl_process_key(&ev->key);
0f0b7264
FB
451 break;
452 case SDL_QUIT:
667accab
TS
453 if (!no_quit) {
454 qemu_system_shutdown_request();
455 }
0f0b7264
FB
456 break;
457 case SDL_MOUSEMOTION:
455204eb
TS
458 if (gui_grab || kbd_mouse_is_absolute() ||
459 absolute_enabled) {
18a6d284 460 sdl_send_mouse_event(0);
0f0b7264
FB
461 }
462 break;
463 case SDL_MOUSEBUTTONDOWN:
464 case SDL_MOUSEBUTTONUP:
465 {
466 SDL_MouseButtonEvent *bev = &ev->button;
09b26c5e 467 if (!gui_grab && !kbd_mouse_is_absolute()) {
0f0b7264
FB
468 if (ev->type == SDL_MOUSEBUTTONDOWN &&
469 (bev->state & SDL_BUTTON_LMASK)) {
470 /* start grabbing all events */
471 sdl_grab_start();
472 }
473 } else {
18a6d284
FB
474 int dz;
475 dz = 0;
476#ifdef SDL_BUTTON_WHEELUP
09b26c5e 477 if (bev->button == SDL_BUTTON_WHEELUP && ev->type == SDL_MOUSEBUTTONDOWN) {
18a6d284 478 dz = -1;
09b26c5e 479 } else if (bev->button == SDL_BUTTON_WHEELDOWN && ev->type == SDL_MOUSEBUTTONDOWN) {
18a6d284
FB
480 dz = 1;
481 }
482#endif
483 sdl_send_mouse_event(dz);
0f0b7264
FB
484 }
485 }
486 break;
0294ffb9 487 case SDL_ACTIVEEVENT:
5b311878
PB
488 if (gui_grab && ev->active.state == SDL_APPINPUTFOCUS &&
489 !ev->active.gain && !gui_fullscreen_initial_grab) {
0294ffb9
FB
490 sdl_grab_end();
491 }
492 break;
0f0b7264
FB
493 default:
494 break;
495 }
496 }
497}
498
d34cab9f
TS
499static void sdl_fill(DisplayState *ds, int x, int y, int w, int h, uint32_t c)
500{
501 SDL_Rect dst = { x, y, w, h };
502 SDL_FillRect(screen, &dst, c);
503}
504
505static void sdl_mouse_warp(int x, int y, int on)
506{
507 if (on) {
508 if (!guest_cursor)
509 sdl_show_cursor();
510 if (gui_grab || kbd_mouse_is_absolute() || absolute_enabled) {
511 SDL_SetCursor(guest_sprite);
512 SDL_WarpMouse(x, y);
513 }
514 } else if (gui_grab)
515 sdl_hide_cursor();
516 guest_cursor = on;
517 guest_x = x, guest_y = y;
518}
519
520static void sdl_mouse_define(int width, int height, int bpp,
521 int hot_x, int hot_y,
522 uint8_t *image, uint8_t *mask)
523{
524 uint8_t sprite[256], *line;
525 int x, y, dst, bypl, src = 0;
526 if (guest_sprite)
527 SDL_FreeCursor(guest_sprite);
528
529 memset(sprite, 0, 256);
530 bypl = ((width * bpp + 31) >> 5) << 2;
531 for (y = 0, dst = 0; y < height; y ++, image += bypl) {
532 line = image;
533 for (x = 0; x < width; x ++, dst ++) {
534 switch (bpp) {
535 case 24:
536 src = *(line ++); src |= *(line ++); src |= *(line ++);
537 break;
538 case 16:
539 case 15:
540 src = *(line ++); src |= *(line ++);
541 break;
542 case 8:
543 src = *(line ++);
544 break;
545 case 4:
546 src = 0xf & (line[x >> 1] >> ((x & 1)) << 2);
547 break;
548 case 2:
549 src = 3 & (line[x >> 2] >> ((x & 3)) << 1);
550 break;
551 case 1:
552 src = 1 & (line[x >> 3] >> (x & 7));
553 break;
554 }
555 if (!src)
556 sprite[dst >> 3] |= (1 << (~dst & 7)) & mask[dst >> 3];
557 }
558 }
559 guest_sprite = SDL_CreateCursor(sprite, mask, width, height, hot_x, hot_y);
560
561 if (guest_cursor &&
562 (gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
563 SDL_SetCursor(guest_sprite);
564}
565
898712a8
FB
566static void sdl_cleanup(void)
567{
d34cab9f
TS
568 if (guest_sprite)
569 SDL_FreeCursor(guest_sprite);
898712a8
FB
570 SDL_Quit();
571}
572
43523e93 573void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
0f0b7264
FB
574{
575 int flags;
09b26c5e 576 uint8_t data = 0;
0f0b7264 577
3d11d0eb
FB
578#if defined(__APPLE__)
579 /* always use generic keymaps */
580 if (!keyboard_layout)
581 keyboard_layout = "en-us";
582#endif
583 if(keyboard_layout) {
584 kbd_layout = init_keyboard_layout(keyboard_layout);
585 if (!kbd_layout)
586 exit(1);
587 }
588
43523e93
TS
589 if (no_frame)
590 gui_noframe = 1;
591
0f0b7264
FB
592 flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
593 if (SDL_Init (flags)) {
594 fprintf(stderr, "Could not initialize SDL - exiting\n");
595 exit(1);
596 }
67b915a5 597#ifndef _WIN32
0ae04d73
FB
598 /* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */
599 signal(SIGINT, SIG_DFL);
600 signal(SIGQUIT, SIG_DFL);
67b915a5 601#endif
0ae04d73 602
0f0b7264
FB
603 ds->dpy_update = sdl_update;
604 ds->dpy_resize = sdl_resize;
605 ds->dpy_refresh = sdl_refresh;
d34cab9f
TS
606 ds->dpy_fill = sdl_fill;
607 ds->mouse_set = sdl_mouse_warp;
608 ds->cursor_define = sdl_mouse_define;
0f0b7264
FB
609
610 sdl_resize(ds, 640, 400);
8a7ddc38 611 sdl_update_caption();
0f0b7264 612 SDL_EnableKeyRepeat(250, 50);
457831f4 613 SDL_EnableUNICODE(1);
0f0b7264 614 gui_grab = 0;
898712a8 615
09b26c5e
FB
616 sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0);
617 sdl_cursor_normal = SDL_GetCursor();
618
898712a8 619 atexit(sdl_cleanup);
d63d307f
FB
620 if (full_screen) {
621 gui_fullscreen = 1;
622 gui_fullscreen_initial_grab = 1;
623 sdl_grab_start();
624 }
0f0b7264 625}