moved axis remapping before checking deadzones

git-svn-id: svn+ssh://svn.code.sf.net/p/spacenav/code/trunk/spacenavd@188 ef983eb1-d774-4af8-acfd-baaf7b16a646
pull/1/head
John Tsiombikas 2015-02-12 15:35:56 +00:00
rodzic cd7e0576e5
commit 69f0a1bd65
3 zmienionych plików z 14 dodań i 7 usunięć

Wyświetl plik

@ -109,5 +109,6 @@
# You probably don't need this setting. Set it to something like 250 if you
# find that your apps stop moving the view while you hold the puck/ball at a
# fixed off-center position (like bottomed out on the vertical axis).
# Set to -1 to disable it (default).
#
#repeat-interval = 0
#repeat-interval = -1

Wyświetl plik

@ -207,14 +207,14 @@ static int read_evdev(struct device *dev, struct dev_input *inp)
inp->type = INP_MOTION;
inp->idx = iev.code - REL_X;
inp->val = iev.value;
/*printf("[%s] EV_REL(%d): %d\n", dev->name, inp->idx, iev.value);*/
printf("[%s] EV_REL(%d): %d\n", dev->name, inp->idx, iev.value);
break;
case EV_ABS:
inp->type = INP_MOTION;
inp->idx = iev.code - ABS_X;
inp->val = map_range(dev, inp->idx, iev.value);
/*printf("[%s] EV_ABS(%d): %d (orig: %d)\n", dev->name, inp->idx, inp->val, iev.value);*/
printf("[%s] EV_ABS(%d): %d (orig: %d)\n", dev->name, inp->idx, inp->val, iev.value);
break;
case EV_KEY:
@ -225,7 +225,7 @@ static int read_evdev(struct device *dev, struct dev_input *inp)
case EV_SYN:
inp->type = INP_FLUSH;
/*printf("[%s] EV_SYN\n", dev->name);*/
printf("[%s] EV_SYN\n", dev->name);
break;
default:

Wyświetl plik

@ -129,11 +129,12 @@ void process_input(struct device *dev, struct dev_input *inp)
switch(inp->type) {
case INP_MOTION:
inp->idx = cfg.map_axis[inp->idx];
if(abs(inp->val) < cfg.dead_threshold[inp->idx] ) {
printf("clamping axis %d event with value %d in deadzone\n", inp->idx, inp->val);
inp->val = 0;
}
inp->idx = cfg.map_axis[inp->idx];
sign = cfg.invert[inp->idx] ? -1 : 1;
inp->val = (int)((float)inp->val * cfg.sensitivity * (inp->idx < 3 ? cfg.sens_trans[inp->idx] : cfg.sens_rot[inp->idx - 3]));
@ -211,8 +212,13 @@ int in_deadzone(struct device *dev)
if((dev_ev = device_event_in_use(dev)) == NULL)
return -1;
for(i=0; i<6; i++) {
if(dev_ev->event.motion.data[i] != 0)
int val = dev_ev->event.motion.data[i];
if(val != 0) {
if(abs(val) < cfg.dead_threshold[i]) {
printf("BUG %d on axis %d not in deadzone? (%d)\n", dev_ev->event.motion.data[i], i, cfg.dead_threshold[i]);
}
return 0;
}
}
return 1;
}