mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-08 10:08:05 +02:00
tools: ptraccel-debug: switch to a mode enum
Fixes the dead code issue introduced in
822c97a1c2, print_accel was always
true so the rest of the code never got triggered.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
8178339b5b
commit
db2d16bfce
1 changed files with 24 additions and 16 deletions
|
|
@ -223,6 +223,13 @@ usage(void)
|
||||||
"Output best viewed with gnuplot. See output for gnuplot commands\n");
|
"Output best viewed with gnuplot. See output for gnuplot commands\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum mode {
|
||||||
|
ACCEL,
|
||||||
|
MOTION,
|
||||||
|
DELTA,
|
||||||
|
SEQUENCE,
|
||||||
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
@ -230,10 +237,7 @@ main(int argc, char **argv)
|
||||||
double step = 0.1,
|
double step = 0.1,
|
||||||
max_dx = 10;
|
max_dx = 10;
|
||||||
int nevents = 0;
|
int nevents = 0;
|
||||||
bool print_accel = true,
|
enum mode mode = ACCEL;
|
||||||
print_motion = false,
|
|
||||||
print_delta = false,
|
|
||||||
print_sequence = false;
|
|
||||||
double custom_deltas[1024];
|
double custom_deltas[1024];
|
||||||
double speed = 0.0;
|
double speed = 0.0;
|
||||||
int dpi = 1000;
|
int dpi = 1000;
|
||||||
|
|
@ -284,13 +288,13 @@ main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
case OPT_MODE:
|
case OPT_MODE:
|
||||||
if (streq(optarg, "accel"))
|
if (streq(optarg, "accel"))
|
||||||
print_accel = true;
|
mode = ACCEL;
|
||||||
else if (streq(optarg, "motion"))
|
else if (streq(optarg, "motion"))
|
||||||
print_motion = true;
|
mode = MOTION;
|
||||||
else if (streq(optarg, "delta"))
|
else if (streq(optarg, "delta"))
|
||||||
print_delta = true;
|
mode = DELTA;
|
||||||
else if (streq(optarg, "sequence"))
|
else if (streq(optarg, "sequence"))
|
||||||
print_sequence = true;
|
mode = SEQUENCE;
|
||||||
else {
|
else {
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -382,8 +386,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
if (!isatty(STDIN_FILENO)) {
|
if (!isatty(STDIN_FILENO)) {
|
||||||
char buf[12];
|
char buf[12];
|
||||||
print_sequence = true;
|
mode = SEQUENCE;
|
||||||
print_motion = false;
|
|
||||||
nevents = 0;
|
nevents = 0;
|
||||||
memset(custom_deltas, 0, sizeof(custom_deltas));
|
memset(custom_deltas, 0, sizeof(custom_deltas));
|
||||||
|
|
||||||
|
|
@ -391,25 +394,30 @@ main(int argc, char **argv)
|
||||||
custom_deltas[nevents++] = strtod(buf, NULL);
|
custom_deltas[nevents++] = strtod(buf, NULL);
|
||||||
}
|
}
|
||||||
} else if (optind < argc) {
|
} else if (optind < argc) {
|
||||||
print_sequence = true;
|
mode = SEQUENCE;
|
||||||
print_motion = false;
|
|
||||||
nevents = 0;
|
nevents = 0;
|
||||||
memset(custom_deltas, 0, sizeof(custom_deltas));
|
memset(custom_deltas, 0, sizeof(custom_deltas));
|
||||||
while (optind < argc)
|
while (optind < argc)
|
||||||
custom_deltas[nevents++] = strtod(argv[optind++], NULL);
|
custom_deltas[nevents++] = strtod(argv[optind++], NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_accel) {
|
switch (mode) {
|
||||||
|
case ACCEL:
|
||||||
if (!profile) /* trackpoint */
|
if (!profile) /* trackpoint */
|
||||||
print_accel_func_trackpoint(filter, tp_range_max);
|
print_accel_func_trackpoint(filter, tp_range_max);
|
||||||
else
|
else
|
||||||
print_accel_func(filter, profile, dpi);
|
print_accel_func(filter, profile, dpi);
|
||||||
} else if (print_delta)
|
break;
|
||||||
|
case DELTA:
|
||||||
print_ptraccel_deltas(filter, step);
|
print_ptraccel_deltas(filter, step);
|
||||||
else if (print_motion)
|
break;
|
||||||
|
case MOTION:
|
||||||
print_ptraccel_movement(filter, nevents, max_dx, step);
|
print_ptraccel_movement(filter, nevents, max_dx, step);
|
||||||
else if (print_sequence)
|
break;
|
||||||
|
case SEQUENCE:
|
||||||
print_ptraccel_sequence(filter, nevents, custom_deltas);
|
print_ptraccel_sequence(filter, nevents, custom_deltas);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
filter_destroy(filter);
|
filter_destroy(filter);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue