From b117ca793d23557568151e99ad9cfe274e3d8f5c Mon Sep 17 00:00:00 2001 From: gocha Date: Wed, 4 Nov 2009 08:41:43 +0000 Subject: [PATCH] change the behavior of menu item "Emulation > Pause" to call TogglePause() rather than Pause(); add Increase/Decrease Volume hotkey. --- desmume/src/windows/hotkey.cpp | 25 +++++++++++++++++++++++++ desmume/src/windows/hotkey.h | 2 ++ desmume/src/windows/main.cpp | 6 +++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/desmume/src/windows/hotkey.cpp b/desmume/src/windows/hotkey.cpp index bdb401510..1b3a06b25 100644 --- a/desmume/src/windows/hotkey.cpp +++ b/desmume/src/windows/hotkey.cpp @@ -222,6 +222,19 @@ void HK_LCDsSwap(int) LCDsSwap(-1); } +extern int sndvolume; +void HK_IncreaseVolume(int, bool justPressed) +{ + sndvolume = std::min(100, sndvolume + 5); + SPU_SetVolume(sndvolume); +} + +void HK_DecreaseVolume(int, bool justPressed) +{ + sndvolume = std::max(0, sndvolume - 5); + SPU_SetVolume(sndvolume); +} + void HK_Reset(int, bool justPressed) {ResetGame();} void HK_RecordAVI(int, bool justPressed) { if (AVI_IsRecording()) AviEnd(); else AviRecordTo(); } @@ -675,6 +688,18 @@ void InitCustomKeys (SCustomKeys *keys) keys->LCDsSwap.page = HOTKEY_PAGE_MOVIE; keys->LCDsSwap.key = VK_NEXT; + keys->IncreaseVolume.handleKeyDown = HK_IncreaseVolume; + keys->IncreaseVolume.code = "IncreaseVolume"; + keys->IncreaseVolume.name = L"Increase Volume"; + keys->IncreaseVolume.page = HOTKEY_PAGE_MOVIE; + keys->IncreaseVolume.key = NULL; + + keys->DecreaseVolume.handleKeyDown = HK_DecreaseVolume; + keys->DecreaseVolume.code = "DecreaseVolume"; + keys->DecreaseVolume.name = L"Decrease Volume"; + keys->DecreaseVolume.page = HOTKEY_PAGE_MOVIE; + keys->DecreaseVolume.key = NULL; + //StateSlots Page -------------------------------------------------- keys->NextSaveSlot.handleKeyDown = HK_NextSaveSlot; keys->NextSaveSlot.code = "NextSaveSlot"; diff --git a/desmume/src/windows/hotkey.h b/desmume/src/windows/hotkey.h index f5081116a..e353e3d9c 100644 --- a/desmume/src/windows/hotkey.h +++ b/desmume/src/windows/hotkey.h @@ -93,6 +93,8 @@ struct SCustomKeys SCustomKey StylusAutoHold; SCustomKey LCDsMode; SCustomKey LCDsSwap; + SCustomKey IncreaseVolume; + SCustomKey DecreaseVolume; SCustomKey LastItem; // dummy, must be last //--methods-- diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index d7783f5f3..56ff98660 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -270,9 +270,9 @@ extern bool userTouchesScreen; static int sndcoretype=SNDCORE_DIRECTX; static int sndbuffersize=735*4; -static int sndvolume=100; static int snd_synchmode=0; static int snd_synchmethod=0; +int sndvolume=100; SoundInterface_struct *SNDCoreList[] = { &SNDDummy, @@ -3596,7 +3596,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM WritePrivateProfileString("Watches", str, &rw_recent_files[i][0], IniName); } - for(int i = 0; i < MAX_RECENT_SCRIPTS; i++) { char str[256]; @@ -3604,6 +3603,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM WritePrivateProfileString("Scripting", str, &Recent_Scripts[i][0], IniName); } + WritePrivateProfileInt("Sound", "Volume", sndvolume, IniName); ExitRunLoop(); } @@ -4498,7 +4498,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM return 0; case IDM_PAUSE: - Pause(); + TogglePause(); return 0; case IDM_GBASLOT: