win: don't queue up key presses at all, send them instantly.

This commit is contained in:
Henrik Rydgard 2013-07-06 21:49:28 +02:00
parent 7e5a68ab16
commit cb87340e71
3 changed files with 16 additions and 38 deletions

View file

@ -144,27 +144,7 @@ int KeyboardDevice::UpdateState(InputState &input_state) {
}
}
}
for (size_t i = 0; i < downKeys.size(); i++) {
KeyInput key;
key.deviceId = DEVICE_ID_KEYBOARD;
key.flags = KEY_DOWN;
key.keyCode = windowsTransTable[downKeys[i]];
if (key.keyCode)
NativeKey(key);
}
downKeys.clear();
for (size_t i = 0; i < upKeys.size(); i++) {
KeyInput key;
key.deviceId = DEVICE_ID_KEYBOARD;
key.flags = KEY_UP;
key.keyCode = windowsTransTable[upKeys[i]];
if (key.keyCode)
NativeKey(key);
}
upKeys.clear();
return 0;
}

View file

@ -9,14 +9,5 @@ public:
virtual int UpdateState(InputState &input_state);
virtual bool IsPad() { return false; }
virtual void KeyDown(int keycode) {
downKeys.push_back(keycode);
}
virtual void KeyUp(int keycode) {
upKeys.push_back(keycode);
}
private:
std::vector<int> downKeys;
std::vector<int> upKeys;
};

View file

@ -3,6 +3,8 @@
#include <windows.h>
#include <tchar.h>
#include <map>
#include "base/NativeApp.h"
#include "Globals.h"
@ -46,6 +48,7 @@
#define ENABLE_TOUCH 0
extern std::map<int, int> windowsTransTable;
BOOL g_bFullScreen = FALSE;
static RECT g_normalRC = {0};
extern bool g_TakeScreenshot;
@ -800,19 +803,23 @@ namespace MainWindow
case WM_KEYDOWN:
{
// Ugly
WindowsHost *whost = static_cast<WindowsHost *>(host);
int vkey = wParam;
whost->keyboard->KeyDown(vkey);
KeyInput key;
key.deviceId = DEVICE_ID_KEYBOARD;
key.flags = KEY_DOWN;
key.keyCode = windowsTransTable[(int)wParam];
if (key.keyCode)
NativeKey(key);
}
return 0;
case WM_KEYUP:
{
// Ugly
WindowsHost *whost = static_cast<WindowsHost *>(host);
int vkey = wParam;
whost->keyboard->KeyUp(vkey);
KeyInput key;
key.deviceId = DEVICE_ID_KEYBOARD;
key.flags = KEY_UP;
key.keyCode = windowsTransTable[(int)wParam];
if (key.keyCode)
NativeKey(key);
}
return 0;