diff --git a/.gitmodules b/.gitmodules index 1e2f38738..6278081a7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "libs/mangle"] path = libs/mangle url = git://github.com/korslund/mangle.git +[submodule "libs/openengine"] + path = libs/openengine + url = git://github.com/korslund/OpenEngine diff --git a/apps/openmw/mwinput/inputmanager.hpp b/apps/openmw/mwinput/inputmanager.hpp index 81cf21dd3..e1b22453a 100644 --- a/apps/openmw/mwinput/inputmanager.hpp +++ b/apps/openmw/mwinput/inputmanager.hpp @@ -1,12 +1,17 @@ #ifndef _MWINPUT_MWINPUTMANAGER_H #define _MWINPUT_MWINPUTMANAGER_H -#include "components/engine/input/listener.hpp" -#include "components/engine/input/dispatcher.hpp" -#include "components/engine/input/poller.hpp" -#include "boost/bind.hpp" -#include "apps/openmw/mwrender/playerpos.hpp" -#include "libs/platform/strings.h" +#include +#include + +#include +#include + +#include + +#include +#include +#include "../mwrender/playerpos.hpp" namespace MWInput { @@ -29,13 +34,10 @@ namespace MWInput // Class that handles all input and key bindings for OpenMW class MWInputManager : public Ogre::FrameListener { - // Note: the order here is important. The OISManager must be - // initialized before poller and listener. - Input::Dispatcher disp; + Mangle::Input::EventPtr disp; Render::OgreRenderer &ogre; - Input::OISManager input; - Input::Poller poller; - Input::InputListener listener; + Mangle::Input::OISDriver input; + OEngine::Input::Poller poller; MWRender::PlayerPos &player; // Count screenshots. TODO: We should move this functionality to @@ -59,21 +61,21 @@ namespace MWInput public: MWInputManager(Render::OgreRenderer &_ogre, MWRender::PlayerPos &_player, bool debug) - : disp(A_LAST), - ogre(_ogre), - input(_ogre, debug), + : ogre(_ogre), + input(ogre.getWindow(), !debug), poller(input), - listener(_ogre, input, disp), player(_player), shotCount(0) { - using namespace Input; + using namespace OEngine::Input; using namespace OIS; + disp = EventPtr(new Dispatcher(A_LAST)); + // Bind MW-specific functions - disp.funcs.bind(A_Quit, boost::bind(&InputListener::exitNow, &listener), + disp->funcs.bind(A_Quit, boost::bind(&InputListener::exitNow, &listener), "Quit program"); - disp.funcs.bind(A_Screenshot, boost::bind(&MWInputManager::screenshot, this), + disp->funcs.bind(A_Screenshot, boost::bind(&MWInputManager::screenshot, this), "Screenshot"); // Add ourselves as a frame listener, to catch movement keys @@ -83,9 +85,9 @@ namespace MWInput listener.setCamera(player.getCamera()); // Key bindings - disp.bind(KC_Q, A_Quit); - disp.bind(KC_ESCAPE, A_Quit); - disp.bind(KC_SYSRQ, A_Screenshot); + disp->bind(KC_Q, A_Quit); + disp->bind(KC_ESCAPE, A_Quit); + disp->bind(KC_SYSRQ, A_Screenshot); // Key bindings for polled keys @@ -109,6 +111,9 @@ namespace MWInput // Used to check for movement keys bool frameStarted(const Ogre::FrameEvent &evt) { + // Tell OIS to handle all input events + input.capture(); + float speed = 300 * evt.timeSinceLastFrame; float moveX = 0, moveY = 0, moveZ = 0; diff --git a/libs/mangle b/libs/mangle index eed875ae0..9f21081c1 160000 --- a/libs/mangle +++ b/libs/mangle @@ -1 +1 @@ -Subproject commit eed875ae043c3c48fd23e18342c17d6f2331cc17 +Subproject commit 9f21081c13f70bc41e20b50c19ed2dac9b458833 diff --git a/libs/openengine b/libs/openengine new file mode 160000 index 000000000..5333b8e23 --- /dev/null +++ b/libs/openengine @@ -0,0 +1 @@ +Subproject commit 5333b8e230e285e9183b0639188283bdbc15af6c diff --git a/old_d_version/ogre/cpp_framelistener.cpp b/old_d_version/ogre/cpp_framelistener.cpp index 0419c0f7e..8c7a37044 100644 --- a/old_d_version/ogre/cpp_framelistener.cpp +++ b/old_d_version/ogre/cpp_framelistener.cpp @@ -1,97 +1,3 @@ -// Frame listener, passed to Ogre. The only thing we use this for is -// to capture input and pass control to D code. -class MorroFrameListener: public FrameListener -{ - -public: - // Start of frame - bool frameStarted(const FrameEvent& evt) - { - TRACE("frameStarted (Input)"); - - if(mWindow->isClosed()) - return false; - - // Capture keyboard and mouse events - mKeyboard->capture(); - mMouse->capture(); - - // Notify the GUI - mGUI->injectFrameEntered(evt.timeSinceLastFrame); - - // Turn over control to the D code - return d_frameStarted(evt.timeSinceLastFrame); - } -}; - -// Recieves input events and sends them to the D event handler. -class InputListener : public OIS::KeyListener, public OIS::MouseListener -{ -public: - bool keyPressed( const OIS::KeyEvent &arg ) - { - /* - std::cout << "KeyPressed {" << arg.key - << ", " << ((OIS::Keyboard*)(arg.device))->getAsString(arg.key) - << "} || Character (" << (char)arg.text << ")\n"; - //*/ - if(guiMode) - mGUI->injectKeyPress(arg); - - d_handleKey(arg.key, arg.text); - return true; - } - - bool mouseMoved( const OIS::MouseEvent &arg ) - { - /* - const OIS::MouseState& s = arg.state; - std::cout << "MouseMoved: Abs(" - << s.X.abs << ", " << s.Y.abs << ", " << s.Z.abs << ") Rel(" - << s.X.rel << ", " << s.Y.rel << ", " << s.Z.rel << ")\n"; - */ - // TODO: this should be handled elsewhere later on, most likely in - // Monster script. - if(guiMode) - mGUI->injectMouseMove(arg); - - d_handleMouseMove(&arg.state); - return true; - } - - bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) - { - /* - const OIS::MouseState& s = arg.state; - std::cout << "Mouse button #" << id << " pressed. Abs(" - << s.X.abs << ", " << s.Y.abs << ", " << s.Z.abs << ") Rel(" - << s.X.rel << ", " << s.Y.rel << ", " << s.Z.rel << ")\n"; - */ - if(guiMode) - mGUI->injectMousePress(arg, id); - - d_handleMouseButton(&arg.state, id); - return true; - } - - bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) - { - if(guiMode) - mGUI->injectMouseRelease(arg, id); - return true; - } - - bool keyReleased( const OIS::KeyEvent &arg ) - { - if(guiMode) - mGUI->injectKeyRelease(arg); - return true; - } -}; - -MorroFrameListener mFrameListener; -InputListener mInput; - // Get current camera orientation, in the form of 'front' and 'up' // vectors. extern "C" void ogre_getCameraOrientation(float *fx, float *fy, float *fz,