Start to approach OSK driver in a different way

This commit is contained in:
twinaphex 2015-01-29 20:33:27 +01:00
parent f258950bcf
commit fc373630ce
22 changed files with 275 additions and 643 deletions

View File

@ -109,7 +109,6 @@ OBJ += frontend/frontend.o \
gfx/video_monitor.o \
gfx/video_pixel_converter.o \
gfx/video_viewport.o \
osk/osk_driver.o \
camera/camera_driver.o \
menu/menu_driver.o \
location/location_driver.o \
@ -162,7 +161,6 @@ OBJ += frontend/frontend.o \
audio/drivers/nullaudio.o \
input/drivers/nullinput.o \
input/drivers_joypad/nullinput_joypad.o \
osk/drivers/nullosk.o \
playlist.o \
movie.o \
record/record_driver.o \

View File

@ -189,6 +189,12 @@ const char* config_get_audio_driver_options(void)
options = (char*)calloc(options_len, sizeof(char));
if (!options)
{
string_list_free(options_l);
return NULL;
}
string_list_join_concat(options, options_len, options_l, "|");
string_list_free(options_l);

View File

@ -61,12 +61,6 @@ static const void *find_driver_nonempty(const char *label, int i,
if (drv)
strlcpy(str, location_driver_find_ident(i), sizeof_str);
}
else if (!strcmp(label, "osk_driver"))
{
drv = osk_driver_find_handle(i);
if (drv)
strlcpy(str, osk_driver_find_ident(i), sizeof_str);
}
#ifdef HAVE_MENU
else if (!strcmp(label, "menu_driver"))
{
@ -190,7 +184,6 @@ void init_drivers_pre(void)
find_input_driver();
find_camera_driver();
find_location_driver();
find_osk_driver();
#ifdef HAVE_MENU
find_menu_driver();
#endif
@ -303,8 +296,6 @@ void init_drivers(int flags)
driver.camera_data_own = false;
if (flags & DRIVER_LOCATION)
driver.location_data_own = false;
if (flags & DRIVER_OSK)
driver.osk_data_own = false;
#ifdef HAVE_MENU
/* By default, we want the menu to persist through driver reinits. */
@ -339,9 +330,6 @@ void init_drivers(int flags)
if ((flags & DRIVER_LOCATION) && driver.location_active)
init_location();
if (flags & DRIVER_OSK)
init_osk();
#ifdef HAVE_MENU
if (flags & DRIVER_MENU)
{
@ -413,12 +401,6 @@ void uninit_drivers(int flags)
driver.location_data = NULL;
}
if ((flags & DRIVER_OSK) && !driver.osk_data_own)
{
uninit_osk();
driver.osk_data = NULL;
}
if ((flags & DRIVER_INPUT) && !driver.input_data_own)
driver.input_data = NULL;

View File

@ -31,7 +31,6 @@
#include "audio/audio_driver.h"
#include "menu/menu_driver.h"
#include "osk/osk_driver.h"
#include "camera/camera_driver.h"
#include "location/location_driver.h"
#include "audio/audio_resampler_driver.h"
@ -169,11 +168,10 @@ enum
DRIVER_AUDIO = 1 << 0,
DRIVER_VIDEO = 1 << 1,
DRIVER_INPUT = 1 << 2,
DRIVER_OSK = 1 << 3,
DRIVER_CAMERA = 1 << 4,
DRIVER_LOCATION = 1 << 5,
DRIVER_MENU = 1 << 6,
DRIVERS_VIDEO_INPUT = 1 << 7
DRIVER_CAMERA = 1 << 3,
DRIVER_LOCATION = 1 << 4,
DRIVER_MENU = 1 << 5,
DRIVERS_VIDEO_INPUT = 1 << 6
};
/* Drivers for RARCH_CMD_DRIVERS_DEINIT and RARCH_CMD_DRIVERS_INIT */
@ -181,7 +179,6 @@ enum
( DRIVER_AUDIO \
| DRIVER_VIDEO \
| DRIVER_INPUT \
| DRIVER_OSK \
| DRIVER_CAMERA \
| DRIVER_LOCATION \
| DRIVER_MENU \
@ -193,7 +190,6 @@ typedef struct driver
const audio_driver_t *audio;
const video_driver_t *video;
const input_driver_t *input;
const input_osk_driver_t *osk;
const camera_driver_t *camera;
const location_driver_t *location;
const rarch_resampler_t *resampler;
@ -205,7 +201,6 @@ typedef struct driver
void *video_context_data;
void *video_shader_data;
void *input_data;
void *osk_data;
void *camera_data;
void *location_data;
void *resampler_data;
@ -251,7 +246,6 @@ typedef struct driver
bool input_data_own;
bool camera_data_own;
bool location_data_own;
bool osk_data_own;
#ifdef HAVE_MENU
bool menu_data_own;
#endif
@ -289,6 +283,7 @@ typedef struct driver
#ifdef HAVE_OVERLAY
input_overlay_t *overlay;
input_overlay_t *osk_overlay;
input_overlay_state_t overlay_state;
#endif

View File

@ -105,6 +105,7 @@ struct defaults
char core_dir[PATH_MAX_LENGTH];
char core_info_dir[PATH_MAX_LENGTH];
char overlay_dir[PATH_MAX_LENGTH];
char osk_overlay_dir[PATH_MAX_LENGTH];
char port_dir[PATH_MAX_LENGTH];
char shader_dir[PATH_MAX_LENGTH];
char savestate_dir[PATH_MAX_LENGTH];
@ -239,12 +240,6 @@ struct settings
int update_interval_distance;
} location;
struct
{
char driver[32];
bool enable;
} osk;
struct
{
char driver[32];
@ -309,6 +304,14 @@ struct settings
char remapping_path[PATH_MAX_LENGTH];
} input;
struct
{
bool enable;
char overlay[PATH_MAX_LENGTH];
float opacity;
float scale;
} osk;
struct
{
unsigned mode;
@ -462,6 +465,7 @@ struct global
#ifdef HAVE_OVERLAY
char overlay_dir[PATH_MAX_LENGTH];
char osk_overlay_dir[PATH_MAX_LENGTH];
#endif
bool block_patch;
@ -608,12 +612,6 @@ struct global
bool movie_end;
} bsv;
struct
{
bool (*cb_init)(void *data);
bool (*cb_callback)(void *data);
} osk;
bool sram_load_disable;
bool sram_save_disable;
bool use_sram;

