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 {
SCustomKey PrintScreen;
SCustomKey LastItem; // dummy, must be last
};
SCustomKey key[];
};
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[];
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

File diff suppressed because it is too large Load Diff

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