kopia lustrzana https://github.com/FreeSpacenav/spacenavd
Change deadzone config to affect the device axes, not the output axes.
Makes much more sense like that.pull/68/head
rodzic
b4dc387931
commit
59b0be26f8
|
@ -32,6 +32,8 @@
|
|||
#dead-zone = 2
|
||||
|
||||
# Separate dead-zone for each rotation and translation axis.
|
||||
# This is still supported, but unclear in face of device axes mapping, and
|
||||
# therefore you are encouraged to use dead-zoneN instead.
|
||||
#
|
||||
#dead-zone-translation-x = 2
|
||||
#dead-zone-translation-y = 2
|
||||
|
@ -40,6 +42,12 @@
|
|||
#dead-zone-rotation-y = 2
|
||||
#dead-zone-rotation-z = 2
|
||||
|
||||
# Separate dead-zone for each device axis.
|
||||
#
|
||||
#dead-zone0 = 2
|
||||
#dead-zone1 = 2
|
||||
# ...
|
||||
#dead-zoneN = 2
|
||||
|
||||
# Selectively invert translation and rotation axes. Valid values are
|
||||
# combinations of the letters x, y, and z.
|
||||
|
|
|
@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
/* all parsable config options... some of them might map to the same cfg field */
|
||||
enum {
|
||||
CFG_REPEAT,
|
||||
CFG_DEADZONE,
|
||||
CFG_DEADZONE, CFG_DEADZONE_N,
|
||||
CFG_DEADZONE_TX, CFG_DEADZONE_TY, CFG_DEADZONE_TZ,
|
||||
CFG_DEADZONE_RX, CFG_DEADZONE_RY, CFG_DEADZONE_RZ,
|
||||
CFG_SENS,
|
||||
|
@ -210,36 +210,51 @@ int read_cfg(const char *fname, struct cfg *cfg)
|
|||
} else if(strcmp(key_str, "dead-zone") == 0) {
|
||||
lptr->opt = CFG_DEADZONE;
|
||||
EXPECT(isint);
|
||||
for(i=0; i<6; i++) {
|
||||
for(i=0; i<MAX_AXES; i++) {
|
||||
cfg->dead_threshold[i] = ival;
|
||||
}
|
||||
|
||||
} else if(sscanf(key_str, "dead-zone%d", &axisidx) == 1) {
|
||||
if(axisidx < 0 || axisidx >= MAX_AXES) {
|
||||
logmsg(LOG_WARNING, "invalid option %s, valid input axis numbers 0 - %d\n", key_str, MAX_AXES - 1);
|
||||
continue;
|
||||
}
|
||||
lptr->opt = CFG_DEADZONE_N;
|
||||
lptr->idx = axisidx;
|
||||
cfg->dead_threshold[axisidx] = ival;
|
||||
|
||||
} else if(strcmp(key_str, "dead-zone-translation-x") == 0) {
|
||||
logmsg(LOG_WARNING, "Deprecated option: %s. You are encouraged to use dead-zoneN instead\n", key_str);
|
||||
lptr->opt = CFG_DEADZONE_TX;
|
||||
EXPECT(isint);
|
||||
cfg->dead_threshold[0] = ival;
|
||||
|
||||
} else if(strcmp(key_str, "dead-zone-translation-y") == 0) {
|
||||
logmsg(LOG_WARNING, "Deprecated option: %s. You are encouraged to use dead-zoneN instead\n", key_str);
|
||||
lptr->opt = CFG_DEADZONE_TY;
|
||||
EXPECT(isint);
|
||||
cfg->dead_threshold[1] = ival;
|
||||
|
||||
} else if(strcmp(key_str, "dead-zone-translation-z") == 0) {
|
||||
logmsg(LOG_WARNING, "Deprecated option: %s. You are encouraged to use dead-zoneN instead\n", key_str);
|
||||
lptr->opt = CFG_DEADZONE_TZ;
|
||||
EXPECT(isint);
|
||||
cfg->dead_threshold[2] = ival;
|
||||
|
||||
} else if(strcmp(key_str, "dead-zone-rotation-x") == 0) {
|
||||
logmsg(LOG_WARNING, "Deprecated option: %s. You are encouraged to use dead-zoneN instead\n", key_str);
|
||||
lptr->opt = CFG_DEADZONE_RX;
|
||||
EXPECT(isint);
|
||||
cfg->dead_threshold[3] = ival;
|
||||
|
||||
} else if(strcmp(key_str, "dead-zone-rotation-y") == 0) {
|
||||
logmsg(LOG_WARNING, "Deprecated option: %s. You are encouraged to use dead-zoneN instead\n", key_str);
|
||||
lptr->opt = CFG_DEADZONE_RY;
|
||||
EXPECT(isint);
|
||||
cfg->dead_threshold[4] = ival;
|
||||
|
||||
} else if(strcmp(key_str, "dead-zone-rotation-z") == 0) {
|
||||
logmsg(LOG_WARNING, "Deprecated option: %s. You are encouraged to use dead-zoneN instead\n", key_str);
|
||||
lptr->opt = CFG_DEADZONE_RZ;
|
||||
EXPECT(isint);
|
||||
cfg->dead_threshold[5] = ival;
|
||||
|
@ -447,7 +462,7 @@ int read_cfg(const char *fname, struct cfg *cfg)
|
|||
|
||||
int write_cfg(const char *fname, struct cfg *cfg)
|
||||
{
|
||||
int i;
|
||||
int i, same;
|
||||
FILE *fp;
|
||||
struct flock flk;
|
||||
struct cfg def;
|
||||
|
@ -495,28 +510,22 @@ int write_cfg(const char *fname, struct cfg *cfg)
|
|||
}
|
||||
}
|
||||
|
||||
if(cfg->dead_threshold[0] == cfg->dead_threshold[1] && cfg->dead_threshold[1] == cfg->dead_threshold[2] && cfg->dead_threshold[2] == cfg->dead_threshold[3] && cfg->dead_threshold[3] == cfg->dead_threshold[4] && cfg->dead_threshold[4] == cfg->dead_threshold[5]) {
|
||||
same = 1;
|
||||
for(i=1; i<MAX_AXES; i++) {
|
||||
if(cfg->dead_threshold[i] != cfg->dead_threshold[i - 1]) {
|
||||
same = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(same) {
|
||||
if(cfg->dead_threshold[0] != def.dead_threshold[0]) {
|
||||
add_cfgopt(CFG_DEADZONE, 0, "dead-zone = %d", cfg->dead_threshold[0]);
|
||||
}
|
||||
} else {
|
||||
if(cfg->dead_threshold[0] != def.dead_threshold[0]) {
|
||||
add_cfgopt(CFG_DEADZONE_TX, 0, "dead-zone-translation-x = %d", cfg->dead_threshold[0]);
|
||||
}
|
||||
if(cfg->dead_threshold[1] != def.dead_threshold[1]) {
|
||||
add_cfgopt(CFG_DEADZONE_TY, 0, "dead-zone-translation-y = %d", cfg->dead_threshold[1]);
|
||||
}
|
||||
if(cfg->dead_threshold[2] != def.dead_threshold[2]) {
|
||||
add_cfgopt(CFG_DEADZONE_TZ, 0, "dead-zone-translation-z = %d", cfg->dead_threshold[2]);
|
||||
}
|
||||
if(cfg->dead_threshold[3] != def.dead_threshold[3]) {
|
||||
add_cfgopt(CFG_DEADZONE_RX, 0, "dead-zone-rotation-x = %d", cfg->dead_threshold[3]);
|
||||
}
|
||||
if(cfg->dead_threshold[4] != def.dead_threshold[4]) {
|
||||
add_cfgopt(CFG_DEADZONE_RY, 0, "dead-zone-rotation-y = %d", cfg->dead_threshold[4]);
|
||||
}
|
||||
if(cfg->dead_threshold[5] != def.dead_threshold[5]) {
|
||||
add_cfgopt(CFG_DEADZONE_RZ, 0, "dead-zone-rotation-z = %d", cfg->dead_threshold[5]);
|
||||
for(i=0; i<MAX_AXES; i++) {
|
||||
if(cfg->dead_threshold[i] != def.dead_threshold[i]) {
|
||||
add_cfgopt(CFG_DEADZONE_N, i, "dead-zone%d = %d", i, cfg->dead_threshold[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,13 +139,12 @@ void process_input(struct device *dev, struct dev_input *inp)
|
|||
|
||||
switch(inp->type) {
|
||||
case INP_MOTION:
|
||||
if((inp->idx = cfg.map_axis[inp->idx]) < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(abs(inp->val) < cfg.dead_threshold[inp->idx] ) {
|
||||
inp->val = 0;
|
||||
}
|
||||
if((inp->idx = cfg.map_axis[inp->idx]) < 0) {
|
||||
break;
|
||||
}
|
||||
sign = cfg.invert[inp->idx] ? -1 : 1;
|
||||
|
||||
sens_rot = disable_rotation ? 0 : cfg.sens_rot[inp->idx - 3];
|
||||
|
|
|
@ -39,8 +39,8 @@ enum {
|
|||
REQ_GCFG_SENS, /* get global sens: R[0] float R[6] status */
|
||||
REQ_SCFG_SENS_AXIS, /* set per-axis sens/ty: Q[0-5] values - R[6] status */
|
||||
REQ_GCFG_SENS_AXIS, /* get per-axis sens/ty: R[0-5] values R[6] status */
|
||||
REQ_SCFG_DEADZONE, /* set deadzones: Q[0-5] values - R[6] status */
|
||||
REQ_GCFG_DEADZONE, /* get deadzones: R[0-5] values R[6] status */
|
||||
REQ_SCFG_DEADZONE, /* set deadzones: Q[0] dev axis Q[1] deadzone - R[6] status */
|
||||
REQ_GCFG_DEADZONE, /* get deadzones: R[0] dev axis - R[0] dev axis R[1] deadzone R[6] status */
|
||||
REQ_SCFG_INVERT, /* set invert axes: Q[0-5] invert - R[6] status */
|
||||
REQ_GCFG_INVERT, /* get invert axes: R[0-5] invert R[6] status */
|
||||
REQ_SCFG_AXISMAP, /* set axis mapping: Q[0] dev axis Q[1] mapping - R[6] status */
|
||||
|
|
|
@ -374,20 +374,22 @@ static int handle_request(struct client *c, struct reqresp *req)
|
|||
break;
|
||||
|
||||
case REQ_SCFG_DEADZONE:
|
||||
for(i=0; i<6; i++) {
|
||||
if(req->data[i] < 0) {
|
||||
logmsg(LOG_WARNING, "client attempted to set invalid deadzone for axis %d: %d\n", i,
|
||||
req->data[i]);
|
||||
sendresp(c, req, -1);
|
||||
return 0;
|
||||
}
|
||||
if(!AXIS_VALID(req->data[0])) {
|
||||
logmsg(LOG_WARNING, "client attempted to set invalid axis deadzone: %d\n", req->data[0]);
|
||||
sendresp(c, req, -1);
|
||||
return 0;
|
||||
}
|
||||
memcpy(cfg.dead_threshold, req->data, 6 * sizeof(int));
|
||||
cfg.dead_threshold[req->data[0]] = req->data[1];
|
||||
sendresp(c, req, 0);
|
||||
break;
|
||||
|
||||
case REQ_GCFG_DEADZONE:
|
||||
memcpy(req->data, cfg.dead_threshold, 6 * sizeof(int));
|
||||
if(!AXIS_VALID(req->data[0])) {
|
||||
logmsg(LOG_WARNING, "client requested invalid axis deadzone: %d\n", req->data[0]);
|
||||
sendresp(c, req, -1);
|
||||
return 0;
|
||||
}
|
||||
req->data[1] = cfg.dead_threshold[req->data[0]];
|
||||
sendresp(c, req, 0);
|
||||
break;
|
||||
|
||||
|
|
|
@ -427,6 +427,9 @@ static void handle_events(fd_set *rset)
|
|||
/* ... and process it, possibly dispatching a spacenav event to clients */
|
||||
process_input(dev, &inp);
|
||||
}
|
||||
/* flush any pending events if we run out of input */
|
||||
inp.type = INP_FLUSH;
|
||||
process_input(dev, &inp);
|
||||
}
|
||||
dev = next;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue