diff options
author | Sascha Hlusiak <saschahlusiak@arcor.de> | 2007-04-07 16:23:34 -0400 |
---|---|---|
committer | Sascha Hlusiak <saschahlusiak@arcor.de> | 2007-04-07 16:23:34 -0400 |
commit | 8d9507e694d4ef36f7409ffc14c476af609ec524 (patch) | |
tree | b0df8e1a18b73887983479b92e312313b6a871b6 | |
parent | 4821113eb34f7bf55a601d59eaeddbfab67183fa (diff) |
Fixed correct calculation of absolute axis position when centered
InitButtonClassDeviceStruct: fixed to MAXBUTTONS buttons since we don't have device data yet
-rw-r--r-- | src/jstk.c | 2 | ||||
-rw-r--r-- | src/jstk_axis.c | 8 |
2 files changed, 6 insertions, 4 deletions
@@ -256,7 +256,7 @@ jstkDeviceControlProc(DeviceIntPtr pJstk, DBG(1, ErrorF("jstkDeviceControlProc what=INIT\n")); for (i=1; i<MAXBUTTONS; i++) map[i] = i; - if (InitButtonClassDeviceStruct(pJstk, priv->buttons, map) == FALSE) { + if (InitButtonClassDeviceStruct(pJstk, MAXBUTTONS, map) == FALSE) { ErrorF("unable to allocate Button class device\n"); return !Success; } diff --git a/src/jstk_axis.c b/src/jstk_axis.c index 4f96e82..5969f0b 100644 --- a/src/jstk_axis.c +++ b/src/jstk_axis.c @@ -310,9 +310,11 @@ jstkHandleAbsoluteAxis(LocalDevicePtr device, int number) { { float rel; int dif; - rel = (priv->axis[i].value > 0) ? - (priv->axis[i].value - priv->axis[i].deadzone) : - (priv->axis[i].value + priv->axis[i].deadzone); + if (priv->axis[i].value >= priv->axis[i].deadzone) + rel = (priv->axis[i].value - priv->axis[i].deadzone); + if (priv->axis[i].value <= -priv->axis[i].deadzone) + rel = (priv->axis[i].value + priv->axis[i].deadzone); + rel = (rel) / (2.0f * (float)(32768 - priv->axis[i].deadzone)); /* rel contains numbers between -0.5 and +0.5 now */ |