diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-11 06:59:54 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-11 06:59:54 +0200 |
commit | 79a415aad234fe8718d6571375c1af51a1edf2a5 (patch) | |
tree | f08816ff89bf902b499e036cd72e9cd2724ca6df | |
parent | a4c5f265b42ba733fa9c3973fb7682e84e605f03 (diff) | |
parent | 9ba347dc2bcb955f81841d76011612bede781ede (diff) |
Merge branch 'unstable' into trackhat
* unstable:
shortcuts: fix short keypresses
timer: fix overflow
-rw-r--r-- | opentrack-compat/timer.hpp | 15 | ||||
-rw-r--r-- | opentrack/shortcuts.cpp | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/opentrack-compat/timer.hpp b/opentrack-compat/timer.hpp index fd710499..8192aa83 100644 --- a/opentrack-compat/timer.hpp +++ b/opentrack-compat/timer.hpp @@ -24,11 +24,12 @@ static inline void opentrack_clock_gettime(int, struct timespec* ts) (void) QueryPerformanceCounter(&d); - d.QuadPart *= 1000000000L; - d.QuadPart /= freq.QuadPart; + long long part = d.QuadPart; + part *= 1000000000ULL; + part /= freq.QuadPart; - ts->tv_sec = d.QuadPart / 1000000000L; - ts->tv_nsec = d.QuadPart % 1000000000L; + ts->tv_sec = part / 1000000000ULL; + ts->tv_nsec = part % 1000000000ULL; } # define clock_gettime opentrack_clock_gettime #else @@ -53,9 +54,9 @@ static inline void clock_gettime(int, struct timespec* ts) class Timer { private: struct timespec state; - long conv(const struct timespec& cur) + long long conv(const struct timespec& cur) { - return (cur.tv_sec - state.tv_sec) * 1000000000L + (cur.tv_nsec - state.tv_nsec); + return (cur.tv_sec - state.tv_sec) * 1000000000LL + (cur.tv_nsec - state.tv_nsec); } public: Timer() { @@ -64,7 +65,7 @@ public: void start() { (void) clock_gettime(CLOCK_MONOTONIC, &state); } - long elapsed() { + long long elapsed() { struct timespec cur; (void) clock_gettime(CLOCK_MONOTONIC, &cur); return conv(cur); diff --git a/opentrack/shortcuts.cpp b/opentrack/shortcuts.cpp index a3c0773b..ba2b7c8e 100644 --- a/opentrack/shortcuts.cpp +++ b/opentrack/shortcuts.cpp @@ -107,7 +107,7 @@ void KeybindingWorker::run() { } // keypresses get dropped with high values - Sleep(8); + Sleep(4); } } #endif |