mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2026-05-05 02:57:58 +02:00
tools: widen frequency resolution to µs in the DPI tool
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@who-t.net>
This commit is contained in:
parent
6f03fd49fb
commit
e1d87fa6df
1 changed files with 10 additions and 10 deletions
|
|
@ -44,7 +44,7 @@
|
||||||
struct measurements {
|
struct measurements {
|
||||||
int distance;
|
int distance;
|
||||||
double frequency;
|
double frequency;
|
||||||
uint32_t ms;
|
uint64_t us;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -58,16 +58,16 @@ usage(void) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t
|
static inline uint64_t
|
||||||
tv2ms(const struct timeval *tv)
|
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
|
static inline double
|
||||||
get_frequency(double last, double current)
|
get_frequency(double last, double current)
|
||||||
{
|
{
|
||||||
return 1000.0/(current - last);
|
return 1000000.0/(current - last);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -98,17 +98,17 @@ static int
|
||||||
handle_event(struct measurements *m, const struct input_event *ev)
|
handle_event(struct measurements *m, const struct input_event *ev)
|
||||||
{
|
{
|
||||||
if (ev->type == EV_SYN) {
|
if (ev->type == EV_SYN) {
|
||||||
const int idle_reset = 3000; /* ms */
|
const int idle_reset = 3000000; /* us */
|
||||||
uint32_t last_millis = m->ms;
|
uint64_t last_us = m->us;
|
||||||
|
|
||||||
m->ms = tv2ms(&ev->time);
|
m->us = tv2us(&ev->time);
|
||||||
|
|
||||||
/* reset after pause */
|
/* reset after pause */
|
||||||
if (last_millis + idle_reset < m->ms) {
|
if (last_us + idle_reset < m->us) {
|
||||||
m->frequency = 0.0;
|
m->frequency = 0.0;
|
||||||
m->distance = 0;
|
m->distance = 0;
|
||||||
} else {
|
} else {
|
||||||
double freq = get_frequency(last_millis, m->ms);
|
double freq = get_frequency(last_us, m->us);
|
||||||
m->frequency = max(freq, m->frequency);
|
m->frequency = max(freq, m->frequency);
|
||||||
return print_current_values(m);
|
return print_current_values(m);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue