]>
Commit | Line | Data |
---|---|---|
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 | |
32 | static SDL_Surface *screen; | |
33 | static int gui_grab; /* if true, all keyboard/mouse events are grabbed */ | |
8a7ddc38 | 34 | static int last_vm_running; |
8e9c4afe FB |
35 | static int gui_saved_grab; |
36 | static int gui_fullscreen; | |
37 | static int gui_key_modifier_pressed; | |
38 | static int gui_keysym; | |
d63d307f | 39 | static int gui_fullscreen_initial_grab; |
32ff25bf FB |
40 | static int gui_grab_code = KMOD_LALT | KMOD_LCTRL; |
41 | static uint8_t modifiers_state[256]; | |
0f0b7264 FB |
42 | |
43 | static void sdl_update(DisplayState *ds, int x, int y, int w, int h) | |
44 | { | |
898712a8 | 45 | // printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h); |
0f0b7264 FB |
46 | SDL_UpdateRect(screen, x, y, w, h); |
47 | } | |
48 | ||
49 | static 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; | |
8e9c4afe FB |
56 | if (gui_fullscreen) |
57 | flags |= SDL_FULLSCREEN; | |
9903da21 FB |
58 | |
59 | again: | |
0f0b7264 FB |
60 | screen = SDL_SetVideoMode(w, h, 0, flags); |
61 | if (!screen) { | |
62 | fprintf(stderr, "Could not open SDL display\n"); | |
63 | exit(1); | |
64 | } | |
9903da21 FB |
65 | if (!screen->pixels && (flags & SDL_HWSURFACE) && (flags & SDL_FULLSCREEN)) { |
66 | flags &= ~SDL_HWSURFACE; | |
67 | goto again; | |
68 | } | |
69 | ||
70 | if (!screen->pixels) { | |
71 | fprintf(stderr, "Could not open SDL display\n"); | |
72 | exit(1); | |
73 | } | |
0f0b7264 FB |
74 | ds->data = screen->pixels; |
75 | ds->linesize = screen->pitch; | |
76 | ds->depth = screen->format->BitsPerPixel; | |
457831f4 FB |
77 | ds->width = w; |
78 | ds->height = h; | |
0f0b7264 FB |
79 | } |
80 | ||
3d11d0eb | 81 | /* generic keyboard conversion */ |
e58d12ed | 82 | |
3d11d0eb FB |
83 | #include "sdl_keysym.h" |
84 | #include "keymaps.c" | |
85 | ||
86 | static kbd_layout_t *kbd_layout = NULL; | |
87 | ||
88 | static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev) | |
e58d12ed | 89 | { |
3d11d0eb FB |
90 | int keysym; |
91 | /* workaround for X11+SDL bug with AltGR */ | |
92 | keysym = ev->keysym.sym; | |
93 | if (keysym == 0 && ev->keysym.scancode == 113) | |
94 | keysym = SDLK_MODE; | |
95 | return keysym2scancode(kbd_layout, keysym); | |
e58d12ed FB |
96 | } |
97 | ||
3d11d0eb FB |
98 | /* specific keyboard conversions from scan codes */ |
99 | ||
100 | #if defined(_WIN32) | |
e58d12ed FB |
101 | |
102 | static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev) | |
103 | { | |
104 | return ev->keysym.scancode; | |
105 | } | |
106 | ||
107 | #else | |
108 | ||
de2200d3 FB |
109 | static const uint8_t x_keycode_to_pc_keycode[61] = { |
110 | 0xc7, /* 97 Home */ | |
111 | 0xc8, /* 98 Up */ | |
112 | 0xc9, /* 99 PgUp */ | |
113 | 0xcb, /* 100 Left */ | |
0f0b7264 | 114 | 0x4c, /* 101 KP-5 */ |
de2200d3 FB |
115 | 0xcd, /* 102 Right */ |
116 | 0xcf, /* 103 End */ | |
117 | 0xd0, /* 104 Down */ | |
118 | 0xd1, /* 105 PgDn */ | |
119 | 0xd2, /* 106 Ins */ | |
120 | 0xd3, /* 107 Del */ | |
121 | 0x9c, /* 108 Enter */ | |
122 | 0x9d, /* 109 Ctrl-R */ | |
22a56b8a | 123 | 0x0, /* 110 Pause */ |
de2200d3 FB |
124 | 0xb7, /* 111 Print */ |
125 | 0xb5, /* 112 Divide */ | |
126 | 0xb8, /* 113 Alt-R */ | |
127 | 0xc6, /* 114 Break */ | |
0f0b7264 FB |
128 | 0x0, /* 115 */ |
129 | 0x0, /* 116 */ | |
130 | 0x0, /* 117 */ | |
131 | 0x0, /* 118 */ | |
132 | 0x0, /* 119 */ | |
b71e95fc | 133 | 0x70, /* 120 Hiragana_Katakana */ |
0f0b7264 FB |
134 | 0x0, /* 121 */ |
135 | 0x0, /* 122 */ | |
b71e95fc | 136 | 0x73, /* 123 backslash */ |
0f0b7264 FB |
137 | 0x0, /* 124 */ |
138 | 0x0, /* 125 */ | |
139 | 0x0, /* 126 */ | |
140 | 0x0, /* 127 */ | |
141 | 0x0, /* 128 */ | |
b71e95fc | 142 | 0x79, /* 129 Henkan */ |
0f0b7264 | 143 | 0x0, /* 130 */ |
b71e95fc | 144 | 0x7b, /* 131 Muhenkan */ |
0f0b7264 | 145 | 0x0, /* 132 */ |
b71e95fc | 146 | 0x7d, /* 133 Yen */ |
0f0b7264 FB |
147 | 0x0, /* 134 */ |
148 | 0x0, /* 135 */ | |
149 | 0x47, /* 136 KP_7 */ | |
150 | 0x48, /* 137 KP_8 */ | |
151 | 0x49, /* 138 KP_9 */ | |
152 | 0x4b, /* 139 KP_4 */ | |
153 | 0x4c, /* 140 KP_5 */ | |
154 | 0x4d, /* 141 KP_6 */ | |
155 | 0x4f, /* 142 KP_1 */ | |
156 | 0x50, /* 143 KP_2 */ | |
157 | 0x51, /* 144 KP_3 */ | |
158 | 0x52, /* 145 KP_0 */ | |
159 | 0x53, /* 146 KP_. */ | |
160 | 0x47, /* 147 KP_HOME */ | |
161 | 0x48, /* 148 KP_UP */ | |
162 | 0x49, /* 149 KP_PgUp */ | |
163 | 0x4b, /* 150 KP_Left */ | |
164 | 0x4c, /* 151 KP_ */ | |
165 | 0x4d, /* 152 KP_Right */ | |
166 | 0x4f, /* 153 KP_End */ | |
167 | 0x50, /* 154 KP_Down */ | |
168 | 0x51, /* 155 KP_PgDn */ | |
169 | 0x52, /* 156 KP_Ins */ | |
170 | 0x53, /* 157 KP_Del */ | |
171 | }; | |
172 | ||
e58d12ed FB |
173 | static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev) |
174 | { | |
175 | int keycode; | |
176 | ||
177 | keycode = ev->keysym.scancode; | |
178 | ||
179 | if (keycode < 9) { | |
180 | keycode = 0; | |
181 | } else if (keycode < 97) { | |
182 | keycode -= 8; /* just an offset */ | |
183 | } else if (keycode < 158) { | |
184 | /* use conversion table */ | |
185 | keycode = x_keycode_to_pc_keycode[keycode - 97]; | |
186 | } else { | |
187 | keycode = 0; | |
188 | } | |
189 | return keycode; | |
190 | } | |
191 | ||
192 | #endif | |
193 | ||
32ff25bf FB |
194 | static void reset_keys(void) |
195 | { | |
196 | int i; | |
197 | for(i = 0; i < 256; i++) { | |
198 | if (modifiers_state[i]) { | |
199 | if (i & 0x80) | |
200 | kbd_put_keycode(0xe0); | |
201 | kbd_put_keycode(i | 0x80); | |
202 | modifiers_state[i] = 0; | |
203 | } | |
204 | } | |
205 | } | |
206 | ||
0f0b7264 FB |
207 | static void sdl_process_key(SDL_KeyboardEvent *ev) |
208 | { | |
32ff25bf | 209 | int keycode, v; |
de2200d3 FB |
210 | |
211 | if (ev->keysym.sym == SDLK_PAUSE) { | |
212 | /* specific case */ | |
213 | v = 0; | |
214 | if (ev->type == SDL_KEYUP) | |
215 | v |= 0x80; | |
216 | kbd_put_keycode(0xe1); | |
217 | kbd_put_keycode(0x1d | v); | |
218 | kbd_put_keycode(0x45 | v); | |
219 | return; | |
220 | } | |
221 | ||
3d11d0eb FB |
222 | if (kbd_layout) { |
223 | keycode = sdl_keyevent_to_keycode_generic(ev); | |
224 | } else { | |
225 | keycode = sdl_keyevent_to_keycode(ev); | |
226 | } | |
de2200d3 FB |
227 | |
228 | switch(keycode) { | |
229 | case 0x00: | |
230 | /* sent when leaving window: reset the modifiers state */ | |
32ff25bf | 231 | reset_keys(); |
de2200d3 FB |
232 | return; |
233 | case 0x2a: /* Left Shift */ | |
234 | case 0x36: /* Right Shift */ | |
235 | case 0x1d: /* Left CTRL */ | |
236 | case 0x9d: /* Right CTRL */ | |
237 | case 0x38: /* Left ALT */ | |
238 | case 0xb8: /* Right ALT */ | |
0f0b7264 | 239 | if (ev->type == SDL_KEYUP) |
de2200d3 FB |
240 | modifiers_state[keycode] = 0; |
241 | else | |
242 | modifiers_state[keycode] = 1; | |
243 | break; | |
244 | case 0x45: /* num lock */ | |
245 | case 0x3a: /* caps lock */ | |
246 | /* SDL does not send the key up event, so we generate it */ | |
247 | kbd_put_keycode(keycode); | |
248 | kbd_put_keycode(keycode | 0x80); | |
249 | return; | |
0f0b7264 | 250 | } |
de2200d3 FB |
251 | |
252 | /* now send the key code */ | |
253 | if (keycode & 0x80) | |
254 | kbd_put_keycode(0xe0); | |
255 | if (ev->type == SDL_KEYUP) | |
256 | kbd_put_keycode(keycode | 0x80); | |
257 | else | |
258 | kbd_put_keycode(keycode & 0x7f); | |
0f0b7264 FB |
259 | } |
260 | ||
8a7ddc38 FB |
261 | static void sdl_update_caption(void) |
262 | { | |
263 | char buf[1024]; | |
264 | strcpy(buf, "QEMU"); | |
265 | if (!vm_running) { | |
266 | strcat(buf, " [Stopped]"); | |
267 | } | |
268 | if (gui_grab) { | |
32ff25bf | 269 | strcat(buf, " - Press Ctrl-Alt to exit grab"); |
8a7ddc38 FB |
270 | } |
271 | SDL_WM_SetCaption(buf, "QEMU"); | |
272 | } | |
273 | ||
0f0b7264 FB |
274 | static void sdl_grab_start(void) |
275 | { | |
0f0b7264 FB |
276 | SDL_ShowCursor(0); |
277 | SDL_WM_GrabInput(SDL_GRAB_ON); | |
278 | /* dummy read to avoid moving the mouse */ | |
279 | SDL_GetRelativeMouseState(NULL, NULL); | |
280 | gui_grab = 1; | |
8a7ddc38 | 281 | sdl_update_caption(); |
0f0b7264 FB |
282 | } |
283 | ||
284 | static void sdl_grab_end(void) | |
285 | { | |
0f0b7264 FB |
286 | SDL_WM_GrabInput(SDL_GRAB_OFF); |
287 | SDL_ShowCursor(1); | |
288 | gui_grab = 0; | |
8a7ddc38 | 289 | sdl_update_caption(); |
0f0b7264 FB |
290 | } |
291 | ||
18a6d284 | 292 | static void sdl_send_mouse_event(int dz) |
0f0b7264 | 293 | { |
18a6d284 | 294 | int dx, dy, state, buttons; |
0f0b7264 FB |
295 | state = SDL_GetRelativeMouseState(&dx, &dy); |
296 | buttons = 0; | |
297 | if (state & SDL_BUTTON(SDL_BUTTON_LEFT)) | |
298 | buttons |= MOUSE_EVENT_LBUTTON; | |
299 | if (state & SDL_BUTTON(SDL_BUTTON_RIGHT)) | |
300 | buttons |= MOUSE_EVENT_RBUTTON; | |
301 | if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) | |
302 | buttons |= MOUSE_EVENT_MBUTTON; | |
0f0b7264 FB |
303 | kbd_mouse_event(dx, dy, dz, buttons); |
304 | } | |
305 | ||
8e9c4afe FB |
306 | static void toggle_full_screen(DisplayState *ds) |
307 | { | |
308 | gui_fullscreen = !gui_fullscreen; | |
309 | sdl_resize(ds, screen->w, screen->h); | |
310 | if (gui_fullscreen) { | |
311 | gui_saved_grab = gui_grab; | |
312 | sdl_grab_start(); | |
313 | } else { | |
314 | if (!gui_saved_grab) | |
315 | sdl_grab_end(); | |
316 | } | |
ee38b4c8 | 317 | vga_invalidate_display(); |
8e9c4afe | 318 | vga_update_display(); |
8e9c4afe FB |
319 | } |
320 | ||
0f0b7264 FB |
321 | static void sdl_refresh(DisplayState *ds) |
322 | { | |
323 | SDL_Event ev1, *ev = &ev1; | |
8e9c4afe FB |
324 | int mod_state; |
325 | ||
8a7ddc38 FB |
326 | if (last_vm_running != vm_running) { |
327 | last_vm_running = vm_running; | |
328 | sdl_update_caption(); | |
329 | } | |
330 | ||
457831f4 FB |
331 | if (is_active_console(vga_console)) |
332 | vga_update_display(); | |
333 | ||
0f0b7264 FB |
334 | while (SDL_PollEvent(ev)) { |
335 | switch (ev->type) { | |
336 | case SDL_VIDEOEXPOSE: | |
337 | sdl_update(ds, 0, 0, screen->w, screen->h); | |
338 | break; | |
339 | case SDL_KEYDOWN: | |
340 | case SDL_KEYUP: | |
341 | if (ev->type == SDL_KEYDOWN) { | |
32ff25bf FB |
342 | mod_state = (SDL_GetModState() & gui_grab_code) == |
343 | gui_grab_code; | |
8e9c4afe | 344 | gui_key_modifier_pressed = mod_state; |
457831f4 | 345 | if (gui_key_modifier_pressed) { |
32ff25bf FB |
346 | int keycode; |
347 | keycode = sdl_keyevent_to_keycode(&ev->key); | |
348 | switch(keycode) { | |
349 | case 0x21: /* 'f' key on US keyboard */ | |
457831f4 FB |
350 | toggle_full_screen(ds); |
351 | gui_keysym = 1; | |
352 | break; | |
32ff25bf FB |
353 | case 0x02 ... 0x0a: /* '1' to '9' keys */ |
354 | console_select(keycode - 0x02); | |
457831f4 FB |
355 | if (is_active_console(vga_console)) { |
356 | /* tell the vga console to redisplay itself */ | |
357 | vga_invalidate_display(); | |
358 | } else { | |
359 | /* display grab if going to a text console */ | |
360 | if (gui_grab) | |
361 | sdl_grab_end(); | |
362 | } | |
363 | gui_keysym = 1; | |
364 | break; | |
365 | default: | |
366 | break; | |
367 | } | |
32ff25bf | 368 | } else if (!is_active_console(vga_console)) { |
457831f4 FB |
369 | int keysym; |
370 | keysym = 0; | |
371 | if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) { | |
372 | switch(ev->key.keysym.sym) { | |
373 | case SDLK_UP: keysym = QEMU_KEY_CTRL_UP; break; | |
374 | case SDLK_DOWN: keysym = QEMU_KEY_CTRL_DOWN; break; | |
375 | case SDLK_LEFT: keysym = QEMU_KEY_CTRL_LEFT; break; | |
376 | case SDLK_RIGHT: keysym = QEMU_KEY_CTRL_RIGHT; break; | |
377 | case SDLK_HOME: keysym = QEMU_KEY_CTRL_HOME; break; | |
378 | case SDLK_END: keysym = QEMU_KEY_CTRL_END; break; | |
379 | case SDLK_PAGEUP: keysym = QEMU_KEY_CTRL_PAGEUP; break; | |
380 | case SDLK_PAGEDOWN: keysym = QEMU_KEY_CTRL_PAGEDOWN; break; | |
381 | default: break; | |
382 | } | |
383 | } else { | |
384 | switch(ev->key.keysym.sym) { | |
385 | case SDLK_UP: keysym = QEMU_KEY_UP; break; | |
386 | case SDLK_DOWN: keysym = QEMU_KEY_DOWN; break; | |
387 | case SDLK_LEFT: keysym = QEMU_KEY_LEFT; break; | |
388 | case SDLK_RIGHT: keysym = QEMU_KEY_RIGHT; break; | |
389 | case SDLK_HOME: keysym = QEMU_KEY_HOME; break; | |
390 | case SDLK_END: keysym = QEMU_KEY_END; break; | |
391 | case SDLK_PAGEUP: keysym = QEMU_KEY_PAGEUP; break; | |
392 | case SDLK_PAGEDOWN: keysym = QEMU_KEY_PAGEDOWN; break; | |
393 | case SDLK_BACKSPACE: keysym = QEMU_KEY_BACKSPACE; break; case SDLK_DELETE: keysym = QEMU_KEY_DELETE; break; | |
394 | default: break; | |
395 | } | |
396 | } | |
397 | if (keysym) { | |
398 | kbd_put_keysym(keysym); | |
399 | } else if (ev->key.keysym.unicode != 0) { | |
400 | kbd_put_keysym(ev->key.keysym.unicode); | |
401 | } | |
8e9c4afe FB |
402 | } |
403 | } else if (ev->type == SDL_KEYUP) { | |
bf2b84e4 | 404 | mod_state = (ev->key.keysym.mod & gui_grab_code); |
8e9c4afe FB |
405 | if (!mod_state) { |
406 | if (gui_key_modifier_pressed) { | |
457831f4 | 407 | if (gui_keysym == 0) { |
32ff25bf | 408 | /* exit/enter grab if pressing Ctrl-Alt */ |
8e9c4afe FB |
409 | if (!gui_grab) |
410 | sdl_grab_start(); | |
411 | else | |
412 | sdl_grab_end(); | |
32ff25bf FB |
413 | /* SDL does not send back all the |
414 | modifiers key, so we must correct it */ | |
415 | reset_keys(); | |
8e9c4afe FB |
416 | break; |
417 | } | |
418 | gui_key_modifier_pressed = 0; | |
419 | gui_keysym = 0; | |
420 | } | |
0f0b7264 FB |
421 | } |
422 | } | |
457831f4 FB |
423 | if (is_active_console(vga_console)) |
424 | sdl_process_key(&ev->key); | |
0f0b7264 FB |
425 | break; |
426 | case SDL_QUIT: | |
979a54fb | 427 | qemu_system_shutdown_request(); |
0f0b7264 FB |
428 | break; |
429 | case SDL_MOUSEMOTION: | |
430 | if (gui_grab) { | |
18a6d284 | 431 | sdl_send_mouse_event(0); |
0f0b7264 FB |
432 | } |
433 | break; | |
434 | case SDL_MOUSEBUTTONDOWN: | |
435 | case SDL_MOUSEBUTTONUP: | |
436 | { | |
437 | SDL_MouseButtonEvent *bev = &ev->button; | |
438 | if (!gui_grab) { | |
439 | if (ev->type == SDL_MOUSEBUTTONDOWN && | |
440 | (bev->state & SDL_BUTTON_LMASK)) { | |
441 | /* start grabbing all events */ | |
442 | sdl_grab_start(); | |
443 | } | |
444 | } else { | |
18a6d284 FB |
445 | int dz; |
446 | dz = 0; | |
447 | #ifdef SDL_BUTTON_WHEELUP | |
448 | if (bev->button == SDL_BUTTON_WHEELUP) { | |
449 | dz = -1; | |
450 | } else if (bev->button == SDL_BUTTON_WHEELDOWN) { | |
451 | dz = 1; | |
452 | } | |
453 | #endif | |
454 | sdl_send_mouse_event(dz); | |
0f0b7264 FB |
455 | } |
456 | } | |
457 | break; | |
0294ffb9 | 458 | case SDL_ACTIVEEVENT: |
d63d307f FB |
459 | if (gui_grab && (ev->active.gain & SDL_ACTIVEEVENTMASK) == 0 && |
460 | !gui_fullscreen_initial_grab) { | |
0294ffb9 FB |
461 | sdl_grab_end(); |
462 | } | |
463 | break; | |
0f0b7264 FB |
464 | default: |
465 | break; | |
466 | } | |
467 | } | |
468 | } | |
469 | ||
898712a8 FB |
470 | static void sdl_cleanup(void) |
471 | { | |
472 | SDL_Quit(); | |
473 | } | |
474 | ||
d63d307f | 475 | void sdl_display_init(DisplayState *ds, int full_screen) |
0f0b7264 FB |
476 | { |
477 | int flags; | |
478 | ||
3d11d0eb FB |
479 | #if defined(__APPLE__) |
480 | /* always use generic keymaps */ | |
481 | if (!keyboard_layout) | |
482 | keyboard_layout = "en-us"; | |
483 | #endif | |
484 | if(keyboard_layout) { | |
485 | kbd_layout = init_keyboard_layout(keyboard_layout); | |
486 | if (!kbd_layout) | |
487 | exit(1); | |
488 | } | |
489 | ||
0f0b7264 FB |
490 | flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE; |
491 | if (SDL_Init (flags)) { | |
492 | fprintf(stderr, "Could not initialize SDL - exiting\n"); | |
493 | exit(1); | |
494 | } | |
67b915a5 | 495 | #ifndef _WIN32 |
0ae04d73 FB |
496 | /* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */ |
497 | signal(SIGINT, SIG_DFL); | |
498 | signal(SIGQUIT, SIG_DFL); | |
67b915a5 | 499 | #endif |
0ae04d73 | 500 | |
0f0b7264 FB |
501 | ds->dpy_update = sdl_update; |
502 | ds->dpy_resize = sdl_resize; | |
503 | ds->dpy_refresh = sdl_refresh; | |
504 | ||
505 | sdl_resize(ds, 640, 400); | |
8a7ddc38 | 506 | sdl_update_caption(); |
0f0b7264 | 507 | SDL_EnableKeyRepeat(250, 50); |
457831f4 | 508 | SDL_EnableUNICODE(1); |
0f0b7264 | 509 | gui_grab = 0; |
898712a8 FB |
510 | |
511 | atexit(sdl_cleanup); | |
d63d307f FB |
512 | if (full_screen) { |
513 | gui_fullscreen = 1; | |
514 | gui_fullscreen_initial_grab = 1; | |
515 | sdl_grab_start(); | |
516 | } | |
0f0b7264 | 517 | } |