[PATCH libevdev] tools: widen frequency resolution to µs in the DPI tool
Peter Hutterer
peter.hutterer at who-t.net
Wed May 20 18:52:35 PDT 2015
The Microsoft Arc Touch Mouse claims 8000fps which is higher than we can
measure in the current milliseconds resolution.
http://www.cnet.com/products/microsoft-arc-touch-mouse-black-series/specs/
https://bugs.freedesktop.org/show_bug.cgi?id=90540
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
tools/mouse-dpi-tool.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/mouse-dpi-tool.c b/tools/mouse-dpi-tool.c
index d05a4fd..7f0e7be 100644
--- a/tools/mouse-dpi-tool.c
+++ b/tools/mouse-dpi-tool.c
@@ -44,7 +44,7 @@
struct measurements {
int distance;
double frequency;
- uint32_t ms;
+ uint64_t us;
};
static int
@@ -58,16 +58,16 @@ usage(void) {
return 1;
}
-static inline uint32_t
-tv2ms(const struct timeval *tv)
+static inline uint64_t
+tv2us(const struct timeval *tv)
{
- return tv->tv_sec * 1000 + tv->tv_usec/1000;
+ return tv->tv_sec * 1000000 + tv->tv_usec;
}
static inline double
get_frequency(double last, double current)
{
- return 1000.0/(current - last);
+ return 1000000.0/(current - last);
}
static int
@@ -98,17 +98,17 @@ static int
handle_event(struct measurements *m, const struct input_event *ev)
{
if (ev->type == EV_SYN) {
- const int idle_reset = 3000; /* ms */
- uint32_t last_millis = m->ms;
+ const int idle_reset = 3000000; /* us */
+ uint64_t last_us = m->us;
- m->ms = tv2ms(&ev->time);
+ m->us = tv2us(&ev->time);
/* reset after pause */
- if (last_millis + idle_reset < m->ms) {
+ if (last_us + idle_reset < m->us) {
m->frequency = 0.0;
m->distance = 0;
} else {
- double freq = get_frequency(last_millis, m->ms);
+ double freq = get_frequency(last_us, m->us);
m->frequency = max(freq, m->frequency);
return print_current_values(m);
}
--
2.3.5
More information about the Input-tools
mailing list