(PS3) Libsnes ports can now set per-system default keybind names

This commit is contained in:
TwinAphex51224 2012-03-06 16:06:47 +01:00
parent 44b873af5b
commit f7c2bfe530
6 changed files with 42 additions and 0 deletions

View File

@ -20,6 +20,8 @@
#include "console_ext.h"
#include "../boolean.h"
#include "../libsnes.hpp"
#include "../input/input_luts.h"
#include "../general.h"
#include <string.h>
#include <ctype.h>
@ -76,3 +78,20 @@ void ssnes_console_name_from_id(char *name, size_t size)
name[i] = tolower(c);
}
}
void ssnes_console_set_default_keybind_names_for_emulator (void)
{
const char *id = snes_library_id();
// Genesis Plus GX/Next
if (strstr(id, "Genesis Plus GX"))
{
strlcpy(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_B], "B button", sizeof(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_B]));
strlcpy(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_A], "C button", sizeof(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_A]));
strlcpy(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_X], "Y button", sizeof(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_X]));
strlcpy(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_Y], "A button", sizeof(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_Y]));
strlcpy(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_L], "X button", sizeof(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_L]));
strlcpy(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_R], "Z button", sizeof(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_R]));
strlcpy(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_SELECT], "Mode button", sizeof(ssnes_default_libsnes_keybind_name_lut[SNES_DEVICE_ID_JOYPAD_SELECT]));
}
}

View File

@ -28,4 +28,8 @@ const char *ssnes_console_get_rom_ext(void);
// Transforms a library id to a name suitable as a pathname.
void ssnes_console_name_from_id(char *name, size_t size);
// Sets custom default keybind names (some systems emulated by the emulator
// will need different keybind names for buttons, etc.)
void ssnes_console_set_default_keybind_names_for_emulator(void);
#endif

View File

@ -25,6 +25,21 @@
uint64_t ssnes_default_keybind_lut[SSNES_FIRST_META_KEY];
char ssnes_default_libsnes_keybind_name_lut[SSNES_FIRST_META_KEY][256] = {
"B Button", /* SNES_DEVICE_ID_JOYPAD_B */
"Y Button", /* SNES_DEVICE_ID_JOYPAD_Y */
"Select button", /* SNES_DEVICE_ID_JOYPAD_SELECT */
"Start button", /* SNES_DEVICE_ID_JOYPAD_START */
"D-Pad Up", /* SNES_DEVICE_ID_JOYPAD_UP */
"D-Pad Down", /* SNES_DEVICE_ID_JOYPAD_DOWN */
"D-Pad Left", /* SNES_DEVICE_ID_JOYPAD_LEFT */
"D-Pad Right", /* SNES_DEVICE_ID_JOYPAD_RIGHT */
"A Button", /* SNES_DEVICE_ID_JOYPAD_A */
"X Button", /* SNES_DEVICE_ID_JOYPAD_X */
"L Button", /* SNES_DEVICE_ID_JOYPAD_L */
"R Button", /* SNES_DEVICE_ID_JOYPAD_R */
};
#if defined(__CELLOS_LV2__)
uint64_t ssnes_platform_keybind_lut[SSNES_LAST_PLATFORM_KEY] = {
CTRL_CIRCLE_MASK,

View File

@ -108,6 +108,7 @@ enum xdk360_device_id
extern uint64_t ssnes_default_keybind_lut[SSNES_FIRST_META_KEY];
extern uint64_t ssnes_platform_keybind_lut[SSNES_LAST_PLATFORM_KEY];
extern char ssnes_default_libsnes_keybind_name_lut[SSNES_FIRST_META_KEY][256];
const char *ssnes_input_find_platform_key_label(uint64_t joykey);
uint64_t ssnes_input_find_previous_platform_key(uint64_t joykey);

View File

@ -583,6 +583,8 @@ int main(int argc, char *argv[])
ps3_input_init();
oskutil_init(&g_console.oskutil_handle, 0);
ssnes_console_set_default_keybind_names_for_emulator();
menu_init();
switch(g_console.external_launcher_support)

View File

@ -744,6 +744,7 @@ static void set_setting_label(menu * menu_obj, uint64_t currentsetting)
else
menu_obj->items[currentsetting].text_color = ORANGE;
const char * value = ssnes_input_find_platform_key_label(g_settings.input.binds[currently_selected_controller_menu][currentsetting-(FIRST_CONTROL_BIND)].joykey);
snprintf(menu_obj->items[currentsetting].text, sizeof(menu_obj->items[currentsetting].text), ssnes_default_libsnes_keybind_name_lut[currentsetting-(FIRST_CONTROL_BIND)]);
snprintf(menu_obj->items[currentsetting].comment, sizeof(menu_obj->items[currentsetting].comment), "INFO - [%s] on the PS3 controller is mapped to action:\n[%s].", menu_obj->items[currentsetting].text, value);
snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), value);
}