packages: joystick/joystick.spec, joystick/joystick-mapping.patch (NEW) - a...
jajcus
jajcus at pld-linux.org
Sun Jan 2 18:03:38 CET 2011
Author: jajcus Date: Sun Jan 2 17:03:38 2011 GMT
Module: packages Tag: HEAD
---- Log message:
- added patch allowing axes and button remapping
- Release .2
---- Files affected:
packages/joystick:
joystick.spec (1.17 -> 1.18) , joystick-mapping.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: packages/joystick/joystick.spec
diff -u packages/joystick/joystick.spec:1.17 packages/joystick/joystick.spec:1.18
--- packages/joystick/joystick.spec:1.17 Tue Feb 13 09:06:36 2007
+++ packages/joystick/joystick.spec Sun Jan 2 18:03:32 2011
@@ -4,7 +4,8 @@
Summary(pl.UTF-8): Narzędzia do obsługi joysticka
Name: joystick
Version: 1.2.15
-Release: 2.%{_snap}.1
+Patch0: %{name}-mapping.patch
+Release: 2.%{_snap}.2
License: GPL
Group: Applications
Source0: %{name}-%{_snap}.tar.gz
@@ -33,6 +34,7 @@
%prep
%setup -q -n %{name}
+%patch0 -p1
%build
%{__make} jstest jscal inputattach evtest ffset fftest\
@@ -61,6 +63,10 @@
All persons listed below can be reached at <cvs_login>@pld-linux.org
$Log$
+Revision 1.18 2011/01/02 17:03:32 jajcus
+- added patch allowing axes and button remapping
+- Release .2
+
Revision 1.17 2007/02/13 08:06:36 glen
- tabs in preamble
================================================================
Index: packages/joystick/joystick-mapping.patch
diff -u /dev/null packages/joystick/joystick-mapping.patch:1.1
--- /dev/null Sun Jan 2 18:03:38 2011
+++ packages/joystick/joystick-mapping.patch Sun Jan 2 18:03:32 2011
@@ -0,0 +1,254 @@
+diff -dur joystick.orig/jscal.1 joystick/jscal.1
+--- joystick.orig/jscal.1 2006-04-30 19:54:44.000000000 +0200
++++ joystick/jscal.1 2011-01-02 17:39:49.000000000 +0100
+@@ -18,6 +18,9 @@
+ .I \-s <x,y,z...>, --set-correction <x,y,z...>
+ Sets correction to specified values.
+ .TP
++.I \-u, --set-mappings <n_of_axes,axmap1,axmap2,...,n_of_buttons,btnmap1,btnmap2,...>
++Sets axis and button mappings.
++.TP
+ .I \-t --test-center
+ Tests if the joystick is corectly calibrated. Returns 2 if the axes are
+ not calibrated, 3 if buttons were pressed, 1 if there was any other
+@@ -29,5 +32,9 @@
+ .I \-p, --print-correction
+ Prints the current correction settings. The format of the output is
+ a jscal command line.
++.TP
++.I \-q, --print-mappings
++Prints the current axis and button mappings. The format of the output is
++a jscal command line.
+ .SH SEE ALSO
+ \fBjstest\fP(1), \fBjsattach\fP(1).
+diff -dur joystick.orig/jscal.c joystick/jscal.c
+--- joystick.orig/jscal.c 2004-10-19 09:51:52.000000000 +0200
++++ joystick/jscal.c 2011-01-02 17:58:15.000000000 +0100
+@@ -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-mappings Print 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) < 0) {
++ perror("jscal: error getting axis map");
++ exit(1);
++ }
++ if (ioctl(fd, JSIOCGBTNMAP, &buttonmap) < 0) {
++ 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,112 @@
+ 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);
++ }
++
++
++ for (i = 0; i < axes; i++)
++ {
++ if (!p) {
++ fprintf(stderr, "jscal: missing mapping for axis %d\n", i);
++ exit(1);
++ }
++ sscanf(++p, "%d", &axis_mapping);
++ p = strstr(p, ",");
++
++
++ if (axis_mapping > ABS_MAX + 1) {
++ fprintf(stderr, "jscal: invalid axis mapping for axis %d (max is %d)\n", i, ABS_MAX + 1);
++ exit(1);
++ }
++ axmap[i] = axis_mapping;
++ }
++
++ if (p) {
++ //buttons
++ sscanf(++p, "%d", &btns_on_cl);
++ p = strstr(p, ",");
++
++ if (btns_on_cl != buttons) {
++ fprintf(stderr, "jscal: joystick has %d buttons and not %d as specified on command line\n",
++ buttons, btns_on_cl);
++ exit(1);
++ }
++
++
++ for (i = 0; i < buttons; i++) {
++ if (!p) {
++ fprintf(stderr, "jscal: missing mapping for button %d\n", i);
++ exit(1);
++ }
++ sscanf(++p, "%d", &btn_mapping);
++ p = strstr(p, ",");
++
++
++ if (btn_mapping > KEY_MAX) {
++ fprintf(stderr, "jscal: invalid button mapping for button %d (max is %d)\n", i, KEY_MAX);
++ exit(1);
++ }
++ if (btn_mapping < BTN_MISC) {
++ fprintf(stderr, "jscal: invalid button mapping for button %d (min is %d)\n", i, BTN_MISC);
++ exit(1);
++ }
++ buttonmap[i] = btn_mapping;
++ }
++ }
++ else {
++ // no mapping for buttons
++ btns_on_cl = 0;
++ }
++
++ if (p) {
++ fprintf(stderr, "jscal: too many values\n");
++ exit(1);
++ }
++
++ if (ioctl(fd, JSIOCSAXMAP, &axmap) < 0) {
++ perror("jscal: error setting axis map");
++ exit(1);
++ }
++ if (btns_on_cl && ioctl(fd, JSIOCSBTNMAP, &buttonmap) < 0) {
++ perror("jscal: error setting button map");
++ exit(1);
++ }
++}
++
+ void set_correction(char *p)
+ {
+ int i,j;
+@@ -461,14 +610,18 @@
+ char *parameter = NULL;
+ int t;
+
++ // /usr/include/getopt.h
+ static struct option long_options[] =
+ {
+ {"calibrate", no_argument, NULL, 'c'},
+ {"help", no_argument, NULL, 'h'},
+ {"set-correction", required_argument, NULL, 's'},
++ {"set-mappings", required_argument, NULL, 'u'},
+ {"test-center", no_argument, NULL, 't'},
+ {"version", no_argument, NULL, 'V'},
+- {"print-correction", no_argument, NULL, 'p'}
++ {"print-correction", no_argument, NULL, 'p'},
++ {"print-mappings", no_argument, NULL, 'q'},
++ {NULL, no_argument, NULL, 0 }
+ };
+
+ if (argc == 1) {
+@@ -477,10 +630,12 @@
+ }
+
+ do {
+- t = getopt_long(argc, argv, "chps:vVt", long_options, &option_index);
++ t = getopt_long(argc, argv, "chpqu:s:vVt", long_options, &option_index);
+ switch (t) {
+ case 'p':
++ case 'q':
+ case 's':
++ case 'u':
+ case 'c':
+ case 't':
+ case 'V':
+@@ -540,9 +695,15 @@
+ case 'p':
+ print_settings(argv[argc -1]);
+ break;
++ case 'q':
++ print_mappings(argv[argc -1]);
++ break;
+ case 's':
+ set_correction(parameter);
+ break;
++ case 'u':
++ set_mappings(parameter);
++ break;
+ case 't':
+ test_center();
+ break;
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/joystick/joystick.spec?r1=1.17&r2=1.18&f=u
More information about the pld-cvs-commit
mailing list