1 |
|
/* |
2 |
|
* video_sdl.cpp - Video/graphics emulation, SDL specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2004 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2005 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
82 |
|
#endif |
83 |
|
|
84 |
|
// Constants |
85 |
+ |
#ifdef WIN32 |
86 |
+ |
const char KEYCODE_FILE_NAME[] = "BasiliskII_keycodes"; |
87 |
+ |
#else |
88 |
|
const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes"; |
89 |
+ |
#endif |
90 |
|
|
91 |
|
|
92 |
|
// Global variables |
810 |
|
SDL_VideoDriverName(video_driver, sizeof(video_driver)); |
811 |
|
bool video_driver_found = false; |
812 |
|
char line[256]; |
813 |
+ |
int n_keys = 0; |
814 |
|
while (fgets(line, sizeof(line) - 1, f)) { |
815 |
|
// Read line |
816 |
|
int len = strlen(line); |
823 |
|
continue; |
824 |
|
|
825 |
|
if (video_driver_found) { |
826 |
< |
// Skip aliases |
826 |
> |
// Skip aliases as long as we have read keycodes yet |
827 |
> |
// Otherwise, it's another mapping and we have to stop |
828 |
|
static const char sdl_str[] = "sdl"; |
829 |
< |
if (strncmp(line, sdl_str, sizeof(sdl_str) - 1) == 0) |
829 |
> |
if (strncmp(line, sdl_str, sizeof(sdl_str) - 1) == 0 && n_keys == 0) |
830 |
|
continue; |
831 |
|
|
832 |
|
// Read keycode |
833 |
|
int x_code, mac_code; |
834 |
|
if (sscanf(line, "%d %d", &x_code, &mac_code) == 2) |
835 |
< |
keycode_table[x_code & 0xff] = mac_code; |
835 |
> |
keycode_table[x_code & 0xff] = mac_code, n_keys++; |
836 |
|
else |
837 |
|
break; |
838 |
|
} else { |
857 |
|
WarningAlert(str); |
858 |
|
return; |
859 |
|
} |
860 |
+ |
|
861 |
+ |
D(bug("Using SDL/%s keycodes table, %d key mappings\n", video_driver, n_keys)); |
862 |
|
} |
863 |
|
} |
864 |
|
|
959 |
|
int max_width = 640, max_height = 480; |
960 |
|
SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); |
961 |
|
if (modes && modes != (SDL_Rect **)-1) { |
962 |
< |
max_width = modes[0]->w; |
963 |
< |
max_height = modes[0]->h; |
962 |
> |
// It turns out that on some implementations, and contrary to the documentation, |
963 |
> |
// the returned list is not sorted from largest to smallest (e.g. Windows) |
964 |
> |
for (int i = 0; modes[i] != NULL; i++) { |
965 |
> |
const int w = modes[i]->w; |
966 |
> |
const int h = modes[i]->h; |
967 |
> |
if (w > max_width && h > max_height) { |
968 |
> |
max_width = w; |
969 |
> |
max_height = h; |
970 |
> |
} |
971 |
> |
} |
972 |
|
if (default_width > max_width) |
973 |
|
default_width = max_width; |
974 |
|
if (default_height > max_height) |
1381 |
|
|
1382 |
|
case SDLK_1: case SDLK_EXCLAIM: return 0x12; |
1383 |
|
case SDLK_2: case SDLK_AT: return 0x13; |
1384 |
< |
// case SDLK_3: case SDLK_numbersign: return 0x14; |
1384 |
> |
case SDLK_3: case SDLK_HASH: return 0x14; |
1385 |
|
case SDLK_4: case SDLK_DOLLAR: return 0x15; |
1386 |
< |
// case SDLK_5: case SDLK_percent: return 0x17; |
1386 |
> |
case SDLK_5: return 0x17; |
1387 |
|
case SDLK_6: return 0x16; |
1388 |
|
case SDLK_7: return 0x1a; |
1389 |
|
case SDLK_8: return 0x1c; |
1390 |
|
case SDLK_9: return 0x19; |
1391 |
|
case SDLK_0: return 0x1d; |
1392 |
|
|
1393 |
< |
// case SDLK_BACKQUOTE: case SDLK_asciitilde: return 0x0a; |
1393 |
> |
case SDLK_BACKQUOTE: return 0x0a; |
1394 |
|
case SDLK_MINUS: case SDLK_UNDERSCORE: return 0x1b; |
1395 |
|
case SDLK_EQUALS: case SDLK_PLUS: return 0x18; |
1396 |
< |
// case SDLK_bracketleft: case SDLK_braceleft: return 0x21; |
1397 |
< |
// case SDLK_bracketright: case SDLK_braceright: return 0x1e; |
1398 |
< |
// case SDLK_BACKSLASH: case SDLK_bar: return 0x2a; |
1396 |
> |
case SDLK_LEFTBRACKET: return 0x21; |
1397 |
> |
case SDLK_RIGHTBRACKET: return 0x1e; |
1398 |
> |
case SDLK_BACKSLASH: return 0x2a; |
1399 |
|
case SDLK_SEMICOLON: case SDLK_COLON: return 0x29; |
1400 |
< |
// case SDLK_apostrophe: case SDLK_QUOTEDBL: return 0x27; |
1400 |
> |
case SDLK_QUOTE: case SDLK_QUOTEDBL: return 0x27; |
1401 |
|
case SDLK_COMMA: case SDLK_LESS: return 0x2b; |
1402 |
|
case SDLK_PERIOD: case SDLK_GREATER: return 0x2f; |
1403 |
|
case SDLK_SLASH: case SDLK_QUESTION: return 0x2c; |