SDL :
- Cleaned up initialization and volume management - Added shortcuts to change the volume at runtime Thanks to chrono for the patch
This commit is contained in:
parent
57b7512db9
commit
b2e13838db
|
@ -12,6 +12,8 @@ CTRL-P: pause
|
||||||
CTRL-F: toggle fullscreen
|
CTRL-F: toggle fullscreen
|
||||||
CTRL-G: rotate between filters
|
CTRL-G: rotate between filters
|
||||||
CTRL-S: toggle sound
|
CTRL-S: toggle sound
|
||||||
|
NUMPAD /: decrease volume
|
||||||
|
NUMPAD *: increase volume
|
||||||
CTRL-E: toggle cheats
|
CTRL-E: toggle cheats
|
||||||
ESC: quit
|
ESC: quit
|
||||||
F11: debugger
|
F11: debugger
|
||||||
|
|
|
@ -74,10 +74,6 @@
|
||||||
#include <lirc/lirc_client.h>
|
#include <lirc/lirc_client.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern bool soundEcho;
|
|
||||||
extern bool soundLowPass;
|
|
||||||
extern bool soundReverse;
|
|
||||||
|
|
||||||
extern void remoteInit();
|
extern void remoteInit();
|
||||||
extern void remoteCleanUp();
|
extern void remoteCleanUp();
|
||||||
extern void remoteStubMain();
|
extern void remoteStubMain();
|
||||||
|
@ -226,7 +222,6 @@ bool sdlMotionButtons[4] = { false, false, false, false };
|
||||||
|
|
||||||
int sdlNumDevices = 0;
|
int sdlNumDevices = 0;
|
||||||
SDL_Joystick **sdlDevices = NULL;
|
SDL_Joystick **sdlDevices = NULL;
|
||||||
bool soundOffFlag;
|
|
||||||
bool wasPaused = false;
|
bool wasPaused = false;
|
||||||
int autoFrameSkip = 0;
|
int autoFrameSkip = 0;
|
||||||
int frameskipadjust = 0;
|
int frameskipadjust = 0;
|
||||||
|
@ -363,6 +358,23 @@ struct option sdlOptions[] = {
|
||||||
{ NULL, no_argument, NULL, 0 }
|
{ NULL, no_argument, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void sdlChangeVolume(float d)
|
||||||
|
{
|
||||||
|
float oldVolume = soundGetVolume();
|
||||||
|
float newVolume = oldVolume + d;
|
||||||
|
|
||||||
|
if (newVolume < 0.0) newVolume = 0.0;
|
||||||
|
if (newVolume > 2.0) newVolume = 2.0;
|
||||||
|
|
||||||
|
if (fabs(newVolume - oldVolume) > 0.001) {
|
||||||
|
char tmp[32];
|
||||||
|
if (newVolume < oldVolume) sprintf(tmp, "Sound volume decreased (%i%%)", (int)(newVolume*100.0+0.5));
|
||||||
|
else sprintf(tmp, "Sound volume increased (%i%%)", (int)(newVolume*100.0+0.5));
|
||||||
|
systemScreenMessage(tmp);
|
||||||
|
soundSetVolume(newVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if WITH_LIRC
|
#if WITH_LIRC
|
||||||
//LIRC code
|
//LIRC code
|
||||||
bool LIRCEnabled = false;
|
bool LIRCEnabled = false;
|
||||||
|
@ -786,19 +798,17 @@ void sdlReadPreferences(FILE *f)
|
||||||
soundQuality = 2;
|
soundQuality = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(!strcmp(key, "soundOff")) {
|
|
||||||
soundOffFlag = sdlFromHex(value) ? true : false;
|
|
||||||
} else if(!strcmp(key, "soundEnable")) {
|
} else if(!strcmp(key, "soundEnable")) {
|
||||||
int res = sdlFromHex(value) & 0x30f;
|
int res = sdlFromHex(value) & 0x30f;
|
||||||
soundSetEnable(res);
|
soundSetEnable(res);
|
||||||
} else if(!strcmp(key, "soundEcho")) {
|
} else if(!strcmp(key, "soundEcho")) {
|
||||||
soundEcho = sdlFromHex(value) ? true : false;
|
/* TODO */
|
||||||
|
/* soundEcho = sdlFromHex(value) ? true : false; */
|
||||||
} else if(!strcmp(key, "soundVolume")) {
|
} else if(!strcmp(key, "soundVolume")) {
|
||||||
float volume;
|
int volume = sdlFromDec(value);
|
||||||
volume = sdlFromHex(value);
|
if (volume < 0 || volume > 200)
|
||||||
if( volume > 100.0f ) volume = 100.0f;
|
volume = 100;
|
||||||
if( volume < 1.0f ) volume = 1.0f;
|
soundSetVolume((float)(volume / 100.0f ));
|
||||||
soundSetVolume( volume );
|
|
||||||
} else if(!strcmp(key, "saveType")) {
|
} else if(!strcmp(key, "saveType")) {
|
||||||
cpuSaveType = sdlFromHex(value);
|
cpuSaveType = sdlFromHex(value);
|
||||||
if(cpuSaveType < 0 || cpuSaveType > 5)
|
if(cpuSaveType < 0 || cpuSaveType > 5)
|
||||||
|
@ -1729,6 +1739,12 @@ void sdlPollEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SDLK_KP_DIVIDE:
|
||||||
|
sdlChangeVolume(-0.1);
|
||||||
|
break;
|
||||||
|
case SDLK_KP_MULTIPLY:
|
||||||
|
sdlChangeVolume(0.1);
|
||||||
|
break;
|
||||||
|
|
||||||
case SDLK_p:
|
case SDLK_p:
|
||||||
if(!(event.key.keysym.mod & MOD_NOCTRL) &&
|
if(!(event.key.keysym.mod & MOD_NOCTRL) &&
|
||||||
|
@ -1921,19 +1937,9 @@ void lircCheckInput(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if( strcmp( CmdLIRC, "VOLUP" ) == 0 ) {
|
} else if( strcmp( CmdLIRC, "VOLUP" ) == 0 ) {
|
||||||
float tempvolumeup;
|
sdlChangeVolume(0.1);
|
||||||
tempvolumeup = soundGetVolume();
|
|
||||||
tempvolumeup = tempvolumeup + 1.0f;
|
|
||||||
if( tempvolumeup > 100.0f ) tempvolumeup = 100.0f;
|
|
||||||
soundSetVolume( tempvolumeup );
|
|
||||||
systemScreenMessage("Sound volume Increased");
|
|
||||||
} else if( strcmp( CmdLIRC, "VOLDOWN" ) == 0 ) {
|
} else if( strcmp( CmdLIRC, "VOLDOWN" ) == 0 ) {
|
||||||
float tempvolumedown;
|
sdlChangeVolume(-0.1);
|
||||||
tempvolumedown = soundGetVolume();
|
|
||||||
tempvolumedown = tempvolumedown - 1.0f;
|
|
||||||
if( tempvolumedown < 1.0f ) tempvolumedown = 1.0f;
|
|
||||||
soundSetVolume( tempvolumedown );
|
|
||||||
systemScreenMessage("Sound volume Decreased");
|
|
||||||
} else if( strcmp( CmdLIRC, "LOADSTATE" ) == 0 ) {
|
} else if( strcmp( CmdLIRC, "LOADSTATE" ) == 0 ) {
|
||||||
sdlReadState(saveSlotPosition);
|
sdlReadState(saveSlotPosition);
|
||||||
} else if( strcmp( CmdLIRC, "SAVESTATE" ) == 0 ) {
|
} else if( strcmp( CmdLIRC, "SAVESTATE" ) == 0 ) {
|
||||||
|
@ -2457,9 +2463,6 @@ int main(int argc, char **argv)
|
||||||
int flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO|
|
int flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO|
|
||||||
SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE;
|
SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE;
|
||||||
|
|
||||||
if(soundOffFlag)
|
|
||||||
flags ^= SDL_INIT_AUDIO;
|
|
||||||
|
|
||||||
if(SDL_Init(flags)) {
|
if(SDL_Init(flags)) {
|
||||||
systemMessage(0, "Failed to init SDL: %s", SDL_GetError());
|
systemMessage(0, "Failed to init SDL: %s", SDL_GetError());
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -2531,7 +2534,6 @@ int main(int argc, char **argv)
|
||||||
emulating = 1;
|
emulating = 1;
|
||||||
renderedFrames = 0;
|
renderedFrames = 0;
|
||||||
|
|
||||||
if(!soundOffFlag)
|
|
||||||
soundInit();
|
soundInit();
|
||||||
|
|
||||||
autoFrameSkipLastTime = throttleLastTime = systemGetClock();
|
autoFrameSkipLastTime = throttleLastTime = systemGetClock();
|
||||||
|
|
|
@ -141,14 +141,6 @@ soundQuality=2
|
||||||
# 0=false, anything else for true
|
# 0=false, anything else for true
|
||||||
soundEcho=0
|
soundEcho=0
|
||||||
|
|
||||||
# Sound Low pass filter
|
|
||||||
# 0=false, anything else for true
|
|
||||||
soundLowPass=0
|
|
||||||
|
|
||||||
# Sound reverse stereo
|
|
||||||
# 0=false, anything else for true
|
|
||||||
soundReverse=0
|
|
||||||
|
|
||||||
# Save Type
|
# Save Type
|
||||||
# 0=automatic, 1=EEPROM, 2=SRAM, 3=Flash, 4=EEPROM+Sensor, 5=NONE
|
# 0=automatic, 1=EEPROM, 2=SRAM, 3=Flash, 4=EEPROM+Sensor, 5=NONE
|
||||||
saveType=0
|
saveType=0
|
||||||
|
@ -158,7 +150,7 @@ saveType=0
|
||||||
flashSize=0
|
flashSize=0
|
||||||
|
|
||||||
# Sound volume
|
# Sound volume
|
||||||
# 0=1x, 1=2x, 2=3x, 3=4x
|
# 0-200=0%-200%
|
||||||
soundVolume=0
|
soundVolume=0
|
||||||
|
|
||||||
# Interframe blending
|
# Interframe blending
|
||||||
|
@ -193,10 +185,6 @@ agbPrint=0
|
||||||
# 0=disable, anything else to enable
|
# 0=disable, anything else to enable
|
||||||
rtcEnabled=0
|
rtcEnabled=0
|
||||||
|
|
||||||
# Sound OFF flag
|
|
||||||
# 0=sound on, anything else turns off sound
|
|
||||||
soundOff=0
|
|
||||||
|
|
||||||
# Sound Enable
|
# Sound Enable
|
||||||
# Controls which channels are enabled: (add values)
|
# Controls which channels are enabled: (add values)
|
||||||
# 1 - Channel 1
|
# 1 - Channel 1
|
||||||
|
|
Loading…
Reference in New Issue