GSoC: dinput8 Action Mapping

Marcus Meissner marcus at jet.franken.de
Mon Aug 1 03:20:41 CDT 2011


On Fri, Jul 29, 2011 at 05:48:43PM -0300, Lucas Zawacki wrote:
> Hello!
> 
> Here's a lot of patches with a ConfigureDevices implementation. These
> patches can be tested with this app I built that uses ConfigureDevices
> to set up a joystick action mapping
> (https://github.com/downloads/lfzawacki/dinput-samples/dolphin-plugin.exe)
> . I also tested it with the Rally Trophy and Star Sonata games.
> 
> Any advice on the dialog code is appreciated, it's the first time I've
> coded something like this and may have missed some things.
> 
> This implementation still lacks some things:
> 
> * Implement username property for devices
> * Tracking down a bug with Rally Trophy that makes the mouse disappear
> while inside the ConfigureDevices dialog.
> * Implement the "Sort Assigned" checkbox
> * Some fixes to the code
> 
> I'll let the code resting here while I keep working on this stuff.

If this is to some degree functional it can also be included already :)

One thing in 0001:

> +    /* Copy action names */
> +    for (i=0; i < diafW.dwNumActions; i++)
> +    {
> +        const char* from = lpdiCDParams->lprgFormats->rgoAction[i].u.lptszActionName;
> +        WCHAR *to = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*MAX_PATH);
> +        MultiByteToWideChar(CP_ACP, 0, from , -1, to , MAX_PATH);
> +        diafW.rgoAction[i].u.lptszActionName = to;
> +    }

The pattern to do this is usually by querying MBtoWC for the result length and then
allocating and doing it for real (untested):

        const char* from = lpdiCDParams->lprgFormats->rgoAction[i].u.lptszActionName;
        WCHAR *to;
	DWORD len;

	len = MultiByteToWideChar(CP_ACP, 0, from , -1, NULL , 0);
        to = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
	MultiByteToWideChar(CP_ACP, 0, from , -1, to, len);
        diafW.rgoAction[i].u.lptszActionName = to;

> +    hr = IDirectInput8WImpl_ConfigureDevices(&This->IDirectInput8W_iface, lpdiCallback, &diCDParamsW, dwFlags, pvRefData);

Should the action format be copied back on error?

> +    /* Copy back configuration */
> +    _copy_diactionformatWtoA(lpdiCDParams->lprgFormats, &diafW);
> +
> +    /* Free memory */
> +    for (i=0; i < diafW.dwNumActions; i++)
> +        HeapFree(GetProcessHeap(), 0, (LPVOID) diafW.rgoAction[i].u.lptszActionName);
> +
> +    HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
>  
> -      FIXME("(this=%p,%p,%p,%04x,%p): stub\n", This, lpdiCallback, lpdiCDParams,
> -            dwFlags, pvRefData);
> -      return 0;
> +    return hr;


I also read over the dialog stuff ... I did not see anything problematic, looked to
my untrained eyes :)

Ciao, Marcus



More information about the wine-devel mailing list