View File

@ -484,7 +484,9 @@ void init_video(void)
init_video_input(tmp);
rarch_main_command(RARCH_CMD_OVERLAY_DEINIT);
rarch_main_command(RARCH_CMD_OSK_OVERLAY_DEINIT);
rarch_main_command(RARCH_CMD_OVERLAY_INIT);
rarch_main_command(RARCH_CMD_OSK_OVERLAY_INIT);
g_extern.measure_data.frame_time_samples_count = 0;

View File

@ -361,12 +361,6 @@ INPUT
#include "../input/drivers_joypad/winxinput_joypad.c"
#endif
#if defined(__CELLOS_LV2__)
#include "../osk/drivers/ps3_osk.c"
#endif
#include "../osk/drivers/nullosk.c"
#if defined(__linux__) && !defined(ANDROID)
#include "../input/drivers/linuxraw_input.c"
#include "../input/drivers_joypad/linuxraw_joypad.c"
@ -515,7 +509,6 @@ DRIVERS
#include "../input/input_driver.c"
#include "../audio/audio_driver.c"
#include "../audio/audio_monitor.c"
#include "../osk/osk_driver.c"
#include "../camera/camera_driver.c"
#include "../location/location_driver.c"
#include "../menu/menu_driver.c"

View File

@ -14,9 +14,11 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include "input_overlay.h"
#include "../general.h"
#include "../driver.h"
#include "../general.h"
#include <file/config_file.h>
#include <compat/posix_string.h>
#include "input_common.h"
@ -565,7 +567,8 @@ end:
return ret;
}
static void input_overlay_load_active(input_overlay_t *ol)
static void input_overlay_load_active(input_overlay_t *ol,
float opacity)
{
if (!ol)
return;
@ -573,7 +576,7 @@ static void input_overlay_load_active(input_overlay_t *ol)
ol->iface->load(ol->iface_data, ol->active->load_images,
ol->active->load_images_size);
input_overlay_set_alpha_mod(ol, g_settings.input.overlay_opacity);
input_overlay_set_alpha_mod(ol, opacity);
input_overlay_set_vertex_geom(ol);
ol->iface->full_screen(ol->iface_data, ol->active->full_screen);
}
@ -587,16 +590,20 @@ static void input_overlay_load_active(input_overlay_t *ol)
*
* Returns: Overlay handle on success, otherwise NULL.
**/
input_overlay_t *input_overlay_new(const char *path, bool enable)
input_overlay_t *input_overlay_new(const char *path, bool enable,
float opacity, float scale_factor)
{
input_overlay_t *ol = (input_overlay_t*)calloc(1, sizeof(*ol));
RARCH_LOG("path is: %s\n", path);
if (!ol)
goto error;
ol->overlay_path = strdup(path);
if (!ol->overlay_path)
{
RARCH_LOG("exits here, path is: %s.\n", path);
free(ol);
return NULL;
}
@ -619,11 +626,11 @@ input_overlay_t *input_overlay_new(const char *path, bool enable)
ol->active = &ol->overlays[0];
input_overlay_load_active(ol);
input_overlay_load_active(ol, opacity);
input_overlay_enable(ol, enable);
input_overlay_set_alpha_mod(ol, g_settings.input.overlay_opacity);
input_overlay_set_scale_factor(ol, g_settings.input.overlay_scale);
input_overlay_set_alpha_mod(ol, opacity);
input_overlay_set_scale_factor(ol, scale_factor);
ol->next_index = (ol->index + 1) % ol->size;
return ol;
@ -802,11 +809,11 @@ static void input_overlay_update_desc_geom(input_overlay_t *ol,
* update the range modifiers for pressed/unpressed regions
* and alpha mods.
**/
void input_overlay_post_poll(input_overlay_t *ol)
void input_overlay_post_poll(input_overlay_t *ol, float opacity)
{
size_t i;
input_overlay_set_alpha_mod(ol, g_settings.input.overlay_opacity);
input_overlay_set_alpha_mod(ol, opacity);
for (i = 0; i < ol->active->size; i++)
{
@ -826,7 +833,7 @@ void input_overlay_post_poll(input_overlay_t *ol)
if (desc->image.pixels)
ol->iface->set_alpha(ol->iface_data, desc->image_index,
desc->alpha_mod * g_settings.input.overlay_opacity);
desc->alpha_mod * opacity);
}
input_overlay_update_desc_geom(ol, desc);
@ -841,12 +848,12 @@ void input_overlay_post_poll(input_overlay_t *ol)
* Call when there is nothing to poll. Allows overlay to
* clear certain state.
**/
void input_overlay_poll_clear(input_overlay_t *ol)
void input_overlay_poll_clear(input_overlay_t *ol, float opacity)
{
size_t i;
ol->blocked = false;
input_overlay_set_alpha_mod(ol, g_settings.input.overlay_opacity);
input_overlay_set_alpha_mod(ol, opacity);
for (i = 0; i < ol->active->size; i++)
{
@ -872,7 +879,7 @@ void input_overlay_poll_clear(input_overlay_t *ol)
* Switch to the next available overlay
* screen.
**/
void input_overlay_next(input_overlay_t *ol)
void input_overlay_next(input_overlay_t *ol, float opacity)
{
if (!ol)
return;
@ -880,7 +887,7 @@ void input_overlay_next(input_overlay_t *ol)
ol->index = ol->next_index;
ol->active = &ol->overlays[ol->index];
input_overlay_load_active(ol);
input_overlay_load_active(ol, opacity);
ol->blocked = true;
ol->next_index = (ol->index + 1) % ol->size;
@ -937,6 +944,5 @@ void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod)
return;
for (i = 0; i < ol->active->load_images_size; i++)
ol->iface->set_alpha(ol->iface_data, i,
g_settings.input.overlay_opacity);
ol->iface->set_alpha(ol->iface_data, i, mod);
}

View File

@ -154,7 +154,8 @@ typedef struct input_overlay_state
*
* Returns: Overlay handle on success, otherwise NULL.
**/
input_overlay_t *input_overlay_new(const char *overlay, bool enable);
input_overlay_t *input_overlay_new(const char *path, bool enable,
float alpha_mod, float scale_factor);
/**
* input_overlay_free:
@ -201,21 +202,23 @@ void input_overlay_poll(input_overlay_t *ol,
/**
* input_overlay_post_poll:
* @ol : overlay handle
*
*
* Called after all the input_overlay_poll() calls to
* update the range modifiers for pressed/unpressed regions
* and alpha mods.
**/
void input_overlay_post_poll(input_overlay_t *ol);
void input_overlay_post_poll(input_overlay_t *ol, float opacity);
/**
* input_overlay_poll_clear:
* @ol : overlay handle
* @opacity : Opacity of overlay.
*
* Call when there is nothing to poll. Allows overlay to
* clear certain state.
**/
void input_overlay_poll_clear(input_overlay_t *ol);
void input_overlay_poll_clear(input_overlay_t *ol, float opacity);
/**
* input_overlay_set_alpha_mod:
@ -243,7 +246,7 @@ void input_overlay_set_scale_factor(input_overlay_t *ol, float scale);
* Switch to the next available overlay
* screen.
**/
void input_overlay_next(input_overlay_t *ol);
void input_overlay_next(input_overlay_t *ol, float opacity);
#ifdef __cplusplus
}

View File

@ -17,6 +17,7 @@
#include "keyboard_line.h"
#include "../general.h"
#include "../driver.h"
#include "../retroarch.h"
#include <stddef.h>
#include <string.h>
#include <stddef.h>
@ -49,6 +50,8 @@ void input_keyboard_line_free(input_keyboard_line_t *state)
free(state->buffer);
free(state);
rarch_main_command(RARCH_CMD_OSK_OVERLAY_STOP);
}
/**
@ -72,6 +75,9 @@ input_keyboard_line_t *input_keyboard_line_new(void *userdata,
state->cb = cb;
state->userdata = userdata;
rarch_main_command(RARCH_CMD_OSK_OVERLAY_START);
return state;
}
@ -243,7 +249,7 @@ void input_keyboard_event(bool down, unsigned code,
if (!down)
return;
if (enable_osk && code != 0x12d)
if (driver.osk_active && code != 0x12d)
{
if (!input_keyboard_line_event(g_keyboard_line, (char)code))
return;

View File

@ -465,10 +465,11 @@ static int16_t input_state(unsigned port, unsigned device,
#ifdef HAVE_OVERLAY
/*
* input_poll_overlay:
* @overlay_device : pointer to overlay
*
* Poll pressed buttons/keys on currently active overlay.
**/
static inline void input_poll_overlay(void)
static inline void input_poll_overlay(input_overlay_t *overlay_device, float opacity)
{
input_overlay_state_t old_key_state;
unsigned i, j, device;
@ -479,7 +480,7 @@ static inline void input_poll_overlay(void)
sizeof(driver.overlay_state.keys));
memset(&driver.overlay_state, 0, sizeof(driver.overlay_state));
device = input_overlay_full_screen(driver.overlay) ?
device = input_overlay_full_screen(overlay_device) ?
RARCH_DEVICE_POINTER_SCREEN : RETRO_DEVICE_POINTER;
for (i = 0;
@ -493,7 +494,7 @@ static inline void input_poll_overlay(void)
int16_t y = driver.input->input_state(driver.input_data, NULL, 0,
device, i, RETRO_DEVICE_ID_POINTER_Y);
input_overlay_poll(driver.overlay, &polled_data, x, y);
input_overlay_poll(overlay_device, &polled_data, x, y);
driver.overlay_state.buttons |= polled_data.buttons;
@ -587,9 +588,9 @@ static inline void input_poll_overlay(void)
}
if (polled)
input_overlay_post_poll(driver.overlay);
input_overlay_post_poll(overlay_device, opacity);
else
input_overlay_poll_clear(driver.overlay);
input_overlay_poll_clear(overlay_device, opacity);
}
#endif
@ -600,11 +601,20 @@ static inline void input_poll_overlay(void)
**/
static void input_poll(void)
{
#ifdef HAVE_OVERLAY
input_overlay_t *overlay_device = driver.overlay;
float opacity = g_settings.input.overlay_opacity;
if (driver.osk_active)
{
overlay_device = driver.osk_overlay;
opacity = g_settings.osk.opacity;
}
#endif
driver.input->poll(driver.input_data);
#ifdef HAVE_OVERLAY
if (driver.overlay)
input_poll_overlay();
if (overlay_device)
input_poll_overlay(overlay_device, opacity);
#endif
#ifdef HAVE_COMMAND

View File

@ -3205,6 +3205,13 @@ static int deferred_push_input_overlay(void *data, void *userdata,
MENU_FILE_OVERLAY, "cfg", NULL);
}
static int deferred_push_input_osk_overlay(void *data, void *userdata,
const char *path, const char *label, unsigned type)
{
return menu_entries_parse_list((file_list_t*)data, (file_list_t*)userdata, path, label, type,
MENU_FILE_OVERLAY, "cfg", NULL);
}
static int deferred_push_video_font_path(void *data, void *userdata,
const char *path, const char *label, unsigned type)
{
@ -4386,6 +4393,8 @@ static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
cbs->action_deferred_push = deferred_push_audio_dsp_plugin;
else if (!strcmp(label, "input_overlay"))
cbs->action_deferred_push = deferred_push_input_overlay;
else if (!strcmp(label, "input_osk_overlay"))
cbs->action_deferred_push = deferred_push_input_osk_overlay;
else if (!strcmp(label, "video_font_path"))
cbs->action_deferred_push = deferred_push_video_font_path;
else if (!strcmp(label, "game_history_path"))

View File

@ -1,73 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include "../../driver.h"
static void *nullosk_init(size_t size)
{
return (void*)-1;
}
static void nullosk_free(void *data)
{
}
static bool nullosk_enable_key_layout(void *data)
{
return true;
}
static void nullosk_create_activation_parameters(void *data)
{
}
static void nullosk_write_message(void *data, const void *data_msg)
{
}
static void nullosk_write_initial_message(void *data, const void *data_msg)
{
}
static bool nullosk_start(void *data)
{
return true;
}
static void *nullosk_get_text_buf(void *data)
{
return NULL;
}
static void nullosk_lifecycle(void *data, uint64_t status)
{
}
input_osk_driver_t input_null_osk = {
nullosk_init,
nullosk_free,
nullosk_enable_key_layout,
nullosk_create_activation_parameters,
nullosk_write_message,
nullosk_write_initial_message,
nullosk_start,
nullosk_lifecycle,
nullosk_get_text_buf,
"null"
};

View File

@ -1,197 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <sys/memory.h>
#include <wchar.h>
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
static void *oskutil_init(size_t size)
{
ps3_osk_t *params = (ps3_osk_t*)calloc(1, sizeof(*params));
if (!params)
return NULL;
params->flags = 0;
if (size)
params->osk_memorycontainer = size;
else
params->osk_memorycontainer = 1024*1024*2;
return params;
}
static void oskutil_free(void *data)
{
ps3_osk_t *params = (ps3_osk_t*)data;
if (params)
free(params);
}
static bool oskutil_enable_key_layout(void *data)
{
(void)data;
if (pOskSetKeyLayoutOption(CELL_OSKDIALOG_10KEY_PANEL | CELL_OSKDIALOG_FULLKEY_PANEL) < 0)
return false;
return true;
}
static void oskutil_create_activation_parameters(void *data)
{
ps3_osk_t *params = (ps3_osk_t*)data;
params->dialogParam.controlPoint.x = 0.0;
params->dialogParam.controlPoint.y = 0.0;
int32_t LayoutMode = CELL_OSKDIALOG_LAYOUTMODE_X_ALIGN_CENTER | CELL_OSKDIALOG_LAYOUTMODE_Y_ALIGN_TOP;
pOskSetLayoutMode(LayoutMode);
params->dialogParam.osk_allowed_panels =
CELL_OSKDIALOG_PANELMODE_ALPHABET |
CELL_OSKDIALOG_PANELMODE_NUMERAL |
CELL_OSKDIALOG_PANELMODE_NUMERAL_FULL_WIDTH |
CELL_OSKDIALOG_PANELMODE_ENGLISH;
params->dialogParam.firstViewPanel = CELL_OSKDIALOG_PANELMODE_ENGLISH;
params->dialogParam.osk_prohibit_flags = 0;
}
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;
}
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;
}
static bool oskutil_start(void *data)
{
ps3_osk_t *params = (ps3_osk_t*)data;
if (params->flags & OSK_IN_USE)
{
RARCH_WARN("OSK util already initialized and in use\n");
return true;
}
if (sys_memory_container_create(&params->containerid, params->osk_memorycontainer) < 0)
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;
oskutil_create_activation_parameters(params);
if (!oskutil_enable_key_layout(params))
return (false);
if (pOskLoadAsync(params->containerid, &params->dialogParam, &params->inputFieldInfo) < 0)
goto do_deinit;
params->flags |= OSK_IN_USE;
return true;
do_deinit:
RARCH_ERR("Could not properly initialize OSK util.\n");
return false;
}
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;
switch (status)
{
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:
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");
/* TODO */
}
else
{
RARCH_LOG("Setting MODE_OSK_ENTRY_FAIL.\n");
/* TODO */
}
osk->flags &= ~OSK_IN_USE;
break;
case CELL_SYSUTIL_OSKDIALOG_UNLOADED:
RARCH_LOG("CELL_SYSUTIL_OSKDIALOG_UNLOADED.\n");
sys_memory_container_destroy(osk->containerid);
break;
}
}
input_osk_driver_t input_ps3_osk = {
oskutil_init,
oskutil_free,
oskutil_enable_key_layout,
oskutil_create_activation_parameters,
oskutil_write_message,
oskutil_write_initial_message,
oskutil_start,
oskutil_lifecycle,
oskutil_get_text_buf,
"ps3"
};

