From 5681cd5466f1dbb60b4001d5f10ae8f94db23803 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 7 Jun 2019 11:29:51 +1000 Subject: [PATCH] Added dinput-SetActionMap-genre patchset --- ...ping-of-controls-based-of-Genre-type.patch | 73 +++++++++++++++++++ ...t-Improved-tracing-of-Semantic-value.patch | 46 ++++++++++++ patches/dinput-SetActionMap-genre/definition | 2 + patches/patchinstall.sh | 61 ++++++++++++---- 4 files changed, 167 insertions(+), 15 deletions(-) create mode 100644 patches/dinput-SetActionMap-genre/0001-dinput-Allow-mapping-of-controls-based-of-Genre-type.patch create mode 100644 patches/dinput-SetActionMap-genre/0002-dinput-Improved-tracing-of-Semantic-value.patch create mode 100644 patches/dinput-SetActionMap-genre/definition diff --git a/patches/dinput-SetActionMap-genre/0001-dinput-Allow-mapping-of-controls-based-of-Genre-type.patch b/patches/dinput-SetActionMap-genre/0001-dinput-Allow-mapping-of-controls-based-of-Genre-type.patch new file mode 100644 index 00000000..ac4ef9ba --- /dev/null +++ b/patches/dinput-SetActionMap-genre/0001-dinput-Allow-mapping-of-controls-based-of-Genre-type.patch @@ -0,0 +1,73 @@ +From 87860f6a1666321684e9dd5e7553a40e1656a9b4 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +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 + diff --git a/patches/dinput-SetActionMap-genre/0002-dinput-Improved-tracing-of-Semantic-value.patch b/patches/dinput-SetActionMap-genre/0002-dinput-Improved-tracing-of-Semantic-value.patch new file mode 100644 index 00000000..fb4c9191 --- /dev/null +++ b/patches/dinput-SetActionMap-genre/0002-dinput-Improved-tracing-of-Semantic-value.patch @@ -0,0 +1,46 @@ +From a4cf8d9241b8dd94937408c9a1d20aacfb9dd2e3 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +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 + diff --git a/patches/dinput-SetActionMap-genre/definition b/patches/dinput-SetActionMap-genre/definition new file mode 100644 index 00000000..9f549d55 --- /dev/null +++ b/patches/dinput-SetActionMap-genre/definition @@ -0,0 +1,2 @@ +Fixes: [47326] dinput: Allow mapping of controls based of genre type. +Depends: dinput-joy-mappings diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index ecf52521..eab6f01a 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -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: