From 78120acf62bd31d8dfdbdc072cf595d684fab08f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 13 Feb 2011 01:20:16 +0000 Subject: [PATCH] hostside: hidrawconv: always report joysticks as doubles -1..+1; disable dpad, as we don't support that properly atm --- hostside/hidrawconv-joytechneos.c | 6 +++--- hostside/hidrawconv.c | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hostside/hidrawconv-joytechneos.c b/hostside/hidrawconv-joytechneos.c index 6b39458..5ad96fe 100644 --- a/hostside/hidrawconv-joytechneos.c +++ b/hostside/hidrawconv-joytechneos.c @@ -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 } }; diff --git a/hostside/hidrawconv.c b/hostside/hidrawconv.c index 738a153..134fabd 100644 --- a/hostside/hidrawconv.c +++ b/hostside/hidrawconv.c @@ -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); } } -- 2.30.2