(PS3) More control settings - NOTE: public controller config save/load

functions do not work properly and do not save the proper values
This commit is contained in:
TwinAphex51224 2012-03-01 14:22:16 +01:00
parent 9a1cf7525e
commit de9db9bcea
5 changed files with 171 additions and 3 deletions

View File

@ -37,6 +37,7 @@
#ifdef __CELLOS_LV2__
#include <sys/timer.h>
#include "ps3/cellframework2/utility/oskutil.h"
#endif
#ifdef XENON
@ -203,6 +204,7 @@ struct console_settings
DWORD volume_device_type;
#endif
char cgp_path[PATH_MAX];
char input_cfg_path[PATH_MAX];
char rom_path[PATH_MAX];
char aspect_ratio_name[PATH_MAX];
char default_rom_startup_dir[PATH_MAX];
@ -210,6 +212,9 @@ struct console_settings
char default_sram_dir[PATH_MAX];
char launch_app_on_exit[PATH_MAX];
float menu_font_size;
#ifdef __CELLOS_LV2__
oskutil_params oskutil_handle;
#endif
};
#endif

View File

@ -314,6 +314,13 @@ static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdat
g_console.ingame_menu_enable = false;
g_console.mode_switch = MODE_EXIT;
break;
case CELL_SYSUTIL_OSKDIALOG_FINISHED:
oskutil_close(&g_console.oskutil_handle);
oskutil_finished(&g_console.oskutil_handle);
break;
case CELL_SYSUTIL_OSKDIALOG_UNLOADED:
oskutil_unload(&g_console.oskutil_handle);
break;
}
}
@ -399,7 +406,7 @@ static void get_environment_settings(int argc, char *argv[])
snprintf(DEFAULT_BORDER_FILE, sizeof(DEFAULT_BORDER_FILE), "%s/%s/borders/Centered-1080p/mega-man-2.png", usrDirPath, EMULATOR_CORE_DIR);
snprintf(DEFAULT_MENU_BORDER_FILE, sizeof(DEFAULT_MENU_BORDER_FILE), "%s/%s/borders/Menu/main-menu.png", usrDirPath, EMULATOR_CORE_DIR);
snprintf(PRESETS_DIR_PATH, sizeof(PRESETS_DIR_PATH), "%s/%s/presets", usrDirPath, EMULATOR_CORE_DIR);
snprintf(INPUT_PRESETS_DIR_PATH, sizeof(INPUT_PRESETS_DIR_PATH), "%s/%s/input-presets", usrDirPath, EMULATOR_CORE_DIR);
snprintf(INPUT_PRESETS_DIR_PATH, sizeof(INPUT_PRESETS_DIR_PATH), "%s/input", PRESETS_DIR_PATH);
snprintf(LIBSNES_DIR_PATH, sizeof(LIBSNES_DIR_PATH), "%s/%s", usrDirPath, EMULATOR_CORE_DIR);
snprintf(BORDERS_DIR_PATH, sizeof(BORDERS_DIR_PATH), "%s/%s/borders", usrDirPath, EMULATOR_CORE_DIR);
snprintf(SHADERS_DIR_PATH, sizeof(SHADERS_DIR_PATH), "%s/%s/shaders", usrDirPath, EMULATOR_CORE_DIR);
@ -554,6 +561,7 @@ int main(int argc, char *argv[])
ps3graphics_video_init(true);
ps3_input_init();
oskutil_init(&g_console.oskutil_handle, 0);
menu_init();
g_console.mode_switch = MODE_MENU;
@ -599,7 +607,8 @@ begin_shutdown:
ssnes_main_deinit();
cell_pad_input_deinit();
ps3_video_deinit();
if(g_console.oskutil_handle.is_running)
oskutil_unload(&g_console.oskutil_handle);
#ifdef HAVE_LOGGER
logger_shutdown();
#endif

View File

