On 06/13/2011 04:17 PM, Lucas Zawacki wrote:
OK, so here is my second try at some patches. These mostly implement keyboard action mapping and there's plenty of tests to go together with it. I believe the keyboard part is pretty much done, as is SetActionMap. Of course I'm ignoring the username strings and all the device ownership part, I'll leave that for later.
As before I'll leave the patches here to get some feedback before I try to commit.
Subject: dinput: EnumDevicesBySemantics enumerating system keyboard and mouse
- DWORD callbackFlags = 0;
- ret = lpCallback(&didevi, lpdid, callbackFlags , 0, pvRef);
I'd like to see a test for callbackFlags = 0. My notes indicate this should be DIEDBS_MAPPEDPRI1 instead.
Also please implement unicode method and call it from ascii. (IDirectInput8AImpl_EnumDevicesBySemantics -> IDirectInput8WImpl_EnumDevicesBySemantics)
Subject: dinput: SetActionMap setting the device buffer and data format.
- IDirectInputDevice8_SetDataFormat(iface, This->data_format.wine_df);
You do not want to do that. It's internal data format which does not have to be anything like real data format. You need to build your data format based on action mapping. I had something like this, not sure if it is correct:
+ DIDATAFORMAT data_format; + DIOBJECTDATAFORMAT *obj_df; + + data_format.dwSize = sizeof(data_format); + data_format.dwObjSize = sizeof(DIOBJECTDATAFORMAT); + data_format.dwFlags = DIDF_ABSAXIS; + data_format.dwDataSize = lpdiaf->dwDataSize; + data_format.dwNumObjs = lpdiaf->dwNumActions; + data_format.rgodf = (LPDIOBJECTDATAFORMAT)obj_df; + + for (i = 0; i < lpdiaf->dwNumActions; i++) + { + if ((lpdiaf->rgoAction[i].dwSemantic & 0x81000400) == 0x81000400) + /* Keyboard */ + memcpy(&obj_df[i], &c_dfDIKeyboard.rgodf[DIDFT_GETINSTANCE(lpdiaf->rgoAction[i].dwObjID)], c_dfDIKeyboard.dwObjSize); + else if ((lpdiaf->rgoAction[i].dwSemantic & 0x82000000) == 0x82000000) + /* Mouse */ + memcpy(&obj_df[i], &c_dfDIMouse2.rgodf[DIDFT_GETINSTANCE(lpdiaf->rgoAction[i].dwObjID)], c_dfDIMouse2.dwObjSize); + + obj_df[i].dwOfs = i * 4; + + This->action_map[DIDFT_GETINSTANCE(lpdiaf->rgoAction[i].dwObjID)] = lpdiaf->rgoAction[i].uAppData; + }
- /* search for actions for this device and apply them */
- for (i=0; i < lpdiaf->dwNumActions; i++) {
if (IsEqualGUID( &lpdiaf->rgoAction[i].guidInstance, &This->guid ) ) {
As I asked before, please put curly braces on a separate line.
Vitaliy.