Commit 67682c24 authored by Lucas Fialho Zawacki's avatar Lucas Fialho Zawacki Committed by Alexandre Julliard

dinput: Added possibility to change the action mapping in the ConfigureDevices dialog.

parent 91496918
...@@ -41,6 +41,7 @@ typedef struct { ...@@ -41,6 +41,7 @@ typedef struct {
IDirectInput8W *lpDI; IDirectInput8W *lpDI;
LPDIACTIONFORMATW lpdiaf; LPDIACTIONFORMATW lpdiaf;
DIDevicesData devices_data; DIDevicesData devices_data;
int display_only;
} ConfigureDevicesData; } ConfigureDevicesData;
/* /*
...@@ -115,6 +116,21 @@ static int lv_get_cur_item(HWND dialog) ...@@ -115,6 +116,21 @@ static int lv_get_cur_item(HWND dialog)
return SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_GETNEXTITEM, -1, LVNI_SELECTED); return SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
} }
static int lv_get_item_data(HWND dialog, int index)
{
LVITEMW item;
if (index < 0) return -1;
item.mask = LVIF_PARAM;
item.iItem = index;
item.iSubItem = 0;
SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_GETITEMW , 0, (LPARAM)&item);
return item.lParam;
}
static void lv_set_action(HWND dialog, int item, int action, LPDIACTIONFORMATW lpdiaf) static void lv_set_action(HWND dialog, int item, int action, LPDIACTIONFORMATW lpdiaf)
{ {
static const WCHAR no_action[] = {'-','\0'}; static const WCHAR no_action[] = {'-','\0'};
...@@ -161,6 +177,12 @@ static LPDIACTIONFORMATW get_cur_lpdiaf(HWND dialog) ...@@ -161,6 +177,12 @@ static LPDIACTIONFORMATW get_cur_lpdiaf(HWND dialog)
return data->lpdiaf; return data->lpdiaf;
} }
static int dialog_display_only(HWND dialog)
{
ConfigureDevicesData *data = (ConfigureDevicesData*) GetWindowLongPtrW(dialog, DWLP_USER);
return data->display_only;
}
static void init_devices(HWND dialog, IDirectInput8W *lpDI, DIDevicesData *data, LPDIACTIONFORMATW lpdiaf) static void init_devices(HWND dialog, IDirectInput8W *lpDI, DIDevicesData *data, LPDIACTIONFORMATW lpdiaf)
{ {
int i; int i;
...@@ -261,6 +283,46 @@ static void show_suitable_actions(HWND dialog) ...@@ -261,6 +283,46 @@ static void show_suitable_actions(HWND dialog)
} }
} }
static void assign_action(HWND dialog)
{
DeviceData *device = get_cur_device(dialog);
LPDIACTIONFORMATW lpdiaf = get_cur_lpdiaf(dialog);
LVFINDINFOW lvFind;
int sel = SendDlgItemMessageW(dialog, IDC_ACTIONLIST, LB_GETCURSEL, 0, 0);
int action = SendDlgItemMessageW(dialog, IDC_ACTIONLIST, LB_GETITEMDATA, sel, 0);
int obj = lv_get_cur_item(dialog);
int old_action = lv_get_item_data(dialog, obj);
int used_obj;
DIDEVICEOBJECTINSTANCEW ddo = device->ddo[obj];
if (old_action == action) return;
/* Clear old action */
if (old_action != -1)
{
lpdiaf->rgoAction[old_action].dwObjID = 0;
lpdiaf->rgoAction[old_action].guidInstance = GUID_NULL;
lpdiaf->rgoAction[old_action].dwHow = DIAH_UNMAPPED;
}
/* Find if action text is already set for other object and unset it */
lvFind.flags = LVFI_PARAM;
lvFind.lParam = action;
used_obj = SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_FINDITEMW, -1, (LPARAM) &lvFind);
lv_set_action(dialog, used_obj, -1, lpdiaf);
/* Set new action */
lpdiaf->rgoAction[action].dwObjID = ddo.dwType;
lpdiaf->rgoAction[action].guidInstance = device->ddi.guidInstance;
lpdiaf->rgoAction[action].dwHow = DIAH_USERCONFIG;
/* Set new action in the list */
lv_set_action(dialog, obj, action, lpdiaf);
}
static INT_PTR CALLBACK ConfigureDevicesDlgProc(HWND dialog, UINT uMsg, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK ConfigureDevicesDlgProc(HWND dialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch(uMsg) switch(uMsg)
...@@ -296,6 +358,19 @@ static INT_PTR CALLBACK ConfigureDevicesDlgProc(HWND dialog, UINT uMsg, WPARAM w ...@@ -296,6 +358,19 @@ static INT_PTR CALLBACK ConfigureDevicesDlgProc(HWND dialog, UINT uMsg, WPARAM w
switch(LOWORD(wParam)) switch(LOWORD(wParam))
{ {
case IDC_ACTIONLIST:
switch (HIWORD(wParam))
{
case LBN_DBLCLK:
/* Ignore this if app did not ask for editing */
if (dialog_display_only(dialog)) break;
assign_action(dialog);
break;
}
break;
case IDC_CONTROLLERCOMBO: case IDC_CONTROLLERCOMBO:
switch (HIWORD(wParam)) switch (HIWORD(wParam))
...@@ -335,6 +410,7 @@ HRESULT _configure_devices(IDirectInput8W *iface, ...@@ -335,6 +410,7 @@ HRESULT _configure_devices(IDirectInput8W *iface,
ConfigureDevicesData data; ConfigureDevicesData data;
data.lpDI = iface; data.lpDI = iface;
data.lpdiaf = lpdiCDParams->lprgFormats; data.lpdiaf = lpdiCDParams->lprgFormats;
data.display_only = !(dwFlags & DICD_EDIT);
InitCommonControls(); InitCommonControls();
......
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