Index: ps/trunk/source/ps/Globals.h =================================================================== --- ps/trunk/source/ps/Globals.h +++ ps/trunk/source/ps/Globals.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2017 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -20,6 +20,7 @@ #include "lib/input.h" #include "lib/frequency_filter.h" +#include "ps/KeyName.h" #include @@ -51,10 +52,9 @@ * Updated by GlobalsInputHandler in response to mouse button up/down events. * * Be aware that SDL_BUTTON_* constants start at 1. Therefore, - * g_mouse_buttons[0] is unused. The order of entries is: - * { unused, left, right, middle, wheel up, wheel down } + * g_mouse_buttons[0] is unused. The order of entries is as in KeyName.h for MOUSE_* */ -extern bool g_mouse_buttons[6]; +extern bool g_mouse_buttons[MOUSE_LAST - MOUSE_BASE]; extern InReaction GlobalsInputHandler(const SDL_Event_* ev); Index: ps/trunk/source/ps/Globals.cpp =================================================================== --- ps/trunk/source/ps/Globals.cpp +++ ps/trunk/source/ps/Globals.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2017 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -18,7 +18,6 @@ #include "precompiled.h" #include "Globals.h" -#include "lib/external_libraries/libsdl.h" #include "network/NetClient.h" #include "ps/GameSetup/Config.h" #include "soundmanager/ISoundManager.h" @@ -30,9 +29,8 @@ int g_mouse_x = 50, g_mouse_y = 50; bool g_mouse_active = true; -// unused, left, right, middle, wheel up, wheel down -// (order is given by SDL_BUTTON_* constants). -bool g_mouse_buttons[6] = {0}; +// g_mouse_buttons[0] is unused. The order of entries is as in KeyName.h for MOUSE_* +bool g_mouse_buttons[MOUSE_LAST - MOUSE_BASE] = {0}; PIFrequencyFilter g_frequencyFilter; Index: ps/trunk/source/ps/Hotkey.cpp =================================================================== --- ps/trunk/source/ps/Hotkey.cpp +++ ps/trunk/source/ps/Hotkey.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2017 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -20,7 +20,6 @@ #include -#include "lib/input.h" #include "ps/CConsole.h" #include "ps/CLogger.h" #include "ps/CStr.h" @@ -142,7 +141,7 @@ if ((int)key.code < EXTRA_KEYS_BASE && g_keys[key.code] == key.negated) return false; // Mouse 'keycodes' are after the modifier keys - else if ((int)key.code > UNIFIED_LAST && g_mouse_buttons[key.code - UNIFIED_LAST] == key.negated) + else if ((int)key.code < MOUSE_LAST && (int)key.code > MOUSE_BASE && g_mouse_buttons[key.code - MOUSE_BASE] == key.negated) return false; // Modifier keycodes are between the normal keys and the mouse 'keys' else if ((int)key.code < UNIFIED_LAST && (int)key.code > SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES) && unified[key.code - UNIFIED_SHIFT] == key.negated) Index: ps/trunk/source/ps/KeyName.h =================================================================== --- ps/trunk/source/ps/KeyName.h +++ ps/trunk/source/ps/KeyName.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2017 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -50,6 +50,7 @@ MOUSE_WHEELDOWN = MOUSE_BASE + 5, MOUSE_X1 = MOUSE_BASE + SDL_BUTTON_X1 + 2, MOUSE_X2 = MOUSE_BASE + SDL_BUTTON_X2 + 2, + MOUSE_LAST, }; #endif // #ifndef INCLUDED_KEYNAME