diff --git a/360/xdk360_input.c b/360/xdk360_input.c index ba642d70e8..e78fd3326d 100644 --- a/360/xdk360_input.c +++ b/360/xdk360_input.c @@ -19,7 +19,7 @@ #include #include "../driver.h" #include "../general.h" -#include "../libsnes.hpp" +#include "../libretro.h" #include "../console/console_ext_input.h" #include "xdk360_input.h" #include "xdk360_video_general.h" @@ -58,26 +58,8 @@ static int16_t xdk360_input_state(void *data, const struct snes_keybind **binds, unsigned index, unsigned id) { (void)data; - unsigned player; - uint64_t button; - - player = 0; - - if (device != SNES_DEVICE_JOYPAD) - return 0; - - if (port == SNES_PORT_2) - { - if(pads_connected < 2) - return 0; - - player = 1; - - if (device == SNES_DEVICE_MULTITAP) - player += index; - } - - button = binds[player][id].joykey; + unsigned player = port; + uint64_t button = binds[player][id].joykey; return (state[player] & button) ? 1 : 0; } @@ -103,22 +85,22 @@ void xdk360_input_map_dpad_to_stick(uint32_t map_dpad_enum, uint32_t controller_ switch(map_dpad_enum) { case DPAD_EMULATION_NONE: - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_UP]; - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_DOWN]; - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LEFT]; - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RIGHT]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_UP]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_DOWN]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LEFT]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RIGHT]; break; case DPAD_EMULATION_LSTICK: - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_UP_DPAD]; - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_DOWN_DPAD]; - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_LEFT_DPAD]; - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_RIGHT_DPAD]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_UP_DPAD]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_DOWN_DPAD]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_LEFT_DPAD]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_RIGHT_DPAD]; break; case DPAD_EMULATION_RSTICK: - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_UP_DPAD]; - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_DOWN_DPAD]; - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_LEFT_DPAD]; - g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_RIGHT_DPAD]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_UP_DPAD]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_DOWN_DPAD]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_LEFT_DPAD]; + g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_RIGHT_DPAD]; break; } } diff --git a/console/console_ext.c b/console/console_ext.c index 31715d20ca..53bb8d559f 100644 --- a/console/console_ext.c +++ b/console/console_ext.c @@ -41,19 +41,15 @@ ROM EXTENSIONS ============================================================ */ -static char g_rom_ext[1024]; - -void ssnes_console_set_rom_ext(const char *ext) -{ - strlcpy(g_rom_ext, ext, sizeof(g_rom_ext)); -} - const char *ssnes_console_get_rom_ext(void) { const char *retval = NULL; - if (*g_rom_ext) - retval = g_rom_ext; + struct retro_system_info info; + retro_get_system_info(&info); + + if (info.valid_extensions) + retval = info.valid_extensions; else retval = "ZIP|zip"; diff --git a/console/console_ext.h b/console/console_ext.h index ef3fe608eb..8936be76e9 100644 --- a/console/console_ext.h +++ b/console/console_ext.h @@ -50,8 +50,6 @@ enum ROM EXTENSIONS ============================================================ */ -void ssnes_console_set_rom_ext(const char *ext); - // Get rom extensions for current library. // Returns NULL if library doesn't have any preferences in particular. const char *ssnes_console_get_rom_ext(void); diff --git a/console/griffin/func_hooks.h b/console/griffin/func_hooks.h index a2371a09dd..c192f43427 100644 --- a/console/griffin/func_hooks.h +++ b/console/griffin/func_hooks.h @@ -25,6 +25,6 @@ #define ssnes_render_cached_frame() \ const char *msg = msg_queue_pull(g_extern.msg_queue); \ - video_frame_func(g_extern.frame_cache.data, g_extern.frame_cache.width, g_extern.frame_cache.height, lines_to_pitch(g_extern.frame_cache.height), msg); + video_frame_func(g_extern.frame_cache.data, g_extern.frame_cache.width, g_extern.frame_cache.height, g_extern.frame_cache.height, msg); #endif diff --git a/ps3/main.c b/ps3/main.c index 8b78e9bacf..8336e0dc7a 100644 --- a/ps3/main.c +++ b/ps3/main.c @@ -159,7 +159,7 @@ static void set_default_settings(void) g_extern.verbose = true; } -static void init_settings(bool load_libsnes_path) +static void init_settings(bool load_libretro_path) { if(!path_file_exists(SYS_CONFIG_FILE)) { @@ -175,13 +175,13 @@ static void init_settings(bool load_libsnes_path) // g_settings - if(load_libsnes_path) + if(load_libretro_path) { - CONFIG_GET_STRING(libsnes, "libsnes_path"); + CONFIG_GET_STRING(libretro, "libretro_path"); - if(!strcmp(g_settings.libsnes, "")) + if(!strcmp(g_settings.libretro, "")) { - //We need to set libsnes to the first entry in the cores + //We need to set libretro to the first entry in the cores //directory so that it will be saved to the config file char ** dir_list = dir_list_new(LIBSNES_DIR_PATH, ".SELF"); if (!dir_list) @@ -194,12 +194,12 @@ static void init_settings(bool load_libsnes_path) if(first_self) { - SSNES_LOG("Set first entry in libsnes %s dir: [%s] to libsnes path.\n", EMULATOR_CORE_DIR, first_self); - strlcpy(g_settings.libsnes, first_self, sizeof(g_settings.libsnes)); + SSNES_LOG("Set first entry in libretro %s dir: [%s] to libretro path.\n", EMULATOR_CORE_DIR, first_self); + strlcpy(g_settings.libretro, first_self, sizeof(g_settings.libretro)); } else { - SSNES_ERR("Failed to set first entry in libsnes %s dir to libsnes path.\n", EMULATOR_CORE_DIR); + SSNES_ERR("Failed to set first entry in libretro %s dir to libretro path.\n", EMULATOR_CORE_DIR); } dir_list_free(dir_list); @@ -269,7 +269,7 @@ static void save_settings(void) conf = config_file_new(NULL); // g_settings - config_set_string(conf, "libsnes_path", g_settings.libsnes); + config_set_string(conf, "libretro_path", g_settings.libretro); config_set_string(conf, "cheat_database_path", g_settings.cheat_database); config_set_bool(conf, "rewind_enable", g_settings.rewind_enable); config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path); @@ -467,19 +467,19 @@ static void startup_ssnes(void) } } -static bool manage_libsnes_core(void) +static bool manage_libretro_core(void) { g_extern.verbose = true; bool return_code; - bool set_libsnes_path = false; + bool set_libretro_path = false; char tmp_path[1024], tmp_path2[1024], tmp_pathnewfile[1024]; snprintf(tmp_path, sizeof(tmp_path), "%s/%s/CORE.SELF", usrDirPath, EMULATOR_CORE_DIR); SSNES_LOG("Assumed path of CORE.SELF: [%s]\n", tmp_path); if(path_file_exists(tmp_path)) { //if CORE.SELF exists, this indicates we have just installed - //a new libsnes port and that we need to change it to a more + //a new libretro port and that we need to change it to a more //sane name. CellFsErrno ret; @@ -491,17 +491,17 @@ static bool manage_libsnes_core(void) if(path_file_exists(tmp_pathnewfile)) { SSNES_LOG("Upgrading emulator core...\n"); - //if libsnes core already exists, then that means we are - //upgrading the libsnes core - so delete pre-existing + //if libretro core already exists, then that means we are + //upgrading the libretro core - so delete pre-existing //file first ret = cellFsUnlink(tmp_pathnewfile); if(ret == CELL_FS_SUCCEEDED) { - SSNES_LOG("Succeeded in removing pre-existing libsnes core: [%s].\n", tmp_pathnewfile); + SSNES_LOG("Succeeded in removing pre-existing libretro core: [%s].\n", tmp_pathnewfile); } else { - SSNES_LOG("Failed to remove pre-existing libsnes core: [%s].\n", tmp_pathnewfile); + SSNES_LOG("Failed to remove pre-existing libretro core: [%s].\n", tmp_pathnewfile); } } @@ -514,25 +514,25 @@ static bool manage_libsnes_core(void) else { SSNES_LOG("Libsnes core [%s] renamed to: [%s].\n", tmp_path, tmp_pathnewfile); - set_libsnes_path = true; + set_libretro_path = true; } } else { - SSNES_LOG("CORE.SELF was not found, libsnes core path will be loaded from config file.\n"); + SSNES_LOG("CORE.SELF was not found, libretro core path will be loaded from config file.\n"); } - if(set_libsnes_path) + if(set_libretro_path) { - //CORE.BIN has been renamed, libsnes path will now be set to the recently - //renamed new libsnes core - strlcpy(g_settings.libsnes, tmp_pathnewfile, sizeof(g_settings.libsnes)); + //CORE.BIN has been renamed, libretro path will now be set to the recently + //renamed new libretro core + strlcpy(g_settings.libretro, tmp_pathnewfile, sizeof(g_settings.libretro)); return_code = 0; } else { //There was no CORE.BIN present, or the CORE.BIN file was not renamed. - //The libsnes core path will still be loaded from the config file + //The libretro core path will still be loaded from the config file return_code = 1; } @@ -568,11 +568,11 @@ int main(int argc, char *argv[]) config_set_defaults(); - bool load_libsnes_path = manage_libsnes_core(); + bool load_libretro_path = manage_libretro_core(); set_default_settings(); - init_settings(load_libsnes_path); - init_libsnes_sym(); + init_settings(load_libretro_path); + init_libretro_sym(); #if(CELL_SDK_VERSION > 0x340000) if (g_console.screenshots_enable) diff --git a/ps3/menu.c b/ps3/menu.c index 2e96bc7200..c65153ae59 100644 --- a/ps3/menu.c +++ b/ps3/menu.c @@ -596,7 +596,7 @@ static void set_setting_label(menu * menu_obj, uint64_t currentsetting) case SETTING_SSNES_DEFAULT_EMU: { char fname[MAX_PATH_LENGTH]; - fill_pathname_base(fname, g_settings.libsnes, sizeof(fname)); + fill_pathname_base(fname, g_settings.libretro, sizeof(fname)); snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "%s", fname); menu_obj->items[currentsetting].text_color = GREEN; @@ -739,7 +739,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].text, sizeof(menu_obj->items[currentsetting].text), ssnes_default_libretro_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); } @@ -938,8 +938,8 @@ static void select_file(uint32_t menu_id) case BORDER_CHOICE: break; case LIBSNES_CHOICE: - strlcpy(g_settings.libsnes, path, - sizeof(g_settings.libsnes)); + strlcpy(g_settings.libretro, path, + sizeof(g_settings.libretro)); strlcpy(g_console.launch_app_on_exit, path, sizeof(g_console.launch_app_on_exit)); g_console.return_to_launcher = true; @@ -2017,8 +2017,12 @@ static void select_rom(void) if (FILEBROWSER_IS_CURRENT_A_FILE(browser)) cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, "INFO - Press X to load the game. "); + struct retro_system_info info; + retro_get_system_info(&info); + const char *id = info.library_name ? info.library_name : "Unknown"; + cellDbgFontPuts (0.09f, 0.05f, FONT_SIZE, RED, "FILE BROWSER"); - cellDbgFontPrintf (0.3f, 0.05f, 0.82f, WHITE, "Libretro core: %s (v%s)", snes_library_id(), g_extern.system.version); + cellDbgFontPrintf (0.3f, 0.05f, 0.82f, WHITE, "Libretro core: %s (v%s)", id, info.library_version); cellDbgFontPrintf (0.7f, 0.05f, 0.82f, WHITE, "%s v%s", EMULATOR_NAME, EMULATOR_VERSION); cellDbgFontPrintf (0.09f, 0.09f, FONT_SIZE, YELLOW, "PATH: %s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser)); @@ -2300,8 +2304,11 @@ static void ingame_menu(uint32_t menu_id) if(CTRL_SQUARE(~state)) { + struct retro_system_info info; + retro_get_system_info(&info); + const char *id = info.library_name ? info.library_name : "Unknown"; cellDbgFontPuts (0.09f, 0.05f, FONT_SIZE, RED, "QUICK MENU"); - cellDbgFontPrintf (0.3f, 0.05f, 0.82f, WHITE, "Libretro core: %s", snes_library_id()); + cellDbgFontPrintf (0.3f, 0.05f, 0.82f, WHITE, "Libretro core: %s", id); cellDbgFontPrintf (0.7f, 0.05f, 0.82f, WHITE, "%s v%s", EMULATOR_NAME, EMULATOR_VERSION); cellDbgFontPrintf(x_position, 0.14f, 1.4f, WHITE, "Resize Mode"); cellDbgFontPrintf (x_position, ypos, font_size, GREEN, "Viewport X: #%d", g_console.custom_viewport_x); @@ -2528,8 +2535,12 @@ static void ingame_menu(uint32_t menu_id) cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_RETURN_TO_XMB)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_XMB), "Return to XMB"); cellDbgFontDraw(); + struct retro_system_info info; + retro_get_system_info(&info); + const char *id = info.library_name ? info.library_name : "Unknown"; + cellDbgFontPuts (0.09f, 0.05f, FONT_SIZE, RED, "QUICK MENU"); - cellDbgFontPrintf (0.3f, 0.05f, 0.82f, WHITE, "Libretro core: %s", snes_library_id()); + cellDbgFontPrintf (0.3f, 0.05f, 0.82f, WHITE, "Libretro core: %s", id); cellDbgFontPrintf (0.7f, 0.05f, 0.82f, WHITE, "%s v%s", EMULATOR_NAME, EMULATOR_VERSION); cellDbgFontDraw(); cellDbgFontPrintf (0.05f, 0.90f, 1.10f, WHITE, special_action_msg); diff --git a/ps3/ps3_input.c b/ps3/ps3_input.c index 53ddedb75d..61d03be6a7 100644 --- a/ps3/ps3_input.c +++ b/ps3/ps3_input.c @@ -98,32 +98,13 @@ static void ps3_input_poll(void *data) } static int16_t ps3_input_state(void *data, const struct snes_keybind **binds, - bool port, unsigned device, + unsigned port, unsigned device, unsigned index, unsigned id) { (void)data; - unsigned pads_connected, player; - uint64_t button; - - player = 0; - pads_connected = cell_pad_input_pads_connected(); - - if (device != RETRO_DEVICE_JOYPAD) - return 0; - - if (port == 1) - { - if(pads_connected < 2) - return 0; - - player = 1; - - if(device == RETRO_DEVICE_MULTITAP) - player += index; - } - - button = binds[player][id].joykey; + unsigned player = port; + uint64_t button = binds[player][id].joykey; return CTRL_MASK(state[player], button) ? 1 : 0; } diff --git a/wii/input.c b/wii/input.c index 7764941890..9f6b3fc59d 100644 --- a/wii/input.c +++ b/wii/input.c @@ -20,7 +20,7 @@ #include #include "../driver.h" -#include "../libsnes.hpp" +#include "../libretro.h" #include // Just plain pads for now. @@ -29,21 +29,14 @@ static bool wpad_state[5][SSNES_FIRST_META_KEY]; static bool g_quit; static int16_t wii_input_state(void *data, const struct snes_keybind **binds, - bool port, unsigned device, + unsigned port, unsigned device, unsigned index, unsigned id) { (void)data; (void)binds; (void)index; - if (device != SNES_DEVICE_JOYPAD) - return 0; - - unsigned player = 0; - if (port == SNES_PORT_2 && device == SNES_DEVICE_MULTITAP) - player = index + 1; - else if (port == SNES_PORT_2) - player = 1; + unsigned player = port; return pad_state[player][id] || wpad_state[player][id]; } diff --git a/wii/main.c b/wii/main.c index 6997a99859..6d7e7d4d86 100644 --- a/wii/main.c +++ b/wii/main.c @@ -19,7 +19,7 @@ #include "../console/sgui.h" #include "../driver.h" #include "../general.h" -#include "../libsnes.hpp" +#include "../libretro.h" #include "driver.h" #include