From fc625b5ffd78b26d64919fc772c5902304b8a904 Mon Sep 17 00:00:00 2001 From: DarkDrifter Date: Sun, 25 Sep 2022 16:31:37 +0200 Subject: [PATCH 1/7] Fix inverted Zoom In/Out bindings (Fixes #524) --- Client/core/CKeyBinds.cpp | 2 +- Client/sdk/game/CControllerConfigManager.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/core/CKeyBinds.cpp b/Client/core/CKeyBinds.cpp index dc6d5a8f3a1..abfe78b2d3c 100644 --- a/Client/core/CKeyBinds.cpp +++ b/Client/core/CKeyBinds.cpp @@ -185,8 +185,8 @@ SBindableGTAControl g_bcControls[] = {{"fire", FIRE, CONTROL_FOOT, false, true, {"backwards", BACKWARDS, CONTROL_FOOT, false, true, _td("Backwards")}, {"left", LEFT, CONTROL_FOOT, false, true, _td("Left")}, {"right", RIGHT, CONTROL_FOOT, false, true, _td("Right")}, - {"zoom_in", ZOOM_IN, CONTROL_FOOT, false, true, _td("Zoom in")}, {"zoom_out", ZOOM_OUT, CONTROL_FOOT, false, true, _td("Zoom out")}, + {"zoom_in", ZOOM_IN, CONTROL_FOOT, false, true, _td("Zoom in")}, {"enter_exit", ENTER_EXIT, CONTROL_BOTH, false, true, _td("Enter/Exit")}, {"change_camera", CHANGE_CAMERA, CONTROL_BOTH, false, true, _td("Change camera")}, // 10 {"jump", JUMP, CONTROL_FOOT, false, true, _td("Jump")}, diff --git a/Client/sdk/game/CControllerConfigManager.h b/Client/sdk/game/CControllerConfigManager.h index c6e7d0574cd..d10df2d14a2 100644 --- a/Client/sdk/game/CControllerConfigManager.h +++ b/Client/sdk/game/CControllerConfigManager.h @@ -150,8 +150,8 @@ enum eControllerAction BACKWARDS, LEFT, RIGHT, - ZOOM_IN, ZOOM_OUT, + ZOOM_IN, ENTER_EXIT, CHANGE_CAMERA, JUMP, From b106ed76516f68857e06b7affff20e6d4138c6b9 Mon Sep 17 00:00:00 2001 From: DarkDrifter Date: Sun, 25 Sep 2022 17:50:23 +0200 Subject: [PATCH 2/7] Revert "Fix inverted Zoom In/Out bindings (Fixes #524)" This reverts commit fc625b5ffd78b26d64919fc772c5902304b8a904. --- Client/core/CKeyBinds.cpp | 2 +- Client/sdk/game/CControllerConfigManager.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/core/CKeyBinds.cpp b/Client/core/CKeyBinds.cpp index abfe78b2d3c..dc6d5a8f3a1 100644 --- a/Client/core/CKeyBinds.cpp +++ b/Client/core/CKeyBinds.cpp @@ -185,8 +185,8 @@ SBindableGTAControl g_bcControls[] = {{"fire", FIRE, CONTROL_FOOT, false, true, {"backwards", BACKWARDS, CONTROL_FOOT, false, true, _td("Backwards")}, {"left", LEFT, CONTROL_FOOT, false, true, _td("Left")}, {"right", RIGHT, CONTROL_FOOT, false, true, _td("Right")}, - {"zoom_out", ZOOM_OUT, CONTROL_FOOT, false, true, _td("Zoom out")}, {"zoom_in", ZOOM_IN, CONTROL_FOOT, false, true, _td("Zoom in")}, + {"zoom_out", ZOOM_OUT, CONTROL_FOOT, false, true, _td("Zoom out")}, {"enter_exit", ENTER_EXIT, CONTROL_BOTH, false, true, _td("Enter/Exit")}, {"change_camera", CHANGE_CAMERA, CONTROL_BOTH, false, true, _td("Change camera")}, // 10 {"jump", JUMP, CONTROL_FOOT, false, true, _td("Jump")}, diff --git a/Client/sdk/game/CControllerConfigManager.h b/Client/sdk/game/CControllerConfigManager.h index d10df2d14a2..c6e7d0574cd 100644 --- a/Client/sdk/game/CControllerConfigManager.h +++ b/Client/sdk/game/CControllerConfigManager.h @@ -150,8 +150,8 @@ enum eControllerAction BACKWARDS, LEFT, RIGHT, - ZOOM_OUT, ZOOM_IN, + ZOOM_OUT, ENTER_EXIT, CHANGE_CAMERA, JUMP, From eb527d5b28134eb2e47d475480aa2c9dae89dc1b Mon Sep 17 00:00:00 2001 From: DarkDrifter Date: Sun, 25 Sep 2022 17:56:59 +0200 Subject: [PATCH 3/7] Better fix for inverted Zoom In/Out bindings (Fixes #524), also fixes Next/Previous Weapon bindings affecting Zoom In/Out when aiming --- Client/core/CKeyBinds.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Client/core/CKeyBinds.cpp b/Client/core/CKeyBinds.cpp index dc6d5a8f3a1..dea69723fce 100644 --- a/Client/core/CKeyBinds.cpp +++ b/Client/core/CKeyBinds.cpp @@ -1920,9 +1920,17 @@ void CKeyBinds::DoPostFramePulse() { if (!bInVehicle) { - cs.ButtonCircle = (g_bcControls[0].bState && !bHasDetonator) ? 255 : 0; // Fire - cs.RightShoulder2 = (g_bcControls[1].bState || (bAimingWeapon && g_bcControls[7].bState)) ? 255 : 0; // Next Weapon / Zoom In - cs.LeftShoulder2 = (g_bcControls[2].bState || (bAimingWeapon && g_bcControls[8].bState)) ? 255 : 0; // Previous Weapon / Zoom Out + cs.ButtonCircle = (g_bcControls[0].bState && !bHasDetonator) ? 255 : 0; // Fire + if (bAimingWeapon) + { + cs.RightShoulder2 = g_bcControls[8].bState ? 255 : 0; // Zoom Out + cs.LeftShoulder2 = g_bcControls[7].bState ? 255 : 0; // Zoom In + } + else + { + cs.RightShoulder2 = g_bcControls[1].bState ? 255 : 0; // Next Weapon + cs.LeftShoulder2 = g_bcControls[2].bState ? 255 : 0; // Previous Weapon + } if (!ControlForwardsBackWards(cs)) { From b0ed88cae8b438045edaa17b1939cb39790c32df Mon Sep 17 00:00:00 2001 From: DarkDrifter Date: Sun, 25 Sep 2022 18:11:18 +0200 Subject: [PATCH 4/7] Remove now useless HACK that prevents Zoom In/Out to be used with mouse wheel --- Client/core/CKeyBinds.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Client/core/CKeyBinds.cpp b/Client/core/CKeyBinds.cpp index dea69723fce..82183d5d5c4 100644 --- a/Client/core/CKeyBinds.cpp +++ b/Client/core/CKeyBinds.cpp @@ -1087,12 +1087,8 @@ void CKeyBinds::CallGTAControlBind(CGTAControlBind* pBind, bool bState) // If its keydown, or there isnt another bind for this control down if (bState || !GetMultiGTAControlState(pBind)) { - // HACK: Are we're trying to ZOOM IN or ZOOM OUT using the mouse wheel? - bool bZoomWheel = m_bMouseWheel && (pBind->control->action == ZOOM_IN || pBind->control->action == ZOOM_OUT); - // If this control is enabled - // HACK: Prevent the game from using the mouse wheel to zoom *again* (it still does this itself) - if (pBind->control->bEnabled && !bZoomWheel) + if (pBind->control->bEnabled) { pBind->control->bState = bState; } From 61125e75fa91cc50351601f24927492bb0849912 Mon Sep 17 00:00:00 2001 From: DarkDrifter Date: Tue, 27 Sep 2022 23:34:32 +0200 Subject: [PATCH 5/7] Fix weapon zoom getting affected by single player Fix weapon zoom in/out getting affected by single player key bindings. We now hook Direct Input scroll wheel data as the game seems to use this value rather than the windows messaging system to handle zoom. --- .../core/DXHook/CProxyDirectInputDevice8.cpp | 27 +++++++++++++++++++ Client/core/DXHook/CProxyDirectInputDevice8.h | 1 + 2 files changed, 28 insertions(+) diff --git a/Client/core/DXHook/CProxyDirectInputDevice8.cpp b/Client/core/DXHook/CProxyDirectInputDevice8.cpp index 83dd3c8cc79..b20d275fddd 100644 --- a/Client/core/DXHook/CProxyDirectInputDevice8.cpp +++ b/Client/core/DXHook/CProxyDirectInputDevice8.cpp @@ -19,6 +19,7 @@ CProxyDirectInputDevice8::CProxyDirectInputDevice8(IDirectInputDevice8A* pDevice // Initialize our device member variable. m_pDevice = pDevice; m_bDropDataIfInputGoesToGUI = true; + m_bIsMouse = false; // Don't block joystick if GUI wants input (so same as XInput joystick) DIDEVICEINSTANCE didi; @@ -31,13 +32,21 @@ CProxyDirectInputDevice8::CProxyDirectInputDevice8(IDirectInputDevice8A* pDevice uint uiHid = (didi.dwDevType >> 16) & 0xff; if (uiType == DI8DEVTYPE_GAMEPAD || uiType == DI8DEVTYPE_JOYSTICK) + { m_bDropDataIfInputGoesToGUI = false; + } + else if (uiType == DI8DEVTYPE_MOUSE) + { + m_bIsMouse = true; + } WriteDebugEvent(SString(" CProxyDirectInputDevice8 Device:%08x Type:0x%x SubType:0x%x HID:0x%x ProductName:%s", pDevice, uiType, uiSubType, uiHid, didi.tszProductName)); } else + { WriteDebugEvent(SString(" CProxyDirectInputDevice8 GetDeviceInfo failed:%08x", hResult)); + } } CProxyDirectInputDevice8::~CProxyDirectInputDevice8() @@ -124,6 +133,24 @@ HRESULT CProxyDirectInputDevice8::GetDeviceState(DWORD a, LPVOID b) } } + // HACK: Don't pass scroll wheel data to the game as it interfers with MTA key bindings + // Without this, zoom in/out with scroll wheel still happens when not bound to + // mouse wheel in MTA but bound in single player. + // A better option could be to instead give this data only when we want it (bound + // in MTA and when scrolling) to retain the proper smooth zoom, but it would require + // forcing the game to use this data even when not bound in single player. + if (m_bIsMouse) + { + hResult = m_pDevice->GetDeviceState(a, b); + + DIMOUSESTATE2* mouseState = reinterpret_cast(b); + mouseState->lZ = 0; + + m_pDevice->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), NULL, &dwNumItems, 0); + + return hResult; + } + return m_pDevice->GetDeviceState(a, b); } diff --git a/Client/core/DXHook/CProxyDirectInputDevice8.h b/Client/core/DXHook/CProxyDirectInputDevice8.h index 347b073a074..d48d4bbb866 100644 --- a/Client/core/DXHook/CProxyDirectInputDevice8.h +++ b/Client/core/DXHook/CProxyDirectInputDevice8.h @@ -57,4 +57,5 @@ class CProxyDirectInputDevice8 : public IDirectInputDevice8A IDirectInputDevice8A* m_pDevice; bool m_bDropDataIfInputGoesToGUI; + bool m_bIsMouse; }; From 12026e0dd03d92b43077c861b5c094bd65ccf37e Mon Sep 17 00:00:00 2001 From: DarkDrifter Date: Wed, 28 Sep 2022 21:16:24 +0200 Subject: [PATCH 6/7] Revert "Fix weapon zoom getting affected by single player" This reverts commit 61125e75fa91cc50351601f24927492bb0849912. --- .../core/DXHook/CProxyDirectInputDevice8.cpp | 27 ------------------- Client/core/DXHook/CProxyDirectInputDevice8.h | 1 - 2 files changed, 28 deletions(-) diff --git a/Client/core/DXHook/CProxyDirectInputDevice8.cpp b/Client/core/DXHook/CProxyDirectInputDevice8.cpp index b20d275fddd..83dd3c8cc79 100644 --- a/Client/core/DXHook/CProxyDirectInputDevice8.cpp +++ b/Client/core/DXHook/CProxyDirectInputDevice8.cpp @@ -19,7 +19,6 @@ CProxyDirectInputDevice8::CProxyDirectInputDevice8(IDirectInputDevice8A* pDevice // Initialize our device member variable. m_pDevice = pDevice; m_bDropDataIfInputGoesToGUI = true; - m_bIsMouse = false; // Don't block joystick if GUI wants input (so same as XInput joystick) DIDEVICEINSTANCE didi; @@ -32,21 +31,13 @@ CProxyDirectInputDevice8::CProxyDirectInputDevice8(IDirectInputDevice8A* pDevice uint uiHid = (didi.dwDevType >> 16) & 0xff; if (uiType == DI8DEVTYPE_GAMEPAD || uiType == DI8DEVTYPE_JOYSTICK) - { m_bDropDataIfInputGoesToGUI = false; - } - else if (uiType == DI8DEVTYPE_MOUSE) - { - m_bIsMouse = true; - } WriteDebugEvent(SString(" CProxyDirectInputDevice8 Device:%08x Type:0x%x SubType:0x%x HID:0x%x ProductName:%s", pDevice, uiType, uiSubType, uiHid, didi.tszProductName)); } else - { WriteDebugEvent(SString(" CProxyDirectInputDevice8 GetDeviceInfo failed:%08x", hResult)); - } } CProxyDirectInputDevice8::~CProxyDirectInputDevice8() @@ -133,24 +124,6 @@ HRESULT CProxyDirectInputDevice8::GetDeviceState(DWORD a, LPVOID b) } } - // HACK: Don't pass scroll wheel data to the game as it interfers with MTA key bindings - // Without this, zoom in/out with scroll wheel still happens when not bound to - // mouse wheel in MTA but bound in single player. - // A better option could be to instead give this data only when we want it (bound - // in MTA and when scrolling) to retain the proper smooth zoom, but it would require - // forcing the game to use this data even when not bound in single player. - if (m_bIsMouse) - { - hResult = m_pDevice->GetDeviceState(a, b); - - DIMOUSESTATE2* mouseState = reinterpret_cast(b); - mouseState->lZ = 0; - - m_pDevice->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), NULL, &dwNumItems, 0); - - return hResult; - } - return m_pDevice->GetDeviceState(a, b); } diff --git a/Client/core/DXHook/CProxyDirectInputDevice8.h b/Client/core/DXHook/CProxyDirectInputDevice8.h index d48d4bbb866..347b073a074 100644 --- a/Client/core/DXHook/CProxyDirectInputDevice8.h +++ b/Client/core/DXHook/CProxyDirectInputDevice8.h @@ -57,5 +57,4 @@ class CProxyDirectInputDevice8 : public IDirectInputDevice8A IDirectInputDevice8A* m_pDevice; bool m_bDropDataIfInputGoesToGUI; - bool m_bIsMouse; }; From 817675cab54e904bbd71b219b4b2a933e4d56f3e Mon Sep 17 00:00:00 2001 From: DarkDrifter Date: Tue, 4 Oct 2022 21:58:31 +0200 Subject: [PATCH 7/7] Revert "Remove now useless HACK that prevents Zoom In/Out to be used with mouse wheel" This reverts commit b0ed88cae8b438045edaa17b1939cb39790c32df. --- Client/core/CKeyBinds.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Client/core/CKeyBinds.cpp b/Client/core/CKeyBinds.cpp index 82183d5d5c4..dea69723fce 100644 --- a/Client/core/CKeyBinds.cpp +++ b/Client/core/CKeyBinds.cpp @@ -1087,8 +1087,12 @@ void CKeyBinds::CallGTAControlBind(CGTAControlBind* pBind, bool bState) // If its keydown, or there isnt another bind for this control down if (bState || !GetMultiGTAControlState(pBind)) { + // HACK: Are we're trying to ZOOM IN or ZOOM OUT using the mouse wheel? + bool bZoomWheel = m_bMouseWheel && (pBind->control->action == ZOOM_IN || pBind->control->action == ZOOM_OUT); + // If this control is enabled - if (pBind->control->bEnabled) + // HACK: Prevent the game from using the mouse wheel to zoom *again* (it still does this itself) + if (pBind->control->bEnabled && !bZoomWheel) { pBind->control->bState = bState; }