summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2013-08-05 20:36:36 +0000
committermichi_cc <michi_cc@openttd.org>2013-08-05 20:36:36 +0000
commit019984a14f01e4463ae479765d2340ff26055367 (patch)
tree291b47c56523ebef7368f3588e921a1cdb78f331 /src/video
parent270d8aa639341f8be7fde9aa6e6f5bb6fa894d4f (diff)
downloadopenttd-019984a14f01e4463ae479765d2340ff26055367.tar.xz
(svn r25671) -Codechange: Pass character and key code separately to the keyboard handler.
Diffstat (limited to 'src/video')
-rw-r--r--src/video/allegro_v.cpp10
-rw-r--r--src/video/cocoa/event.mm6
-rw-r--r--src/video/sdl_v.cpp9
-rw-r--r--src/video/win32_v.cpp8
4 files changed, 20 insertions, 13 deletions
diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp
index 029cc062a..963353f0d 100644
--- a/src/video/allegro_v.cpp
+++ b/src/video/allegro_v.cpp
@@ -304,7 +304,7 @@ static const VkMapping _vk_mapping[] = {
AS(KEY_TILDE, WKC_BACKQUOTE),
};
-static uint32 ConvertAllegroKeyIntoMy()
+static uint32 ConvertAllegroKeyIntoMy(WChar *character)
{
int scancode;
int unicode = ureadkey(&scancode);
@@ -326,7 +326,9 @@ static uint32 ConvertAllegroKeyIntoMy()
DEBUG(driver, 0, "Scancode character pressed %u", scancode);
DEBUG(driver, 0, "Unicode character pressed %u", unicode);
#endif
- return (key << 16) + unicode;
+
+ *character = unicode;
+ return key;
}
static const uint LEFT_BUTTON = 0;
@@ -414,7 +416,9 @@ static void PollEvent()
if ((key_shifts & KB_ALT_FLAG) && (key[KEY_ENTER] || key[KEY_F])) {
ToggleFullScreen(!_fullscreen);
} else if (keypressed()) {
- HandleKeypress(ConvertAllegroKeyIntoMy());
+ WChar character;
+ uint keycode = ConvertAllegroKeyIntoMy(&character);
+ HandleKeypress(keycode, character);
}
}
diff --git a/src/video/cocoa/event.mm b/src/video/cocoa/event.mm
index 0e7831c34..40bf57eb6 100644
--- a/src/video/cocoa/event.mm
+++ b/src/video/cocoa/event.mm
@@ -267,7 +267,7 @@ static uint32 QZ_MapKey(unsigned short sym)
if (_current_mods & NSAlternateKeyMask) key |= WKC_ALT;
if (_current_mods & NSCommandKeyMask) key |= (_settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_META : WKC_CTRL);
- return key << 16;
+ return key;
}
static void QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL down)
@@ -289,8 +289,8 @@ static void QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL dow
}
if (down) {
- uint32 pressed_key = QZ_MapKey(keycode) | unicode;
- HandleKeypress(pressed_key);
+ uint32 pressed_key = QZ_MapKey(keycode);
+ HandleKeypress(pressed_key, unicode);
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/src/video/sdl_v.cpp b/src/video/sdl_v.cpp
index d66ad59a8..a95e86332 100644
--- a/src/video/sdl_v.cpp
+++ b/src/video/sdl_v.cpp
@@ -495,7 +495,7 @@ static const VkMapping _vk_mapping[] = {
AS(SDLK_PERIOD, WKC_PERIOD)
};
-static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
+static uint ConvertSdlKeyIntoMy(SDL_keysym *sym, WChar *character)
{
const VkMapping *map;
uint key = 0;
@@ -531,7 +531,8 @@ static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
if (sym->mod & KMOD_CTRL) key |= WKC_CTRL;
if (sym->mod & KMOD_ALT) key |= WKC_ALT;
- return (key << 16) + sym->unicode;
+ *character = sym->unicode;
+ return key;
}
int VideoDriver_SDL::PollEvent()
@@ -617,7 +618,9 @@ int VideoDriver_SDL::PollEvent()
(ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_f)) {
ToggleFullScreen(!_fullscreen);
} else {
- HandleKeypress(ConvertSdlKeyIntoMy(&ev.key.keysym));
+ WChar character;
+ uint keycode = ConvertSdlKeyIntoMy(&ev.key.keysym, &character);
+ HandleKeypress(keycode, character);
}
break;
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 814fdc4b9..7a6e8a866 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -447,7 +447,7 @@ static LRESULT HandleCharMsg(uint keycode, uint charcode)
charcode = len == 1 ? w : 0;
#endif /* UNICODE */
- HandleKeypress(GB(charcode, 0, 16) | (keycode << 16));
+ HandleKeypress(keycode, charcode);
return 0;
}
@@ -637,7 +637,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
/* No character translation? */
if (charcode == 0) {
- HandleKeypress(0 | (keycode << 16));
+ HandleKeypress(keycode, 0);
return 0;
}
@@ -669,11 +669,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
- HandleKeypress(MapWindowsKey(wParam) << 16);
+ HandleKeypress(MapWindowsKey(wParam), 0);
return 0;
default: // ALT in combination with something else
- HandleKeypress(MapWindowsKey(wParam) << 16);
+ HandleKeypress(MapWindowsKey(wParam), 0);
break;
}
break;