|
|
@ -74,14 +74,18 @@ namespace MWInput
|
|
|
|
, mTimeIdle(0.f)
|
|
|
|
, mTimeIdle(0.f)
|
|
|
|
, mMouseLookEnabled(false)
|
|
|
|
, mMouseLookEnabled(false)
|
|
|
|
, mGuiCursorEnabled(true)
|
|
|
|
, mGuiCursorEnabled(true)
|
|
|
|
|
|
|
|
, mGamepadGuiCursorEnabled(true)
|
|
|
|
, mDetectingKeyboard(false)
|
|
|
|
, mDetectingKeyboard(false)
|
|
|
|
, mOverencumberedMessageDelay(0.f)
|
|
|
|
, mOverencumberedMessageDelay(0.f)
|
|
|
|
, mGuiCursorX(0)
|
|
|
|
, mGuiCursorX(0)
|
|
|
|
, mGuiCursorY(0)
|
|
|
|
, mGuiCursorY(0)
|
|
|
|
, mMouseWheel(0)
|
|
|
|
, mMouseWheel(0)
|
|
|
|
|
|
|
|
, mGamepadZoom(0)
|
|
|
|
, mUserFileExists(userFileExists)
|
|
|
|
, mUserFileExists(userFileExists)
|
|
|
|
, mAlwaysRunActive(Settings::Manager::getBool("always run", "Input"))
|
|
|
|
, mAlwaysRunActive(Settings::Manager::getBool("always run", "Input"))
|
|
|
|
, mSneakToggles(Settings::Manager::getBool("toggle sneak", "Input"))
|
|
|
|
, mSneakToggles(Settings::Manager::getBool("toggle sneak", "Input"))
|
|
|
|
|
|
|
|
, mSneakToggleShortcutTimer(0.f)
|
|
|
|
|
|
|
|
, mSneakGamepadShortcut(false)
|
|
|
|
, mSneaking(false)
|
|
|
|
, mSneaking(false)
|
|
|
|
, mAttemptJump(false)
|
|
|
|
, mAttemptJump(false)
|
|
|
|
, mInvUiScalingFactor(1.f)
|
|
|
|
, mInvUiScalingFactor(1.f)
|
|
|
@ -204,6 +208,8 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
|
|
void InputManager::handleGuiArrowKey(int action)
|
|
|
|
void InputManager::handleGuiArrowKey(int action)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Temporary shut-down of this function until deemed necessary.
|
|
|
|
|
|
|
|
return;
|
|
|
|
if (SDL_IsTextInputActive())
|
|
|
|
if (SDL_IsTextInputActive())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
@ -231,6 +237,96 @@ namespace MWInput
|
|
|
|
MWBase::Environment::get().getWindowManager()->injectKeyPress(key, 0, false);
|
|
|
|
MWBase::Environment::get().getWindowManager()->injectKeyPress(key, 0, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool InputManager::gamepadToGuiControl(const SDL_ControllerButtonEvent &arg, bool release=false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Presumption of GUI mode will be removed in the future.
|
|
|
|
|
|
|
|
// MyGUI KeyCodes *may* change.
|
|
|
|
|
|
|
|
// Currently button releases are ignored.
|
|
|
|
|
|
|
|
if (release)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyGUI::KeyCode key = MyGUI::KeyCode::None;
|
|
|
|
|
|
|
|
switch (arg.button)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_DPAD_UP:
|
|
|
|
|
|
|
|
key = MyGUI::KeyCode::ArrowUp;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
|
|
|
|
|
|
|
|
key = MyGUI::KeyCode::ArrowRight;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
|
|
|
|
|
|
|
|
key = MyGUI::KeyCode::ArrowDown;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
|
|
|
|
|
|
|
|
key = MyGUI::KeyCode::ArrowLeft;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_A:
|
|
|
|
|
|
|
|
// If we are using the joystick as a GUI mouse, A must be handled via mouse.
|
|
|
|
|
|
|
|
if (mGamepadGuiCursorEnabled)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
key = MyGUI::KeyCode::Space;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_B:
|
|
|
|
|
|
|
|
if (MyGUI::InputManager::getInstance().isModalAny())
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->exitCurrentModal();
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_X:
|
|
|
|
|
|
|
|
key = MyGUI::KeyCode::Semicolon;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_Y:
|
|
|
|
|
|
|
|
key = MyGUI::KeyCode::Apostrophe;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
|
|
|
|
|
|
|
|
key = MyGUI::KeyCode::Period;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
|
|
|
|
|
|
|
|
key = MyGUI::KeyCode::Slash;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_BUTTON_LEFTSTICK:
|
|
|
|
|
|
|
|
mGamepadGuiCursorEnabled = !mGamepadGuiCursorEnabled;
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setCursorActive(mGamepadGuiCursorEnabled);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Some keys will work even when Text Input windows/modals are in focus.
|
|
|
|
|
|
|
|
if (SDL_IsTextInputActive())
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->injectKeyPress(key, 0, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool InputManager::gamepadToGuiControl(const SDL_ControllerAxisEvent &arg)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (arg.axis)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
|
|
|
|
|
|
|
|
if (arg.value == 32767) // Treat like a button.
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Minus, 0, false);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
|
|
|
|
|
|
|
|
if (arg.value == 32767) // Treat like a button.
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Equals, 0, false);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_AXIS_LEFTX:
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_AXIS_LEFTY:
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_AXIS_RIGHTX:
|
|
|
|
|
|
|
|
case SDL_CONTROLLER_AXIS_RIGHTY:
|
|
|
|
|
|
|
|
// If we are using the joystick as a GUI mouse, process mouse movement elsewhere.
|
|
|
|
|
|
|
|
if (mGamepadGuiCursorEnabled)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InputManager::channelChanged(ICS::Channel* channel, float currentValue, float previousValue)
|
|
|
|
void InputManager::channelChanged(ICS::Channel* channel, float currentValue, float previousValue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
resetIdleTime ();
|
|
|
|
resetIdleTime ();
|
|
|
@ -264,13 +360,31 @@ namespace MWInput
|
|
|
|
if (mControlSwitch["playercontrols"])
|
|
|
|
if (mControlSwitch["playercontrols"])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (action == A_Use)
|
|
|
|
if (action == A_Use)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(mJoystickLastUsed && currentValue == 1.0 && actionIsActive(A_ToggleWeapon))
|
|
|
|
|
|
|
|
action = A_CycleWeaponRight;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else if (mJoystickLastUsed && currentValue == 1.0 && actionIsActive(A_ToggleSpell))
|
|
|
|
|
|
|
|
action = A_CycleSpellRight;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWMechanics::DrawState_ state = MWBase::Environment::get().getWorld()->getPlayer().getDrawState();
|
|
|
|
MWMechanics::DrawState_ state = MWBase::Environment::get().getWorld()->getPlayer().getDrawState();
|
|
|
|
mPlayer->setAttackingOrSpell(currentValue != 0 && state != MWMechanics::DrawState_Nothing);
|
|
|
|
mPlayer->setAttackingOrSpell(currentValue != 0 && state != MWMechanics::DrawState_Nothing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (action == A_Jump)
|
|
|
|
else if (action == A_Jump)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(mJoystickLastUsed && currentValue == 1.0 && actionIsActive(A_ToggleWeapon))
|
|
|
|
|
|
|
|
action = A_CycleWeaponLeft;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else if (mJoystickLastUsed && currentValue == 1.0 && actionIsActive(A_ToggleSpell))
|
|
|
|
|
|
|
|
action = A_CycleSpellLeft;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
|
|
|
|
mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (currentValue == 1)
|
|
|
|
if (currentValue == 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -280,6 +394,9 @@ namespace MWInput
|
|
|
|
case A_GameMenu:
|
|
|
|
case A_GameMenu:
|
|
|
|
toggleMainMenu ();
|
|
|
|
toggleMainMenu ();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case A_OptionsMenu:
|
|
|
|
|
|
|
|
toggleOptionsMenu();
|
|
|
|
|
|
|
|
break;
|
|
|
|
case A_Screenshot:
|
|
|
|
case A_Screenshot:
|
|
|
|
screenshot();
|
|
|
|
screenshot();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -442,7 +559,7 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
|
|
updateCursorMode();
|
|
|
|
updateCursorMode();
|
|
|
|
|
|
|
|
|
|
|
|
if (mGuiCursorEnabled)
|
|
|
|
if (mGuiCursorEnabled && !(mJoystickLastUsed && !mGamepadGuiCursorEnabled))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue()*2.0f-1.0f;
|
|
|
|
float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue()*2.0f-1.0f;
|
|
|
|
float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue()*2.0f-1.0f;
|
|
|
|
float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue()*2.0f-1.0f;
|
|
|
@ -506,28 +623,17 @@ namespace MWInput
|
|
|
|
// joystick movement
|
|
|
|
// joystick movement
|
|
|
|
float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue();
|
|
|
|
float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue();
|
|
|
|
float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue();
|
|
|
|
float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue();
|
|
|
|
if (xAxis < .5)
|
|
|
|
if (xAxis != .5)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
triedToMove = true;
|
|
|
|
triedToMove = true;
|
|
|
|
mPlayer->setLeftRight (-1);
|
|
|
|
mPlayer->setLeftRight((xAxis - 0.5f) * 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (xAxis > .5)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
triedToMove = true;
|
|
|
|
|
|
|
|
mPlayer->setLeftRight (1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (yAxis < .5)
|
|
|
|
if (yAxis != .5)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
triedToMove = true;
|
|
|
|
triedToMove = true;
|
|
|
|
mPlayer->setAutoMove (false);
|
|
|
|
mPlayer->setAutoMove (false);
|
|
|
|
mPlayer->setForwardBackward (1);
|
|
|
|
mPlayer->setForwardBackward((yAxis - 0.5f) * 2 * -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (yAxis > .5)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
triedToMove = true;
|
|
|
|
|
|
|
|
mPlayer->setAutoMove (false);
|
|
|
|
|
|
|
|
mPlayer->setForwardBackward (-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(mPlayer->getAutoMove())
|
|
|
|
else if(mPlayer->getAutoMove())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -572,6 +678,34 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
|
|
if (!mSneakToggles)
|
|
|
|
if (!mSneakToggles)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if(mJoystickLastUsed)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(actionIsActive(A_Sneak))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(mSneakToggleShortcutTimer) // New Sneak Button Press
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(mSneakToggleShortcutTimer <= 0.3f)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mSneakGamepadShortcut = true;
|
|
|
|
|
|
|
|
toggleSneaking();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
mSneakGamepadShortcut = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!mSneaking)
|
|
|
|
|
|
|
|
toggleSneaking();
|
|
|
|
|
|
|
|
mSneakToggleShortcutTimer = 0.f;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!mSneakGamepadShortcut && mSneaking)
|
|
|
|
|
|
|
|
toggleSneaking();
|
|
|
|
|
|
|
|
if(mSneakToggleShortcutTimer <= 0.3f)
|
|
|
|
|
|
|
|
mSneakToggleShortcutTimer += dt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
mPlayer->setSneak(actionIsActive(A_Sneak));
|
|
|
|
mPlayer->setSneak(actionIsActive(A_Sneak));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -619,6 +753,13 @@ namespace MWInput
|
|
|
|
MWBase::Environment::get().getWorld()->togglePOV();
|
|
|
|
MWBase::Environment::get().getWorld()->togglePOV();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mPreviewPOVDelay = 0.f;
|
|
|
|
mPreviewPOVDelay = 0.f;
|
|
|
|
|
|
|
|
mGamepadZoom = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(mGamepadZoom)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWorld()->changeVanityModeScale(mGamepadZoom);
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWorld()->setCameraDistance(mGamepadZoom, true, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -635,6 +776,8 @@ namespace MWInput
|
|
|
|
updateIdleTime(dt);
|
|
|
|
updateIdleTime(dt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
mGamepadZoom = 0;
|
|
|
|
mAttemptJump = false; // Can only jump on first frame input is on
|
|
|
|
mAttemptJump = false; // Can only jump on first frame input is on
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -649,7 +792,7 @@ namespace MWInput
|
|
|
|
mMouseLookEnabled = !guiMode;
|
|
|
|
mMouseLookEnabled = !guiMode;
|
|
|
|
if (guiMode)
|
|
|
|
if (guiMode)
|
|
|
|
MWBase::Environment::get().getWindowManager()->showCrosshair(false);
|
|
|
|
MWBase::Environment::get().getWindowManager()->showCrosshair(false);
|
|
|
|
MWBase::Environment::get().getWindowManager()->setCursorVisible(guiMode);
|
|
|
|
MWBase::Environment::get().getWindowManager()->setCursorVisible(guiMode && (mJoystickLastUsed && !mGamepadGuiCursorEnabled));
|
|
|
|
// if not in gui mode, the camera decides whether to show crosshair or not.
|
|
|
|
// if not in gui mode, the camera decides whether to show crosshair or not.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -830,6 +973,8 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
|
|
if (mGuiCursorEnabled)
|
|
|
|
if (mGuiCursorEnabled)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!mGamepadGuiCursorEnabled)
|
|
|
|
|
|
|
|
mGamepadGuiCursorEnabled = true;
|
|
|
|
// We keep track of our own mouse position, so that moving the mouse while in
|
|
|
|
// We keep track of our own mouse position, so that moving the mouse while in
|
|
|
|
// game mode does not move the position of the GUI cursor
|
|
|
|
// game mode does not move the position of the GUI cursor
|
|
|
|
mGuiCursorX = static_cast<float>(arg.x) * mInvUiScalingFactor;
|
|
|
|
mGuiCursorX = static_cast<float>(arg.x) * mInvUiScalingFactor;
|
|
|
@ -875,36 +1020,37 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
|
|
void InputManager::buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg )
|
|
|
|
void InputManager::buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!mJoystickEnabled)
|
|
|
|
if (!mJoystickEnabled || mInputBinder->detectingBindingState())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
mJoystickLastUsed = true;
|
|
|
|
mJoystickLastUsed = true;
|
|
|
|
bool guiMode = false;
|
|
|
|
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
|
|
|
|
|
|
|
|
|
|
|
if (arg.button == SDL_CONTROLLER_BUTTON_A || arg.button == SDL_CONTROLLER_BUTTON_B) // We'll pretend that A is left click and B is right click
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
|
|
|
|
if (gamepadToGuiControl(arg, false))
|
|
|
|
if(!mInputBinder->detectingBindingState())
|
|
|
|
return;
|
|
|
|
|
|
|
|
else if (mGamepadGuiCursorEnabled)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
guiMode = MyGUI::InputManager::getInstance().injectMousePress(static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY),
|
|
|
|
// Temporary mouse binding until keyboard controls are available:
|
|
|
|
sdlButtonToMyGUI((arg.button == SDL_CONTROLLER_BUTTON_B) ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT)) && guiMode;
|
|
|
|
if (arg.button == SDL_CONTROLLER_BUTTON_A) // We'll pretend that A is left click.
|
|
|
|
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false);
|
|
|
|
bool mousePressSuccess = MyGUI::InputManager::getInstance().injectMousePress(static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), sdlButtonToMyGUI(SDL_BUTTON_LEFT));
|
|
|
|
if (b && b->getEnabled())
|
|
|
|
if (MyGUI::InputManager::getInstance().getMouseFocusWidget())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
MyGUI::Button* b = MyGUI::InputManager::getInstance().getMouseFocusWidget()->castType<MyGUI::Button>(false);
|
|
|
|
|
|
|
|
if (b && b->getEnabled())
|
|
|
|
MWBase::Environment::get().getWindowManager()->playSound("Menu Click");
|
|
|
|
MWBase::Environment::get().getWindowManager()->playSound("Menu Click");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setPlayerControlsEnabled(!mousePressSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
setPlayerControlsEnabled(!guiMode);
|
|
|
|
setPlayerControlsEnabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
//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);
|
|
|
|
setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0));
|
|
|
|
setPlayerControlsEnabled(!guiFocus);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!mControlsDisabled)
|
|
|
|
if (!mControlsDisabled)
|
|
|
|
mInputBinder->buttonPressed(deviceID, arg);
|
|
|
|
mInputBinder->buttonPressed(deviceID, arg);
|
|
|
@ -912,33 +1058,68 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
|
|
void InputManager::buttonReleased(int deviceID, const SDL_ControllerButtonEvent &arg )
|
|
|
|
void InputManager::buttonReleased(int deviceID, const SDL_ControllerButtonEvent &arg )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!mJoystickEnabled)
|
|
|
|
if(mInputBinder->detectingBindingState())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mInputBinder->buttonReleased(deviceID, arg);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mJoystickEnabled || mControlsDisabled)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
mJoystickLastUsed = true;
|
|
|
|
mJoystickLastUsed = true;
|
|
|
|
if(mInputBinder->detectingBindingState())
|
|
|
|
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
|
|
|
mInputBinder->buttonReleased(deviceID, arg);
|
|
|
|
|
|
|
|
else if(arg.button == SDL_CONTROLLER_BUTTON_A || arg.button == SDL_CONTROLLER_BUTTON_B)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
|
|
|
|
if (gamepadToGuiControl(arg, true))
|
|
|
|
guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), sdlButtonToMyGUI((arg.button == SDL_CONTROLLER_BUTTON_B) ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT)) && guiMode;
|
|
|
|
return;
|
|
|
|
|
|
|
|
else if (mGamepadGuiCursorEnabled)
|
|
|
|
if(mInputBinder->detectingBindingState()) return; // don't allow same mouseup to bind as initiated bind
|
|
|
|
{
|
|
|
|
|
|
|
|
// Temporary mouse binding until keyboard controls are available:
|
|
|
|
|
|
|
|
if (arg.button == SDL_CONTROLLER_BUTTON_A) // We'll pretend that A is left click.
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool mousePressSuccess = MyGUI::InputManager::getInstance().injectMouseRelease(static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), sdlButtonToMyGUI(SDL_BUTTON_LEFT));
|
|
|
|
|
|
|
|
if (mInputBinder->detectingBindingState()) // If the player just triggered binding, don't let button release bind.
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
setPlayerControlsEnabled(!guiMode);
|
|
|
|
setPlayerControlsEnabled(!mousePressSuccess);
|
|
|
|
mInputBinder->buttonReleased(deviceID, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
mInputBinder->buttonReleased(deviceID, arg);
|
|
|
|
setPlayerControlsEnabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
///to escape initial movie
|
|
|
|
//esc, to leave initial movie screen
|
|
|
|
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)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mInputBinder->buttonReleased(deviceID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg )
|
|
|
|
void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!mControlsDisabled && mJoystickEnabled)
|
|
|
|
if(!mJoystickEnabled || mControlsDisabled)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mJoystickLastUsed = true;
|
|
|
|
|
|
|
|
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
gamepadToGuiControl(arg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(mPreviewPOVDelay == 1.f && arg.value) // Preview Mode Gamepad Zooming
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(arg.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mGamepadZoom = static_cast<float>(arg.value / 10000 * 8.5f);
|
|
|
|
|
|
|
|
return; // Do not propogate event.
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(arg.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mGamepadZoom = static_cast<float>(-(arg.value / 10000 * 8.5f));
|
|
|
|
|
|
|
|
return; // Do not propogate event.
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
mInputBinder->axisMoved(deviceID, arg);
|
|
|
|
mInputBinder->axisMoved(deviceID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -975,19 +1156,38 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
|
|
void InputManager::toggleMainMenu()
|
|
|
|
void InputManager::toggleMainMenu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (MyGUI::InputManager::getInstance().isModalAny()) {
|
|
|
|
if (MyGUI::InputManager::getInstance().isModalAny())
|
|
|
|
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->exitCurrentModal();
|
|
|
|
MWBase::Environment::get().getWindowManager()->exitCurrentModal();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!MWBase::Environment::get().getWindowManager()->isGuiMode()) //No open GUIs, open up the MainMenu
|
|
|
|
bool inGame = MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_NoGame;
|
|
|
|
{
|
|
|
|
MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode();
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
|
|
|
|
|
|
|
|
|
|
|
|
if ((inGame && mode == MWGui::GM_MainMenu) || mode == MWGui::GM_Settings)
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (inGame && mode != MWGui::GM_MainMenu)
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_MainMenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else //Close current GUI
|
|
|
|
|
|
|
|
|
|
|
|
void InputManager::toggleOptionsMenu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
|
|
|
|
if (MyGUI::InputManager::getInstance().isModalAny())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->exitCurrentModal();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode();
|
|
|
|
|
|
|
|
bool inGame = MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_NoGame;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((inGame && mode == MWGui::GM_MainMenu) || mode == MWGui::GM_Settings)
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (inGame && mode != MWGui::GM_Settings)
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InputManager::quickLoad() {
|
|
|
|
void InputManager::quickLoad() {
|
|
|
@ -1397,20 +1597,20 @@ namespace MWInput
|
|
|
|
|
|
|
|
|
|
|
|
defaultButtonBindings[A_Activate] = SDL_CONTROLLER_BUTTON_A;
|
|
|
|
defaultButtonBindings[A_Activate] = SDL_CONTROLLER_BUTTON_A;
|
|
|
|
defaultButtonBindings[A_ToggleWeapon] = SDL_CONTROLLER_BUTTON_X;
|
|
|
|
defaultButtonBindings[A_ToggleWeapon] = SDL_CONTROLLER_BUTTON_X;
|
|
|
|
defaultButtonBindings[A_ToggleSpell] = SDL_CONTROLLER_BUTTON_LEFTSHOULDER;
|
|
|
|
defaultButtonBindings[A_ToggleSpell] = SDL_CONTROLLER_BUTTON_Y;
|
|
|
|
//defaultButtonBindings[A_QuickButtonsMenu] = SDL_GetButtonFromScancode(SDL_SCANCODE_F1); // Need to implement, should be ToggleSpell(5) AND Wait(9)
|
|
|
|
//defaultButtonBindings[A_QuickButtonsMenu] = SDL_GetButtonFromScancode(SDL_SCANCODE_F1); // Need to implement, should be ToggleSpell(5) AND Wait(9)
|
|
|
|
defaultButtonBindings[A_Sneak] = SDL_CONTROLLER_BUTTON_RIGHTSTICK;
|
|
|
|
defaultButtonBindings[A_Sneak] = SDL_CONTROLLER_BUTTON_LEFTSTICK;
|
|
|
|
defaultButtonBindings[A_Jump] = SDL_CONTROLLER_BUTTON_Y;
|
|
|
|
defaultButtonBindings[A_Journal] = SDL_CONTROLLER_BUTTON_LEFTSHOULDER;
|
|
|
|
defaultButtonBindings[A_Journal] = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER;
|
|
|
|
defaultButtonBindings[A_Rest] = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER;
|
|
|
|
defaultButtonBindings[A_Rest] = SDL_CONTROLLER_BUTTON_BACK;
|
|
|
|
defaultButtonBindings[A_TogglePOV] = SDL_CONTROLLER_BUTTON_RIGHTSTICK;
|
|
|
|
defaultButtonBindings[A_TogglePOV] = SDL_CONTROLLER_BUTTON_LEFTSTICK;
|
|
|
|
|
|
|
|
defaultButtonBindings[A_Inventory] = SDL_CONTROLLER_BUTTON_B;
|
|
|
|
defaultButtonBindings[A_Inventory] = SDL_CONTROLLER_BUTTON_B;
|
|
|
|
defaultButtonBindings[A_GameMenu] = SDL_CONTROLLER_BUTTON_START;
|
|
|
|
defaultButtonBindings[A_GameMenu] = SDL_CONTROLLER_BUTTON_START;
|
|
|
|
|
|
|
|
defaultButtonBindings[A_OptionsMenu] = SDL_CONTROLLER_BUTTON_BACK;
|
|
|
|
defaultButtonBindings[A_QuickSave] = SDL_CONTROLLER_BUTTON_GUIDE;
|
|
|
|
defaultButtonBindings[A_QuickSave] = SDL_CONTROLLER_BUTTON_GUIDE;
|
|
|
|
defaultButtonBindings[A_QuickKey1] = SDL_CONTROLLER_BUTTON_DPAD_UP;
|
|
|
|
defaultButtonBindings[A_MoveForward] = SDL_CONTROLLER_BUTTON_DPAD_UP;
|
|
|
|
defaultButtonBindings[A_QuickKey2] = SDL_CONTROLLER_BUTTON_DPAD_LEFT;
|
|
|
|
defaultButtonBindings[A_MoveLeft] = SDL_CONTROLLER_BUTTON_DPAD_LEFT;
|
|
|
|
defaultButtonBindings[A_QuickKey3] = SDL_CONTROLLER_BUTTON_DPAD_DOWN;
|
|
|
|
defaultButtonBindings[A_MoveBackward] = SDL_CONTROLLER_BUTTON_DPAD_DOWN;
|
|
|
|
defaultButtonBindings[A_QuickKey4] = SDL_CONTROLLER_BUTTON_DPAD_RIGHT;
|
|
|
|
defaultButtonBindings[A_MoveRight] = SDL_CONTROLLER_BUTTON_DPAD_RIGHT;
|
|
|
|
|
|
|
|
|
|
|
|
std::map<int, int> defaultAxisBindings;
|
|
|
|
std::map<int, int> defaultAxisBindings;
|
|
|
|
defaultAxisBindings[A_MoveForwardBackward] = SDL_CONTROLLER_AXIS_LEFTY;
|
|
|
|
defaultAxisBindings[A_MoveForwardBackward] = SDL_CONTROLLER_AXIS_LEFTY;
|
|
|
@ -1418,6 +1618,7 @@ namespace MWInput
|
|
|
|
defaultAxisBindings[A_LookUpDown] = SDL_CONTROLLER_AXIS_RIGHTY;
|
|
|
|
defaultAxisBindings[A_LookUpDown] = SDL_CONTROLLER_AXIS_RIGHTY;
|
|
|
|
defaultAxisBindings[A_LookLeftRight] = SDL_CONTROLLER_AXIS_RIGHTX;
|
|
|
|
defaultAxisBindings[A_LookLeftRight] = SDL_CONTROLLER_AXIS_RIGHTX;
|
|
|
|
defaultAxisBindings[A_Use] = SDL_CONTROLLER_AXIS_TRIGGERRIGHT;
|
|
|
|
defaultAxisBindings[A_Use] = SDL_CONTROLLER_AXIS_TRIGGERRIGHT;
|
|
|
|
|
|
|
|
defaultAxisBindings[A_Jump] = SDL_CONTROLLER_AXIS_TRIGGERLEFT;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < A_Last; i++)
|
|
|
|
for (int i = 0; i < A_Last; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1485,6 +1686,7 @@ namespace MWInput
|
|
|
|
descriptions[A_Journal] = "sJournal";
|
|
|
|
descriptions[A_Journal] = "sJournal";
|
|
|
|
descriptions[A_Rest] = "sRestKey";
|
|
|
|
descriptions[A_Rest] = "sRestKey";
|
|
|
|
descriptions[A_Inventory] = "sInventory";
|
|
|
|
descriptions[A_Inventory] = "sInventory";
|
|
|
|
|
|
|
|
descriptions[A_OptionsMenu] = "sPreferences";
|
|
|
|
descriptions[A_TogglePOV] = "sTogglePOVCmd";
|
|
|
|
descriptions[A_TogglePOV] = "sTogglePOVCmd";
|
|
|
|
descriptions[A_QuickKeysMenu] = "sQuickMenu";
|
|
|
|
descriptions[A_QuickKeysMenu] = "sQuickMenu";
|
|
|
|
descriptions[A_QuickKey1] = "sQuick1Cmd";
|
|
|
|
descriptions[A_QuickKey1] = "sQuick1Cmd";
|
|
|
@ -1622,6 +1824,7 @@ namespace MWInput
|
|
|
|
ret.push_back(A_Inventory);
|
|
|
|
ret.push_back(A_Inventory);
|
|
|
|
ret.push_back(A_Journal);
|
|
|
|
ret.push_back(A_Journal);
|
|
|
|
ret.push_back(A_Rest);
|
|
|
|
ret.push_back(A_Rest);
|
|
|
|
|
|
|
|
ret.push_back(A_OptionsMenu);
|
|
|
|
ret.push_back(A_Console);
|
|
|
|
ret.push_back(A_Console);
|
|
|
|
ret.push_back(A_QuickSave);
|
|
|
|
ret.push_back(A_QuickSave);
|
|
|
|
ret.push_back(A_QuickLoad);
|
|
|
|
ret.push_back(A_QuickLoad);
|
|
|
@ -1654,6 +1857,7 @@ namespace MWInput
|
|
|
|
ret.push_back(A_Inventory);
|
|
|
|
ret.push_back(A_Inventory);
|
|
|
|
ret.push_back(A_Journal);
|
|
|
|
ret.push_back(A_Journal);
|
|
|
|
ret.push_back(A_Rest);
|
|
|
|
ret.push_back(A_Rest);
|
|
|
|
|
|
|
|
ret.push_back(A_OptionsMenu);
|
|
|
|
ret.push_back(A_QuickSave);
|
|
|
|
ret.push_back(A_QuickSave);
|
|
|
|
ret.push_back(A_QuickLoad);
|
|
|
|
ret.push_back(A_QuickLoad);
|
|
|
|
ret.push_back(A_Screenshot);
|
|
|
|
ret.push_back(A_Screenshot);
|
|
|
|