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 enabled;
return oldstate;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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,39 +562,37 @@ 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().tiaSurface().enablePhosphor(true, 100);
myOSystem.frameBuffer().showMessage("Phosphor blend at maximum"); return;
return;
}
else
blend = std::min(blend+2, 100);
}
else if(direction == -1) // decrease blend
{
if(blend <= 2)
{
myOSystem.frameBuffer().showMessage("Phosphor blend at minimum");
return;
}
else
blend = std::max(blend-2, 0);
} }
else else
blend = std::min(blend+2, 100);
}
else if(direction == -1) // decrease blend
{
if(blend <= 2)
{
myOSystem.frameBuffer().showMessage("Phosphor blend at minimum");
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, 0);
return; return;
}
ostringstream val; else
val << blend; blend = std::max(blend-2, 0);
myProperties.set(Display_PPBlend, val.str());
myOSystem.frameBuffer().showMessage("Phosphor blend " + val.str());
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, blend);
} }
else else
myOSystem.frameBuffer().showMessage("Phosphor effect disabled"); return;
ostringstream val;
val << blend;
myProperties.set(Display_PPBlend, val.str());
myOSystem.frameBuffer().showMessage("Phosphor blend " + val.str());
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, blend);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -