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

View File

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