Stub InputManager

c++11
scrawl 10 years ago
parent 140e67036c
commit 283b252142

@ -23,15 +23,15 @@ add_openmw_dir (mwrender
actors objects renderingmanager animation sky npcanimation vismask actors objects renderingmanager animation sky npcanimation vismask
creatureanimation effectmanager util renderinginterface debugging rendermode creatureanimation effectmanager util renderinginterface debugging rendermode
bulletdebugdraw bulletdebugdraw
# camera activatoranimation # camera
# localmap occlusionquery water shadows # localmap occlusionquery water shadows
# characterpreview globalmap ripplesimulation refraction # characterpreview globalmap ripplesimulation refraction
# terrainstorage renderconst weaponanimation # terrainstorage weaponanimation
) )
#add_openmw_dir (mwinput add_openmw_dir (mwinput
# inputmanagerimp inputmanagerimp
# ) )
add_openmw_dir (mwgui add_openmw_dir (mwgui
layout textinput widgets race class birth review windowmanagerimp console dialogue layout textinput widgets race class birth review windowmanagerimp console dialogue

@ -28,7 +28,7 @@
#include <components/esm/loadcell.hpp> #include <components/esm/loadcell.hpp>
//#include "mwinput/inputmanagerimp.hpp" #include "mwinput/inputmanagerimp.hpp"
#include "mwgui/windowmanagerimp.hpp" #include "mwgui/windowmanagerimp.hpp"
@ -79,7 +79,7 @@ void OMW::Engine::frame(float frametime)
mEnvironment.setFrameDuration (frametime); mEnvironment.setFrameDuration (frametime);
// update input // update input
//MWBase::Environment::get().getInputManager()->update(frametime, false); MWBase::Environment::get().getInputManager()->update(frametime, false);
// When the window is minimized, pause everything. Currently this *has* to be here to work around a MyGUI bug. // When the window is minimized, pause everything. Currently this *has* to be here to work around a MyGUI bug.
// If we are not currently rendering, then RenderItems will not be reused resulting in a memory leak upon changing widget textures. // If we are not currently rendering, then RenderItems will not be reused resulting in a memory leak upon changing widget textures.
@ -335,8 +335,9 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
else else
gameControllerdb = ""; //if it doesn't exist, pass in an empty string gameControllerdb = ""; //if it doesn't exist, pass in an empty string
//MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists, gameControllerdb, mGrab); // FIXME: shouldn't depend on Engine
//mEnvironment.setInputManager (input); MWInput::InputManager* input = new MWInput::InputManager (*this, keybinderUser, keybinderUserExists, gameControllerdb, mGrab);
mEnvironment.setInputManager (input);
std::string myguiResources = (mResDir / "mygui").string(); std::string myguiResources = (mResDir / "mygui").string();
osg::ref_ptr<osg::Group> guiRoot = new osg::Group; osg::ref_ptr<osg::Group> guiRoot = new osg::Group;
@ -354,7 +355,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
{ {
std::string logo = mFallbackMap["Movies_Company_Logo"]; std::string logo = mFallbackMap["Movies_Company_Logo"];
if (!logo.empty()) if (!logo.empty())
window->playVideo(logo, 1); window->playVideo(logo, true);
} }
// Create the world // Create the world
@ -362,7 +363,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
mFileCollections, mContentFiles, mEncoder, mFallbackMap, mFileCollections, mContentFiles, mEncoder, mFallbackMap,
mActivationDistanceOverride, mCellName, mStartupScript)); mActivationDistanceOverride, mCellName, mStartupScript));
MWBase::Environment::get().getWorld()->setupPlayer(); MWBase::Environment::get().getWorld()->setupPlayer();
//input->setPlayer(&mEnvironment.getWorld()->getPlayer()); input->setPlayer(&mEnvironment.getWorld()->getPlayer());
window->initUI(); window->initUI();
window->renderWorldMap(); window->renderWorldMap();

@ -221,7 +221,7 @@ namespace MWGui
mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI); mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI);
mViewer->getCamera()->setCullMask(MWRender::Mask_GUI); mViewer->getCamera()->setCullMask(MWRender::Mask_GUI);
//MWBase::Environment::get().getInputManager()->update(0, true, true); MWBase::Environment::get().getInputManager()->update(0, true, true);
mViewer->frame(); mViewer->frame();