View File

@ -1,148 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <string/string_list.h>
#include "osk_driver.h"
#include "../driver.h"
#include "../general.h"
static const input_osk_driver_t *osk_drivers[] = {
#ifdef __CELLOS_LV2__
&input_ps3_osk,
#endif
&input_null_osk,
NULL,
};
/**
* osk_driver_find_handle:
* @idx : index of driver to get handle to.
*
* Returns: handle to OSK driver at index. Can be NULL
* if nothing found.
**/
const void *osk_driver_find_handle(int idx)
{
const void *drv = osk_drivers[idx];
if (!drv)
return NULL;
return drv;
}
/**
* osk_driver_find_ident:
* @idx : index of driver to get handle to.
*
* Returns: Human-readable identifier of OSK driver at index. Can be NULL
* if nothing found.
**/
const char *osk_driver_find_ident(int idx)
{
const input_osk_driver_t *drv = osk_drivers[idx];
if (!drv)
return NULL;
return drv->ident;
}
/**
* config_get_osk_driver_options:
*
* Get an enumerated list of all OSK (onscreen keyboard) driver names,
* separated by '|'.
*
* Returns: string listing of all OSK (onscreen keyboard) driver names,
* separated by '|'.
**/
const char* config_get_osk_driver_options(void)
{
union string_list_elem_attr attr;
unsigned i;
char *options = NULL;
int options_len = 0;
struct string_list *options_l = string_list_new();
attr.i = 0;
for (i = 0; osk_driver_find_handle(i); i++)
{
const char *opt = osk_driver_find_ident(i);
options_len += strlen(opt) + 1;
string_list_append(options_l, opt, attr);
}
options = (char*)calloc(options_len, sizeof(char));
string_list_join_concat(options, options_len, options_l, "|");
string_list_free(options_l);
options_l = NULL;
return options;
}
/**
* find_osk_driver:
*
* Find OSK (onscreen keyboard) driver.
**/
void find_osk_driver(void)
{
int i = find_driver_index("osk_driver", g_settings.osk.driver);
if (i >= 0)
driver.osk = (const input_osk_driver_t*)osk_driver_find_handle(i);
else
{
unsigned d;
RARCH_ERR("Couldn't find any OSK driver named \"%s\"\n",
g_settings.osk.driver);
RARCH_LOG_OUTPUT("Available OSK drivers are:\n");
for (d = 0; osk_driver_find_handle(d); d++)
RARCH_LOG_OUTPUT("\t%s\n", osk_driver_find_ident(d));
RARCH_WARN("Going to default to first OSK driver...\n");
driver.osk = (const input_osk_driver_t*)osk_driver_find_handle(0);
if (!driver.osk)
rarch_fail(1, "find_osk_driver()");
}
}
void init_osk(void)
{
/* Resource leaks will follow if osk is initialized twice. */
if (driver.osk_data)
return;
find_osk_driver();
/* FIXME - refactor params later based on semantics */
driver.osk_data = driver.osk->init(0);
if (!driver.osk_data)
{
RARCH_ERR("Failed to initialize OSK driver. Will continue without OSK.\n");
driver.osk_active = false;
}
}
void uninit_osk(void)
{
if (driver.osk_data && driver.osk && driver.osk->free)
driver.osk->free(driver.osk_data);
driver.osk_data = NULL;
}

