key defaults specified in the code now, required in order to keep the configuration files valid across multiple versions of openmw

actorid
scrawl 13 years ago
parent 90f1d9c2f2
commit 976ad7a301

@ -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")

@ -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";

@ -7,8 +7,7 @@
#include <OgreRoot.h>
#include <OgreRenderWindow.h>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <OIS/OISInputManager.h>
@ -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;
std::cout << "Loading input configuration: " << configFile << std::endl;
mInputCtrl = new ICS::InputControlSystem(userFile, true, NULL, NULL, A_LAST);
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<int, int> 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<int, int> 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<std::string>(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<OIS::KeyCode>(defaultKeyBindings[i]), ICS::Control::INCREASE);
else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end())
mInputCtrl->addMouseButtonBinding (control1, defaultMouseButtonBindings[i], ICS::Control::INCREASE);
}
}
}
}

@ -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
{

@ -1,100 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<Controller>
<Control name="GameMenu" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="ESCAPE" direction="INCREASE" />
<Channel number="0" direction="DIRECT" percentage="1" />
</Control>
<Control name="Quit" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="Q" direction="INCREASE" />
<Channel number="1" direction="DIRECT" percentage="1" />
</Control>
<Control name="Screenshot" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="SYSRQ" direction="INCREASE" />
<Channel number="2" direction="DIRECT" percentage="1" />
</Control>
<Control name="Inventory" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="I" direction="INCREASE" />
<Channel number="3" direction="DIRECT" percentage="1" />
</Control>
<Control name="Console" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="F1" direction="INCREASE" />
<Channel number="4" direction="DIRECT" percentage="1" />
</Control>
<Control name="MoveLeft" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="A" direction="INCREASE" />
<KeyBinder key="LEFT" direction="INCREASE" />
<Channel number="5" direction="DIRECT" percentage="1" />
</Control>
<Control name="MoveRight" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="D" direction="INCREASE" />
<KeyBinder key="RIGHT" direction="INCREASE" />
<Channel number="6" direction="DIRECT" percentage="1" />
</Control>
<Control name="MoveForward" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="W" direction="INCREASE" />
<KeyBinder key="UP" direction="INCREASE" />
<Channel number="7" direction="DIRECT" percentage="1" />
</Control>
<Control name="MoveBackward" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="S" direction="INCREASE" />
<KeyBinder key="DOWN" direction="INCREASE" />
<Channel number="8" direction="DIRECT" percentage="1" />
</Control>
<Control name="Activate" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="SPACE" direction="INCREASE" />
<Channel number="9" direction="DIRECT" percentage="1" />
</Control>
<Control name="Jump" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="E" direction="INCREASE" />
<Channel number="11" direction="DIRECT" percentage="1" />
</Control>
<Control name="AutoMove" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="Z" direction="INCREASE" />
<Channel number="12" direction="DIRECT" percentage="1" />
</Control>
<Control name="Journal" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="J" direction="INCREASE" />
<Channel number="14" direction="DIRECT" percentage="1" />
</Control>
<Control name="Sneak" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="X" direction="INCREASE" />
<Channel number="22" direction="DIRECT" percentage="1" />
</Control>
<Control name="Walk" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="C" direction="INCREASE" />
<Channel number="23" direction="DIRECT" percentage="1" />
</Control>
<Control name="Crouch" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="LCONTROL" direction="INCREASE" />
<Channel number="24" direction="DIRECT" percentage="1" />
</Control>
<Control name="ReadyWeapon" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="F" direction="INCREASE" />
<Channel number="28" direction="DIRECT" percentage="1" />
</Control>
<Control name="ReadySpell" autoChangeDirectionOnLimitsAfterStop="false" autoReverseToInitialValue="true" initialValue="0" stepSize="MAX" stepsPerSeconds="MAX">
<KeyBinder key="R" direction="INCREASE" />
<Channel number="29" direction="DIRECT" percentage="1" />
</Control>
</Controller>
Loading…
Cancel
Save