Vitaliy Margolen : dinput: Let driver specify default axis mapping.
Alexandre Julliard
julliard at winehq.org
Wed Aug 19 11:31:55 CDT 2009
Module: wine
Branch: master
Commit: fa9c11dad396cdabf7527f7aef94f2cd49efb888
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fa9c11dad396cdabf7527f7aef94f2cd49efb888
Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date: Sat Aug 15 11:58:52 2009 -0600
dinput: Let driver specify default axis mapping.
---
dlls/dinput/joystick.c | 42 ++++++++++++++++++++++++++++--------
dlls/dinput/joystick_linux.c | 2 +-
dlls/dinput/joystick_linuxinput.c | 2 +-
dlls/dinput/joystick_private.h | 2 +-
4 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index 158e4e0..e0be179 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -448,7 +448,7 @@ DWORD joystick_map_pov(POINTL *p)
* Setup the dinput options.
*/
-HRESULT setup_dinput_options(JoystickGenericImpl *This)
+HRESULT setup_dinput_options(JoystickGenericImpl *This, const BYTE *default_axis_map)
{
char buffer[MAX_PATH+16];
HKEY hkey, appkey;
@@ -540,18 +540,40 @@ HRESULT setup_dinput_options(JoystickGenericImpl *This)
}
else
{
- /* No config - set default mapping. */
- for (tokens = 0; tokens < This->device_axis_count; tokens++)
+ int i;
+
+ if (default_axis_map)
{
- if (tokens < 8)
- This->axis_map[tokens] = axis++;
- else if (tokens < 15)
+ /* Use default mapping from the driver */
+ for (i = 0; i < This->device_axis_count; i++)
{
- This->axis_map[tokens++] = 8 + pov;
- This->axis_map[tokens ] = 8 + pov++;
+ This->axis_map[i] = default_axis_map[i];
+ tokens = default_axis_map[i];
+ if (tokens >= 0 && tokens < 8)
+ axis++;
+ else if (tokens < 15)
+ {
+ i++;
+ pov++;
+ This->axis_map[i] = default_axis_map[i];
+ }
+ }
+ }
+ else
+ {
+ /* No config - set default mapping. */
+ for (i = 0; i < This->device_axis_count; i++)
+ {
+ if (i < 8)
+ This->axis_map[i] = axis++;
+ else if (i < 15)
+ {
+ This->axis_map[i++] = 8 + pov;
+ This->axis_map[i ] = 8 + pov++;
+ }
+ else
+ This->axis_map[i] = -1;
}
- else
- This->axis_map[tokens] = -1;
}
}
This->devcaps.dwAxes = axis;
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c
index 6e1988b..764931e 100644
--- a/dlls/dinput/joystick_linux.c
+++ b/dlls/dinput/joystick_linux.c
@@ -310,7 +310,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
newDevice->generic.deadzone = 0;
/* do any user specified configuration */
- hr = setup_dinput_options(&newDevice->generic);
+ hr = setup_dinput_options(&newDevice->generic, NULL);
if (hr != DI_OK)
goto FAILED1;
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
index 1dda212..07524c0 100644
--- a/dlls/dinput/joystick_linuxinput.c
+++ b/dlls/dinput/joystick_linuxinput.c
@@ -433,7 +433,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
}
/* do any user specified configuration */
- if (setup_dinput_options(&newDevice->generic) != DI_OK) goto failed;
+ if (setup_dinput_options(&newDevice->generic, NULL) != DI_OK) goto failed;
/* Create copy of default data format */
if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto failed;
diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h
index 577bf5d..027e81a 100644
--- a/dlls/dinput/joystick_private.h
+++ b/dlls/dinput/joystick_private.h
@@ -53,7 +53,7 @@ typedef struct JoystickGenericImpl
} JoystickGenericImpl;
LONG joystick_map_axis(ObjProps *props, int val);
-HRESULT setup_dinput_options(JoystickGenericImpl *This);
+HRESULT setup_dinput_options(JoystickGenericImpl *This, const BYTE *default_axis_map);
DWORD joystick_map_pov(POINTL *p);
More information about the wine-cvs
mailing list