@ -684,12 +684,22 @@ static void set_setting_label(menu * menu_obj, uint64_t currentsetting)
menu_obj->items[currentsetting].text_color = ORANGE;
break;
case SETTING_CONTROLS_SCHEME:
if(strcmp(g_console.input_cfg_path,"") == 0)
menu_obj->items[currentsetting].text_color = GREEN;
else
menu_obj->items[currentsetting].text_color = ORANGE;
snprintf(menu_obj->items[currentsetting].comment, sizeof(menu_obj->items[currentsetting].comment), "INFO - Input scheme preset [%s] is selected.", g_console.input_cfg_path);
snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), g_console.input_cfg_path);
break;
case SETTING_CONTROLS_NUMBER:
if(currently_selected_controller_menu == 0)
menu_obj->items[currentsetting].text_color = GREEN;
else
menu_obj->items[currentsetting].text_color = ORANGE;
snprintf(menu_obj->items[currentsetting].comment, sizeof(menu_obj->items[currentsetting].comment), "Controller %d is currently selected.", currently_selected_controller_menu+1);
snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "%d", currently_selected_controller_menu+1);
break;
case SETTING_CONTROLS_DPAD_UP:
case SETTING_CONTROLS_DPAD_DOWN:
@ -816,7 +826,7 @@ static void select_file(uint32_t menu_id)
break;
case INPUT_PRESET_CHOICE:
strncpy(dir_path, INPUT_PRESETS_DIR_PATH, sizeof(dir_path));
strncpy(extensions, "conf|CONF", sizeof(extensions));
strncpy(extensions, "cfg|CFG", sizeof(extensions));
strncpy(title, "INPUT PRESETS SELECTION", sizeof(title));
strncpy(object, "Input", sizeof(object));
strncpy(object, "Input preset", sizeof(object));
@ -898,6 +908,9 @@ static void select_file(uint32_t menu_id)
apply_scaling(FBO_INIT);
break;
case INPUT_PRESET_CHOICE:
strlcpy(g_console.input_cfg_path, path, sizeof(g_console.input_cfg_path));
config_read_keybinds(path);
menu_reinit_settings();
break;
case BORDER_CHOICE:
break;
@ -1072,6 +1085,84 @@ static void set_keybind_digital(uint64_t state, uint32_t system_joypad_id, uint3
}
}
static void ssnes_filename_input_and_save (unsigned filename_type)
{
bool filename_entered = false;
char filename_tmp[256], filepath[MAX_PATH_LENGTH];
oskutil_write_initial_message(&g_console.oskutil_handle, L"example");
oskutil_write_message(&g_console.oskutil_handle, L"Enter filename for preset (with no file extension)");
oskutil_start(&g_console.oskutil_handle);
while(OSK_IS_RUNNING(g_console.oskutil_handle))
{
glClear(GL_COLOR_BUFFER_BIT);
gl_frame_menu();
psglSwap();
cell_console_poll();
cellSysutilCheckCallback();
}
if(g_console.oskutil_handle.text_can_be_fetched)
{
strncpy(filename_tmp, OUTPUT_TEXT_STRING(g_console.oskutil_handle), sizeof(filename_tmp));
switch(filename_type)
{
case CONFIG_FILE:
{
}
break;
case SHADER_PRESET_FILE:
{
}
break;
case INPUT_PRESET_FILE:
{
snprintf(filepath, sizeof(filepath), "%s/%s.cfg", INPUT_PRESETS_DIR_PATH, filename_tmp);
}
break;
}
filename_entered = true;
}
if(filename_entered)
{
char filetitle_tmp[512];
oskutil_write_initial_message(&g_console.oskutil_handle, L"Example file title");
oskutil_write_message(&g_console.oskutil_handle, L"Enter title for preset");
oskutil_start(&g_console.oskutil_handle);
while(OSK_IS_RUNNING(g_console.oskutil_handle))
{
/* OSK Util gets updated */
glClear(GL_COLOR_BUFFER_BIT);
ps3graphics_draw_menu();
psglSwap();
cell_console_poll();
cellSysutilCheckCallback();
}
if(g_console.oskutil_handle.text_can_be_fetched)
snprintf(filetitle_tmp, sizeof(filetitle_tmp), "%s", OUTPUT_TEXT_STRING(g_console.oskutil_handle));
else
snprintf(filetitle_tmp, sizeof(filetitle_tmp), "%s", "Custom");
SSNES_LOG("path to save to: %s\n", filepath);
switch(filename_type)
{
case CONFIG_FILE:
break;
case SHADER_PRESET_FILE:
break;
case INPUT_PRESET_FILE:
config_save_keybinds(filepath);
break;
}
}
}
static void producesettingentry(menu * menu_obj, uint64_t switchvalue)
{
uint64_t state;
@ -1543,12 +1634,25 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue)
}
break;
case SETTING_CONTROLS_SCHEME:
if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_CROSS(state) | CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state))
{
menuStackindex++;
menuStack[menuStackindex] = menu_filebrowser;
menuStack[menuStackindex].enum_id = INPUT_PRESET_CHOICE;
set_initial_dir_tmpbrowser = true;
set_delay = DELAY_LONG;
}
if(CTRL_START(state))
{
menu_reinit_settings();
}
break;
case SETTING_CONTROLS_NUMBER:
if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_CROSS(state))
{
if(currently_selected_controller_menu != 0)
currently_selected_controller_menu--;
menu_reinit_settings();
set_delay = DELAY_MEDIUM;
}
@ -1556,6 +1660,7 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue)
{
if(currently_selected_controller_menu < 6)
currently_selected_controller_menu++;
menu_reinit_settings();
set_delay = DELAY_MEDIUM;
}
@ -1599,8 +1704,51 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue)
set_keybind_digital(state, CTRL_R1_MASK, SNES_DEVICE_ID_JOYPAD_R);
break;
case SETTING_CONTROLS_SAVE_CUSTOM_CONTROLS:
if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state) || CTRL_START(state))
{
ssnes_filename_input_and_save(INPUT_PRESET_FILE);
}
break;
case SETTING_CONTROLS_DEFAULT_ALL:
if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state) || CTRL_START(state))
{
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_UP].id = SNES_DEVICE_ID_JOYPAD_UP;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_UP].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_UP];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_DOWN].id = SNES_DEVICE_ID_JOYPAD_DOWN;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_DOWN];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_LEFT].id = SNES_DEVICE_ID_JOYPAD_LEFT;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_LEFT];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_RIGHT].id = SNES_DEVICE_ID_JOYPAD_RIGHT;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_RIGHT];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_A].id = SNES_DEVICE_ID_JOYPAD_A;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_A].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_A];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_B].id = SNES_DEVICE_ID_JOYPAD_B;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_B].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_B];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_X].id = SNES_DEVICE_ID_JOYPAD_X;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_X].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_X];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_Y].id = SNES_DEVICE_ID_JOYPAD_Y;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_Y].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_Y];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_L].id = SNES_DEVICE_ID_JOYPAD_L;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_L].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_L];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_R].id = SNES_DEVICE_ID_JOYPAD_R;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_R].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_R];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_START].id = SNES_DEVICE_ID_JOYPAD_START;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_START].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_START];
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_SELECT].id = SNES_DEVICE_ID_JOYPAD_SELECT;
g_settings.input.binds[currently_selected_controller_menu][SNES_DEVICE_ID_JOYPAD_SELECT].joykey = default_keybind_lut[SNES_DEVICE_ID_JOYPAD_SELECT];
menu_reinit_settings();
}
break;
}

View File

@ -53,6 +53,12 @@ enum {
ORIENTATION_END
};
enum {
CONFIG_FILE,
SHADER_PRESET_FILE,
INPUT_PRESET_FILE
};
enum {
MENU_ITEM_LOAD_STATE = 0,
MENU_ITEM_SAVE_STATE,