@ -334,7 +334,7 @@ namespace MWGui
// Set up visibility // Set up visibility
updateVisible(); updateVisible();
//MWBase::Environment::get().getInputManager()->changeInputMode(false); MWBase::Environment::get().getInputManager()->changeInputMode(false);
} }
void WindowManager::renderWorldMap() void WindowManager::renderWorldMap()
@ -834,7 +834,7 @@ namespace MWGui
mMessageBoxManager->onFrame(0.f); mMessageBoxManager->onFrame(0.f);
MWBase::Environment::get().getInputManager()->update(0, true, false); MWBase::Environment::get().getInputManager()->update(0, true, false);
//mRendering->getWindow()->update(); mViewer->frame();
} }
} }
} }
@ -1132,8 +1132,8 @@ namespace MWGui
mGuiModes.push_back(mode); mGuiModes.push_back(mode);
//bool gameMode = !isGuiMode(); bool gameMode = !isGuiMode();
//MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode); MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
updateVisible(); updateVisible();
} }
@ -1173,8 +1173,8 @@ namespace MWGui
if (!mGuiModes.empty()) if (!mGuiModes.empty())
mGuiModes.pop_back(); mGuiModes.pop_back();
//bool gameMode = !isGuiMode(); bool gameMode = !isGuiMode();
//MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode); MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
updateVisible(); updateVisible();
} }
@ -1190,8 +1190,8 @@ namespace MWGui
++it; ++it;
} }
//bool gameMode = !isGuiMode(); bool gameMode = !isGuiMode();
//MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode); MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
updateVisible(); updateVisible();
} }
@ -1705,7 +1705,7 @@ namespace MWGui
while (mVideoWidget->update() && !MWBase::Environment::get().getStateManager()->hasQuitRequest()) while (mVideoWidget->update() && !MWBase::Environment::get().getStateManager()->hasQuitRequest())
{ {
//MWBase::Environment::get().getInputManager()->update(0, true, false); MWBase::Environment::get().getInputManager()->update(0, true, false);
mViewer->frame(); mViewer->frame();
} }

