changed volume hotkey handling

changing volume also enables sound
changing phoshor also enables phosphor mode
This commit is contained in:
Thomas Jentzsch 2019-02-14 11:07:17 +01:00
parent fa66711c8a
commit 7215f2bbeb
2 changed files with 41 additions and 38 deletions

View File

@ -194,23 +194,19 @@ bool SoundSDL2::mute(bool state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SoundSDL2::toggleMute() bool SoundSDL2::toggleMute()
{ {
bool oldstate = SDL_GetAudioDeviceStatus(myDevice) == SDL_AUDIO_PAUSED; bool enabled = myAudioSettings.enabled();
if(myIsInitializedFlag)
{
string message;
SDL_PauseAudioDevice(myDevice, oldstate ? 0 : 1); setEnabled(!enabled);
myOSystem.console().initializeAudio();
message = "Sound "; string message = "Sound ";
message += oldstate ? "unmuted" : "muted"; message += !enabled ? "unmuted" : "muted";
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showMessage(message);
}
return oldstate; return enabled;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL2::setVolume(uInt32 percent) void SoundSDL2::setVolume(uInt32 percent)
{ {
@ -243,6 +239,15 @@ void SoundSDL2::adjustVolume(Int8 direction)
setVolume(percent); setVolume(percent);
// enabled audio if it is currently disabled
bool enabled = myAudioSettings.enabled();
if (percent > 0 && !enabled)
{
setEnabled(!enabled);
myOSystem.console().initializeAudio();
}
// Now show an onscreen message // Now show an onscreen message
strval << percent; strval << percent;
message = "Volume set to "; message = "Volume set to ";

View File

@ -562,13 +562,13 @@ void Console::changePhosphor(int direction)
{ {
int blend = atoi(myProperties.get(Display_PPBlend).c_str()); int blend = atoi(myProperties.get(Display_PPBlend).c_str());
if(myOSystem.frameBuffer().tiaSurface().phosphorEnabled())
{
if(direction == +1) // increase blend if(direction == +1) // increase blend
{ {
if(blend >= 100) if(blend >= 100)
{ {
myOSystem.frameBuffer().showMessage("Phosphor blend at maximum"); myOSystem.frameBuffer().showMessage("Phosphor blend at maximum");
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, 100);
return; return;
} }
else else
@ -579,6 +579,7 @@ void Console::changePhosphor(int direction)
if(blend <= 2) if(blend <= 2)
{ {
myOSystem.frameBuffer().showMessage("Phosphor blend at minimum"); myOSystem.frameBuffer().showMessage("Phosphor blend at minimum");
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, 0);
return; return;
} }
else else
@ -592,9 +593,6 @@ void Console::changePhosphor(int direction)
myProperties.set(Display_PPBlend, val.str()); myProperties.set(Display_PPBlend, val.str());
myOSystem.frameBuffer().showMessage("Phosphor blend " + val.str()); myOSystem.frameBuffer().showMessage("Phosphor blend " + val.str());
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, blend); myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, blend);
}
else
myOSystem.frameBuffer().showMessage("Phosphor effect disabled");
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -