Input/Qt: Dont lock unused mouse in keyboard pad

This commit is contained in:
Megamouse 2020-09-08 18:30:21 +02:00
parent 22dc2947b3
commit f0053bfc1a
2 changed files with 11 additions and 1 deletions

View file

@ -323,6 +323,12 @@ bool keyboard_pad_handler::get_mouse_lock_state()
void keyboard_pad_handler::mouseMoveEvent(QMouseEvent* event) void keyboard_pad_handler::mouseMoveEvent(QMouseEvent* event)
{ {
if (!m_mouse_move_used)
{
event->ignore();
return;
}
static int movement_x = 0; static int movement_x = 0;
static int movement_y = 0; static int movement_y = 0;
static int last_pos_x = 0; static int last_pos_x = 0;
@ -632,6 +638,7 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr<Pad> pad, const std::
if (p_profile == nullptr) if (p_profile == nullptr)
return false; return false;
m_mouse_move_used = false;
m_deadzone_x = p_profile->mouse_deadzone_x; m_deadzone_x = p_profile->mouse_deadzone_x;
m_deadzone_y = p_profile->mouse_deadzone_y; m_deadzone_y = p_profile->mouse_deadzone_y;
m_multi_x = p_profile->mouse_acceleration_x / 100.0; m_multi_x = p_profile->mouse_acceleration_x / 100.0;
@ -641,13 +648,15 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr<Pad> pad, const std::
m_analog_lerp_factor = p_profile->analog_lerp_factor / 100.0f; m_analog_lerp_factor = p_profile->analog_lerp_factor / 100.0f;
m_trigger_lerp_factor = p_profile->trigger_lerp_factor / 100.0f; m_trigger_lerp_factor = p_profile->trigger_lerp_factor / 100.0f;
auto find_key = [&](const cfg::string& name) const auto find_key = [this](const cfg::string& name)
{ {
int key = FindKeyCode(mouse_list, name, false); int key = FindKeyCode(mouse_list, name, false);
if (key < 0) if (key < 0)
key = GetKeyCode(name); key = GetKeyCode(name);
if (key < 0) if (key < 0)
key = 0; key = 0;
else if (!m_mouse_move_used && (key == mouse::move_left || key == mouse::move_right || key == mouse::move_up || key == mouse::move_down))
m_mouse_move_used = true;
return key; return key;
}; };

View file

@ -101,6 +101,7 @@ protected:
private: private:
QWindow* m_target = nullptr; QWindow* m_target = nullptr;
bool m_mouse_move_used = false;
bool get_mouse_lock_state(); bool get_mouse_lock_state();
std::vector<std::shared_ptr<Pad>> bindings; std::vector<std::shared_ptr<Pad>> bindings;