improved DIKToString

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@688 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2008-09-25 14:37:01 +00:00
parent 1d8cd86b43
commit 96cbb39cd8
1 changed files with 28 additions and 19 deletions

View File

@ -29,32 +29,45 @@ DInput::~DInput()
Free(); Free();
} }
void DInput::DIKToString(unsigned int keycode, char *keyStr) { void DInput::DIKToString(unsigned int keycode, char *keyStr)
HKL layout = GetKeyboardLayout(0); {
BYTE kbstate[256];
switch(keycode) { switch(keycode) {
case DIK_RETURN: case DIK_RETURN:
sprintf(keyStr, "ENTER"); sprintf(keyStr, "Enter");
break; break;
case DIK_UP: case DIK_UP:
sprintf(keyStr, "UP"); sprintf(keyStr, "Up");
break; break;
case DIK_DOWN: case DIK_DOWN:
sprintf(keyStr, "DOWN"); sprintf(keyStr, "Down");
break; break;
case DIK_LEFT: case DIK_LEFT:
sprintf(keyStr, "LEFT"); sprintf(keyStr, "Left");
break; break;
case DIK_RIGHT: case DIK_RIGHT:
sprintf(keyStr, "RIGHT"); sprintf(keyStr, "Right");
break;
case DIK_HOME:
strcpy(keyStr, "Home");
break;
case DIK_END:
strcpy(keyStr, "End");
break;
case DIK_INSERT:
strcpy(keyStr, "Ins");
break;
case DIK_DELETE:
strcpy(keyStr, "Del");
break;
case DIK_PGUP:
strcpy(keyStr, "PgUp");
break;
case DIK_PGDN:
strcpy(keyStr, "PgDn");
break; break;
default: default:
GetKeyboardState(kbstate); GetKeyNameText(keycode << 16, keyStr, 64);
UINT vk = MapVirtualKeyEx(keycode, 1, layout); break;
ToAsciiEx(vk, keycode, kbstate, (LPWORD)keyStr, 0, layout);
keyStr[0] = toupper(keyStr[0]);
} }
} }
@ -86,7 +99,6 @@ HRESULT DInput::Init(HWND hWnd)
return(S_OK); return(S_OK);
} }
void DInput::Free() void DInput::Free()
{ {
if (g_pKeyboard) if (g_pKeyboard)
@ -103,7 +115,6 @@ void DInput::Free()
} }
} }
// Desc: Read the input device's state when in immediate mode and display it. // Desc: Read the input device's state when in immediate mode and display it.
HRESULT DInput::Read() HRESULT DInput::Read()
{ {
@ -143,5 +154,3 @@ HRESULT DInput::Read()
return(S_OK); return(S_OK);
} }