# HG changeset patch # User sbr # Date 1375201180 -7200 # Tue Jul 30 18:19:40 2013 +0200 # Node ID f467cd5ef652eda5e105bf59a14936e48598126d # Parent c2901bee83cb7422cf9375fae4dec5b616caa78d -Add: a window keycode for the '+' key. A new WindowKeyCode WKC_PLUS is declared and is mapped to the video driver keycodes for SDL, Allegro and Win32. SDL provides SDLK_PLUS as scancode for the '+' key (http://www.libsdl.org/docs/html/sdlkey.html). No scancode for '+' exists in the Allegro driver (https://www.allegro.cc/manual/4/api/keyboard-routines/key). The unicode representation of '+' is tested before the scancode mapping loop. Win32 provide 0xBB (VK_OEM_PLUS) as scancode for the '+' key (http://www.kbdedit.com/manual/low_level_vk_list.html). I have no Windows computer and thus haven't tested the Win32 mapping. diff --git a/src/gfx_type.h b/src/gfx_type.h --- a/src/gfx_type.h +++ b/src/gfx_type.h @@ -104,6 +104,7 @@ enum WindowKeyCodes { WKC_COMMA = 151, ///< , Comma WKC_PERIOD = 152, ///< . Period WKC_MINUS = 153, ///< - Minus + WKC_PLUS = 154, ///< + Plus }; /** A single sprite of a list of animated cursors */ diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -312,10 +312,16 @@ static uint32 ConvertAllegroKeyIntoMy() const VkMapping *map; uint key = 0; - for (map = _vk_mapping; map != endof(_vk_mapping); ++map) { - if ((uint)(scancode - map->vk_from) <= map->vk_count) { - key = scancode - map->vk_from + map->map_to; - break; + if (unicode == (int)'+') { + /* No scancode for '+' in allegro, tests the unicode representation. */ + key = WKC_PLUS; + } else { + /* Use allegro scancodes. */ + for (map = _vk_mapping; map != endof(_vk_mapping); ++map) { + if ((uint)(scancode - map->vk_from) <= map->vk_count) { + key = scancode - map->vk_from + map->map_to; + break; + } } } diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -492,7 +492,8 @@ static const VkMapping _vk_mapping[] = { AS(SDLK_QUOTE, WKC_SINGLEQUOTE), AS(SDLK_COMMA, WKC_COMMA), AS(SDLK_MINUS, WKC_MINUS), - AS(SDLK_PERIOD, WKC_PERIOD) + AS(SDLK_PERIOD, WKC_PERIOD), + AS(SDLK_PLUS, WKC_PLUS), }; static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym) diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -149,7 +149,8 @@ static const VkMapping _vk_mapping[] = { AS(0xDE, WKC_SINGLEQUOTE), AS(0xBC, WKC_COMMA), AS(0xBD, WKC_MINUS), - AS(0xBE, WKC_PERIOD) + AS(0xBE, WKC_PERIOD), + AS(0xBB, WKC_PLUS), // VK_OEM_PLUS }; static uint MapWindowsKey(uint sym)