mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Create RARCH_CMD_VOLUME_UP/RARCH_CMD_VOLUME_DOWN
This commit is contained in:
parent
359349895f
commit
323475c516
30
retroarch.c
30
retroarch.c
@ -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;
|
||||
|
@ -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
|
||||
|
28
runloop.c
28
runloop.c
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user