diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index d8e7801e..67f53b82 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -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; diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index f0d1d473..f93e2be3 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -10,6 +10,7 @@ #include #include +#include #include 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 diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index 1c209f60..dd040f88 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -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; } }