Skip to content

Commit

Permalink
Merge branch 'unbind_control' into 'master'
Browse files Browse the repository at this point in the history
Ability to unbind controls in settings menu

See merge request OpenMW/openmw!3393
  • Loading branch information
psi29a committed Sep 6, 2023
2 parents 938c487 + 0836680 commit 30f4cd9
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions apps/openmw/mwinput/bindingsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ namespace MWInput
// Disallow binding escape key
if (key == SDL_SCANCODE_ESCAPE)
{
// Stop binding if esc pressed
// Unbind if esc pressed
if (mDetectingKeyboard)
clearAllKeyBindings(mInputBinder, control);
else
clearAllControllerBindings(mInputBinder, control);
control->setInitialValue(0.0f);
mInputBinder->cancelDetectingBindingState();
MWBase::Environment::get().getWindowManager()->notifyInputActionBound();
return;
Expand Down Expand Up @@ -154,7 +159,14 @@ namespace MWInput
return;
clearAllControllerBindings(mInputBinder, control);
control->setInitialValue(0.0f);
ICS::DetectingBindingListener::joystickButtonBindingDetected(ICS, deviceID, control, button, direction);
if (button == SDL_CONTROLLER_BUTTON_START)
{
// Disallow rebinding SDL_CONTROLLER_BUTTON_START - it is used to open main and without it is not
// even possible to exit the game (or change the binding back).
mInputBinder->cancelDetectingBindingState();
}
else
ICS::DetectingBindingListener::joystickButtonBindingDetected(ICS, deviceID, control, button, direction);
MWBase::Environment::get().getWindowManager()->notifyInputActionBound();
}

Expand All @@ -178,8 +190,11 @@ namespace MWInput
mListener = std::make_unique<BindingsListener>(mInputBinder.get(), this);
mInputBinder->setDetectingBindingListener(mListener.get());

loadKeyDefaults();
loadControllerDefaults();
if (!userFileExists)
{
loadKeyDefaults();
loadControllerDefaults();
}

for (int i = 0; i < A_Last; ++i)
{
Expand Down

0 comments on commit 30f4cd9

Please sign in to comment.