(RARCH_CONSOLE) Use init_drivers_pre once at startup of console

ports - use driver.video, driver.input as much as possible from
then instead of explicit platform-specific drivers
This commit is contained in:
twinaphex 2013-01-07 18:18:44 +01:00
parent 9251eebe13
commit c76ae2a8d1
10 changed files with 64 additions and 87 deletions

View File

@ -271,10 +271,10 @@ HRESULT CRetroArchControls::OnControlNavigate(
case DPAD_EMULATION_NONE:
break;
case DPAD_EMULATION_LSTICK:
input_xinput.set_analog_dpad_mapping(0, DPAD_EMULATION_NONE, controlno);
driver.input->set_analog_dpad_mapping(0, DPAD_EMULATION_NONE, controlno);
break;
case DPAD_EMULATION_RSTICK:
input_xinput.set_analog_dpad_mapping(0, DPAD_EMULATION_LSTICK, controlno);
driver.input->set_analog_dpad_mapping(0, DPAD_EMULATION_LSTICK, controlno);
break;
}
break;
@ -295,10 +295,10 @@ HRESULT CRetroArchControls::OnControlNavigate(
switch(g_settings.input.dpad_emulation[controlno])
{
case DPAD_EMULATION_NONE:
input_xinput.set_analog_dpad_mapping(0, DPAD_EMULATION_LSTICK, controlno);
driver.input->set_analog_dpad_mapping(0, DPAD_EMULATION_LSTICK, controlno);
break;
case DPAD_EMULATION_LSTICK:
input_xinput.set_analog_dpad_mapping(0, DPAD_EMULATION_RSTICK, controlno);
driver.input->set_analog_dpad_mapping(0, DPAD_EMULATION_RSTICK, controlno);
break;
case DPAD_EMULATION_RSTICK:
break;
@ -681,7 +681,6 @@ HRESULT CRetroArchQuickMenu::OnControlNavigate(XUIMessageControlNavigate *pContr
{
bool aspectratio_changed = false;
int current_index;
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
current_index = m_quickmenulist.GetCurSel();
@ -706,7 +705,7 @@ HRESULT CRetroArchQuickMenu::OnControlNavigate(XUIMessageControlNavigate *pContr
rarch_settings_change(S_ROTATION_DECREMENT);
rarch_settings_create_menu_item_label_w(strw_buffer, S_LBL_ROTATION, sizeof(strw_buffer));
m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, strw_buffer);
video_xdk_d3d.set_rotation(driver.video_data, g_extern.console.screen.orientation);
driver.video->set_rotation(driver.video_data, g_extern.console.screen.orientation);
break;
default:
break;
@ -731,7 +730,7 @@ HRESULT CRetroArchQuickMenu::OnControlNavigate(XUIMessageControlNavigate *pContr
rarch_settings_change(S_ROTATION_INCREMENT);
rarch_settings_create_menu_item_label_w(strw_buffer, S_LBL_ROTATION, sizeof(strw_buffer));
m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, strw_buffer);
video_xdk_d3d.set_rotation(driver.video_data, g_extern.console.screen.orientation);
driver.video->set_rotation(driver.video_data, g_extern.console.screen.orientation);
break;
default:
break;
@ -805,7 +804,7 @@ HRESULT CRetroArchQuickMenu::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled
rarch_settings_default(S_DEF_ROTATION);
rarch_settings_create_menu_item_label_w(strw_buffer, S_LBL_ROTATION, sizeof(strw_buffer));
m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, strw_buffer);
video_xdk_d3d.set_rotation(driver.video_data, g_extern.console.screen.orientation);
driver.video->set_rotation(driver.video_data, g_extern.console.screen.orientation);
break;
case MENU_ITEM_RESIZE_MODE:
g_extern.console.rmenu.input_loop = INPUT_LOOP_RESIZE_MODE;

View File

@ -776,9 +776,9 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
else if (action == RGUI_ACTION_RIGHT)
g_settings.input.device[port]++;
g_settings.input.device[port] %= RARCH_DEVICE_LAST;
input_gx.set_default_keybind_lut(g_settings.input.device[port], port);
driver.input->set_default_keybind_lut(g_settings.input.device[port], port);
rarch_input_set_default_keybinds(port);
input_gx.set_analog_dpad_mapping(g_settings.input.device[port], g_settings.input.dpad_emulation[port], port);
driver.input->set_analog_dpad_mapping(g_settings.input.device[port], g_settings.input.dpad_emulation[port], port);
break;
case RGUI_SETTINGS_BIND_DPAD_EMULATION:
g_settings.input.dpad_emulation[port] += DPAD_EMULATION_LAST;
@ -789,7 +789,7 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
else if (action == RGUI_ACTION_RIGHT)
g_settings.input.dpad_emulation[port]++;
g_settings.input.dpad_emulation[port] %= DPAD_EMULATION_LAST;
input_gx.set_analog_dpad_mapping(g_settings.input.device[port], g_settings.input.dpad_emulation[port], port);
driver.input->set_analog_dpad_mapping(g_settings.input.device[port], g_settings.input.dpad_emulation[port], port);
break;
case RGUI_SETTINGS_BIND_UP:
case RGUI_SETTINGS_BIND_DOWN:

View File

@ -1573,10 +1573,10 @@ static void set_setting_action(void *data, unsigned switchvalue, uint64_t input)
case DPAD_EMULATION_NONE:
break;
case DPAD_EMULATION_LSTICK:
input_ptr.set_analog_dpad_mapping(0, DPAD_EMULATION_NONE, currently_selected_controller_menu);
driver.input->set_analog_dpad_mapping(0, DPAD_EMULATION_NONE, currently_selected_controller_menu);
break;
case DPAD_EMULATION_RSTICK:
input_ptr.set_analog_dpad_mapping(0, DPAD_EMULATION_LSTICK, currently_selected_controller_menu);
driver.input->set_analog_dpad_mapping(0, DPAD_EMULATION_LSTICK, currently_selected_controller_menu);
break;
}
}
@ -1586,10 +1586,10 @@ static void set_setting_action(void *data, unsigned switchvalue, uint64_t input)
switch(g_settings.input.dpad_emulation[currently_selected_controller_menu])
{
case DPAD_EMULATION_NONE:
input_ptr.set_analog_dpad_mapping(0, DPAD_EMULATION_LSTICK, currently_selected_controller_menu);
driver.input->set_analog_dpad_mapping(0, DPAD_EMULATION_LSTICK, currently_selected_controller_menu);
break;
case DPAD_EMULATION_LSTICK:
input_ptr.set_analog_dpad_mapping(0, DPAD_EMULATION_RSTICK, currently_selected_controller_menu);
driver.input->set_analog_dpad_mapping(0, DPAD_EMULATION_RSTICK, currently_selected_controller_menu);
break;
case DPAD_EMULATION_RSTICK:
break;
@ -1597,7 +1597,7 @@ static void set_setting_action(void *data, unsigned switchvalue, uint64_t input)
}
if(input & (1ULL << RMENU_DEVICE_NAV_START))
input_ptr.set_analog_dpad_mapping(0, DPAD_EMULATION_LSTICK, currently_selected_controller_menu);
driver.input->set_analog_dpad_mapping(0, DPAD_EMULATION_LSTICK, currently_selected_controller_menu);
break;
case SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_UP:
set_keybind_digital(RETRO_DEVICE_ID_JOYPAD_UP, input);
@ -2292,10 +2292,10 @@ void rmenu_input_poll(void *data, void *state)
uint64_t input_state = 0;
static bool first_held = false;
input_ptr.poll(NULL);
driver.input->poll(NULL);
for (unsigned i = 0; i < RMENU_DEVICE_NAV_LAST; i++)
input_state |= input_ptr.input_state(NULL, rmenu_nav_binds, 0,
input_state |= driver.input->input_state(NULL, rmenu_nav_binds, 0,
RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
//set first button input frame as trigger
@ -2305,11 +2305,11 @@ void rmenu_input_poll(void *data, void *state)
//second button input frame
input_state = 0;
input_ptr.poll(NULL);
driver.input->poll(NULL);
for (unsigned i = 0; i < RMENU_DEVICE_NAV_LAST; i++)
{
input_state |= input_ptr.input_state(NULL, rmenu_nav_binds, 0,
input_state |= driver.input->input_state(NULL, rmenu_nav_binds, 0,
RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
}

View File

@ -19,15 +19,8 @@
#if defined(HAVE_OPENGL)
#define DEVICE_CAST gl_t*
#endif
#if defined(__CELLOS_LV2__)
#define input_ptr input_ps3
#elif defined(ANDROID)
#define input_ptr input_android
#elif defined(_XBOX1)
#define DEVICE_CAST xdk_d3d_video_t*
#define input_ptr input_xinput
#endif
typedef struct

View File

@ -169,7 +169,7 @@ static void find_audio_driver(void)
rarch_fail(1, "find_audio_driver()");
}
void find_video_driver(void)
static void find_video_driver(void)
{
for (unsigned i = 0; i < ARRAY_SIZE(video_drivers); i++)
{

View File

@ -319,8 +319,6 @@ void init_drivers(void);
void init_drivers_pre(void);
void uninit_drivers(void);
void find_video_driver(void);
void init_video_input(void);
void uninit_video_input(void);
void init_audio(void);

View File

@ -284,13 +284,11 @@ static bool rmenu_iterate(void)
uint16_t input_state = 0;
input_gx.poll(NULL);
driver.input->poll(NULL);
for (unsigned i = 0; i < GX_DEVICE_NAV_LAST; i++)
{
input_state |= input_gx.input_state(NULL, gx_nav_binds, 0,
input_state |= driver.input->input_state(NULL, gx_nav_binds, 0,
RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
}
uint16_t trigger_state = input_state & ~old_input_state;
bool do_held = (input_state & ((1ULL << GX_DEVICE_NAV_UP) | (1ULL << GX_DEVICE_NAV_DOWN) | (1ULL << GX_DEVICE_NAV_LEFT) | (1ULL << GX_DEVICE_NAV_RIGHT))) && !(input_state & ((1ULL << GX_DEVICE_NAV_MENU) | (1ULL << GX_DEVICE_NAV_QUIT)));
@ -499,9 +497,10 @@ int main(int argc, char *argv[])
get_environment_settings();
make_directories();
config_set_defaults();
input_gx.init();
find_video_driver();
init_drivers_pre();
driver.input->init();
driver.video->start();
gx_video_t *gx = (gx_video_t*)driver.video_data;
@ -510,24 +509,23 @@ int main(int argc, char *argv[])
char tmp_path[PATH_MAX];
const char *extension = default_paths.executable_extension;
snprintf(tmp_path, sizeof(tmp_path), "%s/", default_paths.core_dir);
const input_driver_t *input = &input_gx;
const char *path_prefix = tmp_path;
char full_path[1024];
snprintf(full_path, sizeof(full_path), "%sCORE%s", path_prefix, extension);
bool find_libretro_file = rarch_configure_libretro_core(full_path, path_prefix, path_prefix,
g_extern.config_path, extension);
rarch_settings_set_default();
rarch_input_set_controls_default(input);
rarch_input_set_controls_default(driver.input);
rarch_config_load();
if (find_libretro_file)
#ifdef HAVE_LIBRETRO_MANAGEMENT
if (rarch_configure_libretro_core(full_path, path_prefix, path_prefix,
g_extern.config_path, extension))
{
RARCH_LOG("New default libretro core saved to config file: %s.\n", g_settings.libretro);
config_save_file(g_extern.config_path);
}
#endif
char core_name[64];
rarch_console_name_from_id(core_name, sizeof(core_name));
@ -537,7 +535,7 @@ int main(int argc, char *argv[])
init_libretro_sym();
input_gx.post_init();
driver.input->post_init();
menu_init();
@ -562,7 +560,7 @@ int main(int argc, char *argv[])
begin_loop:
if(g_extern.console.rmenu.mode == MODE_EMULATION)
{
input_gx.poll(NULL);
driver.input->poll(NULL);
video_set_aspect_ratio_func(g_settings.video.aspect_ratio_idx);
@ -606,7 +604,7 @@ begin_shutdown:
if(g_extern.main_is_init)
rarch_main_deinit();
input_gx.free(NULL);
driver.input->free(NULL);
driver.video->stop();
menu_free();

View File

@ -266,37 +266,34 @@ int main(int argc, char *argv[])
get_environment_settings(argc, argv);
config_set_defaults();
input_ps3.init();
init_drivers_pre();
driver.input->init();
char tmp_path[PATH_MAX];
snprintf(tmp_path, sizeof(tmp_path), "%s/", default_paths.core_dir);
const char *path_prefix = tmp_path;
const char *extension = default_paths.executable_extension;
const input_driver_t *input = &input_ps3;
char core_exe_path[1024];
snprintf(core_exe_path, sizeof(core_exe_path), "%sCORE%s", path_prefix, extension);
#ifdef HAVE_LIBRETRO_MANAGEMENT
bool find_libretro_file = rarch_configure_libretro_core(core_exe_path, path_prefix, path_prefix,
g_extern.config_path, extension);
#else
bool find_libretro_file = false;
#endif
rarch_settings_set_default();
rarch_input_set_controls_default(input);
rarch_input_set_controls_default(driver.input);
rarch_config_load();
if (find_libretro_file)
#ifdef HAVE_LIBRETRO_MANAGEMENT
if (rarch_configure_libretro_core(core_exe_path, path_prefix, path_prefix,
g_extern.config_path, extension))
{
RARCH_LOG("New default libretro core saved to config file: %s.\n", g_settings.libretro);
config_save_file(g_extern.config_path);
}
#endif
init_libretro_sym();
input_ps3.post_init();
driver.input->post_init();
#if (CELL_SDK_VERSION > 0x340000) && !defined(__PSL1GHT__)
if (g_extern.console.screen.state.screenshots.enable)
@ -319,7 +316,6 @@ int main(int argc, char *argv[])
#endif
#endif
find_video_driver();
driver.video->start();
#ifdef HAVE_OSKUTIL
@ -348,7 +344,7 @@ int main(int argc, char *argv[])
begin_loop:
if(g_extern.console.rmenu.mode == MODE_EMULATION)
{
input_ps3.poll(NULL);
driver.input->poll(NULL);
driver.video->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx);
while(rarch_main_iterate());
}
@ -386,7 +382,7 @@ begin_shutdown:
if(g_extern.main_is_init)
rarch_main_deinit();
input_ps3.free(NULL);
driver.input->free(NULL);
driver.video->stop();
menu_free();

View File

@ -127,39 +127,35 @@ int main(int argc, char *argv[])
get_environment_settings(argc, argv);
config_set_defaults();
input_psp.init();
init_drivers_pre();
driver.input->init();
char tmp_path[PATH_MAX];
snprintf(tmp_path, sizeof(tmp_path), "%s/", default_paths.core_dir);
const char *path_prefix = tmp_path;
const char *extension = default_paths.executable_extension;
const input_driver_t *input = &input_psp;
char core_exe_path[1024];
snprintf(core_exe_path, sizeof(core_exe_path), "%sCORE%s", path_prefix, extension);
#ifdef HAVE_LIBRETRO_MANAGEMENT
bool find_libretro_file = rarch_configure_libretro_core(core_exe_path, path_prefix, path_prefix,
g_extern.config_path, extension);
#else
bool find_libretro_file = false;
#endif
rarch_settings_set_default();
rarch_input_set_controls_default(input);
rarch_config_load();
if (find_libretro_file)
#ifdef HAVE_LIBRETRO_MANAGEMENT
if (rarch_configure_libretro_core(core_exe_path, path_prefix, path_prefix,
g_extern.config_path, extension))
{
RARCH_LOG("New default libretro core saved to config file: %s.\n", g_settings.libretro);
config_save_file(g_extern.config_path);
}
#endif
init_libretro_sym();
input_psp.post_init();
driver.input->post_init();
find_video_driver();
driver.video->start();
menu_init();
@ -167,7 +163,7 @@ int main(int argc, char *argv[])
begin_loop:
if (g_extern.console.rmenu.mode == MODE_EMULATION)
{
input_psp.poll(NULL);
driver.input->poll(NULL);
driver.video->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx);
while(rarch_main_iterate());
@ -206,7 +202,7 @@ begin_shutdown:
if(g_extern.main_is_init)
rarch_main_deinit();
input_psp.free(NULL);
driver.input->free(NULL);
driver.video->stop();
menu_free();

View File

@ -144,7 +144,8 @@ int main(int argc, char *argv[])
config_set_defaults();
input_xinput.init();
init_drivers_pre();
driver.input->init();
#ifdef _XBOX1
char path_prefix[256];
@ -153,29 +154,26 @@ int main(int argc, char *argv[])
const char *path_prefix = default_paths.filesystem_root_dir;
#endif
const char *extension = default_paths.executable_extension;
const input_driver_t *input = &input_xinput;
char full_path[1024];
snprintf(full_path, sizeof(full_path), "%sCORE%s", path_prefix, extension);
bool find_libretro_file = rarch_configure_libretro_core(full_path, path_prefix, path_prefix,
g_extern.config_path, extension);
rarch_settings_set_default();
rarch_input_set_controls_default(input);
rarch_input_set_controls_default(driver.input);
rarch_config_load();
if (find_libretro_file)
#ifdef HAVE_LIBRETRO_MANAGEMENT
if (rarch_configure_libretro_core(full_path, path_prefix, path_prefix,
g_extern.config_path, extension))
{
RARCH_LOG("New default libretro core saved to config file: %s.\n", g_settings.libretro);
config_save_file(g_extern.config_path);
}
#endif
init_libretro_sym();
input_xinput.post_init();
find_video_driver();
driver.input->init();
driver.video->start();
system_init();
@ -186,8 +184,7 @@ begin_loop:
if(g_extern.console.rmenu.mode == MODE_EMULATION)
{
input_xinput.poll(NULL);
driver.input->poll(NULL);
driver.video->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx);
while(rarch_main_iterate());
@ -225,7 +222,7 @@ begin_shutdown:
menu_free();
driver.video->stop();
input_xinput.free(NULL);
driver.input->free(NULL);
if(g_extern.console.external_launch.enable)
rarch_console_exec(g_extern.console.external_launch.launch_app);