(RGUI) Can now change drivers from RGUI - you need to restart

for changes to take effect
This commit is contained in:
twinaphex 2013-10-30 17:06:50 +01:00
parent 7c39118f91
commit b2d1fe66b3
3 changed files with 173 additions and 3 deletions

102
driver.c
View File

@ -195,6 +195,34 @@ static void find_audio_driver(void)
rarch_fail(1, "find_audio_driver()");
}
void find_prev_audio_driver(char *str, size_t sizeof_str)
{
unsigned i;
for (i = (ARRAY_SIZE(audio_drivers)-1); i > 0; i--)
{
if (strcasecmp(g_settings.audio.driver, audio_drivers[i]->ident) == 0)
{
strlcpy(str, audio_drivers[i-1]->ident, sizeof_str);
return;
}
}
RARCH_WARN("Couldn't find any previous audio driver (current one: \"%s\")\n", g_settings.audio.driver);
}
void find_next_audio_driver(char *str, size_t sizeof_str)
{
unsigned i;
for (i = 0; i < ARRAY_SIZE(audio_drivers); i++)
{
if (strcasecmp(g_settings.audio.driver, audio_drivers[i]->ident) == 0)
{
strlcpy(str, audio_drivers[i+1]->ident, sizeof_str);
return;
}
}
RARCH_WARN("Couldn't find any next audio driver (current one: \"%s\")\n", g_settings.audio.driver);
}
static void find_video_driver(void)
{
unsigned i;
@ -223,6 +251,52 @@ static void find_video_driver(void)
rarch_fail(1, "find_video_driver()");
}
void find_prev_video_driver(char *str, size_t sizeof_str)
{
unsigned i;
#if defined(HAVE_OPENGL) && defined(HAVE_FBO)
if (g_extern.system.hw_render_callback.context_type)
{
RARCH_LOG("Using HW render, OpenGL driver forced.\n");
strlcpy(str, video_gl.ident, sizeof_str);
return;
}
#endif
for (i = (ARRAY_SIZE(video_drivers)-1); i > 0; i--)
{
if (strcasecmp(g_settings.video.driver, video_drivers[i]->ident) == 0)
{
strlcpy(str, video_drivers[i-1]->ident, sizeof_str);
return;
}
}
RARCH_WARN("Couldn't find any previous video driver (current one: \"%s\")\n", g_settings.video.driver);
}
void find_next_video_driver(char *str, size_t sizeof_str)
{
unsigned i;
#if defined(HAVE_OPENGL) && defined(HAVE_FBO)
if (g_extern.system.hw_render_callback.context_type)
{
RARCH_LOG("Using HW render, OpenGL driver forced.\n");
strlcpy(str, video_gl.ident, sizeof_str);
return;
}
#endif
for (i = 0; i < ARRAY_SIZE(video_drivers); i++)
{
if (strcasecmp(g_settings.video.driver, video_drivers[i]->ident) == 0)
{
strlcpy(str, video_drivers[i]->ident, sizeof_str);
return;
}
}
RARCH_WARN("Couldn't find any next video driver (current one: \"%s\")\n", g_settings.video.driver);
}
static void find_input_driver(void)
{
unsigned i;
@ -242,6 +316,34 @@ static void find_input_driver(void)
rarch_fail(1, "find_input_driver()");
}
void find_prev_input_driver(char *str, size_t sizeof_str)
{
unsigned i;
for (i = (ARRAY_SIZE(input_drivers)-1); i > 0; i--)
{
if (strcasecmp(g_settings.input.driver, input_drivers[i]->ident) == 0)
{
strlcpy(str, input_drivers[i-1]->ident, sizeof_str);
return;
}
}
RARCH_ERR("Couldn't find any previous input driver (current one: \"%s\")\n", g_settings.input.driver);
}
void find_next_input_driver(char *str, size_t sizeof_str)
{
unsigned i;
for (i = 0; i < ARRAY_SIZE(input_drivers); i++)
{
if (strcasecmp(g_settings.input.driver, input_drivers[i]->ident) == 0)
{
strlcpy(str, input_drivers[i]->ident, sizeof_str);
return;
}
}
RARCH_ERR("Couldn't find any next input driver (current one: \"%s\")\n", g_settings.input.driver);
}
void init_drivers_pre(void)
{
find_audio_driver();

View File

@ -486,6 +486,13 @@ void uninit_video_input(void);
void init_audio(void);
void uninit_audio(void);
void find_prev_video_driver(char *str, size_t sizeof_str);
void find_prev_audio_driver(char *str, size_t sizeof_str);
void find_prev_input_driver(char *str, size_t sizeof_str);
void find_next_video_driver(char *str, size_t sizeof_str);
void find_next_audio_driver(char *str, size_t sizeof_str);
void find_next_input_driver(char *str, size_t sizeof_str);
void driver_set_monitor_refresh_rate(float hz);
bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points);
void driver_set_nonblock_state(bool nonblock);

