From 240dc03dd5874146cce431d824c6e5e965c88434 Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Wed, 10 Feb 2021 20:06:12 +0100 Subject: [PATCH] Add support for mouse input as cursor position relative to the rendering window --- src/common/Settings.cpp | 9 +-- src/common/input/Button.cpp | 24 +++++-- src/common/input/DInputKeyboardMouse.cpp | 35 ++++++++++ src/common/input/DInputKeyboardMouse.h | 25 ++++++++ src/common/input/InputDevice.h | 1 + src/common/input/InputManager.cpp | 9 ++- src/common/input/InputManager.h | 4 +- src/common/input/InputWindow.cpp | 64 ++++++++++++++++++- src/common/input/InputWindow.h | 2 + src/common/util/CxbxUtil.cpp | 24 +++++++ src/common/util/CxbxUtil.h | 2 + src/core/kernel/init/CxbxKrnl.cpp | 2 +- src/gui/DlgInputConfig.cpp | 2 +- .../controllers/DlgDukeControllerConfig.cpp | 3 +- src/gui/controllers/DlgSBControllerConfig.cpp | 3 +- 15 files changed, 190 insertions(+), 19 deletions(-) diff --git a/src/common/Settings.cpp b/src/common/Settings.cpp index d7ea2cb38..dd47a9b5f 100644 --- a/src/common/Settings.cpp +++ b/src/common/Settings.cpp @@ -947,12 +947,9 @@ void Settings::RemoveLegacyConfigs(unsigned int CurrentRevision) std::string current_section = std::string(section_input_port) + std::to_string(port_num); std::string device_name = m_si.GetValue(current_section.c_str(), sect_input_port.device, ""); - // NOTE: with C++20, this can be simplified by simply calling device_name.ends_with() - if (device_name.length() >= kb_str.length()) { - if (device_name.compare(device_name.length() - kb_str.length(), kb_str.length(), kb_str) == 0) { - device_name += "Mouse"; - m_si.SetValue(current_section.c_str(), sect_input_port.device, device_name.c_str(), nullptr, true); - } + if (StrEndsWith(device_name, kb_str)) { + device_name += "Mouse"; + m_si.SetValue(current_section.c_str(), sect_input_port.device, device_name.c_str(), nullptr, true); } } diff --git a/src/common/input/Button.cpp b/src/common/input/Button.cpp index 643974378..d793b0e31 100644 --- a/src/common/input/Button.cpp +++ b/src/common/input/Button.cpp @@ -63,10 +63,16 @@ LRESULT CALLBACK ButtonDukeSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA case WM_RBUTTONDOWN: { Button *button = reinterpret_cast