Package: joy2key
Version: 1.6.1
Tags: patch

I own a gamepad, for which the axis belonging to the steering cross only
report values -1,0,1 so the threshold has to be set to 0, which works
when using the build-in calibrate function. The problem is, that when
trying to specify this via the commandline, this is not accepted,
because the values are tested as truth value and 0 evaluates to
false ...

To fix this I created an additional array, holding just the information,
whether the threshold for this axis was defined. To allow manual
calibration, I introduced "x" as placeholder in the threshold
commandline, meaning: "This threshold is not supplied", which was prior
to this work indicated by passing 0 as value.

Please see the attached patch

Thanks

Matthias

-- 
Matthias Bläsing (GPG-Schlüsselkennung: A71B4BD5)
ICQ: 84617206   AIM: linuxfun81   MSN: [EMAIL PROTECTED]
--- joy2key-1.6.1.orig/joy2key.c	2006-12-26 05:46:25.000000000 +0100
+++ joy2key-1.6.1/joy2key.c	2006-12-26 05:55:53.000000000 +0100
@@ -96,6 +96,7 @@
     button_actions[256],
     axis_actions[256][2],
     axis_threshold[256][2], /* 0 = low (down); 1 = hi (up) */
+    axis_threshold_defined[256], /* 1 == defined */
     axis_act_counter=0,
     button_act_counter=0,
     thresh_counter=0,
@@ -160,6 +161,7 @@
 		   JOY2KEY_VERSION, __DATE__, __TIME__);
 
     memset(axis_threshold, 0, sizeof(axis_threshold));
+    memset(axis_threshold_defined, 0, sizeof(axis_threshold_defined));
     memset(axis_actions, 0, sizeof(axis_actions));
     memset(button_actions, 0, sizeof(button_actions));
     memset(button_repeat_flags, 0, sizeof(button_repeat_flags));
@@ -250,7 +252,7 @@
 
     for(i=0; i<numaxes; i++)
     {
-		if(!(axis_threshold[i][0] | axis_threshold[i][1]))
+		if(! axis_threshold_defined[i])
 			calibrate(i);
     }
 
@@ -557,6 +559,8 @@
 					puts("Not enough arguments to -thresh");
 					exit(1);
 				}
+                if(argv[i][0] != 'x'  && argv[i+1][1] != 'x') 
+                    axis_threshold_defined[thresh_counter] = 1;
 				axis_threshold[thresh_counter][0]=atoi(argv[i]);
 				axis_threshold[thresh_counter++][1]=atoi(argv[++i]);
 			}
@@ -718,6 +722,7 @@
     printf("\nUsing deadzone of %i%%\n", deadzone);
     axis_threshold[num][0]=joymid+((axis_threshold[num][0] - joymid) * (deadzone/100.0));
     axis_threshold[num][1]=joymid+((axis_threshold[num][1] - joymid) * (deadzone/100.0));
+    axis_threshold_defined[num] = 1;
     puts("Calibrations set at:");
     printf("Axis %i low threshold set at %i\n", num, axis_threshold[num][0]);
     printf("Axis %i high threshold set at %i\n", num, axis_threshold[num][1]);    

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to