SDL/SDL2: add volume support

+ / - keyboard in game
This commit is contained in:
BeWorld 2020-12-21 13:35:04 +01:00
parent 7434efa6a8
commit bf897ad31d
3 changed files with 20 additions and 1 deletions

View File

@ -97,6 +97,7 @@ The above will give you a nicely scalend game screen and the menu for launching
'F11' - show FPS counter
'F6' - Screenshot
'ALT-ENTER' - Switch window/fullscreen
'+'/'-' - Volume controls
## SDL2 in menu controls

View File

@ -475,7 +475,22 @@ int RunMessageLoop()
bscreenshot = 1;
}
break;
case SDLK_KP_MINUS: // volumme -
nAudVolume -= 500;
if (nAudVolume < 0) {
nAudVolume = 0;
}
if (AudSoundSetVolume() == 0) {
}
break;
case SDLK_KP_PLUS: // volume -+
nAudVolume += 500;
if (nAudVolume > 10000) {
nAudVolume = 10000;
}
if (AudSoundSetVolume() == 0) {
}
break;
default:
break;
}

View File

@ -216,6 +216,9 @@ static int SDLSoundStop()
static int SDLSoundSetVolume()
{
nSDLVolume = int(SDL_MIX_MAXVOLUME * nAudVolume / 10000);
if (nSDLVolume > SDL_MIX_MAXVOLUME) nSDLVolume=SDL_MIX_MAXVOLUME;
if (nSDLVolume < 0) nSDLVolume=0;
return 1;
}