View File

@ -624,6 +624,67 @@ int menu_set_settings(unsigned setting, unsigned action)
driver.video_poke->set_filtering(driver.video_data, 1, g_settings.video.smooth);
break;
case RGUI_SETTINGS_DRIVER_VIDEO:
if (action == RGUI_ACTION_LEFT)
{
char driver[32];
driver[0] = '\0';
find_next_video_driver(driver, sizeof(driver));
if (driver[0] != '\0')
strlcpy(g_settings.video.driver, driver, sizeof(g_settings.video.driver));
}
else if (action == RGUI_ACTION_RIGHT)
{
char driver[32];
driver[0] = '\0';
find_prev_video_driver(driver, sizeof(driver));
if (driver[0] != '\0')
strlcpy(g_settings.video.driver, driver, sizeof(g_settings.video.driver));
}
break;
case RGUI_SETTINGS_DRIVER_AUDIO:
if (action == RGUI_ACTION_LEFT)
{
char driver[32];
driver[0] = '\0';
find_next_audio_driver(driver, sizeof(driver));
if (driver[0] != '\0')
strlcpy(g_settings.audio.driver, driver, sizeof(g_settings.audio.driver));
}
else if (action == RGUI_ACTION_RIGHT)
{
char driver[32];
driver[0] = '\0';
find_prev_audio_driver(driver, sizeof(driver));
if (driver[0] != '\0')
strlcpy(g_settings.audio.driver, driver, sizeof(g_settings.audio.driver));
}
break;
case RGUI_SETTINGS_DRIVER_INPUT:
if (action == RGUI_ACTION_LEFT)
{
char driver[32];
driver[0] = '\0';
find_next_input_driver(driver, sizeof(driver));
if (driver[0] != '\0')
strlcpy(g_settings.input.driver, driver, sizeof(g_settings.input.driver));
}
else if (action == RGUI_ACTION_RIGHT)
{
char driver[32];
driver[0] = '\0';
find_prev_input_driver(driver, sizeof(driver));
if (driver[0] != '\0')
strlcpy(g_settings.input.driver, driver, sizeof(g_settings.input.driver));
}
break;
case RGUI_SETTINGS_VIDEO_GAMMA:
if (action == RGUI_ACTION_START)
{
@ -1094,13 +1155,13 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w,
snprintf(type_str, type_str_size, "%u", g_settings.video.hard_sync_frames);
break;
case RGUI_SETTINGS_DRIVER_VIDEO:
strlcpy(type_str, driver.video->ident, type_str_size);
strlcpy(type_str, g_settings.video.driver, type_str_size);
break;
case RGUI_SETTINGS_DRIVER_AUDIO:
strlcpy(type_str, driver.audio->ident, type_str_size);
strlcpy(type_str, g_settings.audio.driver, type_str_size);
break;
case RGUI_SETTINGS_DRIVER_INPUT:
strlcpy(type_str, driver.input->ident, type_str_size);
strlcpy(type_str, g_settings.input.driver, type_str_size);
break;
case RGUI_SETTINGS_VIDEO_REFRESH_RATE_AUTO:
{