On Wed, Mar 24, 2004 at 12:58:21AM +0100, Christoph Frick wrote:
hi,
im terribly sorry and hope this patch is not yet submited.
> - changed the mapping of the axis to a simplier formula, that ignores
> the middle of an axis
this code lacked the "shifting" of the result by ``wanted min''
also not stated on the first posting: this patch is LGPL licensed
below you find the complete patch again with the fixed part.
--
cu
Index: joystick_linuxinput.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/joystick_linuxinput.c,v
retrieving revision 1.1
diff -u -r1.1 joystick_linuxinput.c
--- joystick_linuxinput.c 12 Feb 2004 23:28:00 -0000 1.1
+++ joystick_linuxinput.c 24 Mar 2004 07:23:15 -0000
@@ -239,7 +239,12 @@
for (i=0;i<ABS_MAX;i++) {
newDevice->wantmin[i] = -32768;
newDevice->wantmax[i] = 32767;
- newDevice->deadz[i] = 1024; /* guessing */
+ /* TODO:
+ * direct input defines a default for the deadzone somewhere; but as long
+ * as in map_axis the code for the dead zone is commented out its no
+ * problem
+ */
+ newDevice->deadz[i] = 0;
}
return newDevice;
}
@@ -412,8 +417,8 @@
This->axes[i][AXE_ABSFUZZ],
This->axes[i][AXE_ABSFLAT]
);
- This->havemax[i] = This->axes[i][AXE_ABSMIN];
- This->havemin[i] = This->axes[i][AXE_ABSMAX];
+ This->havemin[i] = This->axes[i][AXE_ABSMIN];
+ This->havemax[i] = This->axes[i][AXE_ABSMAX];
}
}
MESSAGE("\n");
@@ -460,12 +465,8 @@
if (xmin == xmax) return val;
if ((hmin == hmax) || (hmax==xmid) || (hmin==xmid)) return val;
- /* don't assume total linearity, but linearity starting from a zeropoint */
- if (val > xmid) {
- ret = (val-xmid)*((wmax-wmin)/2)/(hmax-xmid)+0;
- } else {
- ret = (xmid-val)*((wmax-wmin)/2)/(hmin-xmid)+0;
- }
+ /* map the value from the hmin-hmax range into the wmin-wmax range */
+ ret = (val * (wmax-wmin)) / (hmax-hmin) + wmin;
#if 0
/* deadzone doesn't work comfortably enough right now. needs more testing*/
@@ -519,8 +520,54 @@
GEN_EVENT(DIJOFS_BUTTON(2),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
This->js.rgbButtons[2] = ie.value?0x80:0x00;
break;
+ case BTN_TOP:
+ case BTN_X:
+ case BTN_4:
+ GEN_EVENT(DIJOFS_BUTTON(3),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.rgbButtons[3] = ie.value?0x80:0x00;
+ break;
+ case BTN_TOP2:
+ case BTN_Y:
+ case BTN_5:
+ GEN_EVENT(DIJOFS_BUTTON(4),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.rgbButtons[4] = ie.value?0x80:0x00;
+ break;
+ case BTN_PINKIE:
+ case BTN_Z:
+ case BTN_6:
+ GEN_EVENT(DIJOFS_BUTTON(5),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.rgbButtons[5] = ie.value?0x80:0x00;
+ break;
+ case BTN_BASE:
+ case BTN_TL:
+ case BTN_7:
+ GEN_EVENT(DIJOFS_BUTTON(6),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.rgbButtons[6] = ie.value?0x80:0x00;
+ break;
+ case BTN_BASE2:
+ case BTN_TR:
+ case BTN_8:
+ GEN_EVENT(DIJOFS_BUTTON(7),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.rgbButtons[7] = ie.value?0x80:0x00;
+ break;
+ case BTN_BASE3:
+ case BTN_TL2:
+ case BTN_9:
+ GEN_EVENT(DIJOFS_BUTTON(8),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.rgbButtons[8] = ie.value?0x80:0x00;
+ break;
+ case BTN_BASE4:
+ case BTN_TR2:
+ GEN_EVENT(DIJOFS_BUTTON(9),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.rgbButtons[9] = ie.value?0x80:0x00;
+ break;
+ case BTN_BASE5:
+ case BTN_SELECT:
+ GEN_EVENT(DIJOFS_BUTTON(10),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.rgbButtons[10] = ie.value?0x80:0x00;
+ break;
default:
- FIXME("unhandled joystick axe %x, value %d\n",ie.code,ie.value);
+ FIXME("unhandled joystick button %x, value %d\n",ie.code,ie.value);
break;
}
break;
@@ -533,9 +580,22 @@
case ABS_Y:
GEN_EVENT(DIJOFS_Y,ie.value,ie.time.tv_usec,(This->dinput->evsequence)++);
This->js.lY = map_axis(This,1,ie.value);
+ break;
case ABS_Z:
GEN_EVENT(DIJOFS_Z,ie.value,ie.time.tv_usec,(This->dinput->evsequence)++);
This->js.lZ = map_axis(This,2,ie.value);
+ break;
+ case ABS_RX:
+ GEN_EVENT(DIJOFS_RX,ie.value,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.lRx = map_axis(This,3,ie.value);
+ break;
+ case ABS_RY:
+ GEN_EVENT(DIJOFS_RY,ie.value,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.lRy = map_axis(This,4,ie.value);
+ break;
+ case ABS_RZ:
+ GEN_EVENT(DIJOFS_RZ,ie.value,ie.time.tv_usec,(This->dinput->evsequence)++);
+ This->js.lRz = map_axis(This,5,ie.value);
break;
default:
FIXME("unhandled joystick axe event (code %d, value %d)\n",ie.code,ie.value);