Skip to content

Commit

Permalink
debounce: use signed time values
Browse files Browse the repository at this point in the history
  • Loading branch information
merge committed Mar 17, 2017
1 parent 1fbf13a commit c7f0966
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions plugins/debounce.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
struct tslib_debounce {
struct tslib_module_info module;
unsigned int drop_threshold; /* ms */
unsigned long long last_release;
long long last_release;
int last_pressure;
unsigned long long *last_release_mt;
long long *last_release_mt;
int *last_pressure_mt;
int current_max_slots;
};
Expand All @@ -46,8 +46,8 @@ static int debounce_read(struct tslib_module_info *info, struct ts_sample *samp,
int ret;
int num = 0;
int i;
unsigned long long now;
unsigned long dt;
long long now;
long dt;
__attribute__ ((unused)) enum { DOWN, MOVE, UP } mode;
int drop = 0;
int left;
Expand All @@ -58,7 +58,7 @@ static int debounce_read(struct tslib_module_info *info, struct ts_sample *samp,

for (s = samp, i = 0; i < ret; i++, s++) {
now = s->tv.tv_sec * 1e6 + s->tv.tv_usec;
dt = (unsigned long)(now - p->last_release) / 1000; /* ms */
dt = (long)(now - p->last_release) / 1000; /* ms */
mode = MOVE;

if (!s->pressure) {
Expand Down Expand Up @@ -102,8 +102,8 @@ static int debounce_read_mt(struct tslib_module_info *info, struct ts_sample_mt
{
struct tslib_debounce *p = (struct tslib_debounce *)info;
int ret;
unsigned long long now;
unsigned long dt;
long long now;
long dt;
__attribute__ ((unused)) enum { DOWN, MOVE, UP } mode[max_slots];
int drop = 0;
int nr;
Expand All @@ -113,7 +113,7 @@ static int debounce_read_mt(struct tslib_module_info *info, struct ts_sample_mt
if (p->last_release_mt)
free(p->last_release_mt);

p->last_release_mt = calloc(max_slots, sizeof(unsigned long long));
p->last_release_mt = calloc(max_slots, sizeof(long long));
if (!p->last_release_mt)
return -ENOMEM;

Expand Down Expand Up @@ -145,7 +145,7 @@ static int debounce_read_mt(struct tslib_module_info *info, struct ts_sample_mt
continue;

now = samp[nr][i].tv.tv_sec * 1e6 + samp[nr][i].tv.tv_usec;
dt = (unsigned long)(now - p->last_release_mt[i]) / 1000; /* ms */
dt = (long)(now - p->last_release_mt[i]) / 1000; /* ms */
mode[i] = MOVE;

if (!samp[nr][i].pressure) {
Expand Down

0 comments on commit c7f0966

Please sign in to comment.