From 420d2bc5020ff5e2075314a188c6cfb75bffc2a1 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Thu, 21 Jan 2010 19:55:01 +0000 Subject: [PATCH] (Minor timer library code cleanup) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4917 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/Timer.cpp | 18 ++++++++++++++---- Source/Core/Common/Src/Timer.h | 13 ++++--------- .../Core/Core/Src/HW/SI_DeviceGCController.cpp | 4 ++-- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Source/Core/Common/Src/Timer.cpp b/Source/Core/Common/Src/Timer.cpp index 3f851ce8cc..4759729769 100644 --- a/Source/Core/Common/Src/Timer.cpp +++ b/Source/Core/Common/Src/Timer.cpp @@ -18,21 +18,31 @@ #include #include +#ifdef _WIN32 +#include +#include +#endif + #include "Common.h" #include "Timer.h" #include "StringUtil.h" +namespace Common +{ + #ifdef __GNUC__ -u32 timeGetTime() +u32 Timer::GetTimeMs() { struct timeb t; ftime(&t); - return((u32)(t.time * 1000 + t.millitm)); + return ((u32)(t.time * 1000 + t.millitm)); +} +#else +u32 Timer::GetTimeMs() { + return timeGetTime(); } #endif -namespace Common -{ // -------------------------------------------- // Initiate, Start, Stop, and Update the time diff --git a/Source/Core/Common/Src/Timer.h b/Source/Core/Common/Src/Timer.h index 4b9b9496c4..a638920409 100644 --- a/Source/Core/Common/Src/Timer.h +++ b/Source/Core/Common/Src/Timer.h @@ -20,10 +20,7 @@ #include "Common.h" #include -#ifdef _WIN32 -#include -#include -#endif + namespace Common { class Timer @@ -50,7 +47,9 @@ public: std::string GetTimeElapsedFormatted() const; u64 GetTimeElapsed(); -public: + static u32 GetTimeMs(); + +private: u64 m_LastTime; u64 m_StartTime; u64 m_frequency; @@ -59,8 +58,4 @@ public: } // Namespace Common -#ifdef __GNUC__ -u32 timeGetTime(); -#endif // GNUC - #endif // _TIMER_H_ diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp index 457139b821..7d67e7053b 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp @@ -226,11 +226,11 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) { m_LastButtonCombo = tempCombo; if (m_LastButtonCombo != COMBO_NONE) - m_TButtonComboStart = timeGetTime(); + m_TButtonComboStart = Common::Timer::GetTimeMs(); } if (m_LastButtonCombo != COMBO_NONE) { - m_TButtonCombo = timeGetTime(); + m_TButtonCombo = Common::Timer::GetTimeMs(); if ((m_TButtonCombo - m_TButtonComboStart) > 3000) { if (m_LastButtonCombo == COMBO_RESET)