Skip to content

Commit

Permalink
Fix: VkMapping declarations violated C++ ODR rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
Milek7 authored and glx22 committed Feb 14, 2021
1 parent 5a1fa18 commit 751f595
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/video/allegro_v.cpp
Expand Up @@ -235,7 +235,7 @@ bool VideoDriver_Allegro::ClaimMousePointer()
return true;
}

struct VkMapping {
struct AllegroVkMapping {
uint16 vk_from;
byte vk_count;
byte map_to;
Expand All @@ -244,7 +244,7 @@ struct VkMapping {
#define AS(x, z) {x, 0, z}
#define AM(x, y, z, w) {x, y - x, z}

static const VkMapping _vk_mapping[] = {
static const AllegroVkMapping _vk_mapping[] = {
/* Pageup stuff + up/down */
AM(KEY_PGUP, KEY_PGDN, WKC_PAGEUP, WKC_PAGEDOWN),
AS(KEY_UP, WKC_UP),
Expand Down Expand Up @@ -302,7 +302,7 @@ static uint32 ConvertAllegroKeyIntoMy(WChar *character)
int scancode;
int unicode = ureadkey(&scancode);

const VkMapping *map;
const AllegroVkMapping *map;
uint key = 0;

for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
Expand Down
4 changes: 2 additions & 2 deletions src/video/cocoa/cocoa_keys.h
Expand Up @@ -132,14 +132,14 @@
#define QZ_IBOOK_UP 0x3E


struct VkMapping {
struct CocoaVkMapping {
unsigned short vk_from;
byte map_to;
};

#define AS(x, z) {x, z}

static const VkMapping _vk_mapping[] = {
static const CocoaVkMapping _vk_mapping[] = {
AS(QZ_BACKQUOTE, WKC_BACKQUOTE), // key left of '1'
AS(QZ_BACKQUOTE2, WKC_BACKQUOTE), // some keyboards have it on another scancode

Expand Down
2 changes: 1 addition & 1 deletion src/video/cocoa/cocoa_wnd.mm
Expand Up @@ -673,7 +673,7 @@ - (BOOL)internalHandleKeycode:(unsigned short)keycode unicode:(WChar)unicode pre
BOOL interpret_keys = YES;
if (down) {
/* Map keycode to OTTD code. */
auto vk = std::find_if(std::begin(_vk_mapping), std::end(_vk_mapping), [=](const VkMapping &m) { return m.vk_from == keycode; });
auto vk = std::find_if(std::begin(_vk_mapping), std::end(_vk_mapping), [=](const CocoaVkMapping &m) { return m.vk_from == keycode; });
uint32 pressed_key = vk != std::end(_vk_mapping) ? vk->map_to : 0;

if (modifiers & NSShiftKeyMask) pressed_key |= WKC_SHIFT;
Expand Down
8 changes: 4 additions & 4 deletions src/video/sdl2_v.cpp
Expand Up @@ -401,7 +401,7 @@ void VideoDriver_SDL::EditBoxLostFocus()
}


struct VkMapping {
struct SDLVkMapping {
SDL_Keycode vk_from;
byte vk_count;
byte map_to;
Expand All @@ -413,7 +413,7 @@ struct VkMapping {
#define AS_UP(x, z) {x, 0, z, true}
#define AM_UP(x, y, z, w) {x, (byte)(y - x), z, true}

static const VkMapping _vk_mapping[] = {
static const SDLVkMapping _vk_mapping[] = {
/* Pageup stuff + up/down */
AS_UP(SDLK_PAGEUP, WKC_PAGEUP),
AS_UP(SDLK_PAGEDOWN, WKC_PAGEDOWN),
Expand Down Expand Up @@ -468,7 +468,7 @@ static const VkMapping _vk_mapping[] = {

static uint ConvertSdlKeyIntoMy(SDL_Keysym *sym, WChar *character)
{
const VkMapping *map;
const SDLVkMapping *map;
uint key = 0;
bool unprintable = false;

Expand Down Expand Up @@ -508,7 +508,7 @@ static uint ConvertSdlKeyIntoMy(SDL_Keysym *sym, WChar *character)
*/
static uint ConvertSdlKeycodeIntoMy(SDL_Keycode kc)
{
const VkMapping *map;
const SDLVkMapping *map;
uint key = 0;

for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
Expand Down
6 changes: 3 additions & 3 deletions src/video/sdl_v.cpp
Expand Up @@ -403,7 +403,7 @@ bool VideoDriver_SDL::ClaimMousePointer()
return true;
}

struct VkMapping {
struct SDLVkMapping {
#if SDL_VERSION_ATLEAST(1, 3, 0)
SDL_Keycode vk_from;
#else
Expand All @@ -416,7 +416,7 @@ struct VkMapping {
#define AS(x, z) {x, 0, z}
#define AM(x, y, z, w) {x, (byte)(y - x), z}

static const VkMapping _vk_mapping[] = {
static const SDLVkMapping _vk_mapping[] = {
/* Pageup stuff + up/down */
AM(SDLK_PAGEUP, SDLK_PAGEDOWN, WKC_PAGEUP, WKC_PAGEDOWN),
AS(SDLK_UP, WKC_UP),
Expand Down Expand Up @@ -470,7 +470,7 @@ static const VkMapping _vk_mapping[] = {

static uint ConvertSdlKeyIntoMy(SDL_keysym *sym, WChar *character)
{
const VkMapping *map;
const SDLVkMapping *map;
uint key = 0;

for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
Expand Down
6 changes: 3 additions & 3 deletions src/video/win32_v.cpp
Expand Up @@ -114,7 +114,7 @@ bool VideoDriver_Win32::ClaimMousePointer()
return true;
}

struct VkMapping {
struct Win32VkMapping {
byte vk_from;
byte vk_count;
byte map_to;
Expand All @@ -123,7 +123,7 @@ struct VkMapping {
#define AS(x, z) {x, 0, z}
#define AM(x, y, z, w) {x, y - x, z}

static const VkMapping _vk_mapping[] = {
static const Win32VkMapping _vk_mapping[] = {
/* Pageup stuff + up/down */
AM(VK_PRIOR, VK_DOWN, WKC_PAGEUP, WKC_DOWN),
/* Map letters & digits */
Expand Down Expand Up @@ -166,7 +166,7 @@ static const VkMapping _vk_mapping[] = {

static uint MapWindowsKey(uint sym)
{
const VkMapping *map;
const Win32VkMapping *map;
uint key = 0;

for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
Expand Down

0 comments on commit 751f595

Please sign in to comment.