(PS3 RGUI) Working OSK input

This commit is contained in:
twinaphex 2013-11-15 23:19:44 +01:00
parent be356b7b67
commit 9558a47ada
5 changed files with 95 additions and 38 deletions

View File

@ -341,6 +341,7 @@ typedef struct input_osk_driver
void (*write_initial_msg)(void *data, const void *msg);
bool (*start)(void *data);
void (*lifecycle)(void *data, uint64_t status);
void *(*get_text_buf)(void *data);
const char *ident;
} input_osk_driver_t;

View File

@ -992,6 +992,22 @@ static int menu_iterate_func(void *data, unsigned action)
if (menu_ctx && menu_ctx->set_texture)
menu_ctx->set_texture(rgui, false);
#ifdef HAVE_OSK
// process pending osk init callback
if (g_settings.osk.cb_init != NULL)
{
if (g_settings.osk.cb_init(driver.osk_data))
g_settings.osk.cb_init = NULL;
}
// process pending osk callback
if (g_settings.osk.cb_callback != NULL)
{
if (g_settings.osk.cb_callback(driver.osk_data))
g_settings.osk.cb_callback = NULL;
}
#endif
if (menu_type == RGUI_START_SCREEN)
return menu_start_screen_iterate(rgui, action);
else if (menu_type_is(menu_type) == RGUI_SETTINGS)
@ -1321,21 +1337,6 @@ static int menu_iterate_func(void *data, unsigned action)
break;
}
#ifdef HAVE_OSK
// process pending osk init callback
if (g_settings.osk.cb_init != NULL)
{
if (g_settings.osk.cb_init(driver.osk_data))
g_settings.osk.cb_init = NULL;
}
// process pending osk callback
if (g_settings.osk.cb_callback != NULL)
{
if (g_settings.osk.cb_callback(driver.osk_data))
g_settings.osk.cb_callback = NULL;
}
#endif
// refresh values in case the stack changed
file_list_get_last(rgui->menu_stack, &dir, &menu_type);

View File

