-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtimer.h
72 lines (52 loc) · 1.89 KB
/
timer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
VRCustomQuickslots - VR Custom Quickslots SKSE extension for SkyrimVR
Copyright (C) 2018 L Frazer
https://github.com/lfrazer
This file is part of VRCustomQuickslots.
VRCustomQuickslots is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
VRCustomQuickslots is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with VRCustomQuickslots. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __TIMER_H
#define __TIMER_H
#ifndef WIN32
#include <inttypes.h>
#define UINT64 uint64_t
#else
#include <windows.h>
#endif
#include <ctime>
class CTimer
{
public:
CTimer(void); // constructor
void Init(void); // init func
double GetTime(void); // Get current CPU clock accurate time
double GetTimeSlice(void); // time since last timer update
double GetLastTime(void); // last time calculated either by GetTimeSlice
double GetAbsoluteTimeSinceStart(); // get the time since the program started, ignoring pause subtraction time
void TimerUpdate(void); // update the timer once per loop to use time slice
void Pause(void); // pause timer
void Unpause(void); // unpause timer
UINT64 GetLastRawTime();
static time_t GetUnixTimestamp();
static time_t ConvertWebTimeToTimestamp(const char* webtime);
private:
double mStartTime = 0.0;
double mLastTime = 0.0;
double mTimeSlice = 0.0;
double mPauseTime = 0.0;
double mPauseTotalSubtraction = 0.0;
UINT64 mTicksPerSecond = 0;
UINT64 mStartTicks = 0;
int mInitComplete = 0;
UINT64 mLastRawTime = 0;
};
#endif