Added dinput-SetActionMap-genre patchset

This commit is contained in:
Alistair Leslie-Hughes 2019-06-07 11:29:51 +10:00
parent 1d3c799e6f
commit 5681cd5466
4 changed files with 167 additions and 15 deletions

View File

@ -0,0 +1,73 @@
From 87860f6a1666321684e9dd5e7553a40e1656a9b4 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 24 May 2019 16:16:13 +1000
Subject: [PATCH] dinput: Allow mapping of controls based of Genre type.
---
dlls/dinput/device.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 0c9432698ae..00b97bd24bd 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -893,8 +893,15 @@ HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, L
/* Count the actions */
for (i=0; i < lpdiaf->dwNumActions; i++)
- if (IsEqualGUID(&This->guid, &lpdiaf->rgoAction[i].guidInstance))
+ {
+ if (IsEqualGUID(&This->guid, &lpdiaf->rgoAction[i].guidInstance) ||
+ (IsEqualGUID(&IID_NULL, &lpdiaf->rgoAction[i].guidInstance) &&
+ ((lpdiaf->rgoAction[i].dwSemantic & lpdiaf->dwGenre) == lpdiaf->dwGenre ||
+ (lpdiaf->rgoAction[i].dwSemantic & 0xff000000) == 0xff000000 /* Any Axis */) ))
+ {
num_actions++;
+ }
+ }
/* Should return DI_NOEFFECT if we dont have any actions and actionformat has not changed */
if (num_actions == 0 && lpdiaf->dwCRC == new_crc && !(dwFlags & DIDSAM_FORCESAVE)) return DI_NOEFFECT;
@@ -934,7 +941,39 @@ HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, L
action++;
}
+ else if ((lpdiaf->rgoAction[i].dwSemantic & lpdiaf->dwGenre) == lpdiaf->dwGenre ||
+ (lpdiaf->rgoAction[i].dwSemantic & 0xff000000) == 0xff000000 /* Any Axis */)
+ {
+ DWORD obj_id = semantic_to_obj_id(This, lpdiaf->rgoAction[i].dwSemantic);
+ DWORD type = DIDFT_GETTYPE(obj_id);
+ DWORD inst = DIDFT_GETINSTANCE(obj_id);
+ LPDIOBJECTDATAFORMAT obj;
+
+ if (type == DIDFT_PSHBUTTON) type = DIDFT_BUTTON;
+ else if (type == DIDFT_RELAXIS) type = DIDFT_AXIS;
+
+ obj = dataformat_to_odf_by_type(df, inst, type);
+ TRACE("obj %p, inst 0x%08x, type 0x%08x\n", obj, inst, type);
+ if(obj)
+ {
+ memcpy(&obj_df[action], obj, df->dwObjSize);
+
+ This->action_map[action].uAppData = lpdiaf->rgoAction[i].uAppData;
+ This->action_map[action].offset = offset;
+ obj_df[action].dwOfs = offset;
+ offset += (type & DIDFT_BUTTON) ? 1 : 4;
+
+ action++;
+ }
+ }
+ }
+
+ if (action == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, obj_df);
+ return DI_NOEFFECT;
}
+ data_format.dwNumObjs = action;
IDirectInputDevice8_SetDataFormat(iface, &data_format);
--
2.17.1

View File

