From b160406dd45c104ff792e22bed23e460c2b913a4 Mon Sep 17 00:00:00 2001 From: auria Date: Mon, 23 Mar 2009 16:06:48 +0000 Subject: [PATCH] started reconstructing input... git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3292 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/actionmap.cpp | 70 ------------------- src/actionmap.hpp | 51 -------------- src/gui/state_manager.cpp | 2 +- .../Xcode/STK_XCode.xcodeproj/project.pbxproj | 35 +++++----- src/{ => input}/input.hpp | 0 src/{ => input}/input_manager.cpp | 4 +- src/{ => input}/input_manager.hpp | 2 +- src/karts/player_kart.cpp | 2 +- src/main.cpp | 2 +- src/main_loop.cpp | 2 +- src/sdl_manager.cpp | 2 +- src/user_config.hpp | 2 +- 12 files changed, 28 insertions(+), 146 deletions(-) delete mode 100644 src/actionmap.cpp delete mode 100644 src/actionmap.hpp rename src/{ => input}/input.hpp (100%) rename src/{ => input}/input_manager.cpp (99%) rename src/{ => input}/input_manager.hpp (99%) diff --git a/src/actionmap.cpp b/src/actionmap.cpp deleted file mode 100644 index af5d2e734..000000000 --- a/src/actionmap.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// $Id: actionmap.cpp 1259 2007-09-24 12:28:19Z thebohemian $ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2007 Robert Schuster -// -// 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 3 -// of the License, or (at your option) 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, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include - -#include "input.hpp" -#include "actionmap.hpp" - -// ---------------------------------------------------------------------------- -void ActionMap::addStaticEntry(Input input, StaticAction ga) -{ - inputMap[key(input)] = ga; -} // putEntry - -// ---------------------------------------------------------------------------- -StaticAction ActionMap::getStaticEntry(Input input) -{ - return inputMap[key(input)]; -} // getEntry - -// ---------------------------------------------------------------------------- -StaticAction ActionMap::getStaticEntry(Input::InputType type, int id0, int id1, int id2) -{ - return inputMap[key(type, id0, id1, id2)]; -} // getEntry - -// ---------------------------------------------------------------------------- -void ActionMap::clear() -{ - inputMap.clear(); -} - -// ---------------------------------------------------------------------------- -ActionMap::Key ActionMap::key(Input input) -{ - return key(input.type, input.id0, input.id1, input.id2); -} // key - -// ---------------------------------------------------------------------------- -ActionMap::Key ActionMap::key(Input::InputType it, int id0, int id1, int id2) -{ - /* - * A short reminder on the bit distribution and their usage: - * it gets 8 bits (InputType) - * id1 gets 16 bits (button, hat or axis number) - * id2 gets 8 bits (direction bit) - * id0 gets 32 bits (That is because id0 can be the keyboard key ids and - * those are unicode and unicode 4.0 is 32 bit) - * - * Assumption: int is (at least) 32 bit - */ - return Key(it << 24 | id1 << 8 | id2, id0); -} // key - diff --git a/src/actionmap.hpp b/src/actionmap.hpp deleted file mode 100644 index c85150e05..000000000 --- a/src/actionmap.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// $Id: actionmap.hpp 1259 2007-09-24 12:28:19Z thebohemian $ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2007 Robert Schuster -// -// 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 3 -// of the License, or (at your option) 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, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef HEADER_ACTIONMAP_H -#define HEADER_ACTIONMAP_H - -#include -#include "input.hpp" - -/** - * This thing is named after what is put in as values. - */ -class ActionMap -{ - typedef std::pair Key; - - public: - - void clear(); - - void addStaticEntry(Input, StaticAction); - void addPlayerEntry(Input, PlayerAction); - - StaticAction getStaticEntry(Input); - StaticAction getStaticEntry(Input::InputType, int, int, int); - - private: - inline Key key(Input); - Key key(Input::InputType, int, int, int); - - std::map inputMap; - -}; - -#endif diff --git a/src/gui/state_manager.cpp b/src/gui/state_manager.cpp index 76f43dcca..b8a498359 100644 --- a/src/gui/state_manager.cpp +++ b/src/gui/state_manager.cpp @@ -3,7 +3,7 @@ #include "gui/engine.hpp" #include "gui/widget.hpp" #include "gui/screen.hpp" -#include "input_manager.hpp" +#include "input/input_manager.hpp" #include "graphics/irr_driver.hpp" #include "race_manager.hpp" #include "network/network_manager.hpp" diff --git a/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj b/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj index ac983ddfb..cd4dba967 100644 --- a/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj +++ b/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj @@ -22,11 +22,10 @@ 953EAAB20F30A4410000D57D /* triangle_mesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953EAAB10F30A4410000D57D /* triangle_mesh.cpp */; }; 953EAAB60F30A4650000D57D /* translation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953EAAB50F30A4650000D57D /* translation.cpp */; }; 953F038C0F6C880D00C77FE2 /* state_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953F038B0F6C880D00C77FE2 /* state_manager.cpp */; }; - 95A116BF0F77D3BB00B18B3D /* input_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95A116BD0F77D3BB00B18B3D /* input_manager.cpp */; }; 95A117350F77D7BE00B18B3D /* sdl_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95A117330F77D7BE00B18B3D /* sdl_manager.cpp */; }; + 95A1182C0F77EA3100B18B3D /* input_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95A1182A0F77EA3100B18B3D /* input_manager.cpp */; }; 95C1E3F20F699079005D33E6 /* race_gui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95C1E3F10F699079005D33E6 /* race_gui.cpp */; }; 95C1E4000F699427005D33E6 /* font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95C1E3FF0F699427005D33E6 /* font.cpp */; }; - 95C2B1F70F296546000D3E5D /* actionmap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95C2AC210F296540000D3E5D /* actionmap.cpp */; }; 95C2B1FB0F296546000D3E5D /* music_information.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95C2AC280F296540000D3E5D /* music_information.cpp */; }; 95C2B1FC0F296546000D3E5D /* music_ogg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95C2AC2A0F296540000D3E5D /* music_ogg.cpp */; }; 95C2B1FD0F296546000D3E5D /* sfx_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95C2AC2D0F296540000D3E5D /* sfx_manager.cpp */; }; @@ -271,16 +270,15 @@ 953EAAB50F30A4650000D57D /* translation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = translation.cpp; path = ../../utils/translation.cpp; sourceTree = SOURCE_ROOT; }; 953F038B0F6C880D00C77FE2 /* state_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = state_manager.cpp; path = ../../gui/state_manager.cpp; sourceTree = SOURCE_ROOT; }; 953F038E0F6C8AD800C77FE2 /* state_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = state_manager.hpp; path = ../../gui/state_manager.hpp; sourceTree = SOURCE_ROOT; }; - 95A116BD0F77D3BB00B18B3D /* input_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = input_manager.cpp; path = games/supertuxkart/src/input_manager.cpp; sourceTree = SYSTEM_DEVELOPER_DIR; }; - 95A116BE0F77D3BB00B18B3D /* input_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = input_manager.hpp; path = games/supertuxkart/src/input_manager.hpp; sourceTree = SYSTEM_DEVELOPER_DIR; }; - 95A117330F77D7BE00B18B3D /* sdl_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sdl_manager.cpp; path = games/supertuxkart/src/sdl_manager.cpp; sourceTree = SYSTEM_DEVELOPER_DIR; }; - 95A117340F77D7BE00B18B3D /* sdl_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = sdl_manager.hpp; path = games/supertuxkart/src/sdl_manager.hpp; sourceTree = SYSTEM_DEVELOPER_DIR; }; + 95A117330F77D7BE00B18B3D /* sdl_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sdl_manager.cpp; path = ../../sdl_manager.cpp; sourceTree = SOURCE_ROOT; }; + 95A117340F77D7BE00B18B3D /* sdl_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = sdl_manager.hpp; path = ../../sdl_manager.hpp; sourceTree = SOURCE_ROOT; }; + 95A118290F77EA3100B18B3D /* input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = input.hpp; path = ../../input/input.hpp; sourceTree = SOURCE_ROOT; }; + 95A1182A0F77EA3100B18B3D /* input_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = input_manager.cpp; path = ../../input/input_manager.cpp; sourceTree = SOURCE_ROOT; }; + 95A1182B0F77EA3100B18B3D /* input_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = input_manager.hpp; path = ../../input/input_manager.hpp; sourceTree = SOURCE_ROOT; }; 95C1E3EB0F698F23005D33E6 /* race_gui.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = race_gui.hpp; path = ../../gui/race_gui.hpp; sourceTree = SOURCE_ROOT; }; 95C1E3F10F699079005D33E6 /* race_gui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = race_gui.cpp; path = ../../gui/race_gui.cpp; sourceTree = SOURCE_ROOT; }; 95C1E3FF0F699427005D33E6 /* font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = font.cpp; path = ../../gui/font.cpp; sourceTree = SOURCE_ROOT; }; 95C1E4020F69943D005D33E6 /* font.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = font.hpp; path = ../../gui/font.hpp; sourceTree = SOURCE_ROOT; }; - 95C2AC210F296540000D3E5D /* actionmap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = actionmap.cpp; path = ../../actionmap.cpp; sourceTree = SOURCE_ROOT; }; - 95C2AC220F296540000D3E5D /* actionmap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = actionmap.hpp; path = ../../actionmap.hpp; sourceTree = SOURCE_ROOT; }; 95C2AC270F296540000D3E5D /* music.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = music.hpp; path = ../../audio/music.hpp; sourceTree = SOURCE_ROOT; }; 95C2AC280F296540000D3E5D /* music_information.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = music_information.cpp; path = ../../audio/music_information.cpp; sourceTree = SOURCE_ROOT; }; 95C2AC290F296540000D3E5D /* music_information.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = music_information.hpp; path = ../../audio/music_information.hpp; sourceTree = SOURCE_ROOT; }; @@ -575,7 +573,6 @@ 95C2AEDA0F296542000D3E5D /* highscores.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = highscores.hpp; path = ../../highscores.hpp; sourceTree = SOURCE_ROOT; }; 95C2AEDC0F296542000D3E5D /* history.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = history.cpp; path = ../../history.cpp; sourceTree = SOURCE_ROOT; }; 95C2AEDD0F296542000D3E5D /* history.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = history.hpp; path = ../../history.hpp; sourceTree = SOURCE_ROOT; }; - 95C2B0EF0F296545000D3E5D /* input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = input.hpp; path = ../../input.hpp; sourceTree = SOURCE_ROOT; }; 95C2B0F00F296545000D3E5D /* isect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = isect.cpp; path = ../../isect.cpp; sourceTree = SOURCE_ROOT; }; 95C2B0F10F296545000D3E5D /* isect.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = isect.hpp; path = ../../isect.hpp; sourceTree = SOURCE_ROOT; }; 95C2B0F60F296545000D3E5D /* attachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = attachment.cpp; path = ../../items/attachment.cpp; sourceTree = SOURCE_ROOT; }; @@ -1218,6 +1215,17 @@ name = Frameworks; sourceTree = ""; }; + 95A118280F77EA3100B18B3D /* input */ = { + isa = PBXGroup; + children = ( + 95A118290F77EA3100B18B3D /* input.hpp */, + 95A1182A0F77EA3100B18B3D /* input_manager.cpp */, + 95A1182B0F77EA3100B18B3D /* input_manager.hpp */, + ); + name = input; + path = games/supertuxkart/src/input; + sourceTree = SYSTEM_DEVELOPER_DIR; + }; 95C2ABA60F29653F000D3E5D /* src */ = { isa = PBXGroup; children = ( @@ -1229,6 +1237,7 @@ 95C2AE870F296542000D3E5D /* graphics */, 95C65D750F532F7D00BE7BA7 /* io */, 95C2B0F50F296545000D3E5D /* items */, + 95A118280F77EA3100B18B3D /* input */, 95C2B1160F296545000D3E5D /* karts */, 95C2B1290F296545000D3E5D /* lisp */, 95C2B1470F296545000D3E5D /* modes */, @@ -1238,8 +1247,6 @@ 95C2B1AA0F296545000D3E5D /* robots */, 95C2B1CE0F296545000D3E5D /* tracks */, 95C2B1DF0F296546000D3E5D /* utils */, - 95C2AC210F296540000D3E5D /* actionmap.cpp */, - 95C2AC220F296540000D3E5D /* actionmap.hpp */, 95C2AE1C0F296541000D3E5D /* callback.hpp */, 95C2AE1D0F296541000D3E5D /* callback_manager.cpp */, 95C2AE1E0F296541000D3E5D /* callback_manager.hpp */, @@ -1255,9 +1262,6 @@ 95C2AEDA0F296542000D3E5D /* highscores.hpp */, 95C2AEDC0F296542000D3E5D /* history.cpp */, 95C2AEDD0F296542000D3E5D /* history.hpp */, - 95A116BD0F77D3BB00B18B3D /* input_manager.cpp */, - 95A116BE0F77D3BB00B18B3D /* input_manager.hpp */, - 95C2B0EF0F296545000D3E5D /* input.hpp */, 95C2B0F00F296545000D3E5D /* isect.cpp */, 95C2B0F10F296545000D3E5D /* isect.hpp */, 95C2B1330F296545000D3E5D /* loader.cpp */, @@ -2547,7 +2551,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 95C2B1F70F296546000D3E5D /* actionmap.cpp in Sources */, 95C2B1FB0F296546000D3E5D /* music_information.cpp in Sources */, 95C2B1FC0F296546000D3E5D /* music_ogg.cpp in Sources */, 95C2B1FD0F296546000D3E5D /* sfx_manager.cpp in Sources */, @@ -2760,8 +2763,8 @@ 95C1E3F20F699079005D33E6 /* race_gui.cpp in Sources */, 95C1E4000F699427005D33E6 /* font.cpp in Sources */, 953F038C0F6C880D00C77FE2 /* state_manager.cpp in Sources */, - 95A116BF0F77D3BB00B18B3D /* input_manager.cpp in Sources */, 95A117350F77D7BE00B18B3D /* sdl_manager.cpp in Sources */, + 95A1182C0F77EA3100B18B3D /* input_manager.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/input.hpp b/src/input/input.hpp similarity index 100% rename from src/input.hpp rename to src/input/input.hpp diff --git a/src/input_manager.cpp b/src/input/input_manager.cpp similarity index 99% rename from src/input_manager.cpp rename to src/input/input_manager.cpp index f1289cf8b..7b622f20f 100644 --- a/src/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -17,7 +17,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "input_manager.hpp" +#include "input/input_manager.hpp" #include #include @@ -28,7 +28,7 @@ #include -#include "input.hpp" +#include "input/input.hpp" #include "actionmap.hpp" #include "user_config.hpp" diff --git a/src/input_manager.hpp b/src/input/input_manager.hpp similarity index 99% rename from src/input_manager.hpp rename to src/input/input_manager.hpp index 80d7a01fb..9bf871bed 100644 --- a/src/input_manager.hpp +++ b/src/input/input_manager.hpp @@ -26,7 +26,7 @@ #include -#include "input.hpp" +#include "input/input.hpp" class ActionMap; diff --git a/src/karts/player_kart.cpp b/src/karts/player_kart.cpp index 82ef2b40a..b1f7009de 100644 --- a/src/karts/player_kart.cpp +++ b/src/karts/player_kart.cpp @@ -22,7 +22,7 @@ #include "history.hpp" #include "player.hpp" -#include "input_manager.hpp" +#include "input/input_manager.hpp" #include "audio/sfx_manager.hpp" #include "audio/sfx_base.hpp" #include "graphics/camera.hpp" diff --git a/src/main.cpp b/src/main.cpp index cfcba2177..0cedc3e64 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,7 +49,7 @@ #include "race_manager.hpp" #include "main_loop.hpp" #include "material_manager.hpp" -#include "input_manager.hpp" +#include "input/input_manager.hpp" #include "callback_manager.hpp" #include "history.hpp" #include "stk_config.hpp" diff --git a/src/main_loop.cpp b/src/main_loop.cpp index fb107f570..1528422f6 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -22,7 +22,7 @@ #include #include #include "history.hpp" -#include "input_manager.hpp" +#include "input/input_manager.hpp" #include "material_manager.hpp" #include "race_manager.hpp" #include "audio/sound_manager.hpp" diff --git a/src/sdl_manager.cpp b/src/sdl_manager.cpp index 18cc4a8c2..baaf3e28b 100644 --- a/src/sdl_manager.cpp +++ b/src/sdl_manager.cpp @@ -2,7 +2,7 @@ #include "sdl_manager.hpp" #include #include "user_config.hpp" -#include "input_manager.hpp" +#include "input/input_manager.hpp" #include "gui/state_manager.hpp" #include "history.hpp" #include "items/item_manager.hpp" diff --git a/src/user_config.hpp b/src/user_config.hpp index 776e5d71a..e81bc4f54 100644 --- a/src/user_config.hpp +++ b/src/user_config.hpp @@ -45,7 +45,7 @@ #include #include #include -#include "input.hpp" +#include "input/input.hpp" #include "player.hpp" #include "lisp/lisp.hpp" #include "lisp/parser.hpp"