Number of mouse inputs is now tracked, and mouse mode is changed more reliably.
This commit is contained in:
@@ -146,7 +146,6 @@ void InputHandler::add_input_resource(Node *target, InputResource *resource)
|
|||||||
|
|
||||||
if (axis->get_include_mouse())
|
if (axis->get_include_mouse())
|
||||||
{
|
{
|
||||||
Engine *engine = Engine::get_singleton();
|
|
||||||
this->call_deferred("_enable_mouse_capture");
|
this->call_deferred("_enable_mouse_capture");
|
||||||
|
|
||||||
const StringName callback_name = StringName("_on_") + axis->get_axis_name() + INPUTAXIS_MOUSE_INPUT_SUFFIX;
|
const StringName callback_name = StringName("_on_") + axis->get_axis_name() + INPUTAXIS_MOUSE_INPUT_SUFFIX;
|
||||||
@@ -176,8 +175,8 @@ void InputHandler::add_input_resource(Node *target, InputResource *resource)
|
|||||||
}
|
}
|
||||||
void InputHandler::_enable_mouse_capture()
|
void InputHandler::_enable_mouse_capture()
|
||||||
{
|
{
|
||||||
Input *input = Input::get_singleton();
|
this->mouse_input_counter++;
|
||||||
input->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
|
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler::remove_input_resource(Node *target, InputResource *resource)
|
void InputHandler::remove_input_resource(Node *target, InputResource *resource)
|
||||||
@@ -305,7 +304,6 @@ void InputHandler::remove_input_resource(Node *target, InputResource *resource)
|
|||||||
|
|
||||||
if (axis->get_include_mouse())
|
if (axis->get_include_mouse())
|
||||||
{
|
{
|
||||||
Engine *engine = Engine::get_singleton();
|
|
||||||
this->call_deferred("_disable_mouse_capture");
|
this->call_deferred("_disable_mouse_capture");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,6 +313,9 @@ void InputHandler::remove_input_resource(Node *target, InputResource *resource)
|
|||||||
}
|
}
|
||||||
void InputHandler::_disable_mouse_capture()
|
void InputHandler::_disable_mouse_capture()
|
||||||
{
|
{
|
||||||
Input *input = Input::get_singleton();
|
mouse_input_counter--;
|
||||||
input->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
|
if (mouse_input_counter <= 0)
|
||||||
|
{
|
||||||
|
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ private:
|
|||||||
const StringName input_axis_suffixes[3] = { INPUTAXIS_ONE_DIMENSIONAL_SUFFIX, INPUTAXIS_TWO_DIMENSIONAL_SUFFIX, INPUTAXIS_THREE_DIMENSIONAL_SUFFIX };
|
const StringName input_axis_suffixes[3] = { INPUTAXIS_ONE_DIMENSIONAL_SUFFIX, INPUTAXIS_TWO_DIMENSIONAL_SUFFIX, INPUTAXIS_THREE_DIMENSIONAL_SUFFIX };
|
||||||
|
|
||||||
std::map<const StringName, MethodBind*> bound_remove_methods;
|
std::map<const StringName, MethodBind*> bound_remove_methods;
|
||||||
|
|
||||||
|
int8_t mouse_input_counter = 0;
|
||||||
|
|
||||||
// Godot boilerplate below
|
// Godot boilerplate below
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user