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 |
|
|