Merge pull request #2455 from Capostrophic/input

Revert questionable input manager decisions
pull/541/head
Alexei Dobrohotov 5 years ago committed by GitHub
commit 43a58e181f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -202,6 +202,11 @@ namespace MWInput
void InputManager::handleGuiArrowKey(int action)
{
// This is currently keyboard-specific code
// TODO: see if GUI controls can be refactored into a single function
if (mJoystickLastUsed)
return;
if (SDL_IsTextInputActive())
return;
@ -229,13 +234,10 @@ namespace MWInput
MWBase::Environment::get().getWindowManager()->injectKeyPress(key, 0, false);
}
bool InputManager::gamepadToGuiControl(const SDL_ControllerButtonEvent &arg, bool release=false)
bool InputManager::gamepadToGuiControl(const SDL_ControllerButtonEvent &arg)
{
// 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)
@ -386,9 +388,6 @@ namespace MWInput
case A_GameMenu:
toggleMainMenu ();
break;
case A_OptionsMenu:
toggleOptionsMenu();
break;
case A_Screenshot:
screenshot();
break;
@ -406,8 +405,7 @@ namespace MWInput
case A_MoveRight:
case A_MoveForward:
case A_MoveBackward:
// Temporary shut-down of this function until deemed necessary.
//handleGuiArrowKey(action);
handleGuiArrowKey(action);
break;
case A_Journal:
toggleJournal ();
@ -1002,9 +1000,9 @@ namespace MWInput
mJoystickLastUsed = true;
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
{
if (gamepadToGuiControl(arg, false))
if (gamepadToGuiControl(arg))
return;
else if (mGamepadGuiCursorEnabled)
if (mGamepadGuiCursorEnabled)
{
// Temporary mouse binding until keyboard controls are available:
if (arg.button == SDL_CONTROLLER_BUTTON_A) // We'll pretend that A is left click.
@ -1045,9 +1043,7 @@ namespace MWInput
mJoystickLastUsed = true;
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
{
if (gamepadToGuiControl(arg, true))
return;
else if (mGamepadGuiCursorEnabled)
if (mGamepadGuiCursorEnabled)
{
// Temporary mouse binding until keyboard controls are available:
if (arg.button == SDL_CONTROLLER_BUTTON_A) // We'll pretend that A is left click.
@ -1146,37 +1142,19 @@ namespace MWInput
}
if (MWBase::Environment::get().getWindowManager()->isConsoleMode())
return;
bool inGame = MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_NoGame;
MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode();
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);
}
void InputManager::toggleOptionsMenu()
{
if (MyGUI::InputManager::getInstance().isModalAny())
{
MWBase::Environment::get().getWindowManager()->exitCurrentModal();
MWBase::Environment::get().getWindowManager()->toggleConsole();
return;
}
if (MWBase::Environment::get().getWindowManager()->isConsoleMode())
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);
if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) //No open GUIs, open up the MainMenu
{
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
}
else //Close current GUI
{
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
}
}
void InputManager::quickLoad() {
@ -1531,7 +1509,6 @@ namespace MWInput
defaultButtonBindings[A_TogglePOV] = SDL_CONTROLLER_BUTTON_RIGHTSTICK;
defaultButtonBindings[A_Inventory] = SDL_CONTROLLER_BUTTON_B;
defaultButtonBindings[A_GameMenu] = SDL_CONTROLLER_BUTTON_START;
defaultButtonBindings[A_OptionsMenu] = SDL_CONTROLLER_BUTTON_BACK;
defaultButtonBindings[A_QuickSave] = SDL_CONTROLLER_BUTTON_GUIDE;
defaultButtonBindings[A_MoveForward] = SDL_CONTROLLER_BUTTON_DPAD_UP;
defaultButtonBindings[A_MoveLeft] = SDL_CONTROLLER_BUTTON_DPAD_LEFT;
@ -1612,7 +1589,6 @@ namespace MWInput
descriptions[A_Journal] = "sJournal";
descriptions[A_Rest] = "sRestKey";
descriptions[A_Inventory] = "sInventory";
descriptions[A_OptionsMenu] = "sPreferences";
descriptions[A_TogglePOV] = "sTogglePOVCmd";
descriptions[A_QuickKeysMenu] = "sQuickMenu";
descriptions[A_QuickKey1] = "sQuick1Cmd";
@ -1750,7 +1726,6 @@ namespace MWInput
ret.push_back(A_Inventory);
ret.push_back(A_Journal);
ret.push_back(A_Rest);
ret.push_back(A_OptionsMenu);
ret.push_back(A_Console);
ret.push_back(A_QuickSave);
ret.push_back(A_QuickLoad);
@ -1783,7 +1758,6 @@ namespace MWInput
ret.push_back(A_Inventory);
ret.push_back(A_Journal);
ret.push_back(A_Rest);
ret.push_back(A_OptionsMenu);
ret.push_back(A_QuickSave);
ret.push_back(A_QuickLoad);
ret.push_back(A_Screenshot);

@ -226,7 +226,7 @@ namespace MWInput
void setPlayerControlsEnabled(bool enabled);
void handleGuiArrowKey(int action);
// Return true if GUI consumes input.
bool gamepadToGuiControl(const SDL_ControllerButtonEvent &arg, bool release);
bool gamepadToGuiControl(const SDL_ControllerButtonEvent &arg);
bool gamepadToGuiControl(const SDL_ControllerAxisEvent &arg);
void updateCursorMode();
@ -235,7 +235,6 @@ namespace MWInput
private:
void toggleMainMenu();
void toggleOptionsMenu();
void toggleSpell();
void toggleWeapon();
void toggleInventory();
@ -328,8 +327,6 @@ namespace MWInput
A_MoveForwardBackward,
A_MoveLeftRight,
A_OptionsMenu,
A_Last // Marker for the last item
};
};

Loading…
Cancel
Save