🧑‍💻 chore: separate cursor movement part

This commit is contained in:
Helloyunho 2025-07-06 01:25:01 +09:00
parent 17df90bb2e
commit 18571714e1
No known key found for this signature in database
GPG Key ID: 6AFA210B0150BE47
2 changed files with 27 additions and 20 deletions

View File

@ -386,26 +386,7 @@ SDL_AppResult SDL_AppIterate(void* appstate)
g_mousemoved = FALSE;
}
if (g_lastJoystickMouseX != 0 || g_lastJoystickMouseY != 0) {
g_mousemoved = TRUE;
g_lastMouseX = SDL_clamp(g_lastMouseX + g_lastJoystickMouseX, 0, 640);
g_lastMouseY = SDL_clamp(g_lastMouseY + g_lastJoystickMouseY, 0, 480);
if (InputManager()) {
InputManager()->QueueEvent(
c_notificationMouseMove,
g_mousedown ? LegoEventNotificationParam::c_lButtonState : 0,
g_lastMouseX,
g_lastMouseY,
0
);
}
if (g_isle->GetDrawCursor()) {
VideoManager()->MoveCursor(Min((MxS32) g_lastMouseX, 639), Min((MxS32) g_lastMouseY, 479));
}
}
MoveVirtualCursorViaJoystick();
}
return SDL_APP_CONTINUE;
@ -1294,3 +1275,27 @@ IDirect3DRMMiniwinDevice* GetD3DRMMiniwinDevice()
}
return d3drmMiniwinDev;
}
void MoveVirtualCursorViaJoystick()
{
if (g_lastJoystickMouseX != 0 || g_lastJoystickMouseY != 0) {
g_mousemoved = TRUE;
g_lastMouseX = SDL_clamp(g_lastMouseX + g_lastJoystickMouseX, 0, 640);
g_lastMouseY = SDL_clamp(g_lastMouseY + g_lastJoystickMouseY, 0, 480);
if (InputManager()) {
InputManager()->QueueEvent(
c_notificationMouseMove,
g_mousedown ? LegoEventNotificationParam::c_lButtonState : 0,
g_lastMouseX,
g_lastMouseY,
0
);
}
if (g_isle->GetDrawCursor()) {
VideoManager()->MoveCursor(Min((MxS32) g_lastMouseX, 639), Min((MxS32) g_lastMouseY, 479));
}
}
}

View File

@ -107,4 +107,6 @@ extern MxS32 g_closed;
extern IDirect3DRMMiniwinDevice* GetD3DRMMiniwinDevice();
void MoveVirtualCursorViaJoystick();
#endif // ISLEAPP_H