dinput: Let driver specify default axis mapping.

This commit is contained in:
Vitaliy Margolen 2009-08-15 11:58:52 -06:00 committed by Alexandre Julliard
parent 167457efc1
commit fa9c11dad3
4 changed files with 35 additions and 13 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);