Simplify duplicate mouse handler init code

This commit is contained in:
Megamouse 2024-06-27 20:56:50 +02:00
parent c9a082614d
commit 44e4e67aa8
3 changed files with 13 additions and 16 deletions

View file

@ -105,7 +105,7 @@ void MouseHandlerBase::Scroll(u32 index, s8 x, s8 y)
} }
} }
void MouseHandlerBase::Move(u32 index, s32 x_pos_new, s32 y_pos_new, s32 x_max, s32 y_max, const bool is_relative, s32 x_delta, s32 y_delta) void MouseHandlerBase::Move(u32 index, s32 x_pos_new, s32 y_pos_new, s32 x_max, s32 y_max, bool is_relative, s32 x_delta, s32 y_delta)
{ {
std::lock_guard lock(mutex); std::lock_guard lock(mutex);

View file

@ -145,7 +145,7 @@ public:
void Button(u32 index, u8 button, bool pressed); void Button(u32 index, u8 button, bool pressed);
void Scroll(u32 index, s8 x, s8 y); void Scroll(u32 index, s8 x, s8 y);
void Move(u32 index, s32 x_pos_new, s32 y_pos_new, s32 x_max, s32 y_max, const bool is_relative = false, s32 x_delta = 0, s32 y_delta = 0); void Move(u32 index, s32 x_pos_new, s32 y_pos_new, s32 x_max, s32 y_max, bool is_relative = false, s32 x_delta = 0, s32 y_delta = 0);
void SetIntercepted(bool intercepted); void SetIntercepted(bool intercepted);

View file

@ -138,31 +138,28 @@ EmuCallbacks main_application::CreateCallbacks()
callbacks.init_mouse_handler = [this]() callbacks.init_mouse_handler = [this]()
{ {
switch (g_cfg.io.mouse.get()) mouse_handler handler = g_cfg.io.mouse;
{
case mouse_handler::null: if (handler == mouse_handler::null)
{ {
switch (g_cfg.io.move) switch (g_cfg.io.move)
{ {
case move_handler::mouse: case move_handler::mouse:
{ handler = mouse_handler::basic;
basic_mouse_handler* ret = g_fxo->init<MouseHandlerBase, basic_mouse_handler>(Emu.DeserialManager());
ret->moveToThread(get_thread());
ret->SetTargetWindow(m_game_window);
break; break;
}
case move_handler::raw_mouse: case move_handler::raw_mouse:
{ handler = mouse_handler::raw;
g_fxo->init<MouseHandlerBase, raw_mouse_handler>(Emu.DeserialManager());
break; break;
}
default: default:
{
g_fxo->init<MouseHandlerBase, NullMouseHandler>(Emu.DeserialManager());
break; break;
} }
} }
switch (handler)
{
case mouse_handler::null:
{
g_fxo->init<MouseHandlerBase, NullMouseHandler>(Emu.DeserialManager());
break; break;
} }
case mouse_handler::basic: case mouse_handler::basic: