Skip to content

Commit

Permalink
linux evdev: Stop using the time field of input_event
Browse files Browse the repository at this point in the history
Fixes github issue #104.

The time field is being removed from input_event (evdev) for 32bit
systems, to prepare for the year 2038 32bit timestamp rollover. This
breaks the build for spacenavd on 32bit linux systems.

Turns out that value was only ever used by the incorrect dominant axis
implementation which relied on timeouts (see github issue #84).
Therefore the easy fix for the missing time field is to just drop it
altogether and temporarilly disable the dominant axis code altogether
until it's fixed.
  • Loading branch information
jtsiomb committed Jun 2, 2024
1 parent 3985662 commit ed8d255
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
2 changes: 0 additions & 2 deletions src/dev_usb_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,6 @@ static int read_evdev(struct device *dev, struct dev_input *inp)
}

if(rdbytes > 0) {
inp->tm = iev.time;

switch(iev.type) {
case EV_REL:
inp->type = INP_MOTION;
Expand Down
22 changes: 1 addition & 21 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ struct dev_event {
struct dev_event *next;
};

static struct dev_input inp_dom = { -1, {0}, -1, 0 };
static int dom_axis_thres = 2;

static struct dev_event *add_dev_event(struct device *dev);
static struct dev_event *device_event_in_use(struct device *dev);
static void handle_button_action(int act, int val);
Expand Down Expand Up @@ -177,24 +174,7 @@ void process_input(struct device *dev, struct dev_input *inp)
axis_sens = axis < 3 ? sens_trans : sens_rot;

if(dom_axis_mode) {
if(inp_dom.idx != -1) {
/* if more than 100ms have passed ... */
if(inp->tm.tv_sec > inp_dom.tm.tv_sec || inp->tm.tv_usec - inp_dom.tm.tv_usec >= 100000) {
inp_dom.idx = -1;
memset(&inp_dom.tm, 0, sizeof inp_dom.tm);
inp_dom.type = INP_FLUSH;
inp_dom.val = 0;
}
}
if((inp_dom.idx == -1 && (inp->val <= dom_axis_thres || inp->val >= dom_axis_thres))
|| inp_dom.idx == axis) {
inp_dom.idx = axis;
inp_dom.tm = inp->tm;
inp_dom.type = inp->type;
inp_dom.val = inp->val;
} else {
axis_sens = 0;
}
/* TODO */
}
inp->val = (int)((float)inp->val * cfg.sensitivity * axis_sens);

Expand Down
1 change: 0 additions & 1 deletion src/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ enum {

struct dev_input {
int type;
struct timeval tm;
int idx;
int val;
};
Expand Down

0 comments on commit ed8d255

Please sign in to comment.