Commit 39684c7e authored by Lucas Fialho Zawacki's avatar Lucas Fialho Zawacki Committed by Alexandre Julliard

dinput: SetActionMap and queue_event setting mapped data.

parent b590090a
...@@ -604,6 +604,22 @@ void queue_event(LPDIRECTINPUTDEVICE8A iface, int inst_id, DWORD data, DWORD tim ...@@ -604,6 +604,22 @@ void queue_event(LPDIRECTINPUTDEVICE8A iface, int inst_id, DWORD data, DWORD tim
This->data_queue[This->queue_head].dwData = data; This->data_queue[This->queue_head].dwData = data;
This->data_queue[This->queue_head].dwTimeStamp = time; This->data_queue[This->queue_head].dwTimeStamp = time;
This->data_queue[This->queue_head].dwSequence = seq; This->data_queue[This->queue_head].dwSequence = seq;
/* Set uAppData by means of action mapping */
if (This->num_actions > 0)
{
int i;
for (i=0; i < This->num_actions; i++)
{
if (This->action_map[i].offset == ofs)
{
TRACE("Offset %d mapped to uAppData %lu\n", ofs, This->action_map[i].uAppData);
This->data_queue[This->queue_head].uAppData = This->action_map[i].uAppData;
break;
}
}
}
This->queue_head = next_pos; This->queue_head = next_pos;
/* Send event if asked */ /* Send event if asked */
} }
...@@ -783,6 +799,9 @@ ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface) ...@@ -783,6 +799,9 @@ ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface)
HeapFree(GetProcessHeap(), 0, This->data_format.wine_df); HeapFree(GetProcessHeap(), 0, This->data_format.wine_df);
release_DataFormat(&This->data_format); release_DataFormat(&This->data_format);
/* Free action mapping */
HeapFree(GetProcessHeap(), 0, This->action_map);
EnterCriticalSection( &This->dinput->crit ); EnterCriticalSection( &This->dinput->crit );
list_remove( &This->entry ); list_remove( &This->entry );
LeaveCriticalSection( &This->dinput->crit ); LeaveCriticalSection( &This->dinput->crit );
......
...@@ -47,6 +47,12 @@ typedef struct ...@@ -47,6 +47,12 @@ typedef struct
LPDIDATAFORMAT user_df; /* user defined data format */ LPDIDATAFORMAT user_df; /* user defined data format */
} DataFormat; } DataFormat;
typedef struct
{
unsigned int offset;
UINT_PTR uAppData;
} ActionMap;
/* Device implementation */ /* Device implementation */
typedef struct IDirectInputDeviceImpl IDirectInputDeviceImpl; typedef struct IDirectInputDeviceImpl IDirectInputDeviceImpl;
struct IDirectInputDeviceImpl struct IDirectInputDeviceImpl
...@@ -74,6 +80,7 @@ struct IDirectInputDeviceImpl ...@@ -74,6 +80,7 @@ struct IDirectInputDeviceImpl
/* Action mapping */ /* Action mapping */
int num_actions; /* number of actions mapped */ int num_actions; /* number of actions mapped */
ActionMap *action_map; /* array of mappings */
}; };
extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN; extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN;
......
...@@ -609,6 +609,8 @@ static HRESULT WINAPI SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, ...@@ -609,6 +609,8 @@ static HRESULT WINAPI SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
data_format.rgodf = (LPDIOBJECTDATAFORMAT)obj_df; data_format.rgodf = (LPDIOBJECTDATAFORMAT)obj_df;
data_format.dwNumObjs = num_actions; data_format.dwNumObjs = num_actions;
This->base.action_map = HeapAlloc(GetProcessHeap(), 0, sizeof(ActionMap)*num_actions);
for (i = 0; i < lpdiaf->dwNumActions; i++) for (i = 0; i < lpdiaf->dwNumActions; i++)
{ {
if (IsEqualGUID(&This->base.guid, &lpdiaf->rgoAction[i].guidInstance)) if (IsEqualGUID(&This->base.guid, &lpdiaf->rgoAction[i].guidInstance))
...@@ -616,6 +618,8 @@ static HRESULT WINAPI SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, ...@@ -616,6 +618,8 @@ static HRESULT WINAPI SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
int instance = DIDFT_GETINSTANCE(lpdiaf->rgoAction[i].dwObjID); int instance = DIDFT_GETINSTANCE(lpdiaf->rgoAction[i].dwObjID);
memcpy(&obj_df[action], &c_dfDIKeyboard.rgodf[instance], c_dfDIKeyboard.dwObjSize); memcpy(&obj_df[action], &c_dfDIKeyboard.rgodf[instance], c_dfDIKeyboard.dwObjSize);
This->base.action_map[action].uAppData = lpdiaf->rgoAction[i].uAppData;
This->base.action_map[action].offset = action;
obj_df[action].dwOfs = action; obj_df[action].dwOfs = action;
action++; action++;
} }
......
...@@ -834,6 +834,7 @@ static HRESULT WINAPI SysMouseWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, ...@@ -834,6 +834,7 @@ static HRESULT WINAPI SysMouseWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
DIDATAFORMAT data_format; DIDATAFORMAT data_format;
DIOBJECTDATAFORMAT *obj_df = NULL; DIOBJECTDATAFORMAT *obj_df = NULL;
int i, action = 0, num_actions = 0; int i, action = 0, num_actions = 0;
unsigned int offset = 0;
if (This->base.acquired) return DIERR_ACQUIRED; if (This->base.acquired) return DIERR_ACQUIRED;
...@@ -856,15 +857,18 @@ static HRESULT WINAPI SysMouseWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, ...@@ -856,15 +857,18 @@ static HRESULT WINAPI SysMouseWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
data_format.rgodf = (LPDIOBJECTDATAFORMAT)obj_df; data_format.rgodf = (LPDIOBJECTDATAFORMAT)obj_df;
data_format.dwNumObjs = num_actions; data_format.dwNumObjs = num_actions;
This->base.action_map = HeapAlloc(GetProcessHeap(), 0, sizeof(ActionMap)*num_actions);
for (i = 0; i < lpdiaf->dwNumActions; i++) for (i = 0; i < lpdiaf->dwNumActions; i++)
{ {
unsigned int offset = 0;
if (IsEqualGUID(&This->base.guid, &lpdiaf->rgoAction[i].guidInstance)) if (IsEqualGUID(&This->base.guid, &lpdiaf->rgoAction[i].guidInstance))
{ {
int instance = DIDFT_GETINSTANCE(lpdiaf->rgoAction[i].dwObjID); int instance = DIDFT_GETINSTANCE(lpdiaf->rgoAction[i].dwObjID);
memcpy(&obj_df[action], &c_dfDIMouse.rgodf[instance], c_dfDIMouse.dwObjSize); memcpy(&obj_df[action], &c_dfDIMouse.rgodf[instance], c_dfDIMouse.dwObjSize);
This->base.action_map[action].uAppData = lpdiaf->rgoAction[i].uAppData;
This->base.action_map[action].offset = offset;
obj_df[action].dwOfs = offset; obj_df[action].dwOfs = offset;
offset += (obj_df[action].dwType & DIDFT_BUTTON) ? 1 : 4; offset += (obj_df[action].dwType & DIDFT_BUTTON) ? 1 : 4;
......
...@@ -89,7 +89,7 @@ static void test_device_input( ...@@ -89,7 +89,7 @@ static void test_device_input(
return; return;
} }
todo_wine ok (obj_data.uAppData == expected, "Retrieval of action failed uAppData=%lu expected=%d\n", obj_data.uAppData, expected); ok (obj_data.uAppData == expected, "Retrieval of action failed uAppData=%lu expected=%d\n", obj_data.uAppData, expected);
} }
static void test_build_action_map( static void test_build_action_map(
......
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