From a17b23a5f928aefb388e3cc9e643676832ebdb55 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 7 Aug 2024 05:58:44 +0200 Subject: [PATCH 1/2] override mouse coords for dinput --- src/directinput.c | 53 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/src/directinput.c b/src/directinput.c index 358374b..d97723b 100644 --- a/src/directinput.c +++ b/src/directinput.c @@ -1,6 +1,7 @@ #include #include #include "directinput.h" +#include "winapi_hooks.h" #include "debug.h" #include "hook.h" #include "dd.h" @@ -88,16 +89,60 @@ static HRESULT WINAPI fake_did_GetDeviceData( HRESULT result = real_did_GetDeviceData(This, cbObjectData, rgdod, pdwInOut, dwFlags); - if (SUCCEEDED(result) && This == g_mouse_device && !g_mouse_locked && !g_config.devmode) + if (SUCCEEDED(result) && This == g_mouse_device) { - if (pdwInOut) + if (pdwInOut && rgdod && *pdwInOut > 0 && cbObjectData > 0) { - if (rgdod && *pdwInOut > 0 && cbObjectData > 0) + if (!g_mouse_locked && !g_config.devmode) { memset(rgdod, 0, *pdwInOut * cbObjectData); + *pdwInOut = 0; } + else if (g_ddraw.width && g_ddraw.height) + { + POINT pt; + fake_GetCursorPos(&pt); + fake_SetCursorPos((g_ddraw.width / 2), (g_ddraw.height / 2)); - *pdwInOut = 0; + static int x, y; + x += pt.x - (g_ddraw.width / 2); + y += pt.y - (g_ddraw.height / 2); + + if (cbObjectData == sizeof(DIDEVICEOBJECTDATA_DX3)) + { + LPDIDEVICEOBJECTDATA_DX3 rgdod16 = (LPDIDEVICEOBJECTDATA_DX3)rgdod; + + for (int i = 0; i < *pdwInOut; i++) + { + if (rgdod16[i].dwOfs == DIMOFS_X) + { + rgdod16[i].dwData = x; + x = 0; + } + else if (rgdod16[i].dwOfs == DIMOFS_Y) + { + rgdod16[i].dwData = y; + y = 0; + } + } + } + else if (cbObjectData == sizeof(DIDEVICEOBJECTDATA)) + { + for (int i = 0; i < *pdwInOut; i++) + { + if (rgdod[i].dwOfs == DIMOFS_X) + { + rgdod[i].dwData = x; + x = 0; + } + else if (rgdod[i].dwOfs == DIMOFS_Y) + { + rgdod[i].dwData = y; + y = 0; + } + } + } + } } } From 59f8827ae4dbfe80a1e458b1517648830227b5cd Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Thu, 8 Aug 2024 02:19:24 +0200 Subject: [PATCH 2/2] save pdb file for experimental release --- .github/workflows/build.yml | 3 ++- action.yml | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 648427b..0738790 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,7 +83,8 @@ jobs: cp "${{ steps.build-releasexp.outputs.releasexp }}" cnc-ddraw-releasexp - 7z a -tzip -mm=Deflate -mfb=258 -mpass=15 "./cnc-ddraw-experimental/cnc-ddraw-experimental-release.zip" "./cnc-ddraw-releasexp/*" + cp "${{ steps.build-releasexp.outputs.releasexp-pdb }}" cnc-ddraw-experimental + 7z a -tzip -mm=Deflate -mfb=258 -mpass=15 "./cnc-ddraw-experimental/cnc-ddraw-experimental-release.zip" "./cnc-ddraw-releasexp/ddraw.dll" fi if [[ -f "${{ steps.build-debug.outputs.debug }}" ]]; then diff --git a/action.yml b/action.yml index 86b657c..ca39872 100644 --- a/action.yml +++ b/action.yml @@ -46,10 +46,16 @@ outputs: release: description: 'Full path to ddraw.dll built with Release configuration' value: ${{ steps.build-release.outputs.ddraw-dll }} + release-pdb: + description: 'Full path to ddraw.pdb built with Release configuration' + value: ${{ steps.build-release.outputs.ddraw-pdb }} releasexp: description: 'Full path to ddraw.dll built with ReleaseXP configuration' value: ${{ steps.build-releasexp.outputs.ddraw-dll }} + releasexp-pdb: + description: 'Full path to ddraw.pdb built with ReleaseXP configuration' + value: ${{ steps.build-releasexp.outputs.ddraw-pdb }} debug: description: 'Full path to ddraw.dll built with Debug configuration' @@ -119,6 +125,7 @@ runs: "${{ steps.msbuild.outputs.exe }}" "$GITHUB_ACTION_PATH/cnc-ddraw.sln" -p:Configuration=Release -p:Platform=x86 -p:PlatformToolset=v142 # echo "ddraw-dll=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/Release/ddraw.dll")" >> $GITHUB_OUTPUT + echo "ddraw-pdb=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/Release/ddraw.pdb")" >> $GITHUB_OUTPUT echo "::endgroup::" fi @@ -137,6 +144,7 @@ runs: "${{ steps.msbuild.outputs.exe }}" "$GITHUB_ACTION_PATH/cnc-ddraw.sln" -p:Configuration=ReleaseXP -p:Platform=x86 -p:PlatformToolset=v141_xp # echo "ddraw-dll=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/ReleaseXP/ddraw.dll")" >> $GITHUB_OUTPUT + echo "ddraw-pdb=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/ReleaseXP/ddraw.pdb")" >> $GITHUB_OUTPUT echo "::endgroup::" fi