@ -14,8 +14,6 @@
#include <SDL_version.h> #include <SDL_version.h>
#include <openengine/ogre/renderer.hpp>
#include "../engine.hpp" #include "../engine.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -98,16 +96,16 @@ namespace
namespace MWInput namespace MWInput
{ {
InputManager::InputManager(OEngine::Render::OgreRenderer &ogre, InputManager::InputManager(
OMW::Engine& engine, OMW::Engine& engine,
const std::string& userFile, bool userFileExists, const std::string& userFile, bool userFileExists,
const std::string& controllerBindingsFile, bool grab) const std::string& controllerBindingsFile, bool grab)
: mOgre(ogre) : mInputManager(NULL)
, mPlayer(NULL) , mPlayer(NULL)
, mEngine(engine) , mEngine(engine)
, mMouseLookEnabled(false) , mMouseLookEnabled(false)
, mMouseX(ogre.getWindow()->getWidth ()/2.f) , mMouseX(0)//ogre.getWindow()->getWidth ()/2.f)
, mMouseY(ogre.getWindow()->getHeight ()/2.f) , mMouseY(0)//ogre.getWindow()->getHeight ()/2.f)
, mMouseWheel(0) , mMouseWheel(0)
, mDragDrop(false) , mDragDrop(false)
, mGuiCursorEnabled(true) , mGuiCursorEnabled(true)
@ -131,17 +129,18 @@ namespace MWInput
, mFakeDeviceID(1) , mFakeDeviceID(1)
{ {
/*
Ogre::RenderWindow* window = ogre.getWindow (); Ogre::RenderWindow* window = ogre.getWindow ();
mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow(), mOgre.getWindow(), grab); mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow(), mOgre.getWindow(), grab);
mInputManager->setMouseEventCallback (this); mInputManager->setMouseEventCallback (this);
mInputManager->setKeyboardEventCallback (this); mInputManager->setKeyboardEventCallback (this);
mInputManager->setWindowEventCallback(this); mInputManager->setWindowEventCallback(this);
mInputManager->setControllerEventCallback(this); mInputManager->setControllerEventCallback(this);
*/
std::string file = userFileExists ? userFile : ""; std::string file = userFileExists ? userFile : "";
mInputBinder = new ICS::InputControlSystem(file, true, this, NULL, A_Last); mInputBinder = new ICS::InputControlSystem(file, true, this, NULL, A_Last);
adjustMouseRegion (window->getWidth(), window->getHeight()); //adjustMouseRegion (window->getWidth(), window->getHeight());
loadKeyDefaults(); loadKeyDefaults();
loadControllerDefaults(); loadControllerDefaults();
@ -199,7 +198,7 @@ namespace MWInput
delete mInputBinder; delete mInputBinder;
delete mInputManager; //delete mInputManager;
} }
void InputManager::setPlayerControlsEnabled(bool enabled) void InputManager::setPlayerControlsEnabled(bool enabled)
@ -366,24 +365,24 @@ namespace MWInput
void InputManager::updateCursorMode() void InputManager::updateCursorMode()
{ {
bool grab = !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu) //bool grab = !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu)
&& MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_Console; // && MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_Console;
bool was_relative = mInputManager->getMouseRelative(); bool was_relative = 0;//mInputManager->getMouseRelative();
bool is_relative = !MWBase::Environment::get().getWindowManager()->isGuiMode(); bool is_relative = !MWBase::Environment::get().getWindowManager()->isGuiMode();
// don't keep the pointer away from the window edge in gui mode // don't keep the pointer away from the window edge in gui mode
// stop using raw mouse motions and switch to system cursor movements // stop using raw mouse motions and switch to system cursor movements
mInputManager->setMouseRelative(is_relative); //mInputManager->setMouseRelative(is_relative);
//we let the mouse escape in the main menu //we let the mouse escape in the main menu
mInputManager->setGrabPointer(grab && (mGrabCursor || is_relative)); //mInputManager->setGrabPointer(grab && (mGrabCursor || is_relative));
//we switched to non-relative mode, move our cursor to where the in-game //we switched to non-relative mode, move our cursor to where the in-game
//cursor is //cursor is
if( !is_relative && was_relative != is_relative ) if( !is_relative && was_relative != is_relative )
{ {
mInputManager->warpMouse(static_cast<int>(mMouseX), static_cast<int>(mMouseY)); //mInputManager->warpMouse(static_cast<int>(mMouseX), static_cast<int>(mMouseY));
} }
} }
@ -391,9 +390,9 @@ namespace MWInput
{ {
mControlsDisabled = disableControls; mControlsDisabled = disableControls;
mInputManager->setMouseVisible(MWBase::Environment::get().getWindowManager()->getCursorVisible()); //mInputManager->setMouseVisible(MWBase::Environment::get().getWindowManager()->getCursorVisible());
mInputManager->capture(disableEvents); //mInputManager->capture(disableEvents);
// inject some fake mouse movement to force updating MyGUI's widget states // inject some fake mouse movement to force updating MyGUI's widget states
MyGUI::InputManager::getInstance().injectMouseMove( int(mMouseX), int(mMouseY), mMouseWheel); MyGUI::InputManager::getInstance().injectMouseMove( int(mMouseX), int(mMouseY), mMouseWheel);
@ -427,7 +426,7 @@ namespace MWInput
mMouseY = std::max(0.f, std::min(mMouseY, float(viewSize.height))); mMouseY = std::max(0.f, std::min(mMouseY, float(viewSize.height)));
MyGUI::InputManager::getInstance().injectMouseMove(static_cast<int>(mMouseX), static_cast<int>(mMouseY), mMouseWheel); MyGUI::InputManager::getInstance().injectMouseMove(static_cast<int>(mMouseX), static_cast<int>(mMouseY), mMouseWheel);
mInputManager->warpMouse(static_cast<int>(mMouseX), static_cast<int>(mMouseY)); //mInputManager->warpMouse(static_cast<int>(mMouseX), static_cast<int>(mMouseY));
} }
if (mMouseLookEnabled) if (mMouseLookEnabled)
{ {
@ -668,6 +667,7 @@ namespace MWInput
// HACK: to make Morrowind's default keybinding for the console work without printing an extra "^" upon closing // HACK: to make Morrowind's default keybinding for the console work without printing an extra "^" upon closing
// This assumes that SDL_TextInput events always come *after* the key event // This assumes that SDL_TextInput events always come *after* the key event
// (which is somewhat reasonable, and hopefully true for all SDL platforms) // (which is somewhat reasonable, and hopefully true for all SDL platforms)
/*
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym); OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
if (mInputBinder->getKeyBinding(mInputBinder->getControl(A_Console), ICS::Control::INCREASE) if (mInputBinder->getKeyBinding(mInputBinder->getControl(A_Console), ICS::Control::INCREASE)
== arg.keysym.scancode == arg.keysym.scancode
@ -685,6 +685,7 @@ namespace MWInput
if (!mControlsDisabled && !consumed) if (!mControlsDisabled && !consumed)
mInputBinder->keyPressed (arg); mInputBinder->keyPressed (arg);
mJoystickLastUsed = false; mJoystickLastUsed = false;
*/
} }
void InputManager::textInput(const SDL_TextInputEvent &arg) void InputManager::textInput(const SDL_TextInputEvent &arg)
@ -697,11 +698,13 @@ namespace MWInput
void InputManager::keyReleased(const SDL_KeyboardEvent &arg ) void InputManager::keyReleased(const SDL_KeyboardEvent &arg )
{ {
/*
mJoystickLastUsed = false; mJoystickLastUsed = false;
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym); OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc))); setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)));
mInputBinder->keyReleased (arg); mInputBinder->keyReleased (arg);
*/
} }
void InputManager::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ) void InputManager::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id )
@ -827,9 +830,9 @@ namespace MWInput
setPlayerControlsEnabled(!guiMode); setPlayerControlsEnabled(!guiMode);
//esc, to leave initial movie screen //esc, to leave initial movie screen
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE); //OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE);
bool guiFocus = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0); //bool guiFocus = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0);
setPlayerControlsEnabled(!guiFocus); //setPlayerControlsEnabled(!guiFocus);
if (!mControlsDisabled) if (!mControlsDisabled)
mInputBinder->buttonPressed(deviceID, arg); mInputBinder->buttonPressed(deviceID, arg);
@ -853,9 +856,9 @@ namespace MWInput
else else
mInputBinder->buttonReleased(deviceID, arg); mInputBinder->buttonReleased(deviceID, arg);
//to escape initial movie ///to escape initial movie
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE); //OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE);
setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc))); //setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)));
} }
void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg ) void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg )
@ -885,7 +888,7 @@ namespace MWInput
void InputManager::windowResized(int x, int y) void InputManager::windowResized(int x, int y)
{ {
mOgre.windowResized(x,y); //mOgre.windowResized(x,y);
} }
void InputManager::windowClosed() void InputManager::windowClosed()

