1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-05-23 09:41:29 +00:00

Merge branch 'unbind_control' into 'master'

Ability to unbind controls in settings menu

See merge request OpenMW/openmw!3393
This commit is contained in:
psi29a 2023-09-06 08:17:00 +00:00
commit 30f4cd972d
No known key found for this signature in database

View file

@ -77,7 +77,12 @@ namespace MWInput
// Disallow binding escape key // Disallow binding escape key
if (key == SDL_SCANCODE_ESCAPE) 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(); mInputBinder->cancelDetectingBindingState();
MWBase::Environment::get().getWindowManager()->notifyInputActionBound(); MWBase::Environment::get().getWindowManager()->notifyInputActionBound();
return; return;
@ -154,7 +159,14 @@ namespace MWInput
return; return;
clearAllControllerBindings(mInputBinder, control); clearAllControllerBindings(mInputBinder, control);
control->setInitialValue(0.0f); 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(); MWBase::Environment::get().getWindowManager()->notifyInputActionBound();
} }
@ -178,8 +190,11 @@ namespace MWInput
mListener = std::make_unique<BindingsListener>(mInputBinder.get(), this); mListener = std::make_unique<BindingsListener>(mInputBinder.get(), this);
mInputBinder->setDetectingBindingListener(mListener.get()); mInputBinder->setDetectingBindingListener(mListener.get());
loadKeyDefaults(); if (!userFileExists)
loadControllerDefaults(); {
loadKeyDefaults();
loadControllerDefaults();
}
for (int i = 0; i < A_Last; ++i) for (int i = 0; i < A_Last; ++i)
{ {