Commit fa9c11da authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

dinput: Let driver specify default axis mapping.

parent 167457ef
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment