diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index faf16c9e4b8..8938ca427ce 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -16,6 +16,7 @@ #include #include +#include // MAME headers #include "emu.h" @@ -43,6 +44,9 @@ #define MAKE_DI_SCAN(scan, isextended) (scan & 0x7f) | (isextended ? 0x80 : 0x00) #define WINOSD(machine) downcast(&machine.osd()) +// min(x, y) macro interferes with chrono time_point::min() +#undef min + //============================================================ // PARAMETERS //============================================================ @@ -93,7 +97,7 @@ static int win_physical_height; //============================================================ // event handling -static DWORD last_event_check; +static std::chrono::system_clock::time_point last_event_check; // debugger static int in_background; @@ -348,7 +352,7 @@ win_window_info::win_window_info(running_machine &machine) m_target(nullptr), m_targetview(0), m_targetorient(0), - m_lastclicktime(0), + m_lastclicktime(std::chrono::system_clock::time_point::min()), m_lastclickx(0), m_lastclicky(0), m_renderer(nullptr), @@ -378,12 +382,12 @@ win_window_info::~win_window_info() void winwindow_process_events_periodic(running_machine &machine) { - DWORD currticks = GetTickCount(); + auto currticks = std::chrono::system_clock::now(); assert(GetCurrentThreadId() == main_threadid); // update once every 1/8th of a second - if (currticks - last_event_check < 1000 / 8) + if (currticks - last_event_check < std::chrono::milliseconds(1000 / 8)) return; winwindow_process_events(machine, TRUE, FALSE); } @@ -441,7 +445,7 @@ void winwindow_process_events(running_machine &machine, int ingame, bool nodispa assert(GetCurrentThreadId() == main_threadid); // remember the last time we did this - last_event_check = GetTickCount(); + last_event_check = std::chrono::system_clock::now(); do { @@ -1348,15 +1352,15 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR case WM_LBUTTONDOWN: { - DWORD ticks = GetTickCount(); + auto ticks = std::chrono::system_clock::now(); window->machine().ui_input().push_mouse_down_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); // check for a double-click - if (ticks - window->m_lastclicktime < GetDoubleClickTime() && + if (ticks - window->m_lastclicktime < std::chrono::milliseconds(GetDoubleClickTime()) && GET_X_LPARAM(lparam) >= window->m_lastclickx - 4 && GET_X_LPARAM(lparam) <= window->m_lastclickx + 4 && GET_Y_LPARAM(lparam) >= window->m_lastclicky - 4 && GET_Y_LPARAM(lparam) <= window->m_lastclicky + 4) { - window->m_lastclicktime = 0; + window->m_lastclicktime = std::chrono::system_clock::time_point::min(); window->machine().ui_input().push_mouse_double_click_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); } else diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h index b42903b9dff..8ca2d832b47 100644 --- a/src/osd/windows/window.h +++ b/src/osd/windows/window.h @@ -15,6 +15,7 @@ #include #include +#include #include #include "video.h" #include "render.h" @@ -114,9 +115,9 @@ public: render_layer_config m_targetlayerconfig; // input info - DWORD m_lastclicktime; - int m_lastclickx; - int m_lastclicky; + std::chrono::system_clock::time_point m_lastclicktime; + int m_lastclickx; + int m_lastclicky; // drawing data osd_renderer * m_renderer;