View File

@ -1,89 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __OSK_DRIVER__H
#define __OSK_DRIVER__H
#include <stdint.h>
#include <stddef.h>
#include <boolean.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct input_osk_driver
{
void *(*init)(size_t size);
void (*free)(void *data);
bool (*enable_key_layout)(void *data);
void (*oskutil_create_activation_parameters)(void *data);
void (*write_msg)(void *data, const void *msg);
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;
extern input_osk_driver_t input_ps3_osk;
extern input_osk_driver_t input_null_osk;
/**
* osk_driver_find_handle:
* @index : index of driver to get handle to.
*
* Returns: handle to OSK driver at index. Can be NULL
* if nothing found.
**/
const void *osk_driver_find_handle(int index);
/**
* osk_driver_find_ident:
* @index : index of driver to get handle to.
*
* Returns: Human-readable identifier of OSK driver at index. Can be NULL
* if nothing found.
**/
const char *osk_driver_find_ident(int index);
/**
* config_get_osk_driver_options:
*
* Get an enumerated list of all OSK (onscreen keyboard) driver names,
* separated by '|'.
*
* Returns: string listing of all OSK (onscreen keyboard) driver names,
* separated by '|'.
**/
const char* config_get_osk_driver_options(void);
/**
* find_osk_driver:
*
* Find OSK (onscreen keyboard) driver.
**/
void find_osk_driver(void);
void init_osk(void);
void uninit_osk(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -2669,6 +2669,7 @@ bool rarch_main_command(unsigned cmd)
if (driver.overlay)
input_overlay_free(driver.overlay);
driver.overlay = NULL;
memset(&driver.overlay_state, 0, sizeof(driver.overlay_state));
#endif
break;
@ -2678,14 +2679,52 @@ bool rarch_main_command(unsigned cmd)
if (!*g_settings.input.overlay)
break;
driver.overlay = input_overlay_new(g_settings.input.overlay, g_settings.input.overlay_enable);
driver.overlay = input_overlay_new(g_settings.input.overlay, g_settings.input.overlay_enable,
g_settings.input.overlay_opacity, g_settings.input.overlay_scale);
if (!driver.overlay)
RARCH_ERR("Failed to load overlay.\n");
#endif
break;
case RARCH_CMD_OSK_OVERLAY_STOP:
#ifdef HAVE_OVERLAY
driver.osk_active = false;
g_settings.osk.opacity = 0;
input_overlay_set_alpha_mod(driver.osk_overlay,
g_settings.osk.opacity);
#endif
break;
case RARCH_CMD_OSK_OVERLAY_START:
#ifdef HAVE_OVERLAY
driver.osk_active = true;
g_settings.osk.opacity = 100;
input_overlay_set_alpha_mod(driver.osk_overlay,
g_settings.osk.opacity);
#endif
break;
case RARCH_CMD_OSK_OVERLAY_DEINIT:
#ifdef HAVE_OVERLAY
if (driver.osk_active)
return false;
if (driver.osk_overlay)
input_overlay_free(driver.osk_overlay);
driver.osk_overlay = NULL;
#endif
break;
case RARCH_CMD_OSK_OVERLAY_INIT:
#ifdef HAVE_OVERLAY
if (driver.osk_active)
return false;
rarch_main_command(RARCH_CMD_OSK_OVERLAY_DEINIT);
driver.osk_overlay = input_overlay_new(g_settings.osk.overlay, g_settings.osk.enable,
g_settings.osk.opacity, g_settings.osk.scale);
if (!driver.osk_overlay)
RARCH_ERR("Failed to load OSK overlay.\n");
#endif
break;
case RARCH_CMD_OVERLAY_NEXT:
#ifdef HAVE_OVERLAY
input_overlay_next(driver.overlay);
input_overlay_next(driver.overlay, g_settings.input.overlay_opacity);
#endif
break;
case RARCH_CMD_DSP_FILTER_DEINIT:

View File

@ -297,8 +297,6 @@
# Enable or disable the current overlay.
# input_overlay_enable = true
# If enabled, overrides the input binds with the remapped binds set for the current core.
# input_remap_binds_enable = true
# Path to input overlay
# input_overlay =
@ -309,6 +307,23 @@
# Overlay scale
# input_overlay_scale = 1.0
#### OSK (Onscreen Keyboard) Overlay
# Defines a directory where overlays are kept for easy access.
# osk_overlay_directory =
# Enable OSK overlay.
# input_osk_overlay_enable = true
# Path to OSK overlay
# input_osk_overlay =
# OSK Overlay opacity
# input_osk_overlay_opacity = 1.0
# OSK Overlay scale
# input_osk_overlay_scale = 1.0
#### Input
# Input driver. Depending on video driver, it might force a different input driver.
@ -320,6 +335,9 @@
# Path to input remapping file.
# input_remapping_path =
# If enabled, overrides the input binds with the remapped binds set for the current core.
# input_remap_binds_enable = true
# Maximum amount of users supported by RetroArch.
# input_max_users = 16

View File

@ -70,7 +70,15 @@ enum basic_event
RARCH_CMD_OVERLAY_SET_ALPHA_MOD,
/* Cycle to next overlay. */
RARCH_CMD_OVERLAY_NEXT,
/* Start OSK overlay. */
RARCH_CMD_OSK_OVERLAY_START,
/* Stops OSK overlay. */
RARCH_CMD_OSK_OVERLAY_STOP,
/* Initializes graphics filter. */
RARCH_CMD_OSK_OVERLAY_INIT,
/* Initializes overlay. */
RARCH_CMD_OSK_OVERLAY_DEINIT,
/* Deinitializes overlay. */
RARCH_CMD_DSP_FILTER_INIT,
/* Deinitializes graphics filter. */
RARCH_CMD_DSP_FILTER_DEINIT,

View File

@ -290,26 +290,6 @@ const char *config_get_default_menu(void)
}
#endif
/**
* config_get_default_osk:
*
* Gets default OSK driver.
*
* Returns: Default OSK driver.
**/
const char *config_get_default_osk(void)
{
switch (OSK_DEFAULT_DRIVER)
{
case OSK_PS3:
return "ps3";
default:
break;
}
return "null";
}
/**
* config_get_default_camera:
*
@ -376,7 +356,6 @@ static void config_set_defaults(void)
#endif
const char *def_camera = config_get_default_camera();
const char *def_location = config_get_default_location();
const char *def_osk = config_get_default_osk();
if (def_camera)
strlcpy(g_settings.camera.driver,
@ -384,9 +363,6 @@ static void config_set_defaults(void)
if (def_location)
strlcpy(g_settings.location.driver,
def_location, sizeof(g_settings.location.driver));
if (def_osk)
strlcpy(g_settings.osk.driver,
def_osk, sizeof(g_settings.osk.driver));
if (def_video)
strlcpy(g_settings.video.driver,
def_video, sizeof(g_settings.video.driver));
@ -677,6 +653,19 @@ static void config_set_defaults(void)
g_extern.overlay_dir,
"gamepads/retropad/retropad.cfg",
sizeof(g_settings.input.overlay));
#endif
}
if (*g_defaults.osk_overlay_dir)
{
fill_pathname_expand_special(g_extern.osk_overlay_dir,
g_defaults.osk_overlay_dir, sizeof(g_extern.osk_overlay_dir));
#ifdef RARCH_MOBILE
if (!*g_settings.input.overlay)
fill_pathname_join(g_settings.osk.overlay,
g_extern.osk_overlay_dir,
"overlays/keyboards/US-101/US-101.cfg",
sizeof(g_settings.osk.overlay));
#endif
}
#endif
@ -1362,6 +1351,15 @@ static bool config_load_file(const char *path, bool set_defaults)
CONFIG_GET_BOOL(input.overlay_enable, "input_overlay_enable");
CONFIG_GET_FLOAT(input.overlay_opacity, "input_overlay_opacity");
CONFIG_GET_FLOAT(input.overlay_scale, "input_overlay_scale");
CONFIG_GET_PATH_EXTERN(osk_overlay_dir, "osk_overlay_directory");
if (!strcmp(g_extern.osk_overlay_dir, "default"))
*g_extern.osk_overlay_dir = '\0';
CONFIG_GET_PATH(osk.overlay, "input_osk_overlay");
CONFIG_GET_BOOL(osk.enable, "input_osk_overlay_enable");
CONFIG_GET_FLOAT(osk.opacity, "input_osk_overlay_opacity");
CONFIG_GET_FLOAT(osk.scale, "input_osk_overlay_scale");
#endif
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
@ -1985,6 +1983,15 @@ bool config_save_file(const char *path)
g_settings.input.overlay_opacity);
config_set_float(conf, "input_overlay_scale",
g_settings.input.overlay_scale);
config_set_path(conf, "osk_overlay_directory",
*g_extern.osk_overlay_dir ? g_extern.osk_overlay_dir : "default");
config_set_path(conf, "input_osk_overlay", g_settings.input.overlay);
config_set_bool(conf, "input_osk_overlay_enable", g_settings.osk.enable);
config_set_float(conf, "input_osk_overlay_opacity",
g_settings.osk.opacity);
config_set_float(conf, "input_osk_overlay_scale",
g_settings.osk.scale);
#endif
config_set_path(conf, "video_font_path", g_settings.video.font_path);

View File

@ -3311,6 +3311,19 @@ static void load_content_change_handler(void *data)
rarch_main_command(RARCH_CMD_LOAD_CONTENT);
}
static void osk_overlay_enable_toggle_change_handler(void *data)
{
rarch_setting_t *setting = (rarch_setting_t *)data;
if (!setting)
return;
if (setting->value.boolean)
rarch_main_command(RARCH_CMD_OSK_OVERLAY_INIT);
else
rarch_main_command(RARCH_CMD_OSK_OVERLAY_DEINIT);
}
static void overlay_enable_toggle_change_handler(void *data)
{
rarch_setting_t *setting = (rarch_setting_t *)data;
@ -5117,26 +5130,6 @@ static bool setting_data_append_list_input_options(
}
END_SUB_GROUP(list, list_info);
}
START_SUB_GROUP(
list,
list_info,
"Onscreen Keyboard",
group_info.name,
subgroup_info);
CONFIG_BOOL(
g_settings.osk.enable,
"osk_enable",
"Onscreen Keyboard Enable",
false,
"OFF",
"ON",
group_info.name,
subgroup_info.name,
general_write_handler,
general_read_handler);
END_SUB_GROUP(list, list_info);
START_SUB_GROUP(
list,
@ -5234,6 +5227,50 @@ static bool setting_data_append_list_overlay_options(
return true;
}
static bool setting_data_append_list_osk_overlay_options(
rarch_setting_t **list,
rarch_setting_info_t *list_info)
{
#ifdef HAVE_OVERLAY
rarch_setting_group_info_t group_info;
rarch_setting_group_info_t subgroup_info;
START_GROUP(group_info, "Onscreen Keyboard Overlay Options");
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info);
CONFIG_BOOL(
g_settings.osk.enable,
"input_osk_overlay_enable",
"OSK Overlay Enable",
true,
"OFF",
"ON",
group_info.name,
subgroup_info.name,
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].change_handler = osk_overlay_enable_toggle_change_handler;
CONFIG_PATH(
g_settings.osk.overlay,
"input_osk_overlay",
"OSK Overlay Preset",
g_extern.osk_overlay_dir,
group_info.name,
subgroup_info.name,
general_write_handler,
general_read_handler);
settings_list_current_add_values(list, list_info, "cfg");
settings_list_current_add_cmd(list, list_info, RARCH_CMD_OSK_OVERLAY_INIT);
settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY);
END_SUB_GROUP(list, list_info);
END_GROUP(list, list_info);
#endif
return true;
}
static bool setting_data_append_list_menu_options(
rarch_setting_t **list,
rarch_setting_info_t *list_info)
@ -5981,6 +6018,21 @@ static bool setting_data_append_list_path_options(
list,
list_info,
SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR | SD_FLAG_BROWSER_ACTION);
CONFIG_DIR(
g_extern.osk_overlay_dir,
"osk_overlay_directory",
"OSK Overlay Directory",
g_defaults.osk_overlay_dir,
"<default>",
group_info.name,
subgroup_info.name,
general_write_handler,
general_read_handler);
settings_data_list_current_add_flags(
list,
list_info,
SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR | SD_FLAG_BROWSER_ACTION);
#endif
CONFIG_DIR(
@ -6239,6 +6291,12 @@ rarch_setting_t *setting_data_new(unsigned mask)
if (!setting_data_append_list_overlay_options(&list, list_info))
goto error;
}
if (mask & SL_FLAG_OSK_OVERLAY_OPTIONS)
{
if (!setting_data_append_list_osk_overlay_options(&list, list_info))
goto error;
}
if (mask & SL_FLAG_MENU_OPTIONS)
{

View File

@ -70,17 +70,18 @@ enum setting_list_flags
SL_FLAG_AUDIO_OPTIONS = (1 << 6),
SL_FLAG_INPUT_OPTIONS = (1 << 7),
SL_FLAG_OVERLAY_OPTIONS = (1 << 8),
SL_FLAG_MENU_OPTIONS = (1 << 9),
SL_FLAG_UI_OPTIONS = (1 << 10),
SL_FLAG_CORE_MANAGER_OPTIONS = (1 << 11),
SL_FLAG_NETPLAY_OPTIONS = (1 << 12),
SL_FLAG_USER_OPTIONS = (1 << 13),
SL_FLAG_PATH_OPTIONS = (1 << 14),
SL_FLAG_PRIVACY_OPTIONS = (1 << 15),
SL_FLAG_PLAYLIST_OPTIONS = (1 << 16),
SL_FLAG_ARCHIVE_OPTIONS = (1 << 17),
SL_FLAG_PATCH_OPTIONS = (1 << 18),
SL_FLAG_ALL = (1 << 19),
SL_FLAG_OSK_OVERLAY_OPTIONS = (1 << 9),
SL_FLAG_MENU_OPTIONS = (1 << 10),
SL_FLAG_UI_OPTIONS = (1 << 11),
SL_FLAG_CORE_MANAGER_OPTIONS = (1 << 12),
SL_FLAG_NETPLAY_OPTIONS = (1 << 13),
SL_FLAG_USER_OPTIONS = (1 << 14),
SL_FLAG_PATH_OPTIONS = (1 << 15),
SL_FLAG_PRIVACY_OPTIONS = (1 << 16),
SL_FLAG_PLAYLIST_OPTIONS = (1 << 17),
SL_FLAG_ARCHIVE_OPTIONS = (1 << 18),
SL_FLAG_PATCH_OPTIONS = (1 << 19),
SL_FLAG_ALL = (1 << 20),
};
#define SL_FLAG_ALL_SETTINGS (SL_FLAG_ALL - SL_FLAG_MAIN_MENU)