mirror of
https://github.com/libretro/RetroArch
synced 2025-03-24 13:43:32 +00:00
(PS3) Fixes OSK code
This commit is contained in:
parent
6d9413fab8
commit
95961d1ccb
@ -884,144 +884,91 @@ static void set_keybind_digital(uint64_t default_retro_joypad_id, uint64_t input
|
||||
|
||||
#if defined(HAVE_OSKUTIL)
|
||||
#ifdef __CELLOS_LV2__
|
||||
static char filepath[PATH_MAX];
|
||||
|
||||
static bool osk_callback_enter_rsound(void *data)
|
||||
{
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
|
||||
if(!(OSK_IS_RUNNING(g_extern.console.misc.oskutil_handle)) && g_extern.console.misc.oskutil_handle.text_can_be_fetched)
|
||||
if (g_extern.lifecycle_mode_state & (1ULL << MODE_OSK_ENTRY_SUCCESS))
|
||||
{
|
||||
strlcpy(g_settings.audio.device, OUTPUT_TEXT_STRING(g_extern.console.misc.oskutil_handle), sizeof(g_settings.audio.device));
|
||||
|
||||
if(!rstate->osk_unbind_after_finish)
|
||||
rstate->osk_callback = NULL;
|
||||
|
||||
return true;
|
||||
RARCH_LOG("OSK - Applying input data.\n");
|
||||
char tmp_str[256];
|
||||
int num = wcstombs(tmp_str, g_extern.console.misc.oskutil_handle.text_buf, sizeof(tmp_str));
|
||||
tmp_str[num] = 0;
|
||||
snprintf(g_settings.audio.device, sizeof(g_settings.audio.device), "%s", tmp_str);
|
||||
goto do_exit;
|
||||
}
|
||||
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_OSK_ENTRY_FAIL))
|
||||
goto do_exit;
|
||||
|
||||
return false;
|
||||
|
||||
do_exit:
|
||||
g_extern.lifecycle_mode_state &= ~((1ULL << MODE_OSK_DRAW) | (1ULL << MODE_OSK_ENTRY_SUCCESS) |
|
||||
(1ULL << MODE_OSK_ENTRY_FAIL));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool osk_callback_enter_rsound_init(void *data)
|
||||
{
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
|
||||
oskutil_write_initial_message(&g_extern.console.misc.oskutil_handle, L"192.168.1.1");
|
||||
oskutil_write_message(&g_extern.console.misc.oskutil_handle, L"Enter IP address for the RSound Server.");
|
||||
oskutil_start(&g_extern.console.misc.oskutil_handle);
|
||||
|
||||
rstate->osk_unbind_after_finish = true;
|
||||
rstate->osk_callback = osk_callback_enter_rsound;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool osk_callback_enter_title_init(void *data);
|
||||
|
||||
static bool osk_callback_enter_filename(void *data)
|
||||
{
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
char filename_tmp[256];
|
||||
|
||||
if(!(OSK_IS_RUNNING(g_extern.console.misc.oskutil_handle)) && g_extern.console.misc.oskutil_handle.text_can_be_fetched)
|
||||
if (g_extern.lifecycle_mode_state & (1ULL << MODE_OSK_ENTRY_SUCCESS))
|
||||
{
|
||||
strlcpy(filename_tmp, OUTPUT_TEXT_STRING(g_extern.console.misc.oskutil_handle), sizeof(filename_tmp));
|
||||
RARCH_LOG("OSK - Applying input data.\n");
|
||||
char tmp_str[256];
|
||||
char filepath[PATH_MAX];
|
||||
int num = wcstombs(tmp_str, g_extern.console.misc.oskutil_handle.text_buf, sizeof(tmp_str));
|
||||
tmp_str[num] = 0;
|
||||
snprintf(tmp_str, sizeof(tmp_str), "%s", tmp_str);
|
||||
|
||||
switch(rstate->osk_param)
|
||||
switch(rmenu_state.osk_param)
|
||||
{
|
||||
case CONFIG_FILE:
|
||||
break;
|
||||
case SHADER_PRESET_FILE:
|
||||
snprintf(filepath, sizeof(filepath), "%s/%s.cgp", default_paths.cgp_dir, filename_tmp);
|
||||
break;
|
||||
case INPUT_PRESET_FILE:
|
||||
snprintf(filepath, sizeof(filepath), "%s/%s.cfg", default_paths.input_presets_dir, filename_tmp);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!rstate->osk_unbind_after_finish)
|
||||
rstate->osk_callback = NULL;
|
||||
|
||||
rstate->osk_init = osk_callback_enter_title_init;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool osk_callback_enter_filename_init(void *data)
|
||||
{
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
|
||||
oskutil_write_initial_message(&g_extern.console.misc.oskutil_handle, L"example");
|
||||
oskutil_write_message(&g_extern.console.misc.oskutil_handle,
|
||||
L"Enter filename for preset (with no file extension)");
|
||||
oskutil_start(&g_extern.console.misc.oskutil_handle);
|
||||
|
||||
rstate->osk_unbind_after_finish = false;
|
||||
|
||||
if(!rstate->osk_unbind_after_finish)
|
||||
rstate->osk_init = NULL;
|
||||
|
||||
rstate->osk_callback = osk_callback_enter_filename;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool osk_callback_enter_title(void *data)
|
||||
{
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
char filetitle_tmp[256];
|
||||
|
||||
if(!(OSK_IS_RUNNING(g_extern.console.misc.oskutil_handle)) && g_extern.console.misc.oskutil_handle.text_can_be_fetched)
|
||||
{
|
||||
if(g_extern.console.misc.oskutil_handle.text_can_be_fetched)
|
||||
snprintf(filetitle_tmp, sizeof(filetitle_tmp), "%s", OUTPUT_TEXT_STRING(g_extern.console.misc.oskutil_handle));
|
||||
else
|
||||
snprintf(filetitle_tmp, sizeof(filetitle_tmp), "%s", "Custom");
|
||||
|
||||
switch(rstate->osk_param)
|
||||
{
|
||||
case CONFIG_FILE:
|
||||
break;
|
||||
case SHADER_PRESET_FILE:
|
||||
{
|
||||
struct gl_cg_cgp_info current_settings;
|
||||
current_settings.shader[0] = g_settings.video.cg_shader_path;
|
||||
current_settings.shader[1] = g_settings.video.second_pass_shader;
|
||||
current_settings.filter_linear[0] = g_settings.video.smooth;
|
||||
current_settings.filter_linear[1] = g_settings.video.second_pass_smooth;
|
||||
current_settings.render_to_texture = true;
|
||||
current_settings.fbo_scale = g_settings.video.fbo.scale_x; //fbo.scale_x and y are the same anyway
|
||||
gl_cg_save_cgp(filepath, ¤t_settings);
|
||||
}
|
||||
snprintf(filepath, sizeof(filepath), "%s/%s.cgp", default_paths.cgp_dir, tmp_str);
|
||||
RARCH_LOG("[osk_callback_enter_filename]: filepath is: %s.\n", filepath);
|
||||
|
||||
struct gl_cg_cgp_info current_settings;
|
||||
current_settings.shader[0] = g_settings.video.cg_shader_path;
|
||||
current_settings.shader[1] = g_settings.video.second_pass_shader;
|
||||
current_settings.filter_linear[0] = g_settings.video.smooth;
|
||||
current_settings.filter_linear[1] = g_settings.video.second_pass_smooth;
|
||||
current_settings.render_to_texture = true;
|
||||
current_settings.fbo_scale = g_settings.video.fbo.scale_x; //fbo.scale_x and y are the same anyway
|
||||
gl_cg_save_cgp(filepath, ¤t_settings);
|
||||
break;
|
||||
case INPUT_PRESET_FILE:
|
||||
snprintf(filepath, sizeof(filepath), "%s/%s.cfg", default_paths.input_presets_dir, tmp_str);
|
||||
RARCH_LOG("[osk_callback_enter_filename]: filepath is: %s.\n", filepath);
|
||||
config_save_keybinds(filepath);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!rstate->osk_unbind_after_finish)
|
||||
rstate->osk_callback = NULL;
|
||||
|
||||
return true;
|
||||
goto do_exit;
|
||||
}
|
||||
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_OSK_ENTRY_FAIL))
|
||||
goto do_exit;
|
||||
|
||||
return false;
|
||||
do_exit:
|
||||
g_extern.lifecycle_mode_state &= ~((1ULL << MODE_OSK_DRAW) | (1ULL << MODE_OSK_ENTRY_SUCCESS) |
|
||||
(1ULL << MODE_OSK_ENTRY_FAIL));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool osk_callback_enter_title_init(void *data)
|
||||
static bool osk_callback_enter_filename_init(void *data)
|
||||
{
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)state;
|
||||
|
||||
oskutil_write_initial_message(&g_extern.console.misc.oskutil_handle, L"Example file title");
|
||||
oskutil_write_message(&g_extern.console.misc.oskutil_handle, L"Enter title for preset");
|
||||
oskutil_write_initial_message(&g_extern.console.misc.oskutil_handle, L"example");
|
||||
oskutil_write_message(&g_extern.console.misc.oskutil_handle, L"Enter filename for preset");
|
||||
oskutil_start(&g_extern.console.misc.oskutil_handle);
|
||||
|
||||
rstate->osk_unbind_after_finish = true;
|
||||
rstate->osk_callback = osk_callback_enter_title;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1345,6 +1292,7 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input)
|
||||
{
|
||||
rmenu_state.osk_param = SHADER_PRESET_FILE;
|
||||
rmenu_state.osk_init = osk_callback_enter_filename_init;
|
||||
rmenu_state.osk_callback = osk_callback_enter_filename;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -1387,6 +1335,7 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input)
|
||||
{
|
||||
#ifdef HAVE_OSKUTIL
|
||||
rmenu_state.osk_init = osk_callback_enter_rsound_init;
|
||||
rmenu_state.osk_callback = osk_callback_enter_rsound;
|
||||
#endif
|
||||
}
|
||||
if(input & (1ULL << RMENU_DEVICE_NAV_START))
|
||||
@ -1704,6 +1653,7 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input)
|
||||
rmenu_state_t *rstate = (rmenu_state_t*)&rmenu_state;
|
||||
rstate->osk_param = INPUT_PRESET_FILE;
|
||||
rstate->osk_init = osk_callback_enter_filename_init;
|
||||
rstate->osk_callback = osk_callback_enter_filename;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@ -2567,19 +2517,17 @@ bool rmenu_iterate(void)
|
||||
current_menu.input_poll(¤t_menu, &rmenu_state);
|
||||
|
||||
#ifdef HAVE_OSKUTIL
|
||||
bool osk_init_succeeded = false;
|
||||
bool osk_callback_finished = false;
|
||||
if(rmenu_state.osk_init)
|
||||
osk_init_succeeded = rmenu_state.osk_init(&rmenu_state);
|
||||
if(rmenu_state.osk_init != NULL)
|
||||
{
|
||||
if (rmenu_state.osk_init(&rmenu_state))
|
||||
rmenu_state.osk_init = NULL;
|
||||
}
|
||||
|
||||
if(osk_init_succeeded && rmenu_state.osk_unbind_after_finish)
|
||||
rmenu_state.osk_init = NULL;
|
||||
|
||||
if(rmenu_state.osk_callback)
|
||||
osk_callback_finished = rmenu_state.osk_callback(&rmenu_state);
|
||||
|
||||
if(osk_callback_finished && rmenu_state.osk_unbind_after_finish)
|
||||
rmenu_state.osk_callback = NULL;
|
||||
if(rmenu_state.osk_callback != NULL)
|
||||
{
|
||||
if (rmenu_state.osk_callback(&rmenu_state))
|
||||
rmenu_state.osk_callback = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int input_entry_ret = 0;
|
||||
|
@ -37,7 +37,6 @@ typedef struct
|
||||
uint64_t input;
|
||||
uint64_t old_state;
|
||||
#ifdef HAVE_OSKUTIL
|
||||
bool osk_unbind_after_finish;
|
||||
unsigned osk_param;
|
||||
bool (*osk_init)(void *data);
|
||||
bool (*osk_callback)(void *data);
|
||||
|
@ -159,12 +159,33 @@ static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdat
|
||||
g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT);
|
||||
break;
|
||||
#ifdef HAVE_OSKUTIL
|
||||
case CELL_SYSUTIL_OSKDIALOG_LOADED:
|
||||
break;
|
||||
case CELL_SYSUTIL_OSKDIALOG_INPUT_CANCELED:
|
||||
RARCH_LOG("CELL_SYSUTIL_OSKDIALOG_INPUT_CANCELED.\n");
|
||||
pOskAbort(); //fall-through
|
||||
case CELL_SYSUTIL_OSKDIALOG_FINISHED:
|
||||
oskutil_close(osk);
|
||||
oskutil_finished(osk);
|
||||
if (status == CELL_SYSUTIL_OSKDIALOG_FINISHED)
|
||||
RARCH_LOG("CELL_SYSUTIL_OSKDIALOG_FINISHED.\n");
|
||||
|
||||
pOskUnloadAsync(&osk->outputInfo);
|
||||
|
||||
if (osk->outputInfo.result == CELL_OSKDIALOG_INPUT_FIELD_RESULT_OK)
|
||||
{
|
||||
RARCH_LOG("Setting MODE_OSK_ENTRY_SUCCESS.\n");
|
||||
g_extern.lifecycle_mode_state |= (1ULL << MODE_OSK_ENTRY_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_LOG("Setting MODE_OSK_ENTRY_FAIL.\n");
|
||||
g_extern.lifecycle_mode_state |= (1ULL << MODE_OSK_ENTRY_FAIL);
|
||||
}
|
||||
|
||||
osk->flags &= ~OSK_IN_USE;
|
||||
break;
|
||||
case CELL_SYSUTIL_OSKDIALOG_UNLOADED:
|
||||
oskutil_unload(osk);
|
||||
RARCH_LOG("CELL_SYSUTIL_OSKDIALOG_UNLOADED.\n");
|
||||
sys_memory_container_destroy(g_extern.console.misc.oskutil_handle.containerid);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
@ -399,13 +420,6 @@ static void system_deinit(void)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
|
||||
#ifdef HAVE_OSKUTIL
|
||||
oskutil_params *osk = &g_extern.console.misc.oskutil_handle;
|
||||
|
||||
if(osk)
|
||||
oskutil_unload(osk);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER)
|
||||
inl_logger_deinit();
|
||||
#endif
|
||||
|
@ -136,6 +136,9 @@ enum menu_enums
|
||||
MODE_UNZIP_TO_CACHEDIR,
|
||||
MODE_UNZIP_DELETE_PENDING,
|
||||
MODE_FILEBROWSER_REFRESH_PENDING,
|
||||
MODE_OSK_DRAW,
|
||||
MODE_OSK_ENTRY_SUCCESS,
|
||||
MODE_OSK_ENTRY_FAIL,
|
||||
};
|
||||
|
||||
// All config related settings go here.
|
||||
|
@ -290,11 +290,10 @@ static int16_t ps3_input_state(void *data, const struct retro_keybind **binds,
|
||||
void oskutil_init(oskutil_params *params, unsigned containersize)
|
||||
{
|
||||
params->flags = 0;
|
||||
params->is_running = false;
|
||||
if(containersize)
|
||||
params->osk_memorycontainer = containersize;
|
||||
else
|
||||
params->osk_memorycontainer = 1024*1024*7;
|
||||
params->osk_memorycontainer = 1024*1024*2;
|
||||
}
|
||||
|
||||
static bool oskutil_enable_key_layout (void)
|
||||
@ -337,18 +336,24 @@ void oskutil_write_initial_message(oskutil_params *params, const wchar_t* msg)
|
||||
|
||||
bool oskutil_start(oskutil_params *params)
|
||||
{
|
||||
memset(params->osk_text_buffer, 0, sizeof(*params->osk_text_buffer));
|
||||
memset(params->osk_text_buffer_char, 0, 256);
|
||||
|
||||
params->text_can_be_fetched = false;
|
||||
|
||||
if (params->flags & OSK_IN_USE)
|
||||
return (true);
|
||||
{
|
||||
RARCH_WARN("OSK util already initialized and in use\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
int ret = sys_memory_container_create(¶ms->containerid, params->osk_memorycontainer);
|
||||
int ret = 0;
|
||||
|
||||
ret = sys_memory_container_create(¶ms->containerid, params->osk_memorycontainer);
|
||||
|
||||
if(ret < 0)
|
||||
return (false);
|
||||
goto do_deinit;
|
||||
|
||||
params->outputInfo.osk_callback_return_param = CELL_OSKDIALOG_INPUT_FIELD_RESULT_OK;
|
||||
params->outputInfo.osk_callback_num_chars = 256;
|
||||
params->outputInfo.osk_callback_return_string = (uint16_t *)params->text_buf;
|
||||
|
||||
memset(params->text_buf, 0, sizeof(*params->text_buf));
|
||||
|
||||
params->inputFieldInfo.osk_inputfield_max_length = CELL_OSKDIALOG_STRING_SIZE;
|
||||
|
||||
@ -358,55 +363,19 @@ bool oskutil_start(oskutil_params *params)
|
||||
return (false);
|
||||
|
||||
ret = pOskLoadAsync(params->containerid, ¶ms->dialogParam, ¶ms->inputFieldInfo);
|
||||
if(ret < 0)
|
||||
return (false);
|
||||
|
||||
if (ret < 0)
|
||||
goto do_deinit;
|
||||
|
||||
params->flags |= OSK_IN_USE;
|
||||
params->is_running = true;
|
||||
g_extern.lifecycle_mode_state |= (1ULL << MODE_OSK_DRAW);
|
||||
|
||||
return (true);
|
||||
return true;
|
||||
|
||||
do_deinit:
|
||||
RARCH_ERR("Could not properly initialize OSK util.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
void oskutil_close(oskutil_params *params)
|
||||
{
|
||||
pOskAbort();
|
||||
}
|
||||
|
||||
void oskutil_finished(oskutil_params *params)
|
||||
{
|
||||
int num;
|
||||
|
||||
params->outputInfo.osk_callback_return_param = CELL_OSKDIALOG_INPUT_FIELD_RESULT_OK;
|
||||
params->outputInfo.osk_callback_num_chars = 256;
|
||||
params->outputInfo.osk_callback_return_string = (uint16_t *)params->osk_text_buffer;
|
||||
|
||||
pOskUnloadAsync(¶ms->outputInfo);
|
||||
|
||||
switch (params->outputInfo.osk_callback_return_param)
|
||||
{
|
||||
case CELL_OSKDIALOG_INPUT_FIELD_RESULT_OK:
|
||||
num = wcstombs(params->osk_text_buffer_char, params->osk_text_buffer, 256);
|
||||
params->osk_text_buffer_char[num]=0;
|
||||
params->text_can_be_fetched = true;
|
||||
break;
|
||||
case CELL_OSKDIALOG_INPUT_FIELD_RESULT_CANCELED:
|
||||
case CELL_OSKDIALOG_INPUT_FIELD_RESULT_ABORT:
|
||||
case CELL_OSKDIALOG_INPUT_FIELD_RESULT_NO_INPUT_TEXT:
|
||||
default:
|
||||
params->osk_text_buffer_char[0]=0;
|
||||
params->text_can_be_fetched = false;
|
||||
break;
|
||||
}
|
||||
|
||||
params->flags &= ~OSK_IN_USE;
|
||||
}
|
||||
|
||||
void oskutil_unload(oskutil_params *params)
|
||||
{
|
||||
sys_memory_container_destroy(params->containerid);
|
||||
params->is_running = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*============================================================
|
||||
@ -454,6 +423,8 @@ static void* ps3_input_init(void)
|
||||
cellPadInit(MAX_PADS);
|
||||
#ifdef HAVE_MOUSE
|
||||
cellMouseInit(MAX_MICE);
|
||||
#endif
|
||||
#ifdef HAVE_OSKUTIL
|
||||
#endif
|
||||
return (void*)-1;
|
||||
}
|
||||
|
@ -29,9 +29,6 @@
|
||||
#define DEADZONE_LOW 55
|
||||
#define DEADZONE_HIGH 210
|
||||
|
||||
#define OSK_IS_RUNNING(object) object.is_running
|
||||
#define OUTPUT_TEXT_STRING(object) object.osk_text_buffer_char
|
||||
|
||||
#ifdef HAVE_OSKUTIL
|
||||
|
||||
typedef struct
|
||||
@ -39,11 +36,8 @@ typedef struct
|
||||
unsigned int osk_memorycontainer;
|
||||
wchar_t init_message[CELL_OSKDIALOG_STRING_SIZE + 1];
|
||||
wchar_t message[CELL_OSKDIALOG_STRING_SIZE + 1];
|
||||
wchar_t osk_text_buffer[CELL_OSKDIALOG_STRING_SIZE + 1];
|
||||
char osk_text_buffer_char[CELL_OSKDIALOG_STRING_SIZE + 1];
|
||||
wchar_t text_buf[CELL_OSKDIALOG_STRING_SIZE + 1];
|
||||
uint32_t flags;
|
||||
bool is_running;
|
||||
bool text_can_be_fetched;
|
||||
sys_memory_container_t containerid;
|
||||
CellOskDialogPoint pos;
|
||||
CellOskDialogInputFieldInfo inputFieldInfo;
|
||||
@ -54,11 +48,6 @@ typedef struct
|
||||
void oskutil_write_message(oskutil_params *params, const wchar_t* msg);
|
||||
void oskutil_write_initial_message(oskutil_params *params, const wchar_t* msg);
|
||||
void oskutil_init(oskutil_params *params, unsigned containersize);
|
||||
bool oskutil_start(oskutil_params *params);
|
||||
void oskutil_stop(oskutil_params *params);
|
||||
void oskutil_finished(oskutil_params *params);
|
||||
void oskutil_close(oskutil_params *params);
|
||||
void oskutil_unload(oskutil_params *params);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user