win32: route all the old hardcoded accelerators through the hotkey system

This commit is contained in:
zeromus 2009-02-11 04:23:52 +00:00
parent 4247b76b47
commit cfdc18fa53
8 changed files with 1299 additions and 1375 deletions

View File

@ -1083,7 +1083,6 @@ unsigned short gfx3d_glGetVecRes(unsigned int index)
}
#ifdef USE_GEOMETRY_FIFO_EMULATION
extern void NDS_Pause();
void gfx3d_execute(u8 cmd, u32 param)
{

Binary file not shown.

View File

@ -24,39 +24,54 @@
#include <windows.h>
#include <tchar.h>
#include <string>
enum HotkeyPage {
HOTKEY_PAGE_TOOLS=0,
HOTKEY_PAGE_PLACEHOLDER=1,
HOTKEY_PAGE_MAIN=0,
HOTKEY_PAGE_STATE,
HOTKEY_PAGE_STATE_SLOTS,
NUM_HOTKEY_PAGE,
};
static LPCTSTR hotkeyPageTitle[] = {
_T("Tools"),
_T("Placeholder"),
_T("Main"),
_T("Savestates"),
_T("Savestate Slots"),
_T("NUM_HOTKEY_PAGE"),
};
struct SCustomKey {
typedef void (*THandler) (void);
struct SCustomKey
{
typedef void (*THandler) (int param);
WORD key;
WORD modifiers;
THandler handleKeyDown;
THandler handleKeyUp;
HotkeyPage page;
LPCTSTR name;
std::wstring name;
const char* code;
int param;
//HotkeyTiming timing;
};
union SCustomKeys {
struct {
struct SCustomKeys
{
SCustomKey Save[10];
SCustomKey Load[10];
SCustomKey Slot[10];
SCustomKey QuickSave, QuickLoad;
SCustomKey Pause, FrameAdvance;
SCustomKey PrintScreen;
SCustomKey LastItem; // dummy, must be last
//--methods--
SCustomKey &key(int i) { return ((SCustomKey*)this)[i]; }
SCustomKey const &key(int i) const { return ((SCustomKey*)this)[i]; }
};
SCustomKey key[];
};
//SCustomKey key[];
extern SCustomKeys CustomKeys;
@ -66,7 +81,11 @@ void InitCustomKeys (SCustomKeys *keys);
int GetModifiers(int key);
//HOTKEY HANDLERS
void HK_PrintScreen();
void HK_PrintScreen(int);
void HK_StateSaveSlot(int);
void HK_StateLoadSlot(int);
void HK_StateSetSlot(int);
void HK_Pause(int);
#endif //HOTKEY_H_INCLUDED

View File

@ -346,7 +346,7 @@ static void ReadHotkey(const char* name, WORD& output)
static void LoadHotkeyConfig()
{
SCustomKey *key = CustomKeys.key;
SCustomKey *key = &CustomKeys.key(0);
while (!IsLastCustomKey(key)) {
ReadHotkey(key->code,key->key);
@ -358,7 +358,7 @@ static void LoadHotkeyConfig()
static void SaveHotkeyConfig()
{
SCustomKey *key = CustomKeys.key;
SCustomKey *key = &CustomKeys.key(0);
while (!IsLastCustomKey(key)) {
WritePrivateProfileInt("Hotkeys",(char*)key->code,key->key,IniName);
@ -1011,7 +1011,7 @@ int GetNumHotKeysAssignedTo (WORD Key, int modifiers)
|| (k->key == VK_MENU && modifiers & CUSTKEY_ALT_MASK) \
|| (k->key == VK_CONTROL && modifiers & CUSTKEY_CTRL_MASK)))
SCustomKey *key = CustomKeys.key;
SCustomKey *key = &CustomKeys.key(0);
while (!IsLastCustomKey(key)) {
if (MATCHES_KEY(key)) {
count++;
@ -2199,13 +2199,13 @@ void input_process()
static void set_hotkeyinfo(HWND hDlg)
{
HotkeyPage page = (HotkeyPage) SendDlgItemMessage(hDlg,IDC_HKCOMBO,CB_GETCURSEL,0,0);
SCustomKey *key = CustomKeys.key;
SCustomKey *key = &CustomKeys.key(0);
int i = 0;
while (!IsLastCustomKey(key) && i < NUM_HOTKEY_CONTROLS) {
if (page == key->page) {
SendDlgItemMessage(hDlg, IDC_HOTKEY_Table[i], WM_USER+44, key->key, key->modifiers);
SetDlgItemText(hDlg, IDC_LABEL_HK_Table[i], key->name);
SetDlgItemTextW(hDlg, IDC_LABEL_HK_Table[i], key->name.c_str());
ShowWindow(GetDlgItem(hDlg, IDC_HOTKEY_Table[i]), SW_SHOW);
i++;
}
@ -2284,19 +2284,19 @@ switch(msg)
int modifiers = GetModifiers(wParam);
page = (HotkeyPage) SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_GETCURSEL, 0, 0);
TCHAR text[256];
wchar_t text[256];
which = GetDlgCtrlID((HWND)lParam);
for (i = 0; i < NUM_HOTKEY_CONTROLS; i++) {
if (which == IDC_HOTKEY_Table[i])
break;
}
GetDlgItemText(hDlg, IDC_LABEL_HK_Table[i], text, COUNT(text));
GetDlgItemTextW(hDlg, IDC_LABEL_HK_Table[i], text, COUNT(text));
SCustomKey *key = CustomKeys.key;
SCustomKey *key = &CustomKeys.key(0);
while (!IsLastCustomKey(key)) {
if (page == key->page) {
if (lstrcmp(text, key->name) == 0) {
if(text == key->name) {
key->key = wParam;
key->modifiers = modifiers;
break;

View File

@ -38,9 +38,6 @@ InputCust * GetInputCustom(HWND hwnd);
#define CUSTKEY_CTRL_MASK 0x02
#define CUSTKEY_SHIFT_MASK 0x04
struct SJoypad {
BOOL Enabled;
WORD Left;
@ -111,6 +108,8 @@ extern SJoypad ToggleJoypadStorage[8];
//extern SCustomKeys CustomKeys;
extern SJoypad TurboToggleJoypadStorage[8];
void RunInputConfig();
void RunHotkeyConfig();
#endif

View File

@ -955,34 +955,7 @@ void NDS_UnPause()
}
}
void StateSaveSlot(int num)
{
if (!paused)
{
NDS_Pause();
savestate_slot(num); //Savestate
NDS_UnPause();
}
else
savestate_slot(num); //Savestate
lastSaveState = num; //Set last savestate used
SaveStateMessages(num, 0); //Display state loaded message
}
void StateLoadSlot(int num)
{
BOOL wasPaused = paused;
NDS_Pause();
loadstate_slot(num); //Loadstate
lastSaveState = num; //Set last savestate used
SaveStateMessages(num, 1); //Display state loaded message
if(!wasPaused)
NDS_UnPause();
else
Display();
}
#ifdef EXPERIMENTAL_GBASLOT
BOOL LoadROM(char * filename)
@ -1785,11 +1758,11 @@ int GetModifiers(int key)
int HandleKeyUp(WPARAM wParam, LPARAM lParam, int modifiers)
{
SCustomKey *key = CustomKeys.key;
SCustomKey *key = &CustomKeys.key(0);
while (!IsLastCustomKey(key)) {
if (wParam == key->key && modifiers == key->modifiers && key->handleKeyUp) {
key->handleKeyUp();
key->handleKeyUp(key->param);
}
key++;
}
@ -1805,10 +1778,10 @@ int HandleKeyMessage(WPARAM wParam, LPARAM lParam, int modifiers)
if(!(wParam == 0 || wParam == VK_ESCAPE)) // if it's the 'disabled' key, it's never pressed as a hotkey
{
SCustomKey *key = CustomKeys.key;
SCustomKey *key = &CustomKeys.key(0);
while (!IsLastCustomKey(key)) {
if (wParam == key->key && modifiers == key->modifiers && key->handleKeyDown) {
key->handleKeyDown();
key->handleKeyDown(key->param);
hitHotKey = true;
}
key++;
@ -1822,8 +1795,31 @@ int HandleKeyMessage(WPARAM wParam, LPARAM lParam, int modifiers)
return 1;
}
void Pause()
{
if (emu_paused) NDS_UnPause();
else NDS_Pause();
emu_paused ^= 1;
MainWindow->checkMenu(IDM_PAUSE, emu_paused ? MF_CHECKED : MF_UNCHECKED);
}
void RunConfig(int num)
void FrameAdvance()
{
frameAdvance = true;
execute = TRUE;
emu_paused = 1;
MainWindow->checkMenu(IDM_PAUSE, emu_paused ? MF_CHECKED : MF_UNCHECKED);
}
enum CONFIGSCREEN
{
CONFIGSCREEN_INPUT,
CONFIGSCREEN_HOTKEY,
CONFIGSCREEN_FIRMWARE,
CONFIGSCREEN_SOUND
};
void RunConfig(CONFIGSCREEN which)
{
HWND hwnd = MainWindow->getHWnd();
bool tpaused=false;
@ -1833,18 +1829,20 @@ void RunConfig(int num)
NDS_Pause();
}
switch(num) {
case 0:
void RunInputConfig();
switch(which)
{
case CONFIGSCREEN_INPUT:
RunInputConfig();
break;
case 1:
void RunHotkeyConfig();
case CONFIGSCREEN_HOTKEY:
RunHotkeyConfig();
break;
case 2:
case CONFIGSCREEN_FIRMWARE:
DialogBox(hAppInst,MAKEINTRESOURCE(IDD_FIRMSETTINGS), hwnd, (DLGPROC) FirmConfig_Proc);
break;
case CONFIGSCREEN_SOUND:
DialogBox(hAppInst, MAKEINTRESOURCE(IDD_SOUNDSETTINGS), hwnd, (DLGPROC)SoundSettingsDlgProc);
break;
}
if (tpaused)
@ -2058,7 +2056,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
case IDM_OPEN:
return OpenFile();
case IDM_PRINTSCREEN:
HK_PrintScreen();
HK_PrintScreen(0);
return 0;
case IDM_QUICK_PRINTSCREEN:
{
@ -2117,109 +2115,64 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
}
return 0;
case IDM_STATE_SAVE_F1:
StateSaveSlot(1);
HK_StateSaveSlot(1);
return 0;
case IDM_STATE_SAVE_F2:
StateSaveSlot(2);
HK_StateSaveSlot(2);
return 0;
case IDM_STATE_SAVE_F3:
StateSaveSlot(3);
HK_StateSaveSlot(3);
return 0;
case IDM_STATE_SAVE_F4:
StateSaveSlot(4);
HK_StateSaveSlot(4);
return 0;
case IDM_STATE_SAVE_F5:
StateSaveSlot(5);
HK_StateSaveSlot(5);
return 0;
case IDM_STATE_SAVE_F6:
StateSaveSlot(6);
HK_StateSaveSlot(6);
return 0;
case IDM_STATE_SAVE_F7:
StateSaveSlot(7);
HK_StateSaveSlot(7);
return 0;
case IDM_STATE_SAVE_F8:
StateSaveSlot(8);
HK_StateSaveSlot(8);
return 0;
case IDM_STATE_SAVE_F9:
StateSaveSlot(9);
HK_StateSaveSlot(9);
return 0;
case IDM_STATE_SAVE_F10:
StateSaveSlot(10);
HK_StateSaveSlot(10);
return 0;
case IDM_STATE_LOAD_F1:
StateLoadSlot(1);
HK_StateLoadSlot(1);
return 0;
case IDM_STATE_LOAD_F2:
StateLoadSlot(2);
HK_StateLoadSlot(2);
return 0;
case IDM_STATE_LOAD_F3:
StateLoadSlot(3);
HK_StateLoadSlot(3);
return 0;
case IDM_STATE_LOAD_F4:
StateLoadSlot(4);
HK_StateLoadSlot(4);
return 0;
case IDM_STATE_LOAD_F5:
StateLoadSlot(5);
HK_StateLoadSlot(5);
return 0;
case IDM_STATE_LOAD_F6:
StateLoadSlot(6);
HK_StateLoadSlot(6);
return 0;
case IDM_STATE_LOAD_F7:
StateLoadSlot(7);
HK_StateLoadSlot(7);
return 0;
case IDM_STATE_LOAD_F8:
StateLoadSlot(8);
HK_StateLoadSlot(8);
return 0;
case IDM_STATE_LOAD_F9:
StateLoadSlot(9);
HK_StateLoadSlot(9);
return 0;
case IDM_STATE_LOAD_F10:
StateLoadSlot(10);
return 0;
case ACCEL_I: //Quick Save
StateSaveSlot(lastSaveState);
return 0;
case ACCEL_P: //Quick Load
StateLoadSlot(lastSaveState);
return 0;
//Save slot selection
case ACCEL_0:
lastSaveState = 0;
SaveStateMessages(0,2);
return 0;
case ACCEL_1:
lastSaveState = 1;
SaveStateMessages(1,2);
return 0;
case ACCEL_2:
lastSaveState = 2;
SaveStateMessages(2,2);
return 0;
case ACCEL_3:
lastSaveState = 3;
SaveStateMessages(3,2);
return 0;
case ACCEL_4:
lastSaveState = 4;
SaveStateMessages(4,2);
return 0;
case ACCEL_5:
lastSaveState = 5;
SaveStateMessages(5,2);
case ACCEL_6:
lastSaveState = 6;
SaveStateMessages(6,2);
return 0;
case ACCEL_7:
lastSaveState = 7;
SaveStateMessages(7,2);
case ACCEL_8:
lastSaveState = 8;
SaveStateMessages(8,2);
return 0;
case ACCEL_9:
lastSaveState = 9;
SaveStateMessages(9,2);
HK_StateLoadSlot(10);
return 0;
case IDM_IMPORTBACKUPMEMORY:
{
@ -2245,19 +2198,20 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
NDS_UnPause();
return 0;
}
case IDM_SOUNDSETTINGS:
{
bool tpaused=false;
if (execute)
{
tpaused=true;
NDS_Pause();
}
DialogBox(hAppInst, MAKEINTRESOURCE(IDD_SOUNDSETTINGS), hwnd, (DLGPROC)SoundSettingsDlgProc);
if (tpaused)
NDS_UnPause();
}
case IDM_CONFIG:
RunConfig(CONFIGSCREEN_INPUT);
return 0;
case IDM_HOTKEY_CONFIG:
RunConfig(CONFIGSCREEN_HOTKEY);
return 0;
case IDM_FIRMSETTINGS:
RunConfig(CONFIGSCREEN_FIRMWARE);
return 0;
case IDM_SOUNDSETTINGS:
RunConfig(CONFIGSCREEN_SOUND);
return 0;
case IDM_GAME_INFO:
{
CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_GAME_INFO), hwnd, GinfoView_Proc);
@ -2411,12 +2365,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
}
return 0;
case ACCEL_SPACEBAR:
case IDM_PAUSE:
if (emu_paused) NDS_UnPause();
else NDS_Pause();
emu_paused ^= 1;
MainWindow->checkMenu(IDM_PAUSE, emu_paused ? MF_CHECKED : MF_UNCHECKED);
Pause();
return 0;
case IDM_GBASLOT:
@ -2431,13 +2381,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
CheatsSearchDialog(hwnd);
return 0;
case ACCEL_N: //Frame Advance
frameAdvance = true;
execute = TRUE;
emu_paused = 1;
MainWindow->checkMenu(IDM_PAUSE, emu_paused ? MF_CHECKED : MF_UNCHECKED);
return 0;
case ID_VIEW_FRAMECOUNTER:
frameCounterDisplay ^= 1;
MainWindow->checkMenu(ID_VIEW_FRAMECOUNTER, frameCounterDisplay ? MF_CHECKED : MF_UNCHECKED);
@ -2519,16 +2462,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
}
return 0;
case IDM_CONFIG:
RunConfig(0);
return 0;
case IDM_HOTKEY_CONFIG:
RunConfig(1);
return 0;
case IDM_FIRMSETTINGS:
RunConfig(2);
return 0;
case IDC_FRAMESKIPAUTO:
case IDC_FRAMESKIP0:
case IDC_FRAMESKIP1:

View File

@ -4,5 +4,13 @@
#include "CWindow.h"
extern WINCLASS *MainWindow;
extern volatile BOOL execute, paused;
void NDS_Pause();
void NDS_UnPause();
extern unsigned int lastSaveState;
void SaveStateMessages(int slotnum, int whichMessage);
void Display();
void Pause();
void FrameAdvance();
#endif

View File

@ -2303,39 +2303,5 @@ END
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDR_MAIN_ACCEL ACCELERATORS
BEGIN
"0", ACCEL_0, VIRTKEY
"1", ACCEL_1, VIRTKEY
"2", ACCEL_2, VIRTKEY
"3", ACCEL_3, VIRTKEY
"4", ACCEL_4, VIRTKEY
"5", ACCEL_5, VIRTKEY
"6", ACCEL_6, VIRTKEY
"7", ACCEL_7, VIRTKEY
"8", ACCEL_8, VIRTKEY
"9", ACCEL_9, VIRTKEY
"I", ACCEL_I, VIRTKEY
"N", ACCEL_N, VIRTKEY
"P", ACCEL_P, VIRTKEY
VK_SPACE, ACCEL_SPACEBAR, VIRTKEY
VK_F1, IDM_STATE_LOAD_F1, VIRTKEY
VK_F10, IDM_STATE_LOAD_F10, VIRTKEY
VK_F2, IDM_STATE_LOAD_F2, VIRTKEY
VK_F3, IDM_STATE_LOAD_F3, VIRTKEY
VK_F4, IDM_STATE_LOAD_F4, VIRTKEY
VK_F5, IDM_STATE_LOAD_F5, VIRTKEY
VK_F6, IDM_STATE_LOAD_F6, VIRTKEY
VK_F7, IDM_STATE_LOAD_F7, VIRTKEY
VK_F8, IDM_STATE_LOAD_F8, VIRTKEY
VK_F9, IDM_STATE_LOAD_F9, VIRTKEY
VK_F1, IDM_STATE_SAVE_F1, VIRTKEY, SHIFT
VK_F10, IDM_STATE_SAVE_F10, VIRTKEY, SHIFT
VK_F2, IDM_STATE_SAVE_F2, VIRTKEY, SHIFT
VK_F3, IDM_STATE_SAVE_F3, VIRTKEY, SHIFT
VK_F4, IDM_STATE_SAVE_F4, VIRTKEY, SHIFT
VK_F5, IDM_STATE_SAVE_F5, VIRTKEY, SHIFT
VK_F6, IDM_STATE_SAVE_F6, VIRTKEY, SHIFT
VK_F7, IDM_STATE_SAVE_F7, VIRTKEY, SHIFT
VK_F8, IDM_STATE_SAVE_F8, VIRTKEY, SHIFT
VK_F9, IDM_STATE_SAVE_F9, VIRTKEY, SHIFT
"O", ACCEL_CTRL_O, VIRTKEY, CONTROL
END