diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-12-31 21:06:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-12-31 21:06:01 +0300 |
commit | dd22711fd400dc1d55c54b18bd37dd5d7630b966 (patch) | |
tree | 353060be7ff550d7a291f5a53953926e071a3191 /src | |
parent | cd5cd6387c8a62f90a8f44c3657812f3e9a4cab9 (diff) | |
download | manaplus-dd22711fd400dc1d55c54b18bd37dd5d7630b966.tar.gz manaplus-dd22711fd400dc1d55c54b18bd37dd5d7630b966.tar.bz2 manaplus-dd22711fd400dc1d55c54b18bd37dd5d7630b966.tar.xz manaplus-dd22711fd400dc1d55c54b18bd37dd5d7630b966.zip |
Move keyvalue into enums directory.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/enums/input/keyvalue.h | 131 | ||||
-rw-r--r-- | src/gui/sdlinput.cpp | 116 | ||||
-rw-r--r-- | src/input/key.h | 52 |
5 files changed, 192 insertions, 109 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d036d542d..083488f3c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -976,6 +976,7 @@ SET(SRCS input/inputmanager.cpp input/inputmanager.h enums/input/inputtype.h + enums/input/keyvalue.h events/inputevent.h input/joystick.cpp input/joystick.h diff --git a/src/Makefile.am b/src/Makefile.am index 050888e8e..ae4b07cbc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -506,6 +506,7 @@ SRC += events/actionevent.h \ input/inputmanager.cpp \ input/inputmanager.h \ enums/input/inputtype.h \ + enums/input/keyvalue.h \ input/joystick.cpp \ input/joystick.h \ input/keyboardconfig.cpp \ diff --git a/src/enums/input/keyvalue.h b/src/enums/input/keyvalue.h new file mode 100644 index 000000000..aadf892c8 --- /dev/null +++ b/src/enums/input/keyvalue.h @@ -0,0 +1,131 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2015 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Guichan nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ENUMS_INPUT_KEYVALUE_H +#define ENUMS_INPUT_KEYVALUE_H + +#include "localconsts.h" + +// windows.h defines DELETE which breaks this file as we have a constant named +// DELETE, hence we undefine DELETE if it is defined and hope people don't use +// that windows define with Guichan. +#if defined (_WIN32) && defined(DELETE) +#undef DELETE +#endif + +namespace KeyValue +{ + enum + { + SPACE = ' ', + TAB = '\t', + ENTER = '\n', + // Negative values, to avoid conflicts with higher character codes. + LEFT_ALT = -1000, + RIGHT_ALT, + LEFT_SHIFT, + RIGHT_SHIFT, + LEFT_CONTROL, + RIGHT_CONTROL, + LEFT_META, + RIGHT_META, + LEFT_SUPER, + RIGHT_SUPER, + INSERT, + HOME, + PAGE_UP, + DELETE_, + END, + PAGE_DOWN, + ESCAPE, + CAPS_LOCK, + BACKSPACE, + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + PRINT_SCREEN, + SCROLL_LOCK, + PAUSE, + NUM_LOCK, + ALT_GR, + LEFT, + RIGHT, + UP, + DOWN, + TEXTINPUT + }; +} // namespace KeyValue + +#endif // ENUMS_INPUT_KEYVALUE_H diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index f3dcc47b2..60fa494ea 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -77,6 +77,8 @@ #include "sdlshared.h" +#include "enums/input/keyvalue.h" + #include "input/inputmanager.h" #include "gui/gui.h" @@ -154,7 +156,7 @@ void SDLInput::pushInput(const SDL_Event &event) #ifdef USE_SDL2 case SDL_TEXTINPUT: keyInput.setType(KeyEventType::PRESSED); - keyInput.setKey(Key(Key::TEXTINPUT)); + keyInput.setKey(Key(KeyValue::TEXTINPUT)); keyInput.setText(event.text.text); mKeyInputQueue.push(keyInput); break; @@ -334,31 +336,31 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event) switch (keysym.sym) { case SDLK_TAB: - value = Key::TAB; + value = KeyValue::TAB; break; case SDLK_LALT: - value = Key::LEFT_ALT; + value = KeyValue::LEFT_ALT; break; case SDLK_RALT: - value = Key::RIGHT_ALT; + value = KeyValue::RIGHT_ALT; break; case SDLK_LSHIFT: - value = Key::LEFT_SHIFT; + value = KeyValue::LEFT_SHIFT; break; case SDLK_RSHIFT: - value = Key::RIGHT_SHIFT; + value = KeyValue::RIGHT_SHIFT; break; case SDLK_LCTRL: - value = Key::LEFT_CONTROL; + value = KeyValue::LEFT_CONTROL; break; case SDLK_RCTRL: - value = Key::RIGHT_CONTROL; + value = KeyValue::RIGHT_CONTROL; break; case SDLK_BACKSPACE: - value = Key::BACKSPACE; + value = KeyValue::BACKSPACE; break; case SDLK_PAUSE: - value = Key::PAUSE; + value = KeyValue::PAUSE; break; case SDLK_SPACE: // Special characters like ~ (tilde) ends up @@ -369,124 +371,124 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event) if (event.type == SDL_KEYUP || keysym.unicode == ' ') #endif { - value = Key::SPACE; + value = KeyValue::SPACE; } break; case SDLK_ESCAPE: #ifdef USE_SDL2 case SDLK_AC_BACK: #endif - value = Key::ESCAPE; + value = KeyValue::ESCAPE; break; case SDLK_DELETE: - value = Key::DELETE_; + value = KeyValue::DELETE_; break; case SDLK_INSERT: - value = Key::INSERT; + value = KeyValue::INSERT; break; case SDLK_HOME: - value = Key::HOME; + value = KeyValue::HOME; break; case SDLK_END: - value = Key::END; + value = KeyValue::END; break; case SDLK_PAGEUP: - value = Key::PAGE_UP; + value = KeyValue::PAGE_UP; break; case SDLK_PRINT: - value = Key::PRINT_SCREEN; + value = KeyValue::PRINT_SCREEN; break; case SDLK_PAGEDOWN: - value = Key::PAGE_DOWN; + value = KeyValue::PAGE_DOWN; break; case SDLK_F1: - value = Key::F1; + value = KeyValue::F1; break; case SDLK_F2: - value = Key::F2; + value = KeyValue::F2; break; case SDLK_F3: - value = Key::F3; + value = KeyValue::F3; break; case SDLK_F4: - value = Key::F4; + value = KeyValue::F4; break; case SDLK_F5: - value = Key::F5; + value = KeyValue::F5; break; case SDLK_F6: - value = Key::F6; + value = KeyValue::F6; break; case SDLK_F7: - value = Key::F7; + value = KeyValue::F7; break; case SDLK_F8: - value = Key::F8; + value = KeyValue::F8; break; case SDLK_F9: - value = Key::F9; + value = KeyValue::F9; break; case SDLK_F10: - value = Key::F10; + value = KeyValue::F10; break; case SDLK_F11: - value = Key::F11; + value = KeyValue::F11; break; case SDLK_F12: - value = Key::F12; + value = KeyValue::F12; break; case SDLK_F13: - value = Key::F13; + value = KeyValue::F13; break; case SDLK_F14: - value = Key::F14; + value = KeyValue::F14; break; case SDLK_F15: - value = Key::F15; + value = KeyValue::F15; break; case SDLK_NUMLOCK: - value = Key::NUM_LOCK; + value = KeyValue::NUM_LOCK; break; case SDLK_CAPSLOCK: - value = Key::CAPS_LOCK; + value = KeyValue::CAPS_LOCK; break; case SDLK_SCROLLOCK: - value = Key::SCROLL_LOCK; + value = KeyValue::SCROLL_LOCK; break; case SDLK_RMETA: - value = Key::RIGHT_META; + value = KeyValue::RIGHT_META; break; case SDLK_LMETA: - value = Key::LEFT_META; + value = KeyValue::LEFT_META; break; #ifndef USE_SDL2 case SDLK_LSUPER: - value = Key::LEFT_SUPER; + value = KeyValue::LEFT_SUPER; break; case SDLK_RSUPER: - value = Key::RIGHT_SUPER; + value = KeyValue::RIGHT_SUPER; break; #endif case SDLK_MODE: - value = Key::ALT_GR; + value = KeyValue::ALT_GR; break; case SDLK_UP: - value = Key::UP; + value = KeyValue::UP; break; case SDLK_DOWN: - value = Key::DOWN; + value = KeyValue::DOWN; break; case SDLK_LEFT: - value = Key::LEFT; + value = KeyValue::LEFT; break; case SDLK_RIGHT: - value = Key::RIGHT; + value = KeyValue::RIGHT; break; case SDLK_RETURN: - value = Key::ENTER; + value = KeyValue::ENTER; break; case SDLK_KP_ENTER: - value = Key::ENTER; + value = KeyValue::ENTER; break; default: @@ -498,34 +500,34 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event) switch (keysym.sym) { case SDLK_KP0: - value = Key::INSERT; + value = KeyValue::INSERT; break; case SDLK_KP1: - value = Key::END; + value = KeyValue::END; break; case SDLK_KP2: - value = Key::DOWN; + value = KeyValue::DOWN; break; case SDLK_KP3: - value = Key::PAGE_DOWN; + value = KeyValue::PAGE_DOWN; break; case SDLK_KP4: - value = Key::LEFT; + value = KeyValue::LEFT; break; case SDLK_KP5: value = 0; break; case SDLK_KP6: - value = Key::RIGHT; + value = KeyValue::RIGHT; break; case SDLK_KP7: - value = Key::HOME; + value = KeyValue::HOME; break; case SDLK_KP8: - value = Key::UP; + value = KeyValue::UP; break; case SDLK_KP9: - value = Key::PAGE_UP; + value = KeyValue::PAGE_UP; break; default: break; diff --git a/src/input/key.h b/src/input/key.h index 5ed721702..0a657010a 100644 --- a/src/input/key.h +++ b/src/input/key.h @@ -86,58 +86,6 @@ class Key final */ explicit Key(const int value = 0); - enum - { - SPACE = ' ', - TAB = '\t', - ENTER = '\n', - // Negative values, to avoid conflicts with higher character codes. - LEFT_ALT = -1000, - RIGHT_ALT, - LEFT_SHIFT, - RIGHT_SHIFT, - LEFT_CONTROL, - RIGHT_CONTROL, - LEFT_META, - RIGHT_META, - LEFT_SUPER, - RIGHT_SUPER, - INSERT, - HOME, - PAGE_UP, - DELETE_, - END, - PAGE_DOWN, - ESCAPE, - CAPS_LOCK, - BACKSPACE, - F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, - F13, - F14, - F15, - PRINT_SCREEN, - SCROLL_LOCK, - PAUSE, - NUM_LOCK, - ALT_GR, - LEFT, - RIGHT, - UP, - DOWN, - TEXTINPUT - }; - /** * Checks if a key is a character. * |