From 72c86b99eb87b23c11fdc795ec6f3668f283b95c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 24 Jun 2022 23:27:02 +0200 Subject: added general:cursor_inactive_timeout --- src/helpers/Timer.cpp | 17 +++++++++++++++++ src/helpers/Timer.hpp | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/helpers/Timer.cpp create mode 100644 src/helpers/Timer.hpp (limited to 'src/helpers') diff --git a/src/helpers/Timer.cpp b/src/helpers/Timer.cpp new file mode 100644 index 00000000..33162d30 --- /dev/null +++ b/src/helpers/Timer.cpp @@ -0,0 +1,17 @@ +#include "Timer.hpp" + +void CTimer::reset() { + m_tpLastReset = std::chrono::system_clock::now(); +} + +std::chrono::system_clock::duration CTimer::getDuration() { + return std::chrono::system_clock::now() - m_tpLastReset; +} + +int CTimer::getMillis() { + return std::chrono::duration_cast(getDuration()).count(); +} + +float CTimer::getSeconds() { + return std::chrono::duration_cast(getDuration()).count() / 1000.f; +} \ No newline at end of file diff --git a/src/helpers/Timer.hpp b/src/helpers/Timer.hpp new file mode 100644 index 00000000..2e8d6adc --- /dev/null +++ b/src/helpers/Timer.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "../defines.hpp" + +class CTimer { +public: + void reset(); + float getSeconds(); + int getMillis(); + +private: + std::chrono::system_clock::time_point m_tpLastReset; + + std::chrono::system_clock::duration getDuration(); +}; \ No newline at end of file -- cgit v1.2.3