|
|
|
@ -14,8 +14,6 @@
|
|
|
|
|
|
|
|
|
|
#include <SDL_version.h>
|
|
|
|
|
|
|
|
|
|
#include <openengine/ogre/renderer.hpp>
|
|
|
|
|
|
|
|
|
|
#include "../engine.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
@ -98,16 +96,16 @@ namespace
|
|
|
|
|
|
|
|
|
|
namespace MWInput
|
|
|
|
|
{
|
|
|
|
|
InputManager::InputManager(OEngine::Render::OgreRenderer &ogre,
|
|
|
|
|
InputManager::InputManager(
|
|
|
|
|
OMW::Engine& engine,
|
|
|
|
|
const std::string& userFile, bool userFileExists,
|
|
|
|
|
const std::string& controllerBindingsFile, bool grab)
|
|
|
|
|
: mOgre(ogre)
|
|
|
|
|
: mInputManager(NULL)
|
|
|
|
|
, mPlayer(NULL)
|
|
|
|
|
, mEngine(engine)
|
|
|
|
|
, mMouseLookEnabled(false)
|
|
|
|
|
, mMouseX(ogre.getWindow()->getWidth ()/2.f)
|
|
|
|
|
, mMouseY(ogre.getWindow()->getHeight ()/2.f)
|
|
|
|
|
, mMouseX(0)//ogre.getWindow()->getWidth ()/2.f)
|
|
|
|
|
, mMouseY(0)//ogre.getWindow()->getHeight ()/2.f)
|
|
|
|
|
, mMouseWheel(0)
|
|
|
|
|
, mDragDrop(false)
|
|
|
|
|
, mGuiCursorEnabled(true)
|
|
|
|
@ -131,17 +129,18 @@ namespace MWInput
|
|
|
|
|
, mFakeDeviceID(1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Ogre::RenderWindow* window = ogre.getWindow ();
|
|
|
|
|
|
|
|
|
|
mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow(), mOgre.getWindow(), grab);
|
|
|
|
|
mInputManager->setMouseEventCallback (this);
|
|
|
|
|
mInputManager->setKeyboardEventCallback (this);
|
|
|
|
|
mInputManager->setWindowEventCallback(this);
|
|
|
|
|
mInputManager->setControllerEventCallback(this);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
std::string file = userFileExists ? userFile : "";
|
|
|
|
|
mInputBinder = new ICS::InputControlSystem(file, true, this, NULL, A_Last);
|
|
|
|
|
adjustMouseRegion (window->getWidth(), window->getHeight());
|
|
|
|
|
//adjustMouseRegion (window->getWidth(), window->getHeight());
|
|
|
|
|
|
|
|
|
|
loadKeyDefaults();
|
|
|
|
|
loadControllerDefaults();
|
|
|
|
@ -199,7 +198,7 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
delete mInputBinder;
|
|
|
|
|
|
|
|
|
|
delete mInputManager;
|
|
|
|
|
//delete mInputManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InputManager::setPlayerControlsEnabled(bool enabled)
|
|
|
|
@ -366,24 +365,24 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
void InputManager::updateCursorMode()
|
|
|
|
|
{
|
|
|
|
|
bool grab = !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu)
|
|
|
|
|
&& MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_Console;
|
|
|
|
|
//bool grab = !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu)
|
|
|
|
|
// && 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();
|
|
|
|
|
|
|
|
|
|
// don't keep the pointer away from the window edge in gui mode
|
|
|
|
|
// 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
|
|
|
|
|
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
|
|
|
|
|
//cursor is
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
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)));
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
@ -668,6 +667,7 @@ namespace MWInput
|
|
|
|
|
// 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
|
|
|
|
|
// (which is somewhat reasonable, and hopefully true for all SDL platforms)
|
|
|
|
|
/*
|
|
|
|
|
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
|
|
|
|
|
if (mInputBinder->getKeyBinding(mInputBinder->getControl(A_Console), ICS::Control::INCREASE)
|
|
|
|
|
== arg.keysym.scancode
|
|
|
|
@ -685,6 +685,7 @@ namespace MWInput
|
|
|
|
|
if (!mControlsDisabled && !consumed)
|
|
|
|
|
mInputBinder->keyPressed (arg);
|
|
|
|
|
mJoystickLastUsed = false;
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InputManager::textInput(const SDL_TextInputEvent &arg)
|
|
|
|
@ -697,11 +698,13 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
void InputManager::keyReleased(const SDL_KeyboardEvent &arg )
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
mJoystickLastUsed = false;
|
|
|
|
|
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
|
|
|
|
|
|
|
|
|
|
setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)));
|
|
|
|
|
mInputBinder->keyReleased (arg);
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InputManager::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id )
|
|
|
|
@ -827,9 +830,9 @@ namespace MWInput
|
|
|
|
|
setPlayerControlsEnabled(!guiMode);
|
|
|
|
|
|
|
|
|
|
//esc, to leave initial movie screen
|
|
|
|
|
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE);
|
|
|
|
|
bool guiFocus = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0);
|
|
|
|
|
setPlayerControlsEnabled(!guiFocus);
|
|
|
|
|
//OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE);
|
|
|
|
|
//bool guiFocus = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0);
|
|
|
|
|
//setPlayerControlsEnabled(!guiFocus);
|
|
|
|
|
|
|
|
|
|
if (!mControlsDisabled)
|
|
|
|
|
mInputBinder->buttonPressed(deviceID, arg);
|
|
|
|
@ -853,9 +856,9 @@ namespace MWInput
|
|
|
|
|
else
|
|
|
|
|
mInputBinder->buttonReleased(deviceID, arg);
|
|
|
|
|
|
|
|
|
|
//to escape initial movie
|
|
|
|
|
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE);
|
|
|
|
|
setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)));
|
|
|
|
|
///to escape initial movie
|
|
|
|
|
//OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE);
|
|
|
|
|
//setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg )
|
|
|
|
@ -885,7 +888,7 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
void InputManager::windowResized(int x, int y)
|
|
|
|
|
{
|
|
|
|
|
mOgre.windowResized(x,y);
|
|
|
|
|
//mOgre.windowResized(x,y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InputManager::windowClosed()
|
|
|
|
|