Use SDL_Timer for unknown input dragging events

This commit is contained in:
Anonymous Maarten 2024-12-27 17:32:19 +01:00
parent 69f0ddaafc
commit 888676ab12
3 changed files with 21 additions and 13 deletions

View File

@ -397,6 +397,11 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event)
case WM_QUIT:
return SDL_APP_SUCCESS;
break;
case WM_TIMER:
if (InputManager()) {
InputManager()->QueueEvent(c_notificationTimer, (MxU8) (uintptr_t) event->user.data1, 0, 0, 0);
}
break;
default:
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unknown SDL Windows message: 0x%" SDL_PRIx32, event->user.code);
break;

View File

@ -10,6 +10,7 @@
#include <SDL3/SDL_joystick.h>
#include <SDL3/SDL_keyboard.h>
#include <SDL3/SDL_timer.h>
#include <windows.h>
class LegoCameraController;
@ -145,7 +146,7 @@ class LegoInputManager : public MxPresenter {
MxS32 m_x; // 0x6c
MxS32 m_y; // 0x70
MxS32 m_unk0x74; // 0x74
UINT m_autoDragTimerID; // 0x78
SDL_TimerID m_autoDragTimerID; // 0x78
UINT m_autoDragTime; // 0x7c
MxBool m_unk0x80; // 0x80
MxBool m_unk0x81; // 0x81

View File

@ -514,16 +514,22 @@ MxBool LegoInputManager::FUN_1005cdf0(LegoEventNotificationParam& p_param)
return result;
}
static Uint32 SDLCALL LegoInputManagerTimerCallback(void* userdata, SDL_TimerID timerID, Uint32 interval)
{
LegoInputManager* input_manager = (LegoInputManager*) userdata;
SDL_Event event;
event.type = g_LegoSdlEvents.windows_message;
event.user.code = WM_TIMER;
event.user.data1 = (void*) (uintptr_t) timerID;
event.user.data2 = NULL;
return interval;
}
// FUNCTION: LEGO1 0x1005cfb0
// FUNCTION: BETA10 0x10089fc5
void LegoInputManager::StartAutoDragTimer()
{
HWND hWnd = (HWND) SDL_GetPointerProperty(
SDL_GetWindowProperties(MxOmni::GetInstance()->GetWindowHandle()),
SDL_PROP_WINDOW_WIN32_HWND_POINTER,
NULL
);
m_autoDragTimerID = ::SetTimer(hWnd, 1, m_autoDragTime, NULL);
m_autoDragTimerID = SDL_AddTimer(m_autoDragTime, LegoInputManagerTimerCallback, this);
}
// FUNCTION: LEGO1 0x1005cfd0
@ -531,12 +537,8 @@ void LegoInputManager::StartAutoDragTimer()
void LegoInputManager::StopAutoDragTimer()
{
if (m_autoDragTimerID) {
HWND hWnd = (HWND) SDL_GetPointerProperty(
SDL_GetWindowProperties(MxOmni::GetInstance()->GetWindowHandle()),
SDL_PROP_WINDOW_WIN32_HWND_POINTER,
NULL
);
::KillTimer(hWnd, m_autoDragTimerID);
SDL_RemoveTimer(m_autoDragTimerID);
m_autoDragTimerID = 0;
}
}