Alternative fix strategy by checking for binding state

pull/128/head
Fil Krynicki 11 years ago
parent bbb7ceab43
commit 97caa1f8a4

@ -558,36 +558,51 @@ namespace MWInput
void InputManager::keyReleased(const SDL_KeyboardEvent &arg ) void InputManager::keyReleased(const SDL_KeyboardEvent &arg )
{ {
mInputBinder->keyReleased (arg);
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym); OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)); setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)));
mInputBinder->keyReleased (arg);
} }
void InputManager::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ) void InputManager::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id )
{ {
mInputBinder->mousePressed (arg, id); bool guiMode = false;
if (id != SDL_BUTTON_LEFT && id != SDL_BUTTON_RIGHT) if (id == SDL_BUTTON_LEFT || id == SDL_BUTTON_RIGHT) // MyGUI has no use for these events
return; // MyGUI has no use for these events
MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id));
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
{ {
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false); MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id));
if (b && b->getEnabled()) guiMode = guiMode && MWBase::Environment::get().getWindowManager()->isGuiMode();
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
{ {
MWBase::Environment::get().getSoundManager ()->playSound ("Menu Click", 1.f, 1.f); MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false);
if (b && b->getEnabled())
{
MWBase::Environment::get().getSoundManager ()->playSound ("Menu Click", 1.f, 1.f);
}
} }
} }
setPlayerControlsEnabled(!guiMode);
mInputBinder->mousePressed (arg, id);
} }
void InputManager::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ) void InputManager::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id )
{ {
mInputBinder->mouseReleased (arg, id);
MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, sdlButtonToMyGUI(id)); if(mInputBinder->detectingBindingState())
{
mInputBinder->mouseReleased (arg, id);
} else {
bool guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, sdlButtonToMyGUI(id));
guiMode = guiMode && MWBase::Environment::get().getWindowManager()->isGuiMode();
if(mInputBinder->detectingBindingState()) return; // don't allow same mouseup to bind as initiated bind
setPlayerControlsEnabled(!guiMode);
mInputBinder->mouseReleased (arg, id);
}
} }
void InputManager::mouseMoved(const SFO::MouseMotionEvent &arg ) void InputManager::mouseMoved(const SFO::MouseMotionEvent &arg )

@ -796,6 +796,11 @@ namespace ICS
mMouseAxisBindingInitialValues[0] = ICS_MOUSE_AXIS_BINDING_NULL_VALUE; mMouseAxisBindingInitialValues[0] = ICS_MOUSE_AXIS_BINDING_NULL_VALUE;
} }
bool InputControlSystem::detectingBindingState()
{
return mDetectingBindingControl != NULL;
}
void InputControlSystem::cancelDetectingBindingState() void InputControlSystem::cancelDetectingBindingState()
{ {
mDetectingBindingControl = NULL; mDetectingBindingControl = NULL;

@ -146,6 +146,7 @@ namespace ICS
void enableDetectingBindingState(Control* control, Control::ControlChangingDirection direction); void enableDetectingBindingState(Control* control, Control::ControlChangingDirection direction);
void cancelDetectingBindingState(); void cancelDetectingBindingState();
bool detectingBindingState();
bool save(std::string fileName = ""); bool save(std::string fileName = "");

Loading…
Cancel
Save