fix text enter

This commit is contained in:
Eduardo Bart 2011-04-14 12:09:16 -03:00
parent 6392f71641
commit 4f386a854a
2 changed files with 16 additions and 19 deletions

View File

@ -517,10 +517,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
case WM_CHAR:
{
if(wParam >= 32 && wParam <= 255) {
inputEvent.type = EV_TEXT_ENTER;
inputEvent.keychar = wParam;
inputEvent.keycode = KC_UNKNOWN;
g_engine.onInputEvent(inputEvent);
}
break;
}
case WM_CLOSE:
@ -536,22 +538,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
case WM_KEYDOWN:
{
inputEvent.type = EV_KEY_DOWN;
inputEvent.ctrl = HIWORD(GetKeyState(VK_CONTROL)) == 0 ? false : true;
inputEvent.alt = HIWORD(GetKeyState(VK_MENU)) == 0 ? false : true;
inputEvent.shift = HIWORD(GetKeyState(VK_SHIFT)) == 0 ? false : true;
inputEvent.keycode = win32.keyMap[wParam];
g_engine.onInputEvent(inputEvent);
break;
}
case WM_KEYUP:
{
inputEvent.type = EV_KEY_UP;
if(win32.keyMap.find(wParam) != win32.keyMap.end()) {
inputEvent.type = uMsg == WM_KEYDOWN ? EV_KEY_DOWN : WM_KEYUP;
inputEvent.ctrl = HIWORD(GetKeyState(VK_CONTROL)) == 0 ? false : true;
inputEvent.alt = HIWORD(GetKeyState(VK_MENU)) == 0 ? false : true;
inputEvent.shift = HIWORD(GetKeyState(VK_SHIFT)) == 0 ? false : true;
inputEvent.keycode = win32.keyMap[wParam];
}
g_engine.onInputEvent(inputEvent);
break;
}

View File

@ -337,12 +337,14 @@ void Platform::poll()
static XComposeStatus compose = {NULL, 0};
len = XLookupString(&event.xkey, buf, sizeof(buf), &keysym, &compose);
}
if(len > 0 &&
// for some reason these keys produces characters and we don't want that
keysym != XK_BackSpace &&
keysym != XK_Return &&
keysym != XK_Delete &&
keysym != XK_Escape
keysym != XK_Escape &&
(uchar)(buf[0]) >= 32
) {
//logDebug("char: %c code: %d", buf[0], (uchar)buf[0]);
inputEvent.type = EV_TEXT_ENTER;