mirror of
https://github.com/gopher64/gopher64.git
synced 2026-07-11 01:25:20 +02:00
add way to change audio volume (#330)
* add way to change audio volume * more
This commit is contained in:
@@ -195,6 +195,12 @@ bool sdl_event_filter(void *userdata, SDL_Event *event)
|
||||
case SDL_SCANCODE_F7:
|
||||
callback.load_state = true;
|
||||
break;
|
||||
case SDL_SCANCODE_LEFTBRACKET:
|
||||
callback.lower_volume = true;
|
||||
break;
|
||||
case SDL_SCANCODE_RIGHTBRACKET:
|
||||
callback.raise_volume = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -449,6 +455,8 @@ CALL_BACK rdp_check_callback()
|
||||
CALL_BACK return_value = callback;
|
||||
callback.save_state = false;
|
||||
callback.load_state = false;
|
||||
callback.lower_volume = false;
|
||||
callback.raise_volume = false;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ extern "C"
|
||||
bool save_state;
|
||||
bool load_state;
|
||||
bool enable_speedlimiter;
|
||||
bool lower_volume;
|
||||
bool raise_volume;
|
||||
} CALL_BACK;
|
||||
|
||||
void rdp_init(void *_window, GFX_INFO _gfx_info);
|
||||
|
||||
@@ -86,6 +86,28 @@ pub fn close(ui: &mut ui::Ui) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn lower_audio_volume(ui: &ui::Ui) {
|
||||
unsafe {
|
||||
let mut gain = sdl3_sys::audio::SDL_GetAudioStreamGain(ui.audio.audio_stream) - 0.05;
|
||||
if gain < 0.0 {
|
||||
gain = 0.0;
|
||||
}
|
||||
sdl3_sys::audio::SDL_SetAudioStreamGain(ui.audio.audio_stream, gain);
|
||||
sdl3_sys::audio::SDL_SetAudioStreamGain(ui.audio.event_audio_stream, gain);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn raise_audio_volume(ui: &ui::Ui) {
|
||||
unsafe {
|
||||
let mut gain = sdl3_sys::audio::SDL_GetAudioStreamGain(ui.audio.audio_stream) + 0.05;
|
||||
if gain > 1.0 {
|
||||
gain = 1.0;
|
||||
}
|
||||
sdl3_sys::audio::SDL_SetAudioStreamGain(ui.audio.audio_stream, gain);
|
||||
sdl3_sys::audio::SDL_SetAudioStreamGain(ui.audio.event_audio_stream, gain);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play_netplay_audio(ui: &mut ui::Ui, error: u32) {
|
||||
if ui.audio.event_audio_stream.is_null() {
|
||||
return;
|
||||
|
||||
@@ -114,6 +114,12 @@ pub fn check_callback(device: &mut device::Device) {
|
||||
}
|
||||
device.vi.enable_speed_limiter = callback.enable_speedlimiter;
|
||||
}
|
||||
|
||||
if callback.lower_volume {
|
||||
ui::audio::lower_audio_volume(&device.ui);
|
||||
} else if callback.raise_volume {
|
||||
ui::audio::raise_audio_volume(&device.ui);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_register(reg: u32, value: u32) {
|
||||
|
||||
Reference in New Issue
Block a user