removed the global disable-translation/disable-rotation options, and

moved the state variables out of the cfg structure.
pull/67/head
John Tsiombikas 2022-02-10 07:05:56 +02:00
rodzic 6e458f1676
commit 946a0874d2
3 zmienionych plików z 16 dodań i 29 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2019 John Tsiombikas <nuclear@member.fsf.org>
Copyright (C) 2007-2022 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -68,8 +68,6 @@ void default_cfg(struct cfg *cfg)
cfg->devname[i] = 0;
cfg->devid[i][0] = cfg->devid[i][1] = -1;
}
cfg->disable_translation = 0;
cfg->disable_rotation = 0;
}
#define EXPECT(cond) \
@ -197,14 +195,6 @@ int read_cfg(const char *fname, struct cfg *cfg)
EXPECT(isfloat);
cfg->sens_rot[2] = fval;
} else if(strcmp(key_str, "disable-rotation") == 0) {
EXPECT(isint);
cfg->disable_rotation = ival;
} else if(strcmp(key_str, "disable-translation") == 0) {
EXPECT(isint);
cfg->disable_translation = ival;
} else if(strcmp(key_str, "invert-rot") == 0) {
if(strchr(val_str, 'x')) {
cfg->invert[RX] = !def_axinv[RX];
@ -390,10 +380,6 @@ int write_cfg(const char *fname, struct cfg *cfg)
}
fputc('\n', fp);
fprintf(fp, "disable-rotation = %d\n", cfg->disable_rotation);
fprintf(fp, "disable-translation = %d\n", cfg->disable_translation);
fputc('\n', fp);
fprintf(fp, "# dead zone; any motion less than this number, is discarded as noise.\n");
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]) {

Wyświetl plik

@ -1,6 +1,6 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2019 John Tsiombikas <nuclear@member.fsf.org>
Copyright (C) 2007-2022 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -45,8 +45,6 @@ enum {
struct cfg {
float sensitivity, sens_trans[3], sens_rot[3];
int disable_rotation;
int disable_translation;
int dead_threshold[MAX_AXES];
int invert[MAX_AXES];
int map_axis[MAX_AXES];

Wyświetl plik

@ -1,6 +1,6 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2013 John Tsiombikas <nuclear@member.fsf.org>
Copyright (C) 2007-2022 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -56,6 +56,9 @@ static unsigned int msec_dif(struct timeval tv1, struct timeval tv2);
static struct dev_event *dev_ev_list = NULL;
static int disable_translation, disable_rotation;
static struct dev_event *add_dev_event(struct device *dev)
{
struct dev_event *dev_ev, *iter;
@ -143,8 +146,8 @@ void process_input(struct device *dev, struct dev_input *inp)
}
sign = cfg.invert[inp->idx] ? -1 : 1;
sens_rot = cfg.disable_rotation ? 0 : cfg.sens_rot[inp->idx - 3];
sens_trans = cfg.disable_translation ? 0 : cfg.sens_trans[inp->idx];
sens_rot = disable_rotation ? 0 : cfg.sens_rot[inp->idx - 3];
sens_trans = disable_translation ? 0 : cfg.sens_trans[inp->idx];
inp->val = (int)((float)inp->val * cfg.sensitivity * (inp->idx < 3 ? sens_trans : sens_rot));
@ -224,6 +227,8 @@ void process_input(struct device *dev, struct dev_input *inp)
static void handle_button_action(int act, int pressed)
{
if(pressed) return; /* perform all actions on release */
switch(act) {
case BNACT_SENS_INC:
cfg.sensitivity *= 1.1f;
@ -235,17 +240,15 @@ static void handle_button_action(int act, int pressed)
cfg.sensitivity = 1.0f;
break;
case BNACT_DISABLE_ROTATION:
if(pressed == BTN_RELEASE) {
cfg.disable_rotation = !cfg.disable_rotation;
if (cfg.disable_rotation)
cfg.disable_translation = 0;
disable_rotation = !disable_rotation;
if(disable_rotation) {
disable_translation = 0;
}
break;
case BNACT_DISABLE_TRANSLATION:
if(pressed == BTN_RELEASE) {
cfg.disable_translation = !cfg.disable_translation;
if (cfg.disable_translation)
cfg.disable_rotation = 0;
disable_translation = !disable_translation;
if(disable_translation) {
disable_rotation = 0;
}
break;
}