Bug#444142: joystick: Updated patch for version 20051019-1.1 including patch for the jscal manpage
Package: joystick Version: 20051019-1.1 Followup-For: Bug #444142 I attach the joystick axis and button remapping patch for version 20051019-1.1. It patches - utils/jscal.c to perform button and axis remapping - debian/jscal.1 manpage to document the new command line arguments of jscal -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.18-4-686 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8) Shell: /bin/sh linked to /bin/bash diff -ur joystick-20051019/debian/jscal.1 /home/kajla/usr/src/joystick/debian/jscal.1 --- joystick-20051019/debian/jscal.1 2007-09-27 13:24:32.0 +0200 +++ /home/kajla/usr/src/joystick/debian/jscal.1 2007-09-27 13:24:43.0 +0200 @@ -8,26 +8,25 @@ .B jscal is a joystick calibration program for Linux joystick driver. .SH OPTIONS -.TP -.I \-c, --calibrate +.IP \fB\-c\fR, \fB\-\-calibrate\fR Calibrate the joystick. -.TP -.I \-h, --help +.IP \fB\-h\fR, \fB\-\-help\fR Print out a summary of available options. -.TP -.I \-s x,y,z..., --set-correction x,y,z... +.IP \fB\-s\fR, \fB\-\-set\-correction\fR \fIx,y,z...\fR Sets correction to specified values. -.TP -.I \-t --test-center +.IP \fB\-u\fR, \fB\-\-set\-mappings\fR \fIn_of_axes,axmap1,axmap2,...,n_of_buttons,btnmap1,btnmap2,...\fR +Sets axis and button mappings. +.IP \fB\-t\fR, \fB\-\-test\-center\fR Tests if the joystick is correctly calibrated. Returns 2 if the axes are not calibrated, 3 if buttons were pressed, 1 if there was any other error, and 0 on success. -.TP -.I \-V, --version +.IP \fB\-V\fR, \fB\-\-version\fR Prints the version numbers. -.TP -.I \-p, --print-correction +.IP \fB\-p\fR, \fB\-\-print\-correction\fR Prints the current correction settings. The format of the output is a jscal command line. +.IP \fB\-q\fR, \fB\-\-print\-mappings\fR +Prints the current axis and button mappings. The format of the output is +a jscal command line. .SH SEE ALSO \fBjstest\fP(1), \fBinputattach\fP(1). Only in /home/kajla/usr/src/joystick/debian: .svn Only in /home/kajla/usr/src/joystick: .svn diff -ur joystick-20051019/utils/jscal.c /home/kajla/usr/src/joystick/utils/jscal.c --- joystick-20051019/utils/jscal.c 2004-10-19 09:51:52.0 +0200 +++ /home/kajla/usr/src/joystick/utils/jscal.c 2007-09-26 12:56:33.0 +0200 @@ -61,6 +61,8 @@ int fd; struct js_corr corr[MAX_AXES]; +__u8 axmap[ABS_MAX + 1]; +__u16 buttonmap[(KEY_MAX - BTN_MISC + 1)]; char axes, buttons, fuzz; int version; struct correction_data corda[MAX_AXES]; @@ -163,6 +165,12 @@ puts( -V --version Prints the version numbers); puts( -p --print-correction Prints the current settings as a jscal); puts( command line); + puts( -q --print-mappingsPrint the current axis and button); + puts( mappings as a jscal command line); + puts( -u n_of_axes,axmap1,axmap2,...,); + puts( n_of_buttons,btnmap1,btnmap2,); + puts( ... --set-mappings Sets axis and button mappings to the); + puts(specified values); putchar('\n'); } @@ -316,6 +324,42 @@ (version 8) 0xff, version 0xff); } +void print_mappings(char *devicename) +{ + int i; + + if (ioctl(fd, JSIOCGAXES, axes)) { + perror(jscal: error getting axes); + exit(1); + } + if (ioctl(fd, JSIOCGBUTTONS, buttons)) { + perror(jscal: error getting buttons); + exit(1); + } + if (ioctl(fd, JSIOCGAXMAP, axmap)) { + perror(jscal: error getting axis map); + exit(1); + } + if (ioctl(fd, JSIOCGBTNMAP, buttonmap)) { + perror(jscal: error getting button map); + exit(1); + } + + printf(jscal -u %d, axes); + for (i = 0; i axes; i++) + { + printf( ,%d, axmap[i]); + } + + printf(,%d, buttons); + for (i = 0; i buttons; i++) + { + printf( ,%d, buttonmap[i]); + } + + printf( %s\n,devicename); +} + void print_settings(char *devicename) { int i,j; @@ -342,6 +386,107 @@ printf( %s\n,devicename); } +// n axes n buttons +// 10,0,1,2,5,6,16,17,40,41,42:13,288,289,290,291,292,293,294,295,296,297,298,299,300 +void set_mappings(char *p) +{ + int i; + int axes_on_cl = 0; + int btns_on_cl = 0; + int axis_mapping = 0; + int btn_mapping = 0; + + if (ioctl(fd, JSIOCGAXES, axes)) { + perror(jscal: error getting axes); + exit(1); + } + if (ioctl(fd, JSIOCGBUTTONS, buttons)) { + perror(jscal: error getting buttons); + exit(1); + } + + if (axes MAX_AXES) axes = MAX_AXES; + + if (!p) { + fprintf(stderr, jscal: missing argument for --set-mappings\n); + exit(1); + } + + //axes + sscanf(p, %d, axes_on_cl); + p = strstr(p, ,); + + if (axes_on_cl != axes) { + fprintf(stderr, jscal: joystick has %d axes and not %d as specified on command line\n, + axes, axes_on_cl); + exit(1);
Bug#444142: joystick: Adding axis and button remapping capability to the included jscal tool
Package: joystick Version: 20051019-1 Severity: wishlist Tags: patch Motivation I found no simple tool that would remap the joystick axes and buttons on the device driver level (joydev module), while the driver clearly provides the interface for this. My patch extends to capabilities of jscal in order to remap axes and buttons. While remapping in the X configuration file is possible, that mapping does not seem to help in all games. Detail I bought a Trust GM-2550 Predator joystick the other day, and I noticed that the axes were mapped incorrectly: the throttle in place of the rudder, and the pinky button's axes were shifted up 1 slot in the axis map. I found no tool to re-map the axes on the device driver (joydev) level. While remapping is possible in the X config, this did not solve the problem for - for example - SearchAndRescue. Also I found no way to remap joystick buttons on the device driver level. This is quite necessary for example for tuxkart, because some of the buttons the game uses are unfortunately unreachable while holding the joystick comfortably (some buttons are too far on the stick). I found that the joydev kernel module does provide the API for axes and button remapping. I added two command line options to jscal and two corresponding functions that utilize the API and remap buttons and axes. I have tested the axes and button remapping, and it works as intended. I can swap buttons and axes as I wish. Implementation Please find the diff of jscal.c in joystick attached (joystick.diff). The modified jscal.c adds two command line arguments: -q --print-mappingsPrint the current axis and button mappings as a jscal command line and -u n_of_axes,axmap1,axmap2,..., n_of_buttons,btnmap1,btnmap2, ... --set-mappings Sets axis and button mappings to the specified values An example output of -q looks like this (./jscal -q /dev/input/js0): jscal -u 10,0,1,2,5,6,16,17,40,41,42,13,288,289,290,291,292,293,294,295,296,297,298,299,300 /dev/input/js0 The joystick has 10 axes and 13 buttons. If now one is to switch axes 2 and 5 (to get the rudder and the throttle right), one has to execute: jscal -u 10,0,1,5,2,6,16,17,40,41,42,13,288,289,290,291,292,293,294,295,296,297,298,299,300 /dev/input/js0 changing 2,5 to 5,2 on the line. Remapping buttons is done the same way. -- System Information: Debian Release: lenny/sid APT prefers testing APT policy: (500, 'testing'), (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.18-4-686 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8) Shell: /bin/sh linked to /bin/bash Only in joystick-20051019: debian Only in /home/kajla/usr/src/joystick/: .svn diff -ur joystick-20051019/utils/jscal.c /home/kajla/usr/src/joystick/utils/jscal.c --- joystick-20051019/utils/jscal.c 2004-10-19 09:51:52.0 +0200 +++ /home/kajla/usr/src/joystick/utils/jscal.c 2007-09-26 12:56:33.0 +0200 @@ -61,6 +61,8 @@ int fd; struct js_corr corr[MAX_AXES]; +__u8 axmap[ABS_MAX + 1]; +__u16 buttonmap[(KEY_MAX - BTN_MISC + 1)]; char axes, buttons, fuzz; int version; struct correction_data corda[MAX_AXES]; @@ -163,6 +165,12 @@ puts( -V --version Prints the version numbers); puts( -p --print-correction Prints the current settings as a jscal); puts( command line); + puts( -q --print-mappingsPrint the current axis and button); + puts( mappings as a jscal command line); + puts( -u n_of_axes,axmap1,axmap2,...,); + puts( n_of_buttons,btnmap1,btnmap2,); + puts( ... --set-mappings Sets axis and button mappings to the); + puts(specified values); putchar('\n'); } @@ -316,6 +324,42 @@ (version 8) 0xff, version 0xff); } +void print_mappings(char *devicename) +{ + int i; + + if (ioctl(fd, JSIOCGAXES, axes)) { + perror(jscal: error getting axes); + exit(1); + } + if (ioctl(fd, JSIOCGBUTTONS, buttons)) { + perror(jscal: error getting buttons); + exit(1); + } + if (ioctl(fd, JSIOCGAXMAP, axmap)) { + perror(jscal: error getting axis map); + exit(1); + } + if (ioctl(fd, JSIOCGBTNMAP, buttonmap)) { + perror(jscal: error getting button map); + exit(1); + } + + printf(jscal -u %d, axes); + for (i = 0; i axes; i++) + { + printf( ,%d, axmap[i]); + } + + printf(,%d, buttons); + for (i = 0; i buttons; i++) + { + printf( ,%d, buttonmap[i]); + } + + printf( %s\n,devicename); +} + void print_settings(char *devicename) { int i,j; @@ -342,6 +386,107 @@ printf( %s\n,devicename); } +// n axes n buttons +// 10,0,1,2,5,6,16,17,40,41,42:13,288,289,290,291,292,293,294,295,296,297,298,299,300 +void set_mappings(char *p) +{ + int i; + int axes_on_cl = 0; + int
Bug#443967: O: joystick
Package: wnpp Severity: normal The last version of the package - 20051019-1 - dates back almost two years. The package maintainer - Edward Betts [EMAIL PROTECTED] - does not respond to emails. -- System Information: Debian Release: lenny/sid APT prefers testing APT policy: (500, 'testing'), (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.18-4-686 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8) Shell: /bin/sh linked to /bin/bash -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]