From 880030665f622c4550ea090bc44cc28d40997be6 Mon Sep 17 00:00:00 2001 From: rheiny Date: Sun, 11 Feb 2007 16:55:47 +0000 Subject: [PATCH] Separated input from mapinput --- src/drivers/win/input.cpp | 575 ----------------------------------- src/drivers/win/input.h | 14 + src/drivers/win/mapinput.cpp | 575 +++++++++++++++++++++++++++++++++++ src/drivers/win/mapinput.h | 4 + vc8/fceux.vcproj | 8 + 5 files changed, 601 insertions(+), 575 deletions(-) create mode 100644 src/drivers/win/mapinput.cpp create mode 100644 src/drivers/win/mapinput.h diff --git a/src/drivers/win/input.cpp b/src/drivers/win/input.cpp index e4d60174..b4891957 100644 --- a/src/drivers/win/input.cpp +++ b/src/drivers/win/input.cpp @@ -133,24 +133,8 @@ static unsigned char *keys=0; static unsigned char *keys_nr=0; static int DIPS=0; -static uint8 keyonce[MKK_COUNT]; //#define KEY(__a) keys_nr[MKK(__a)] -static int _keyonly(int a) -{ - if(keys_nr[a]) - { - if(!keyonce[a]) - { - keyonce[a]=1; - return(1); - } - } - else - keyonce[a]=0; - return(0); -} - int cidisabled=0; #define MK(x) {{BUTTC_KEYBOARD},{0},{MKK(x)},1} @@ -1389,17 +1373,6 @@ void DestroyInput(void) } } -#define CMD_KEY_MASK 0xff -#define CMD_KEY_LSHIFT (1<<16) -#define CMD_KEY_RSHIFT (1<<17) -#define CMD_KEY_SHIFT (CMD_KEY_LSHIFT|CMD_KEY_RSHIFT) -#define CMD_KEY_LCTRL (1<<18) -#define CMD_KEY_RCTRL (1<<19) -#define CMD_KEY_CTRL (CMD_KEY_LCTRL|CMD_KEY_RCTRL) -#define CMD_KEY_LALT (1<<20) -#define CMD_KEY_RALT (1<<21) -#define CMD_KEY_ALT (CMD_KEY_LALT|CMD_KEY_RALT) - int FCEUD_CommandMapping[EMUCMD_MAX]; CFGSTRUCT HotkeyConfig[]={ @@ -1407,88 +1380,6 @@ CFGSTRUCT HotkeyConfig[]={ ENDCFGSTRUCT }; -static struct -{ - int cmd; - int key; -} DefaultCommandMapping[]= -{ - { EMUCMD_RESET, SCAN_R | CMD_KEY_CTRL }, - { EMUCMD_PAUSE, SCAN_F2, }, - { EMUCMD_FRAME_ADVANCE, SCAN_TAB, }, - { EMUCMD_SCREENSHOT, SCAN_F9 }, - { EMUCMD_HIDE_MENU_TOGGLE, SCAN_ESCAPE }, - { EMUCMD_SPEED_SLOWER, SCAN_MINUS, }, // think about these - { EMUCMD_SPEED_FASTER, SCAN_EQUAL, }, // think about these - { EMUCMD_SPEED_TURBO, SCAN_GRAVE, }, //tilde - { EMUCMD_SAVE_SLOT_0, SCAN_0, }, - { EMUCMD_SAVE_SLOT_1, SCAN_1, }, - { EMUCMD_SAVE_SLOT_2, SCAN_2, }, - { EMUCMD_SAVE_SLOT_3, SCAN_3, }, - { EMUCMD_SAVE_SLOT_4, SCAN_4, }, - { EMUCMD_SAVE_SLOT_5, SCAN_5, }, - { EMUCMD_SAVE_SLOT_6, SCAN_6, }, - { EMUCMD_SAVE_SLOT_7, SCAN_7, }, - { EMUCMD_SAVE_SLOT_8, SCAN_8, }, - { EMUCMD_SAVE_SLOT_9, SCAN_9, }, - { EMUCMD_SAVE_STATE, SCAN_F5, }, - { EMUCMD_LOAD_STATE, SCAN_F7, }, - //get feedback from TAS people about these - /*{ EMUCMD_MOVIE_FRAME_DISPLAY_TOGGLE, SCAN_PERIOD, }, - { EMUCMD_FDS_EJECT_INSERT, SCAN_F8, }, - { EMUCMD_FDS_SIDE_SELECT, SCAN_F6, }, - { EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, SCAN_COMMA, }, - { EMUCMD_MOVIE_READONLY_TOGGLE, SCAN_8 | CMD_KEY_SHIFT, },*/ - { EMUCMD_MISC_REWIND, SCAN_R, }, - //mbg 7/31/06 - these have been removed as defaults until we decide whether hotkey philosophy permits them - //{ EMUCMD_SAVE_STATE_SLOT_0, SCAN_F10 | CMD_KEY_SHIFT, }, - //{ EMUCMD_SAVE_STATE_SLOT_1, SCAN_F1 | CMD_KEY_SHIFT, }, - //{ EMUCMD_SAVE_STATE_SLOT_2, SCAN_F2 | CMD_KEY_SHIFT, }, - //{ EMUCMD_SAVE_STATE_SLOT_3, SCAN_F3 | CMD_KEY_SHIFT, }, - //{ EMUCMD_SAVE_STATE_SLOT_4, SCAN_F4 | CMD_KEY_SHIFT, }, - //{ EMUCMD_SAVE_STATE_SLOT_5, SCAN_F5 | CMD_KEY_SHIFT, }, - //{ EMUCMD_SAVE_STATE_SLOT_6, SCAN_F6 | CMD_KEY_SHIFT, }, - //{ EMUCMD_SAVE_STATE_SLOT_7, SCAN_F7 | CMD_KEY_SHIFT, }, - //{ EMUCMD_SAVE_STATE_SLOT_8, SCAN_F8 | CMD_KEY_SHIFT, }, - //{ EMUCMD_SAVE_STATE_SLOT_9, SCAN_F9 | CMD_KEY_SHIFT, }, - //{ EMUCMD_LOAD_STATE_SLOT_0, SCAN_F10, }, - //{ EMUCMD_LOAD_STATE_SLOT_1, SCAN_F1, }, - //{ EMUCMD_LOAD_STATE_SLOT_2, SCAN_F2, }, - //{ EMUCMD_LOAD_STATE_SLOT_3, SCAN_F3, }, - //{ EMUCMD_LOAD_STATE_SLOT_4, SCAN_F4, }, - //{ EMUCMD_LOAD_STATE_SLOT_5, SCAN_F5, }, - //{ EMUCMD_LOAD_STATE_SLOT_6, SCAN_F6, }, - //{ EMUCMD_LOAD_STATE_SLOT_7, SCAN_F7, }, - //{ EMUCMD_LOAD_STATE_SLOT_8, SCAN_F8, }, - //{ EMUCMD_LOAD_STATE_SLOT_9, SCAN_F9, }, -/* { EMUCMD_MOVIE_SLOT_0, SCAN_0 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_SLOT_1, SCAN_1 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_SLOT_2, SCAN_2 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_SLOT_3, SCAN_3 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_SLOT_4, SCAN_4 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_SLOT_5, SCAN_5 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_SLOT_6, SCAN_6 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_SLOT_7, SCAN_7 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_SLOT_8, SCAN_8 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_SLOT_9, SCAN_9 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_RECORD, SCAN_F5 | CMD_KEY_ALT, }, - { EMUCMD_MOVIE_REPLAY, SCAN_F7 | CMD_KEY_ALT, },*/ -}; - -#define NUM_DEFAULT_MAPPINGS (sizeof(DefaultCommandMapping)/sizeof(DefaultCommandMapping[0])) - -void ApplyDefaultCommandMapping(void) -{ - int i; - - memset(FCEUD_CommandMapping, 0, sizeof(FCEUD_CommandMapping)); - - for(i=0; ihThreadExit) - { - if (WaitForSingleObject(args->hThreadExit, 20) == WAIT_OBJECT_0) - break; - - // Poke our owner dialog periodically. - PostMessage(args->hwndDlg, WM_USER, 0, 0); - } - - return 0; -} - -static int GetKeyPressed() -{ - int key=0; - int i; - - keys_nr=GetKeyboard_nr(); - - for(i=0; i<256 && !key; ++i) - { - if(_keyonly(i)) - key=i; - } - return key; -} - -static int NothingPressed() -{ - int i; - - keys_nr=GetKeyboard_nr(); - - for(i=0; i<256; ++i) - { - if(keys_nr[i]) - return 0; - } - return 1; -} - -static int GetKeyMeta(int key) -{ - int meta = key & (~CMD_KEY_MASK); - switch(key & CMD_KEY_MASK) - { - case SCAN_LEFTCONTROL: - case SCAN_RIGHTCONTROL: return CMD_KEY_CTRL | meta; - case SCAN_LEFTALT: - case SCAN_RIGHTALT: return CMD_KEY_ALT | meta; - case SCAN_LEFTSHIFT: - case SCAN_RIGHTSHIFT: return CMD_KEY_SHIFT | meta; - default: - break; - } - - return meta; -} - -static void ClearExtraMeta(int* key) -{ - switch((*key)&0xff) - { - case SCAN_LEFTCONTROL: - case SCAN_RIGHTCONTROL: *key &= ~(CMD_KEY_CTRL); break; - case SCAN_LEFTALT: - case SCAN_RIGHTALT: *key &= ~(CMD_KEY_ALT); break; - case SCAN_LEFTSHIFT: - case SCAN_RIGHTSHIFT: *key &= ~(CMD_KEY_SHIFT); break; - default: - break; - } -} - -static BOOL CALLBACK ChangeInputDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static HANDLE hThread = NULL; - static DWORD dwThreadId = 0; - static struct INPUTDLGTHREADARGS threadargs; - static int key=0; - - switch (uMsg) - { - case WM_INITDIALOG: - { - // Start the message thread. - threadargs.hThreadExit = CreateEvent(NULL, TRUE, FALSE, NULL); - threadargs.hwndDlg = hwndDlg; - hThread = CreateThread(NULL, 0, NewInputDialogThread, (LPVOID)&threadargs, 0, &dwThreadId); - key=0; - memset(keyonce, 0, sizeof(keyonce)); - KeyboardSetBackgroundAccess(1); - SetFocus(GetDlgItem(hwndDlg, 100)); - } - return FALSE; - - case WM_COMMAND: - if(LOWORD(wParam) == 202 && HIWORD(wParam) == BN_CLICKED) - { - key=0; - PostMessage(hwndDlg, WM_USER+1, 0, 0); // Send quit message. - } - else if(LOWORD(wParam) == 200 && HIWORD(wParam) == BN_CLICKED) - { - key=-1; - PostMessage(hwndDlg, WM_USER+1, 0, 0); // Send quit message. - } - - break; - - case WM_USER: - { - // Our thread sent us a timer signal. - int newkey; - int meta=GetKeyMeta(key); - - KeyboardUpdateState(); - - if((newkey=GetKeyPressed()) != 0) - { - key = newkey | meta; - ClearExtraMeta(&key); - SetDlgItemText(hwndDlg, 100, GetKeyComboName(key)); - } - else if(NothingPressed() && key) - PostMessage(hwndDlg, WM_USER+1, 0, 0); // Send quit message. - } - break; - - case WM_USER+1: - { - // Done with keyboard. - KeyboardSetBackgroundAccess(0); - - // Kill the thread. - SetEvent(threadargs.hThreadExit); - WaitForSingleObject(hThread, INFINITE); - CloseHandle(hThread); - CloseHandle(threadargs.hThreadExit); - - // End the dialog. - EndDialog(hwndDlg, key); - return TRUE; - } - - default: - break; - } - - return FALSE; -} - -static int* ConflictTable=0; - -static int ShouldDisplayMapping(int mapn, int filter) -{ - //mbg merge 7/17/06 changed to if..elseif - if(filter==0) /* No filter */ - return 1; - else if(filter <= EMUCMDTYPE_MAX) /* Filter by type */ - return (FCEUI_CommandTable[mapn].type == filter-1); - else if(filter == EMUCMDTYPE_MAX+1) /* Assigned */ - return FCEUD_CommandMapping[mapn]; - else if(filter == EMUCMDTYPE_MAX+2) /* Unassigned */ - return !(FCEUD_CommandMapping[mapn]); - else if(filter == EMUCMDTYPE_MAX+3) /* Conflicts */ - return ConflictTable[mapn]; - else - return 0; -} - -static void PopulateMappingDisplay(HWND hwndDlg) -{ - LVITEM lvi; - int i; - int idx; - HWND hwndListView = GetDlgItem(hwndDlg, 1003); - int num=SendMessage(hwndListView, LVM_GETITEMCOUNT, 0, 0); - int filter = (int)SendDlgItemMessage(hwndDlg, 300, CB_GETCURSEL, 0, 0); - - // Delete everything in the current display. - for(i=num; i>0; --i) - SendMessage(hwndListView, LVM_DELETEITEM, (WPARAM)i-1, 0); - - // Get the filter type. - ConflictTable=0; - if (filter == EMUCMDTYPE_MAX+3) - { - // Set up the conflict table. - ConflictTable=(int*)malloc(sizeof(int)*EMUCMD_MAX); - memset(ConflictTable, 0, sizeof(int)*EMUCMD_MAX); - for(i=0; icode == LVN_ITEMACTIVATE) - { - int nSel = SendMessage(hwndListView, LVM_GETNEXTITEM, (WPARAM)-1, LVNI_SELECTED); - if (nSel != -1) - { - int nCmd; - int nRet; - LVITEM lvi; - - // Get the corresponding input - memset(&lvi, 0, sizeof(lvi)); - lvi.mask = LVIF_PARAM; - lvi.iItem = nSel; - lvi.iSubItem = 0; - SendMessage(hwndListView, LVM_GETITEM, 0, (LPARAM)&lvi); - nCmd = lvi.lParam; - - nRet = DialogBox(fceu_hInstance,"NEWINPUT",hwndListView,ChangeInputDialogProc); - if (nRet) - { - // nRet will be -1 when the user selects "clear". - FCEUD_CommandMapping[nCmd] = (nRet<0) ? 0 : nRet; - - memset(&lvi, 0, sizeof(lvi)); - lvi.mask = LVIF_TEXT; - lvi.iItem = nSel; - lvi.iSubItem = 2; - lvi.pszText = GetKeyComboName(FCEUD_CommandMapping[nCmd]); - SendMessage(hwndListView, LVM_SETITEM, (WPARAM)0, (LPARAM)&lvi); - } - } - } - return TRUE; - } - break; - - default: - break; - } - break; - - default: - break; - } - - return FALSE; -} - -/** -* Show input mapping configuration dialog. -**/ -void MapInput(void) -{ - // Make a backup of the current mappings, in case the user changes their mind. - int* backupmapping = (int*)malloc(sizeof(FCEUD_CommandMapping)); - memcpy(backupmapping, FCEUD_CommandMapping, sizeof(FCEUD_CommandMapping)); - - if(!DialogBox(fceu_hInstance, "MAPINPUT", hAppWnd, MapInputDialogProc)) - { - memcpy(FCEUD_CommandMapping, backupmapping, sizeof(FCEUD_CommandMapping)); - } - - free(backupmapping); -} - void FCEUD_TurboOn(void) { //NoWaiting|=1; diff --git a/src/drivers/win/input.h b/src/drivers/win/input.h index efce2b56..820a818e 100644 --- a/src/drivers/win/input.h +++ b/src/drivers/win/input.h @@ -3,6 +3,17 @@ #include "dinput.h" +#define CMD_KEY_MASK 0xff +#define CMD_KEY_LSHIFT (1<<16) +#define CMD_KEY_RSHIFT (1<<17) +#define CMD_KEY_SHIFT (CMD_KEY_LSHIFT|CMD_KEY_RSHIFT) +#define CMD_KEY_LCTRL (1<<18) +#define CMD_KEY_RCTRL (1<<19) +#define CMD_KEY_CTRL (CMD_KEY_LCTRL|CMD_KEY_RCTRL) +#define CMD_KEY_LALT (1<<20) +#define CMD_KEY_RALT (1<<21) +#define CMD_KEY_ALT (CMD_KEY_LALT|CMD_KEY_RALT) + void ConfigInput(HWND hParent); int InitDInput(void); void CreateInputStuff(void); @@ -54,6 +65,9 @@ void FCEUD_UpdateInput(); extern const char* ScanNames[]; extern CFGSTRUCT HotkeyConfig[]; + +extern int FCEUD_CommandMapping[EMUCMD_MAX]; + #endif #endif \ No newline at end of file diff --git a/src/drivers/win/mapinput.cpp b/src/drivers/win/mapinput.cpp new file mode 100644 index 00000000..b94eb7c1 --- /dev/null +++ b/src/drivers/win/mapinput.cpp @@ -0,0 +1,575 @@ +#include "common.h" +#include "mapinput.h" +#include "input.h" +#include "keyscan.h" +#include "keyboard.h" +#include "../../input.h" + +static int* ConflictTable=0; +static uint8 keyonce[MKK_COUNT]; +static unsigned char *keys_nr=0; + +void KeyboardUpdateState(void); //mbg merge 7/17/06 yech had to add this + +static const char* ScanNames[256]= +{ + /* 0x00-0x0f */ 0, "Escape", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "Minus", "Equals", "Backspace", "Tab", + /* 0x10-0x1f */ "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "Enter", "Left Ctrl", "A", "S", + /* 0x20-0x2f */ "D", "F", "G", "H", "J", "K", "L", "Semicolon", "Apostrophe", "Tilde", "Left Shift", "Backslash", "Z", "X", "C", "V", + /* 0x30-0x3f */ "B", "N", "M", "Comma", "Period", "Slash", "Right Shift", "Numpad *", "Left Alt", "Space", "Caps Lock", "F1", "F2", "F3", "F4", "F5", + /* 0x40-0x4f */ "F6", "F7", "F8", "F9", "F10", "NumLock", "ScrollLock", "Numpad 7", "Numpad 8", "Numpad 9", "Numpad Minus", "Numpad 4", "Numpad 5", "Numpad 6", "Numpad Plus", "Numpad 1", + /* 0x50-0x5f */ "Numpad 2", "Numpad 3", "Numpad 0", "Numpad Period", 0, 0, "Backslash", "F11", "F12", 0, 0, 0, 0, 0, 0, 0, + /* 0x60-0x6f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x70-0x7f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x80-0x8f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x90-0x9f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Numpad Enter", "Right Ctrl", 0, 0, + /* 0xa0-0xaf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xb0-0xbf */ 0, 0, 0, 0, 0, "Numpad Divide", 0, "PrintScrn", "Right Alt", 0, 0, 0, 0, 0, 0, 0, + /* 0xc0-0xcf */ 0, 0, 0, 0, 0, "Pause", 0, "Home", "Up Arrow", "PgUp", 0, "Left Arrow", 0, "Right Arrow", 0, "End", + /* 0xd0-0xdf */ "Down Arrow", "PgDn", "Ins", "Del", 0, 0, 0, 0, 0, 0, 0, "Left Win", "Right Win", "AppMenu", 0, 0, + /* 0xe0-0xef */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xf0-0xff */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +struct INPUTDLGTHREADARGS +{ + HANDLE hThreadExit; + HWND hwndDlg; +}; + +static int _keyonly(int a) +{ + if(keys_nr[a]) + { + if(!keyonce[a]) + { + keyonce[a]=1; + return(1); + } + } + else + keyonce[a]=0; + return(0); +} + +static int GetKeyPressed() +{ + int key=0; + int i; + + keys_nr=GetKeyboard_nr(); + + for(i=0; i<256 && !key; ++i) + { + if(_keyonly(i)) + key=i; + } + return key; +} + +static int NothingPressed() +{ + int i; + + keys_nr=GetKeyboard_nr(); + + for(i=0; i<256; ++i) + { + if(keys_nr[i]) + return 0; + } + return 1; +} + +static int GetKeyMeta(int key) +{ + int meta = key & (~CMD_KEY_MASK); + switch(key & CMD_KEY_MASK) + { + case SCAN_LEFTCONTROL: + case SCAN_RIGHTCONTROL: return CMD_KEY_CTRL | meta; + case SCAN_LEFTALT: + case SCAN_RIGHTALT: return CMD_KEY_ALT | meta; + case SCAN_LEFTSHIFT: + case SCAN_RIGHTSHIFT: return CMD_KEY_SHIFT | meta; + default: + break; + } + + return meta; +} + +static void ClearExtraMeta(int* key) +{ + switch((*key)&0xff) + { + case SCAN_LEFTCONTROL: + case SCAN_RIGHTCONTROL: *key &= ~(CMD_KEY_CTRL); break; + case SCAN_LEFTALT: + case SCAN_RIGHTALT: *key &= ~(CMD_KEY_ALT); break; + case SCAN_LEFTSHIFT: + case SCAN_RIGHTSHIFT: *key &= ~(CMD_KEY_SHIFT); break; + default: + break; + } +} + +static DWORD WINAPI NewInputDialogThread(LPVOID lpvArg) +{ + struct INPUTDLGTHREADARGS* args = (struct INPUTDLGTHREADARGS*)lpvArg; + + while (args->hThreadExit) + { + if (WaitForSingleObject(args->hThreadExit, 20) == WAIT_OBJECT_0) + break; + + // Poke our owner dialog periodically. + PostMessage(args->hwndDlg, WM_USER, 0, 0); + } + + return 0; +} + +static struct +{ + int cmd; + int key; +} DefaultCommandMapping[]= +{ + { EMUCMD_RESET, SCAN_R | CMD_KEY_CTRL }, + { EMUCMD_PAUSE, SCAN_F2, }, + { EMUCMD_FRAME_ADVANCE, SCAN_TAB, }, + { EMUCMD_SCREENSHOT, SCAN_F9 }, + { EMUCMD_HIDE_MENU_TOGGLE, SCAN_ESCAPE }, + { EMUCMD_SPEED_SLOWER, SCAN_MINUS, }, // think about these + { EMUCMD_SPEED_FASTER, SCAN_EQUAL, }, // think about these + { EMUCMD_SPEED_TURBO, SCAN_GRAVE, }, //tilde + { EMUCMD_SAVE_SLOT_0, SCAN_0, }, + { EMUCMD_SAVE_SLOT_1, SCAN_1, }, + { EMUCMD_SAVE_SLOT_2, SCAN_2, }, + { EMUCMD_SAVE_SLOT_3, SCAN_3, }, + { EMUCMD_SAVE_SLOT_4, SCAN_4, }, + { EMUCMD_SAVE_SLOT_5, SCAN_5, }, + { EMUCMD_SAVE_SLOT_6, SCAN_6, }, + { EMUCMD_SAVE_SLOT_7, SCAN_7, }, + { EMUCMD_SAVE_SLOT_8, SCAN_8, }, + { EMUCMD_SAVE_SLOT_9, SCAN_9, }, + { EMUCMD_SAVE_STATE, SCAN_F5, }, + { EMUCMD_LOAD_STATE, SCAN_F7, }, + //get feedback from TAS people about these + /*{ EMUCMD_MOVIE_FRAME_DISPLAY_TOGGLE, SCAN_PERIOD, }, + { EMUCMD_FDS_EJECT_INSERT, SCAN_F8, }, + { EMUCMD_FDS_SIDE_SELECT, SCAN_F6, }, + { EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, SCAN_COMMA, }, + { EMUCMD_MOVIE_READONLY_TOGGLE, SCAN_8 | CMD_KEY_SHIFT, },*/ + { EMUCMD_MISC_REWIND, SCAN_R, }, + //mbg 7/31/06 - these have been removed as defaults until we decide whether hotkey philosophy permits them + //{ EMUCMD_SAVE_STATE_SLOT_0, SCAN_F10 | CMD_KEY_SHIFT, }, + //{ EMUCMD_SAVE_STATE_SLOT_1, SCAN_F1 | CMD_KEY_SHIFT, }, + //{ EMUCMD_SAVE_STATE_SLOT_2, SCAN_F2 | CMD_KEY_SHIFT, }, + //{ EMUCMD_SAVE_STATE_SLOT_3, SCAN_F3 | CMD_KEY_SHIFT, }, + //{ EMUCMD_SAVE_STATE_SLOT_4, SCAN_F4 | CMD_KEY_SHIFT, }, + //{ EMUCMD_SAVE_STATE_SLOT_5, SCAN_F5 | CMD_KEY_SHIFT, }, + //{ EMUCMD_SAVE_STATE_SLOT_6, SCAN_F6 | CMD_KEY_SHIFT, }, + //{ EMUCMD_SAVE_STATE_SLOT_7, SCAN_F7 | CMD_KEY_SHIFT, }, + //{ EMUCMD_SAVE_STATE_SLOT_8, SCAN_F8 | CMD_KEY_SHIFT, }, + //{ EMUCMD_SAVE_STATE_SLOT_9, SCAN_F9 | CMD_KEY_SHIFT, }, + //{ EMUCMD_LOAD_STATE_SLOT_0, SCAN_F10, }, + //{ EMUCMD_LOAD_STATE_SLOT_1, SCAN_F1, }, + //{ EMUCMD_LOAD_STATE_SLOT_2, SCAN_F2, }, + //{ EMUCMD_LOAD_STATE_SLOT_3, SCAN_F3, }, + //{ EMUCMD_LOAD_STATE_SLOT_4, SCAN_F4, }, + //{ EMUCMD_LOAD_STATE_SLOT_5, SCAN_F5, }, + //{ EMUCMD_LOAD_STATE_SLOT_6, SCAN_F6, }, + //{ EMUCMD_LOAD_STATE_SLOT_7, SCAN_F7, }, + //{ EMUCMD_LOAD_STATE_SLOT_8, SCAN_F8, }, + //{ EMUCMD_LOAD_STATE_SLOT_9, SCAN_F9, }, +/* { EMUCMD_MOVIE_SLOT_0, SCAN_0 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_SLOT_1, SCAN_1 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_SLOT_2, SCAN_2 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_SLOT_3, SCAN_3 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_SLOT_4, SCAN_4 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_SLOT_5, SCAN_5 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_SLOT_6, SCAN_6 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_SLOT_7, SCAN_7 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_SLOT_8, SCAN_8 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_SLOT_9, SCAN_9 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_RECORD, SCAN_F5 | CMD_KEY_ALT, }, + { EMUCMD_MOVIE_REPLAY, SCAN_F7 | CMD_KEY_ALT, },*/ +}; + +#define NUM_DEFAULT_MAPPINGS (sizeof(DefaultCommandMapping)/sizeof(DefaultCommandMapping[0])) + +static const char* GetKeyName(int code) +{ + static char name[16]; + + code &= 0xff; + if(ScanNames[code]) + return ScanNames[code]; + + sprintf(name, "Key 0x%.2x", code); + return name; +} + +static char* GetKeyComboName(int c) +{ + static char text[80]; + + text[0]='\0'; + if(!c) + return text; + + if ((c & CMD_KEY_CTRL) == CMD_KEY_CTRL) strcat(text, "Ctrl + "); + else if ((c & CMD_KEY_CTRL) == CMD_KEY_LCTRL) strcat(text, "Left Ctrl + "); + else if ((c & CMD_KEY_CTRL) == CMD_KEY_RCTRL) strcat(text, "Right Ctrl + "); + if ((c & CMD_KEY_ALT) == CMD_KEY_ALT) strcat(text, "Alt + "); + else if ((c & CMD_KEY_ALT) == CMD_KEY_LALT) strcat(text, "Left Alt + "); + else if ((c & CMD_KEY_ALT) == CMD_KEY_RALT) strcat(text, "Right Alt + "); + if ((c & CMD_KEY_SHIFT) == CMD_KEY_SHIFT) strcat(text, "Shift + "); + else if ((c & CMD_KEY_SHIFT) == CMD_KEY_LSHIFT) strcat(text, "Left Shift + "); + else if ((c & CMD_KEY_SHIFT) == CMD_KEY_RSHIFT) strcat(text, "Right Shift + "); + + strcat(text, GetKeyName(c & CMD_KEY_MASK)); + + return text; +} + +void ApplyDefaultCommandMapping(void) +{ + int i; + + memset(FCEUD_CommandMapping, 0, sizeof(FCEUD_CommandMapping)); + + for(i=0; i0; --i) + SendMessage(hwndListView, LVM_DELETEITEM, (WPARAM)i-1, 0); + + // Get the filter type. + ConflictTable=0; + if (filter == EMUCMDTYPE_MAX+3) + { + // Set up the conflict table. + ConflictTable=(int*)malloc(sizeof(int)*EMUCMD_MAX); + memset(ConflictTable, 0, sizeof(int)*EMUCMD_MAX); + for(i=0; icode == LVN_ITEMACTIVATE) + { + int nSel = SendMessage(hwndListView, LVM_GETNEXTITEM, (WPARAM)-1, LVNI_SELECTED); + if (nSel != -1) + { + int nCmd; + int nRet; + LVITEM lvi; + + // Get the corresponding input + memset(&lvi, 0, sizeof(lvi)); + lvi.mask = LVIF_PARAM; + lvi.iItem = nSel; + lvi.iSubItem = 0; + SendMessage(hwndListView, LVM_GETITEM, 0, (LPARAM)&lvi); + nCmd = lvi.lParam; + + nRet = DialogBox(fceu_hInstance,"NEWINPUT",hwndListView,ChangeInputDialogProc); + if (nRet) + { + // nRet will be -1 when the user selects "clear". + FCEUD_CommandMapping[nCmd] = (nRet<0) ? 0 : nRet; + + memset(&lvi, 0, sizeof(lvi)); + lvi.mask = LVIF_TEXT; + lvi.iItem = nSel; + lvi.iSubItem = 2; + lvi.pszText = GetKeyComboName(FCEUD_CommandMapping[nCmd]); + SendMessage(hwndListView, LVM_SETITEM, (WPARAM)0, (LPARAM)&lvi); + } + } + } + return TRUE; + } + break; + + default: + break; + } + break; + + default: + break; + } + + return FALSE; +} + +/** +* Show input mapping configuration dialog. +**/ +void MapInput(void) +{ + // Make a backup of the current mappings, in case the user changes their mind. + int* backupmapping = (int*)malloc(sizeof(FCEUD_CommandMapping)); + memcpy(backupmapping, FCEUD_CommandMapping, sizeof(FCEUD_CommandMapping)); + + if(!DialogBox(fceu_hInstance, "MAPINPUT", hAppWnd, MapInputDialogProc)) + { + memcpy(FCEUD_CommandMapping, backupmapping, sizeof(FCEUD_CommandMapping)); + } + + free(backupmapping); +} + diff --git a/src/drivers/win/mapinput.h b/src/drivers/win/mapinput.h new file mode 100644 index 00000000..1bf94601 --- /dev/null +++ b/src/drivers/win/mapinput.h @@ -0,0 +1,4 @@ +#ifndef WIN_MAPINPUT_h +#define WIN_MAPINPUT_h + +#endif diff --git a/vc8/fceux.vcproj b/vc8/fceux.vcproj index 0aaaec25..30605ad5 100644 --- a/vc8/fceux.vcproj +++ b/vc8/fceux.vcproj @@ -938,6 +938,14 @@ RelativePath="..\src\drivers\win\main.h" > + + + +