@ -286,6 +286,47 @@ int menu_settings_toggle_setting(void *data, unsigned setting, unsigned action,
return menu_set_settings(rgui, setting, action);
}
#ifdef HAVE_OSK
static bool osk_callback_enter_rsound(void *data)
{
if (g_extern.lifecycle_state & (1ULL << MODE_OSK_ENTRY_SUCCESS)
&& driver.osk && driver.osk->get_text_buf)
{
RARCH_LOG("OSK - Applying input data.\n");
char tmp_str[256];
wchar_t *text_buf = (wchar_t*)driver.osk->get_text_buf(driver.osk_data);
int num = wcstombs(tmp_str, text_buf, sizeof(tmp_str));
tmp_str[num] = 0;
strlcpy(g_settings.audio.device, tmp_str, sizeof(g_settings.audio.device));
goto do_exit;
}
else if (g_extern.lifecycle_state & (1ULL << MODE_OSK_ENTRY_FAIL))
goto do_exit;
return false;
do_exit:
g_extern.lifecycle_state &= ~((1ULL << MODE_OSK_ENTRY_SUCCESS) |
(1ULL << MODE_OSK_ENTRY_FAIL));
return true;
}
static bool osk_callback_enter_rsound_init(void *data)
{
if (!driver.osk)
return false;
if (driver.osk->write_initial_msg)
driver.osk->write_initial_msg(driver.osk_data, L"192.168.1.1");
if (driver.osk->write_msg)
driver.osk->write_msg(driver.osk_data, L"Enter IP address for the RSound Server.");
if (driver.osk->start)
driver.osk->start(driver.osk_data);
return true;
}
#endif
int menu_set_settings(void *data, unsigned setting, unsigned action)
{
rgui_handle_t *rgui = (rgui_handle_t*)data;
@ -1297,6 +1338,15 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
#ifndef HAVE_RMENU
rgui->need_refresh = true;
#endif
break;
case RGUI_SETTINGS_RSOUND_SERVER_IP_ADDRESS:
#if defined(HAVE_RSOUND) && defined(HAVE_OSK)
if (action == RGUI_ACTION_OK)
{
g_settings.osk.cb_init = osk_callback_enter_rsound_init;
g_settings.osk.cb_callback = osk_callback_enter_rsound;
}
#endif
break;
case RGUI_SETTINGS_SHADER_APPLY:

View File

@ -607,7 +607,7 @@ struct global
struct
{
unsigned mode;
#ifdef _XBOX1
#ifdef RARCH_CONSOLE
unsigned volume_level;
#endif
} sound;

View File

@ -44,22 +44,6 @@
#define DEADZONE_LOW 55
#define DEADZONE_HIGH 210
#ifdef HAVE_OSK
typedef struct ps3_osk
{
unsigned int osk_memorycontainer;
wchar_t init_message[CELL_OSKDIALOG_STRING_SIZE + 1];
wchar_t message[CELL_OSKDIALOG_STRING_SIZE + 1];
wchar_t text_buf[CELL_OSKDIALOG_STRING_SIZE + 1];
uint32_t flags;
sys_memory_container_t containerid;
CellOskDialogPoint pos;
CellOskDialogInputFieldInfo inputFieldInfo;
CellOskDialogCallbackReturnParam outputInfo;
CellOskDialogParam dialogParam;
} ps3_osk_t;
#endif
/*============================================================
PS3 PAD
============================================================ */
@ -270,9 +254,23 @@ static int16_t ps3_input_state(void *data, const struct retro_keybind **binds,
#ifdef HAVE_OSK
typedef struct ps3_osk
{
unsigned int osk_memorycontainer;
wchar_t init_message[CELL_OSKDIALOG_STRING_SIZE + 1];
wchar_t message[CELL_OSKDIALOG_STRING_SIZE + 1];
wchar_t text_buf[CELL_OSKDIALOG_STRING_SIZE + 1];
uint32_t flags;
sys_memory_container_t containerid;
CellOskDialogPoint pos;
CellOskDialogInputFieldInfo inputFieldInfo;
CellOskDialogCallbackReturnParam outputInfo;
CellOskDialogParam dialogParam;
} ps3_osk_t;
#define OSK_IN_USE 1
void *oskutil_init(size_t size)
static void *oskutil_init(size_t size)
{
ps3_osk_t *params = (ps3_osk_t*)calloc(1, sizeof(*params));
@ -288,7 +286,7 @@ void *oskutil_init(size_t size)
return params;
}
void oskutil_free(void *data)
static void oskutil_free(void *data)
{
ps3_osk_t *params = (ps3_osk_t*)data;
@ -325,21 +323,21 @@ static void oskutil_create_activation_parameters(void *data)
params->dialogParam.osk_prohibit_flags = 0;
}
void oskutil_write_message(void *data, const void *data_msg)
static void oskutil_write_message(void *data, const void *data_msg)
{
ps3_osk_t *params = (ps3_osk_t*)data;
const wchar_t *msg = (const wchar_t*)data_msg;
params->inputFieldInfo.osk_inputfield_message = (uint16_t*)msg;
}
void oskutil_write_initial_message(void *data, const void *data_msg)
static void oskutil_write_initial_message(void *data, const void *data_msg)
{
ps3_osk_t *params = (ps3_osk_t*)data;
const wchar_t *msg = (const wchar_t*)data_msg;
params->inputFieldInfo.osk_inputfield_starttext = (uint16_t*)msg;
}
bool oskutil_start(void *data)
static bool oskutil_start(void *data)
{
ps3_osk_t *params = (ps3_osk_t*)data;
@ -377,7 +375,13 @@ do_deinit:
return false;
}
void oskutil_lifecycle(void *data, uint64_t status)
static void *oskutil_get_text_buf(void *data)
{
ps3_osk_t *osk = (ps3_osk_t*)data;
return osk->text_buf;
}
static void oskutil_lifecycle(void *data, uint64_t status)
{
ps3_osk_t *osk = (ps3_osk_t*)data;
@ -423,6 +427,7 @@ const input_osk_driver_t input_ps3_osk = {
oskutil_write_initial_message,
oskutil_start,
oskutil_lifecycle,
oskutil_get_text_buf,
"ps3osk"
};
#endif