@ -0,0 +1,46 @@
From a4cf8d9241b8dd94937408c9a1d20aacfb9dd2e3 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Tue, 28 May 2019 14:37:25 +1000
Subject: [PATCH 2/2] dinput: Improved tracing of Semantic value.
---
dlls/dinput/dinput_main.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index cf050cb71ed..79ef9620de9 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -290,6 +290,20 @@ static void _dump_EnumDevices_dwFlags(DWORD dwFlags)
TRACE("\n");
}
+static char *dump_semantic(DWORD semantic)
+{
+ if((semantic & 0xff000000) == 0xff000000)
+ return "Any AXIS";
+ else if((semantic & 0x82000000) == 0x82000000)
+ return "Mouse";
+ else if((semantic & 0x81000000) == 0x81000000)
+ return "Keybaord";
+ else if((semantic & DIVIRTUAL_FLYING_HELICOPTER) == DIVIRTUAL_FLYING_HELICOPTER)
+ return "Helicopter";
+
+ return "Unknown";
+}
+
static void _dump_diactionformatA(LPDIACTIONFORMATA lpdiActionFormat)
{
unsigned int i;
@@ -312,7 +326,7 @@ static void _dump_diactionformatA(LPDIACTIONFORMATA lpdiActionFormat)
{
TRACE("diaf.rgoAction[%u]:\n", i);
TRACE("\tuAppData=0x%lx\n", lpdiActionFormat->rgoAction[i].uAppData);
- TRACE("\tdwSemantic=0x%08x\n", lpdiActionFormat->rgoAction[i].dwSemantic);
+ TRACE("\tdwSemantic=0x%08x (%s)\n", lpdiActionFormat->rgoAction[i].dwSemantic, dump_semantic(lpdiActionFormat->rgoAction[i].dwSemantic));
TRACE("\tdwFlags=0x%x\n", lpdiActionFormat->rgoAction[i].dwFlags);
TRACE("\tszActionName=%s\n", debugstr_a(lpdiActionFormat->rgoAction[i].u.lptszActionName));
TRACE("\tguidInstance=%s\n", debugstr_guid(&lpdiActionFormat->rgoAction[i].guidInstance));
--
2.20.1

View File

@ -0,0 +1,2 @@
Fixes: [47326] dinput: Allow mapping of controls based of genre type.
Depends: dinput-joy-mappings

View File

@ -126,6 +126,7 @@ patch_enable_all ()
enable_ddraw_Texture_Wrong_Caps="$1"
enable_ddraw_Write_Vtable="$1"
enable_ddraw_version_check="$1"
enable_dinput_SetActionMap_genre="$1"
enable_dinput_axis_recalc="$1"
enable_dinput_joy_mappings="$1"
enable_dinput_reconnect_joystick="$1"
@ -504,6 +505,9 @@ patch_enable ()
ddraw-version-check)
enable_ddraw_version_check="$2"
;;
dinput-SetActionMap-genre)
enable_dinput_SetActionMap_genre="$2"
;;
dinput-axis-recalc)
enable_dinput_axis_recalc="$2"
;;
@ -1964,6 +1968,13 @@ if test "$enable_dsound_EAX" -eq 1; then
enable_dsound_Fast_Mixer=1
fi
if test "$enable_dinput_SetActionMap_genre" -eq 1; then
if test "$enable_dinput_joy_mappings" -gt 1; then
abort "Patchset dinput-joy-mappings disabled, but dinput-SetActionMap-genre depends on that."
fi
enable_dinput_joy_mappings=1
fi
if test "$enable_ddraw_version_check" -eq 1; then
if test "$enable_ddraw_Device_Caps" -gt 1; then
abort "Patchset ddraw-Device_Caps disabled, but ddraw-version-check depends on that."
@ -2954,21 +2965,6 @@ if test "$enable_ddraw_version_check" -eq 1; then
) >> "$patchlist"
fi
# Patchset dinput-axis-recalc
# |
# | This patchset fixes the following Wine bugs:
# | * [#41317] dinput: Recalculated Axis after deadzone change.
# |
# | Modified files:
# | * dlls/dinput/joystick.c
# |
if test "$enable_dinput_axis_recalc" -eq 1; then
patch_apply dinput-axis-recalc/0001-dinput-Recalculated-Axis-after-deadzone-change.patch
(
printf '%s\n' '+ { "Bruno Jesus", "dinput: Recalculated Axis after deadzone change.", 1 },';
) >> "$patchlist"
fi
# Patchset dinput-joy-mappings
# |
# | This patchset fixes the following Wine bugs:
@ -2989,6 +2985,41 @@ if test "$enable_dinput_joy_mappings" -eq 1; then
) >> "$patchlist"
fi
# Patchset dinput-SetActionMap-genre
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * dinput-joy-mappings
# |
# | This patchset fixes the following Wine bugs:
# | * [#47326] dinput: Allow mapping of controls based of genre type.
# |
# | Modified files:
# | * dlls/dinput/device.c, dlls/dinput/dinput_main.c
# |
if test "$enable_dinput_SetActionMap_genre" -eq 1; then
patch_apply dinput-SetActionMap-genre/0001-dinput-Allow-mapping-of-controls-based-of-Genre-type.patch
patch_apply dinput-SetActionMap-genre/0002-dinput-Improved-tracing-of-Semantic-value.patch
(
printf '%s\n' '+ { "Alistair Leslie-Hughes", "dinput: Allow mapping of controls based of Genre type.", 1 },';
printf '%s\n' '+ { "Alistair Leslie-Hughes", "dinput: Improved tracing of Semantic value.", 1 },';
) >> "$patchlist"
fi
# Patchset dinput-axis-recalc
# |
# | This patchset fixes the following Wine bugs:
# | * [#41317] dinput: Recalculated Axis after deadzone change.
# |
# | Modified files:
# | * dlls/dinput/joystick.c
# |
if test "$enable_dinput_axis_recalc" -eq 1; then
patch_apply dinput-axis-recalc/0001-dinput-Recalculated-Axis-after-deadzone-change.patch
(
printf '%s\n' '+ { "Bruno Jesus", "dinput: Recalculated Axis after deadzone change.", 1 },';
) >> "$patchlist"
fi
# Patchset dinput-reconnect-joystick
# |
# | This patchset fixes the following Wine bugs: