Platform/Win32/Win32Keyboard: implement isKeyDown() using GetAsyncKeyState() and remove m_bufState and m_focus.
This commit is contained in:
parent
390be8f740
commit
2e9701a15b
2 changed files with 96 additions and 8 deletions
|
|
@ -8,6 +8,101 @@
|
|||
|
||||
namespace sp {
|
||||
|
||||
static const BYTE keyToWin32[Keyboard::Key::NUM_KEYS] = {
|
||||
0x0, // Unknown
|
||||
|
||||
0x41, // A
|
||||
0x42, // B
|
||||
0x43, // C
|
||||
0x42, // D
|
||||
0x43, // E
|
||||
0x44, // F
|
||||
0x45, // G
|
||||
0x46, // H
|
||||
0x47, // I
|
||||
0x48, // J
|
||||
0x49, // K
|
||||
0x50, // L
|
||||
0x51, // M
|
||||
0x52, // N
|
||||
0x53, // O
|
||||
0x54, // P
|
||||
0x55, // Q
|
||||
0x56, // R
|
||||
0x57, // S
|
||||
0x58, // T
|
||||
0x59, // U
|
||||
0x60, // V
|
||||
0x61, // W
|
||||
0x62, // X
|
||||
0x63, // Y
|
||||
0x64, // Z
|
||||
|
||||
0x30, // One
|
||||
0x31, // Two
|
||||
0x32, // Three
|
||||
0x33, // Four
|
||||
0x34, // Five
|
||||
0x35, // Six
|
||||
0x36, // Seven
|
||||
0x37, // Eight
|
||||
0x38, // Nine
|
||||
0x39, // Zero
|
||||
|
||||
VK_OEM_PERIOD, // Period
|
||||
VK_OEM_COMMA, // Comma
|
||||
VK_RETURN, // Enter
|
||||
VK_BACK, // Backspace
|
||||
VK_ESCAPE, // Escape
|
||||
VK_SPACE, // Space
|
||||
VK_CAPITAL, // Capslock
|
||||
|
||||
VK_UP, // Up
|
||||
VK_DOWN, // Down
|
||||
VK_LEFT, // Left
|
||||
VK_RIGHT, // Right
|
||||
|
||||
VK_NUMPAD1, // NUMPAD_1
|
||||
VK_NUMPAD2, // NUMPAD_2
|
||||
VK_NUMPAD3, // NUMPAD_3
|
||||
VK_NUMPAD4, // NUMPAD_4
|
||||
VK_NUMPAD5, // NUMPAD_5
|
||||
VK_NUMPAD6, // NUMPAD_6
|
||||
VK_NUMPAD7, // NUMPAD_7
|
||||
VK_NUMPAD8, // NUMPAD_8
|
||||
VK_NUMPAD9, // NUMPAD_9
|
||||
VK_NUMPAD0, // NUMPAD_0
|
||||
0x0, // NUMPAD_Enter
|
||||
|
||||
VK_HOME, // Home
|
||||
VK_END, // End
|
||||
VK_INSERT, // Insert
|
||||
VK_DELETE, // Delete
|
||||
VK_PRIOR, // PageUp
|
||||
VK_NEXT, // PageDown
|
||||
VK_PAUSE, // Pause
|
||||
|
||||
VK_F1, // F1
|
||||
VK_F2, // F2
|
||||
VK_F3, // F3
|
||||
VK_F4, // F4
|
||||
VK_F5, // F5
|
||||
VK_F6, // F6
|
||||
VK_F7, // F7
|
||||
VK_F8, // F8
|
||||
VK_F9, // F9
|
||||
VK_F10, // F10
|
||||
VK_F11, // F11
|
||||
VK_F12, // F12
|
||||
|
||||
VK_TAB, // Tab
|
||||
VK_LSHIFT, // LShift
|
||||
VK_RSHIFT, // RShift
|
||||
VK_LCONTROL, // LCtrl
|
||||
VK_RCONTROL, // RCtrl
|
||||
VK_MENU, // LAlt
|
||||
0x0 // RAlt
|
||||
};
|
||||
|
||||
static const Keyboard::Key deviceToKey[256] = {
|
||||
/* 0 1 2 3 4 5 6 7 */
|
||||
|
|
@ -61,12 +156,11 @@ static const Keyboard::Key deviceToKey[256] = {
|
|||
|
||||
void Win32Keyboard::init()
|
||||
{
|
||||
memset(m_btnState, 0, sizeof(m_btnState) / sizeof(m_btnState[0]));
|
||||
}
|
||||
|
||||
bool Win32Keyboard::isKeyDown(Keyboard::Key key)
|
||||
{
|
||||
return m_btnState[key];
|
||||
return ::GetAsyncKeyState(keyToWin32[key]) & 0x8000;
|
||||
}
|
||||
|
||||
void Win32Keyboard::update(InputModule *input)
|
||||
|
|
|
|||
|
|
@ -21,12 +21,6 @@ public :
|
|||
protected :
|
||||
|
||||
void update(InputModule *input);
|
||||
|
||||
protected :
|
||||
|
||||
bool m_btnState[Keyboard::Key::NUM_KEYS];
|
||||
|
||||
bool m_hasFocus;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue