supposedly handle >1000hz
authorIan Kelling <iank@fsf.org>
Mon, 20 Sep 2021 14:59:21 +0000 (10:59 -0400)
committerIan Kelling <iank@fsf.org>
Mon, 20 Sep 2021 14:59:21 +0000 (10:59 -0400)
From
https://gist.github.com/Sporif/314d5796e48ff0e9f63ec5b89f967b66
I don't have a > 1000hz mouse to be sure.

evhz.c

diff --git a/evhz.c b/evhz.c
index 3b4d0cf0bd5e79b64769a8b9753be2a388387b5b..c7ba33d5e59637d01822648767b89a8c3603364d 100644 (file)
--- a/evhz.c
+++ b/evhz.c
@@ -118,13 +118,13 @@ int main(int argc, char *argv[]) {
                 unsigned long long time, timediff;
                 unsigned hz = 0;
 
-                time = (unsigned long long)event.time.tv_sec * 1000ULL;
-                time += (unsigned long long)event.time.tv_usec / 1000ULL;
+                time = (unsigned long long)event.time.tv_sec * 1000000ULL;
+                time += (unsigned long long)event.time.tv_usec;
 
                 timediff = time - events[i].prev_time;
 
                 if(timediff != 0)
-                    hz = 1000ULL / timediff;
+                    hz = 1000000ULL / timediff;
 
                 if(hz > 0) {
                     unsigned j, maxavg;