chiark / gitweb /
hostside: hidrawconv: always report joysticks as doubles -1..+1; disable dpad, as...
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 13 Feb 2011 01:20:16 +0000 (01:20 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 13 Feb 2011 01:20:16 +0000 (01:20 +0000)
hostside/hidrawconv-joytechneos.c
hostside/hidrawconv.c

index 6b3945834748acee047ad36e5f28ccbdee199b06..5ad96fed3b60e1f0cc9519c4f57a5f4b24ce3ad5 100644 (file)
@@ -16,11 +16,11 @@ static const KeyBit keybits[]= {
   { 0 }
 };
 static const ValLoc vallocs[]= {
-  { "EV_ABS ABS_X",          1,0,-1, 0xff, 0x7f },
+  { "EV_ABS ABS_X",          1,0,-1, 0xff, 0x80 },
   { "EV_ABS ABS_Y",          2,0,-1, 0xff, 0x80 },
-  { "EV_ABS ABS_RUDDER",     3,0,+1, 0xff, 0x7f },
+  { "EV_ABS ABS_RUDDER",     3,0,+1, 0xff, 0x80 },
   { "EV_ABS ABS_THROTTLE",   4,0,-1, 0xff, 0x80 },
-  { "EV_ABS DPAD",           5,0,+1, 0x0f, 0x00 },
+//  { "EV_ABS DPAD",           5,0,+1, 0x0f, 0x00 },
   { 0 }
 };
 
index 738a153be5740c9b5fec1f5d43704c14b4820398..134fabd45db42eeaf1e3368a05b6d598aaf0eefb 100644 (file)
@@ -8,6 +8,8 @@
  * exit status:
  *   0      all ok
  *   other  some other problem
+ *
+ * joystick values are always doubles from -1 to 0 to +1
  */
 
 #include "hidrawconv.h"
@@ -38,7 +40,9 @@ void reportlocs(const uint8_t msg[], const uint8_t last[],
     if (mb==lb) continue;
     mb >>= loc->rshift;
     mb -= loc->zero;
-    printf("%s %d\n", loc->str, loc->sign * (int8_t)mb);
+    double val= (int8_t)mb;
+    val /= (val >= 0 ? 127 : 128);
+    printf("%s %.5f\n", loc->str, loc->sign * val);
   }
 }