summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/sdl/input.c
diff options
context:
space:
mode:
author Couriersud <couriersud@users.noreply.github.com>2012-02-16 01:38:13 +0000
committer Couriersud <couriersud@users.noreply.github.com>2012-02-16 01:38:13 +0000
commitebe89a47d3653294795abeda63701823ef194746 (patch)
tree6d3d50f612dc2e202b1d99bbb1b6b677e30ee31b /src/osd/sdl/input.c
parent1ea68a18b1deec0e7f42c189b7e733d7728e877d (diff)
Fixed testkeys to work with SDL2.0. Keymaps can now contain SDL1.3 and SDL2.0 mappings. Updated km-de.txt as an example. [Couriersud]
Diffstat (limited to 'src/osd/sdl/input.c')
-rw-r--r--src/osd/sdl/input.c58
1 files changed, 32 insertions, 26 deletions
diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c
index bd0fc49f6b2..1434f1392e7 100644
--- a/src/osd/sdl/input.c
+++ b/src/osd/sdl/input.c
@@ -496,8 +496,7 @@ static key_lookup_table sdl_lookup_table[] =
KE8(F6, F7, F8, F9, F10, F11, F12, F13 )
KE8(F14, F15, NUMLOCKCLEAR, CAPSLOCK, SCROLLLOCK, RSHIFT, LSHIFT, RCTRL )
KE5(LCTRL, RALT, LALT, LGUI, RGUI)
- KE(PRINTSCREEN)
- KE(MENU)
+ KE8(GRAVE, LEFTBRACKET,RIGHTBRACKET, SEMICOLON, APOSTROPHE, BACKSLASH, PRINTSCREEN,MENU )
KE(UNDO)
{-1, ""}
};
@@ -542,7 +541,6 @@ static key_lookup_table sdl_lookup_table[] =
};
#endif
-
//============================================================
// INLINE FUNCTIONS
//============================================================
@@ -955,9 +953,10 @@ static kt_table * sdlinput_read_keymap(running_machine &machine)
int line = 1;
int index,i, sk, vk, ak;
char buf[256];
- char mks[21];
- char sks[21];
- char kns[21];
+ char mks[41];
+ char sks[41];
+ char kns[41];
+ int sdl2section=0;
if (!machine.options().bool_value(SDLOPTION_KEYMAP))
return sdl_key_trans_table;
@@ -977,34 +976,41 @@ static kt_table * sdlinput_read_keymap(running_machine &machine)
while (!feof(keymap_file))
{
- fgets(buf, 255, keymap_file);
- if (*buf && buf[0] && buf[0] != '#')
+ char *ret = fgets(buf, 255, keymap_file);
+ if (ret && buf[0] != '\n' && buf[0] != '#')
{
buf[255]=0;
i=strlen(buf);
if (i && buf[i-1] == '\n')
buf[i-1] = 0;
- mks[0]=0;
- sks[0]=0;
- memset(kns, 0, ARRAY_LENGTH(kns));
- sscanf(buf, "%20s %20s %x %x %20c\n",
- mks, sks, &vk, &ak, kns);
+ if (strncmp(buf,"[SDL2]",6) == 0)
+ {
+ sdl2section = 1;
+ }
+ else if (((SDLMAME_SDL2) ^ sdl2section) == 0)
+ {
+ mks[0]=0;
+ sks[0]=0;
+ memset(kns, 0, ARRAY_LENGTH(kns));
+ sscanf(buf, "%40s %40s %x %x %40c\n",
+ mks, sks, &vk, &ak, kns);
- index=lookup_mame_index(mks);
- sk = lookup_sdl_code(sks);
+ index=lookup_mame_index(mks);
+ sk = lookup_sdl_code(sks);
- if ( sk >= 0 && index >=0)
- {
- key_trans_table[index].sdl_key = sk;
- // vk and ak are not really needed
- //key_trans_table[index][VIRTUAL_KEY] = vk;
- //key_trans_table[index][ASCII_KEY] = ak;
- key_trans_table[index].ui_name = auto_alloc_array(machine, char, strlen(kns)+1);
- strcpy(key_trans_table[index].ui_name, kns);
- mame_printf_verbose("Keymap: Mapped <%s> to <%s> with ui-text <%s>\n", sks, mks, kns);
+ if ( sk >= 0 && index >=0)
+ {
+ key_trans_table[index].sdl_key = sk;
+ // vk and ak are not really needed
+ //key_trans_table[index][VIRTUAL_KEY] = vk;
+ //key_trans_table[index][ASCII_KEY] = ak;
+ key_trans_table[index].ui_name = auto_alloc_array(machine, char, strlen(kns)+1);
+ strcpy(key_trans_table[index].ui_name, kns);
+ mame_printf_verbose("Keymap: Mapped <%s> to <%s> with ui-text <%s>\n", sks, mks, kns);
+ }
+ else
+ mame_printf_warning("Keymap: Error on line %d - %s key not found: %s\n", line, (sk<0) ? "sdl" : "mame", buf);
}
- else
- mame_printf_warning("Keymap: Error on line %d - %s key not found: %s\n", line, (sk<0) ? "sdl" : "mame", buf);
}
line++;
}