@ -66,7 +66,7 @@ namespace MWInput
public ICS::DetectingBindingListener public ICS::DetectingBindingListener
{ {
public: public:
InputManager(OEngine::Render::OgreRenderer &_ogre, InputManager(
OMW::Engine& engine, OMW::Engine& engine,
const std::string& userFile, bool userFileExists, const std::string& userFile, bool userFileExists,
const std::string& controllerBindingsFile, bool grab); const std::string& controllerBindingsFile, bool grab);
@ -143,7 +143,6 @@ namespace MWInput
private: private:
bool mJoystickLastUsed; bool mJoystickLastUsed;
OEngine::Render::OgreRenderer &mOgre;
MWWorld::Player* mPlayer; MWWorld::Player* mPlayer;
OMW::Engine& mEngine; OMW::Engine& mEngine;

@ -1,51 +0,0 @@
#include "activatoranimation.hpp"
#include <OgreSceneNode.h>
#include <OgreParticleSystem.h>
#include <components/esm/loadacti.hpp>
#include "renderconst.hpp"
namespace MWRender
{
ActivatorAnimation::~ActivatorAnimation()
{
}
ActivatorAnimation::ActivatorAnimation(const MWWorld::Ptr &ptr, const std::string& model)
: Animation(ptr, ptr.getRefData().getBaseNode())
{
if(!model.empty())
{
setObjectRoot(model, false);
setRenderProperties(mObjectRoot, RV_Misc, RQG_Main, RQG_Alpha);
addAnimSource(model);
}
else
{
// No model given. Create an object root anyway, so that lights can be added to it if needed.
mObjectRoot = NifOgre::ObjectScenePtr (new NifOgre::ObjectScene(mInsert->getCreator()));
}
}
void ActivatorAnimation::addLight(const ESM::Light *light)
{
addExtraLight(mInsert->getCreator(), mObjectRoot, light);
}
void ActivatorAnimation::removeParticles()
{
for (unsigned int i=0; i<mObjectRoot->mParticles.size(); ++i)
{
// Don't destroyParticleSystem, the ParticleSystemController is still holding a pointer to it.
// Don't setVisible, this could conflict with a VisController.
// The following will remove all spawned particles, then set the speed factor to zero so that no new ones will be spawned.
mObjectRoot->mParticles[i]->setSpeedFactor(0.f);
mObjectRoot->mParticles[i]->clear();
}
}
}

@ -1,24 +0,0 @@
#ifndef GAME_RENDER_ACTIVATORANIMATION_H
#define GAME_RENDER_ACTIVATORANIMATION_H
#include "animation.hpp"
namespace MWWorld
{
class Ptr;
}
namespace MWRender
{
class ActivatorAnimation : public Animation
{
public:
ActivatorAnimation(const MWWorld::Ptr& ptr, const std::string &model);
virtual ~ActivatorAnimation();
void addLight(const ESM::Light *light);
void removeParticles();
};
}
#endif

@ -270,7 +270,6 @@ namespace MWScript
std::string InterpreterContext::getActionBinding(const std::string& action) const std::string InterpreterContext::getActionBinding(const std::string& action) const
{ {
/*
MWBase::InputManager* input = MWBase::Environment::get().getInputManager(); MWBase::InputManager* input = MWBase::Environment::get().getInputManager();
std::vector<int> actions = input->getActionKeySorting (); std::vector<int> actions = input->getActionKeySorting ();
for (std::vector<int>::const_iterator it = actions.begin(); it != actions.end(); ++it) for (std::vector<int>::const_iterator it = actions.begin(); it != actions.end(); ++it)
@ -287,7 +286,6 @@ namespace MWScript
return input->getActionKeyBindingName (*it); return input->getActionKeyBindingName (*it);
} }
} }
*/
return "None"; return "None";
} }

Loading…
Cancel
Save