diff --git a/CMakeLists.txt b/CMakeLists.txt index 79e33f1815..68fdee1e8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -285,9 +285,6 @@ endif (APPLE) configure_file(${OpenMW_SOURCE_DIR}/files/settings-default.cfg "${OpenMW_BINARY_DIR}/settings-default.cfg") -configure_file(${OpenMW_SOURCE_DIR}/files/input-default.xml - "${OpenMW_BINARY_DIR}/input-default.xml") - configure_file(${OpenMW_SOURCE_DIR}/files/transparency-overrides.cfg "${OpenMW_BINARY_DIR}/transparency-overrides.cfg") diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 128d975534..edd0dead11 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -271,22 +271,10 @@ void OMW::Engine::go() settings.loadUser(globaldefault); // Get the path for the keybinder xml file - std::string keybinderDefault; - - // load user settings if they exist, otherwise just load the default settings as user settings - const std::string keybinderUser = (mCfgMgr.getUserPath() / "input.xml").string(); - const std::string keybinderDefaultLocal = (mCfgMgr.getLocalPath() / "input-default.xml").string(); - const std::string keybinderDefaultGlobal = (mCfgMgr.getGlobalPath() / "input-default.xml").string(); - - bool keybinderUserExists = boost::filesystem::exists(keybinderUser); - - if (boost::filesystem::exists(keybinderDefaultLocal)) - keybinderDefault = keybinderDefaultLocal; - else if (boost::filesystem::exists(keybinderDefaultGlobal)) - keybinderDefault = keybinderDefaultGlobal; - else - throw std::runtime_error ("No default input settings found! Make sure the file \"input-default.xml\" was properly installed."); + std::string keybinderUser = (mCfgMgr.getUserPath() / "input.xml").string(); + if (!boost::filesystem::exists(keybinderUser)) + keybinderUser = ""; mFpsLevel = settings.getInt("fps", "HUD"); @@ -386,7 +374,7 @@ void OMW::Engine::go() mEnvironment.setInputManager (new MWInput::InputManager (*mOgre, MWBase::Environment::get().getWorld()->getPlayer(), - *MWBase::Environment::get().getWindowManager(), mDebug, *this, keybinderDefault, keybinderUser, keybinderUserExists)); + *MWBase::Environment::get().getWindowManager(), mDebug, *this, keybinderUser)); std::cout << "\nPress Q/ESC or close window to exit.\n"; diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index e1eacae055..0318995389 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -7,8 +7,7 @@ #include #include -#include -#include +#include #include @@ -32,8 +31,7 @@ namespace MWInput MWBase::WindowManager &windows, bool debug, OMW::Engine& engine, - const std::string& defaultFile, - const std::string& userFile, bool userFileExists) + const std::string& userFile) : mOgre(ogre) , mPlayer(player) , mWindows(windows) @@ -43,6 +41,7 @@ namespace MWInput , mMouseY(ogre.getWindow()->getHeight ()/2.f) , mUserFile(userFile) , mDragDrop(false) + , mGuiCursorEnabled(false) { Ogre::RenderWindow* window = ogre.getWindow (); size_t windowHnd; @@ -102,15 +101,9 @@ namespace MWInput MyGUI::InputManager::getInstance().injectMouseMove(mMouseX, mMouseY, mMouse->getMouseState ().Z.abs); - std::string configFile; - if (userFileExists) - configFile = userFile; - else - configFile = defaultFile; + mInputCtrl = new ICS::InputControlSystem(userFile, true, NULL, NULL, A_LAST); - std::cout << "Loading input configuration: " << configFile << std::endl; - - mInputCtrl = new ICS::InputControlSystem(configFile, true, NULL, NULL, A_LAST); + loadKeyDefaults(); for (int i = 0; i < A_LAST; ++i) { @@ -339,8 +332,7 @@ namespace MWInput { mInputCtrl->keyReleased (arg); - if (mGuiCursorEnabled) - MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(arg.key)); + MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(arg.key)); return true; } @@ -359,8 +351,7 @@ namespace MWInput { mInputCtrl->mouseReleased (arg, id); - if (mGuiCursorEnabled) - MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, MyGUI::MouseButton::Enum(id)); + MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, MyGUI::MouseButton::Enum(id)); return true; } @@ -449,11 +440,15 @@ namespace MWInput { bool gameMode = !mWindows.isGuiMode(); + std::cout << "gameMode: " << gameMode << std::endl; + // Toggle between game mode and inventory mode if(gameMode) mWindows.pushGuiMode(MWGui::GM_Inventory); else if(mWindows.getMode() == MWGui::GM_Inventory) mWindows.popGuiMode(); + else + std::cout << "toggleInv didnt do anything!!!" << std::endl; // .. but don't touch any other mode. } @@ -516,4 +511,44 @@ namespace MWInput return mInputCtrl->getChannel (id)->getValue () == 1; } + void InputManager::loadKeyDefaults () + { + // using hardcoded key defaults is inevitable, if we want the configuration files to stay valid + // across different versions of OpenMW (in the case where another input action is added) + std::map defaultKeyBindings; + + defaultKeyBindings[A_Activate] = OIS::KC_SPACE; + defaultKeyBindings[A_MoveBackward] = OIS::KC_S; + defaultKeyBindings[A_MoveForward] = OIS::KC_W; + defaultKeyBindings[A_MoveLeft] = OIS::KC_A; + defaultKeyBindings[A_MoveRight] = OIS::KC_D; + defaultKeyBindings[A_ToggleWeapon] = OIS::KC_F; + defaultKeyBindings[A_ToggleSpell] = OIS::KC_R; + defaultKeyBindings[A_Console] = OIS::KC_F1; + defaultKeyBindings[A_Crouch] = OIS::KC_LCONTROL; + defaultKeyBindings[A_AutoMove] = OIS::KC_Q; + defaultKeyBindings[A_Jump] = OIS::KC_E; + defaultKeyBindings[A_Journal] = OIS::KC_J; + defaultKeyBindings[A_Rest] = OIS::KC_T; + defaultKeyBindings[A_GameMenu] = OIS::KC_ESCAPE; + + std::map defaultMouseButtonBindings; + defaultMouseButtonBindings[A_Inventory] = OIS::MB_Right; + + for (int i = 0; i < A_LAST; ++i) + { + if (mInputCtrl->getChannel(i)->getControlsCount () == 0) + { + ICS::Control* control1 = new ICS::Control(boost::lexical_cast(i), false, true, 0, ICS::ICS_MAX, ICS::ICS_MAX); + mInputCtrl->addControl(control1); + control1->attachChannel(mInputCtrl->getChannel(i), ICS::Channel::DIRECT); + + if (defaultKeyBindings.find(i) != defaultKeyBindings.end()) + mInputCtrl->addKeyBinding(control1, static_cast(defaultKeyBindings[i]), ICS::Control::INCREASE); + else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end()) + mInputCtrl->addMouseButtonBinding (control1, defaultMouseButtonBindings[i], ICS::Control::INCREASE); + } + } + } + } diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index ba42327eeb..9fc77aeeb4 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -61,8 +61,7 @@ namespace MWInput MWBase::WindowManager &_windows, bool debug, OMW::Engine& engine, - const std::string& defaultFile, - const std::string& userFile, bool userFileExists); + const std::string& userFile); virtual ~InputManager(); @@ -130,6 +129,8 @@ namespace MWInput bool actionIsActive (int id); + void loadKeyDefaults(); + private: enum Actions { diff --git a/files/input-default.xml b/files/input-default.xml deleted file mode 100644 index e44b3455ac..0000000000 --- a/files/input-default.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -