(Minor timer library code cleanup)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4917 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2010-01-21 19:55:01 +00:00
parent 9893122a58
commit 420d2bc502
3 changed files with 20 additions and 15 deletions

View File

@ -18,21 +18,31 @@
#include <time.h> #include <time.h>
#include <sys/timeb.h> #include <sys/timeb.h>
#ifdef _WIN32
#include <Windows.h>
#include <mmsystem.h>
#endif
#include "Common.h" #include "Common.h"
#include "Timer.h" #include "Timer.h"
#include "StringUtil.h" #include "StringUtil.h"
namespace Common
{
#ifdef __GNUC__ #ifdef __GNUC__
u32 timeGetTime() u32 Timer::GetTimeMs()
{ {
struct timeb t; struct timeb t;
ftime(&t); ftime(&t);
return ((u32)(t.time * 1000 + t.millitm)); return ((u32)(t.time * 1000 + t.millitm));
} }
#else
u32 Timer::GetTimeMs() {
return timeGetTime();
}
#endif #endif
namespace Common
{
// -------------------------------------------- // --------------------------------------------
// Initiate, Start, Stop, and Update the time // Initiate, Start, Stop, and Update the time

View File

@ -20,10 +20,7 @@
#include "Common.h" #include "Common.h"
#include <string> #include <string>
#ifdef _WIN32
#include <Windows.h>
#include <mmsystem.h>
#endif
namespace Common namespace Common
{ {
class Timer class Timer
@ -50,7 +47,9 @@ public:
std::string GetTimeElapsedFormatted() const; std::string GetTimeElapsedFormatted() const;
u64 GetTimeElapsed(); u64 GetTimeElapsed();
public: static u32 GetTimeMs();
private:
u64 m_LastTime; u64 m_LastTime;
u64 m_StartTime; u64 m_StartTime;
u64 m_frequency; u64 m_frequency;
@ -59,8 +58,4 @@ public:
} // Namespace Common } // Namespace Common
#ifdef __GNUC__
u32 timeGetTime();
#endif // GNUC
#endif // _TIMER_H_ #endif // _TIMER_H_

View File

@ -226,11 +226,11 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
{ {
m_LastButtonCombo = tempCombo; m_LastButtonCombo = tempCombo;
if (m_LastButtonCombo != COMBO_NONE) if (m_LastButtonCombo != COMBO_NONE)
m_TButtonComboStart = timeGetTime(); m_TButtonComboStart = Common::Timer::GetTimeMs();
} }
if (m_LastButtonCombo != COMBO_NONE) if (m_LastButtonCombo != COMBO_NONE)
{ {
m_TButtonCombo = timeGetTime(); m_TButtonCombo = Common::Timer::GetTimeMs();
if ((m_TButtonCombo - m_TButtonComboStart) > 3000) if ((m_TButtonCombo - m_TButtonComboStart) > 3000)
{ {
if (m_LastButtonCombo == COMBO_RESET) if (m_LastButtonCombo == COMBO_RESET)