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);

View File

@ -145,7 +145,7 @@ public:
void Button(u32 index, u8 button, bool pressed);
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);

View File

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