Create RARCH_CMD_VOLUME_UP/RARCH_CMD_VOLUME_DOWN

This commit is contained in:
twinaphex 2015-03-21 09:25:21 +01:00
parent 359349895f
commit 323475c516
3 changed files with 34 additions and 26 deletions

View File

@ -2238,6 +2238,30 @@ static bool rarch_update_system_info(struct retro_system_info *_info,
return true;
}
/**
* set_volume:
* @gain : amount of gain to be applied to current volume level.
*
* Adjusts the current audio volume level.
*
**/
static void set_volume(float gain)
{
char msg[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
settings->audio.volume += gain;
settings->audio.volume = max(settings->audio.volume, -80.0f);
settings->audio.volume = min(settings->audio.volume, 12.0f);
snprintf(msg, sizeof(msg), "Volume: %.1f dB", settings->audio.volume);
rarch_main_msg_queue_push(msg, 1, 180, true);
RARCH_LOG("%s\n", msg);
global->audio_data.volume_gain = db_to_gain(settings->audio.volume);
}
/**
* rarch_main_command:
* @cmd : Command index.
@ -2928,6 +2952,12 @@ bool rarch_main_command(unsigned cmd)
case RARCH_CMD_PERFCNT_REPORT_FRONTEND_LOG:
rarch_perf_log();
break;
case RARCH_CMD_VOLUME_UP:
set_volume(0.5f);
break;
case RARCH_CMD_VOLUME_DOWN:
set_volume(-0.5f);
break;
}
return true;

View File

@ -191,6 +191,8 @@ enum basic_event
RARCH_CMD_PERFCNT_REPORT_FRONTEND_LOG,
RARCH_CMD_REMAPPING_INIT,
RARCH_CMD_REMAPPING_DEINIT,
RARCH_CMD_VOLUME_UP,
RARCH_CMD_VOLUME_DOWN,
};
enum action_state

View File

@ -37,30 +37,6 @@ static struct runloop *g_runloop;
static struct global *g_extern;
/**
* set_volume:
* @gain : amount of gain to be applied to current volume level.
*
* Adjusts the current audio volume level.
*
**/
static void set_volume(float gain)
{
char msg[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
settings->audio.volume += gain;
settings->audio.volume = max(settings->audio.volume, -80.0f);
settings->audio.volume = min(settings->audio.volume, 12.0f);
snprintf(msg, sizeof(msg), "Volume: %.1f dB", settings->audio.volume);
rarch_main_msg_queue_push(msg, 1, 180, true);
RARCH_LOG("%s\n", msg);
global->audio_data.volume_gain = db_to_gain(settings->audio.volume);
}
/**
* check_pause:
* @pressed : was libretro pause key pressed?
@ -644,9 +620,9 @@ static int do_state_checks(
rarch_main_command(RARCH_CMD_AUDIO_MUTE_TOGGLE);
if (volume_up_pressed)
set_volume(0.5f);
rarch_main_command(RARCH_CMD_VOLUME_UP);
else if (volume_down_pressed)
set_volume(-0.5f);
rarch_main_command(RARCH_CMD_VOLUME_DOWN);
#ifdef HAVE_NETPLAY
if (driver->netplay_data)