mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 09:23:53 +00:00
Merge branch 'xbox-bindings' into 'master'
xbox-bindings See merge request OpenMW/openmw!69
This commit is contained in:
commit
3ce261ddd4
2 changed files with 61 additions and 9 deletions
|
@ -67,6 +67,7 @@ namespace MWInput
|
||||||
, 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"))
|
||||||
|
@ -252,13 +253,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)
|
||||||
{
|
{
|
||||||
|
@ -607,6 +626,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -623,6 +649,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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -926,8 +954,30 @@ namespace MWInput
|
||||||
void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg )
|
void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg )
|
||||||
{
|
{
|
||||||
if (!mControlsDisabled && mJoystickEnabled)
|
if (!mControlsDisabled && mJoystickEnabled)
|
||||||
|
{
|
||||||
|
if(arg.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT)
|
||||||
|
{
|
||||||
|
mGamepadZoom = 0;
|
||||||
|
if(!MWBase::Environment::get().getWindowManager()->isGuiMode() && mPreviewPOVDelay == 1.f && arg.value)
|
||||||
|
{
|
||||||
|
mGamepadZoom = static_cast<float>(arg.value / 10000 * 8.5f);
|
||||||
|
return; // Do not propogate event.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(arg.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT)
|
||||||
|
{
|
||||||
|
mGamepadZoom = 0;
|
||||||
|
if(!MWBase::Environment::get().getWindowManager()->isGuiMode() && mPreviewPOVDelay == 1.f && arg.value)
|
||||||
|
{
|
||||||
|
mGamepadZoom = static_cast<float>(-(arg.value / 10000 * 8.5f));
|
||||||
|
return; // Do not propogate event.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mInputBinder->axisMoved(deviceID, arg);
|
mInputBinder->axisMoved(deviceID, arg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InputManager::controllerAdded(int deviceID, const SDL_ControllerDeviceEvent &arg)
|
void InputManager::controllerAdded(int deviceID, const SDL_ControllerDeviceEvent &arg)
|
||||||
{
|
{
|
||||||
|
@ -1327,15 +1377,15 @@ 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_QuickKeysMenu] = SDL_CONTROLLER_BUTTON_BACK; // Ideally a new menu, A_QuickButtonsMenu should be implemented with only 4 quick keys.
|
||||||
defaultButtonBindings[A_QuickSave] = SDL_CONTROLLER_BUTTON_GUIDE;
|
defaultButtonBindings[A_QuickSave] = SDL_CONTROLLER_BUTTON_GUIDE;
|
||||||
defaultButtonBindings[A_QuickKey1] = SDL_CONTROLLER_BUTTON_DPAD_UP;
|
defaultButtonBindings[A_QuickKey1] = SDL_CONTROLLER_BUTTON_DPAD_UP;
|
||||||
defaultButtonBindings[A_QuickKey2] = SDL_CONTROLLER_BUTTON_DPAD_LEFT;
|
defaultButtonBindings[A_QuickKey2] = SDL_CONTROLLER_BUTTON_DPAD_LEFT;
|
||||||
|
@ -1348,6 +1398,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++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -196,6 +196,7 @@ namespace MWInput
|
||||||
float mGuiCursorX;
|
float mGuiCursorX;
|
||||||
float mGuiCursorY;
|
float mGuiCursorY;
|
||||||
int mMouseWheel;
|
int mMouseWheel;
|
||||||
|
float mGamepadZoom;
|
||||||
bool mUserFileExists;
|
bool mUserFileExists;
|
||||||
bool mAlwaysRunActive;
|
bool mAlwaysRunActive;
|
||||||
bool mSneakToggles;
|
bool mSneakToggles;
|
||||||
|
|
Loading…
Reference in a new issue