Package: joystick Version: 1:1.7.1-1 Severity: normal Dear Maintainer,
jscal asks user to move axis to a position and push any button. This causes a problem when a trigger of a gamepad is both axis and a button. In this case when user pulls the trigger, a button event is sent and jscal continues before user has had a change to move the trigger to the requested position. The problem appears with ZEROPLUS P4 Wired Gamepad. I wrote a patch to add -b option to jscal to choose one button to use as the continue button. -- Package-specific info: looking at device '/devices/pci0000:00/0000:00:01.2/0000:20:00.0/0000:21:08.0/0000:2a:00.3/usb3/3-6/3-6.2/3-6.2:1.3/0003:0C12:0E16.000A/input/input38/js0': KERNEL=="js0" SUBSYSTEM=="input" DRIVER=="" ATTR{power/async}=="disabled" ATTR{power/control}=="auto" ATTR{power/runtime_active_kids}=="0" ATTR{power/runtime_active_time}=="0" ATTR{power/runtime_enabled}=="disabled" ATTR{power/runtime_status}=="unsupported" ATTR{power/runtime_suspended_time}=="0" ATTR{power/runtime_usage}=="0" looking at parent device '/devices/pci0000:00/0000:00:01.2/0000:20:00.0/0000:21:08.0/0000:2a:00.3/usb3/3-6/3-6.2/3-6.2:1.3/0003:0C12:0E16.000A/input/input38': KERNELS=="input38" SUBSYSTEMS=="input" DRIVERS=="" ATTRS{capabilities/abs}=="3003f" ATTRS{capabilities/ev}=="1b" ATTRS{capabilities/ff}=="0" ATTRS{capabilities/key}=="3fff000000000000 0 0 0 0" ATTRS{capabilities/led}=="0" ATTRS{capabilities/msc}=="10" ATTRS{capabilities/rel}=="0" ATTRS{capabilities/snd}=="0" ATTRS{capabilities/sw}=="0" ATTRS{id/bustype}=="0003" ATTRS{id/product}=="0e16" ATTRS{id/vendor}=="0c12" ATTRS{id/version}=="0111" ATTRS{inhibited}=="0" ATTRS{name}=="ZEROPLUS P4 Wired Gamepad" ATTRS{phys}=="usb-0000:2a:00.3-6.2/input3" ATTRS{power/async}=="disabled" ATTRS{power/control}=="auto" ATTRS{power/runtime_active_kids}=="0" ATTRS{power/runtime_active_time}=="0" ATTRS{power/runtime_enabled}=="disabled" ATTRS{power/runtime_status}=="unsupported" ATTRS{power/runtime_suspended_time}=="0" ATTRS{power/runtime_usage}=="0" ATTRS{properties}=="0" ATTRS{uniq}=="" -- System Information: Debian Release: 11.2 APT prefers stable-security APT policy: (500, 'stable-security'), (500, 'stable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 5.15.11 (SMP w/24 CPU threads) Kernel taint flags: TAINT_UNSIGNED_MODULE Locale: LANG=fi_FI.UTF-8, LC_CTYPE=fi_FI.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages joystick depends on: ii libc6 2.31-13+deb11u2 ii libsdl2-2.0-0 2.0.14+dfsg2-3 Versions of packages joystick recommends: ii evtest 1:1.34-1 ii inputattach 1:1.7.1-1 joystick suggests no packages. -- no debconf information
diff -ur a/utils/jscal.c b/utils/jscal.c --- a/utils/jscal.c 2019-10-05 22:52:45.000000000 +0300 +++ b/utils/jscal.c 2022-02-11 20:26:46.574281686 +0200 @@ -76,6 +76,8 @@ } +static int button = -1; + int get_time(void) { struct timeval tv; @@ -154,6 +156,7 @@ puts("Usage: jscal <device>"); putchar('\n'); puts(" -c --calibrate Calibrate the joystick"); + puts(" -b <number> --button Button to continue calibrating"); puts(" -h --help Display this help"); puts(" -s <x,y,z...> --set-correction Sets correction to specified values"); puts(" -t --test-center Tests if joystick is corectly calibrated"); @@ -265,16 +268,29 @@ b = js.buttons; + const char * push_msg; + if(button == -1) { + push_msg = "Move axis %d to %s position and push any button.\n"; + }else{ + push_msg = "Move axis %d to %s position and push the button.\n"; + } for (axis = 0; axis < axes; axis++) for (pos = 0; pos < NUM_POS; pos++) { while(b ^ js.buttons) wait_for_event(fd, &js); - printf("Move axis %d to %s position and push any button.\n", axis, pos_name[pos]); + printf(push_msg, axis, pos_name[pos]); - while (!(b ^ js.buttons)) { - print_position(axis, js.axis[axis]); - wait_for_event(fd, &js); - } + if(button == -1) + while (!(b ^ js.buttons)) { + print_position(axis, js.axis[axis]); + wait_for_event(fd, &js); + } + else + while (!(js.buttons & button)) { + print_position(axis, js.axis[axis]); + wait_for_event(fd, &js); + } + putcs("Hold ... "); @@ -670,6 +686,7 @@ // /usr/include/getopt.h static struct option long_options[] = { + {"button", required_argument, NULL, 'b'}, {"calibrate", no_argument, NULL, 'c'}, {"help", no_argument, NULL, 'h'}, {"set-correction", required_argument, NULL, 's'}, @@ -687,7 +704,7 @@ } do { - t = getopt_long(argc, argv, "chpqu:s:vVt", long_options, &option_index); + t = getopt_long(argc, argv, "b:chpqu:s:vVt", long_options, &option_index); switch (t) { case 'p': case 'q': @@ -704,6 +721,9 @@ parameter = optarg; } break; + case 'b': + button = 1 << atoi(optarg); + break; case 'h': help(); exit(0);