summaryrefslogtreecommitdiff
path: root/video
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-11-15 19:35:52 +0000
committerDarkvater <darkvater@openttd.org>2006-11-15 19:35:52 +0000
commit3a03b70319d432b76695d84b4342d1f441ea08b1 (patch)
treea33f8b2226bf03932b173095e369e476546d58ad /video
parent4a986e43d4c6e91fae4404d2c92125e6e8fa6cc2 (diff)
downloadopenttd-3a03b70319d432b76695d84b4342d1f441ea08b1.tar.xz
(svn r7153) -Fix [FS#279]: Some keyboard events possibly lost under high CPU load, handle
keyboard input in place instead of global variables magic. (KUDr)
Diffstat (limited to 'video')
-rw-r--r--video/cocoa_v.m5
-rw-r--r--video/sdl_v.c3
-rw-r--r--video/win32_v.c12
3 files changed, 11 insertions, 9 deletions
diff --git a/video/cocoa_v.m b/video/cocoa_v.m
index e55e40b14..e10e87dc2 100644
--- a/video/cocoa_v.m
+++ b/video/cocoa_v.m
@@ -347,8 +347,9 @@ static void QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL dow
}
if (down) {
- _pressed_key = QZ_MapKey(keycode) | unicode;
- DEBUG(driver, 2)("cocoa_v: QZ_KeyEvent: %x (%x), down, mapping: %x", keycode, unicode, _pressed_key);
+ uint32 pressed_key = QZ_MapKey(keycode) | unicode;
+ HandleKeypress(pressed_key);
+ DEBUG(driver, 2)("cocoa_v: QZ_KeyEvent: %x (%x), down, mapping: %x", keycode, unicode, pressed_key);
} else {
DEBUG(driver, 2)("cocoa_v: QZ_KeyEvent: %x (%x), up", keycode, unicode);
}
diff --git a/video/sdl_v.c b/video/sdl_v.c
index d9ddc6219..b0630b27d 100644
--- a/video/sdl_v.c
+++ b/video/sdl_v.c
@@ -380,9 +380,8 @@ static int PollEvent(void)
(ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_f)) {
ToggleFullScreen(!_fullscreen);
} else {
- _pressed_key = ConvertSdlKeyIntoMy(&ev.key.keysym);
+ HandleKeypress(ConvertSdlKeyIntoMy(&ev.key.keysym));
}
-
break;
case SDL_VIDEORESIZE: {
diff --git a/video/win32_v.c b/video/win32_v.c
index f6ecf069c..747b6ef81 100644
--- a/video/win32_v.c
+++ b/video/win32_v.c
@@ -346,23 +346,25 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
WORD w = 0;
byte ks[256];
uint scancode;
+ uint32 pressed_key;
GetKeyboardState(ks);
if (ToAscii(wParam, 0, ks, &w, 0) == 0) {
w = 0; // no translation was possible
}
- _pressed_key = w | MapWindowsKey(wParam) << 16;
+ pressed_key = w | MapWindowsKey(wParam) << 16;
scancode = GB(lParam, 16, 8);
- if (scancode == 41) _pressed_key = w | WKC_BACKQUOTE << 16;
+ if (scancode == 41) pressed_key = w | WKC_BACKQUOTE << 16;
- if ((_pressed_key >> 16) == ('D' | WKC_CTRL) && !_wnd.fullscreen) {
+ if ((pressed_key >> 16) == ('D' | WKC_CTRL) && !_wnd.fullscreen) {
_double_size ^= 1;
_wnd.double_size = _double_size;
ClientSizeChanged(_wnd.width, _wnd.height);
MarkWholeScreenDirty();
}
+ HandleKeypress(pressed_key);
break;
}
@@ -377,11 +379,11 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
return 0; // do nothing
case VK_F10: /* F10, ignore activation of menu */
- _pressed_key = MapWindowsKey(wParam) << 16;
+ HandleKeypress(MapWindowsKey(wParam) << 16);
return 0;
default: /* ALT in combination with something else */
- _pressed_key = MapWindowsKey(wParam) << 16;
+ HandleKeypress(MapWindowsKey(wParam) << 16);
break;
}
break;