From 4f965da4f185e654d20838f75321c5a3fe68356f Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 28 Mar 2015 11:08:25 +1100 Subject: [PATCH 1/2] Revert the recent changes related to updating hwnd --- Source/Core/Core/Core.cpp | 20 +++---------------- Source/Core/Core/HotkeyManager.h | 2 ++ Source/Core/DolphinWX/InputConfigDiag.cpp | 3 --- .../ControllerInterface.cpp | 7 +------ .../ControllerInterface/ControllerInterface.h | 3 --- 5 files changed, 6 insertions(+), 29 deletions(-) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index ec47ca09c9..113ac0e553 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -26,7 +26,6 @@ #include "Core/CoreTiming.h" #include "Core/DSPEmulator.h" #include "Core/Host.h" -#include "Core/HotkeyManager.h" #include "Core/MemTools.h" #include "Core/Movie.h" #include "Core/NetPlayProto.h" @@ -97,7 +96,6 @@ static bool s_is_stopping = false; static bool s_hardware_initialized = false; static bool s_is_started = false; static void* s_window_handle = nullptr; -static bool s_window_handle_changed = false; static std::string s_state_filename; static std::thread s_emu_thread; static StoppedCallbackFunc s_on_stopped_callback = nullptr; @@ -230,12 +228,7 @@ bool Init() !!SConfig::GetInstance().m_SYSCONF->GetData("IPL.AR")); } - s_window_handle_changed = false; - if (s_window_handle != Host_GetRenderHandle()) - { - s_window_handle = Host_GetRenderHandle(); - s_window_handle_changed = true; - } + s_window_handle = Host_GetRenderHandle(); // Start the emu thread s_emu_thread = std::thread(EmuThread); @@ -437,11 +430,6 @@ void EmuThread() else { // Update references in case controllers were refreshed - if (s_window_handle_changed) - { - g_controller_interface.Initialize(s_window_handle); - HotkeyManagerEmu::LoadConfig(); - } Pad::LoadConfig(); Keyboard::LoadConfig(); } @@ -456,10 +444,9 @@ void EmuThread() // Activate Wiimotes which don't have source set to "None" for (unsigned int i = 0; i != MAX_BBMOTES; ++i) - { if (g_wiimote_sources[i]) GetUsbPointer()->AccessWiiMote(i | 0x100)->Activate(true); - } + } AudioCommon::InitSoundStream(); @@ -570,8 +557,7 @@ void EmuThread() if (init_controllers) { - if (core_parameter.bWii) - Wiimote::Shutdown(); + Wiimote::Shutdown(); Keyboard::Shutdown(); Pad::Shutdown(); init_controllers = false; diff --git a/Source/Core/Core/HotkeyManager.h b/Source/Core/Core/HotkeyManager.h index 4054a4fac5..bd76395046 100644 --- a/Source/Core/Core/HotkeyManager.h +++ b/Source/Core/Core/HotkeyManager.h @@ -39,4 +39,6 @@ namespace HotkeyManagerEmu bool IsEnabled(); void Enable(bool enable_toggle); bool IsPressed(int Id, bool held); + + static bool enabled; } diff --git a/Source/Core/DolphinWX/InputConfigDiag.cpp b/Source/Core/DolphinWX/InputConfigDiag.cpp index 4997ca318e..4c3d70c99a 100644 --- a/Source/Core/DolphinWX/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/InputConfigDiag.cpp @@ -1060,9 +1060,6 @@ GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const unsigned i mapping->Add(dio, 1, wxEXPAND|wxLEFT|wxTOP|wxBOTTOM, 5); mapping->Add(control_group_sizer, 0, wxLEFT|wxEXPAND, 5); - wxCommandEvent event; - RefreshDevices(event); - UpdateGUI(); SetSizerAndFit(mapping); // needed diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index a3c14a0ab5..1330cb1e0a 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -44,7 +44,7 @@ ControllerInterface g_controller_interface; void ControllerInterface::Initialize(void* const hwnd) { if (m_is_init) - DeInit(); + return; m_hwnd = hwnd; @@ -102,11 +102,6 @@ void ControllerInterface::Shutdown() delete d; } - DeInit(); -} - -void ControllerInterface::DeInit() -{ m_devices.clear(); #ifdef CIFACE_USE_XINPUT diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index 1b2c93951f..9ab8427ad2 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -117,9 +117,6 @@ public: void Initialize(void* const hwnd); void Reinitialize(); void Shutdown(); - - void DeInit(); - bool IsInit() const { return m_is_init; } void UpdateReference(ControlReference* control, const ciface::Core::DeviceQualifier& default_device) const; From 9947324296d942897b5248bd5651cddbd9078751 Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 28 Mar 2015 11:38:14 +1100 Subject: [PATCH 2/2] Track the co-ordinates of the mouse relative to the pointed window instead of the original hwnd. --- .../ControllerInterface/DInput/DInputKeyboardMouse.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp index c96e51a830..af4e3f0981 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp @@ -31,11 +31,11 @@ static const struct }; // lil silly -static HWND hwnd; +static HWND m_hwnd; void InitKeyboardMouse(IDirectInput8* const idi8, std::vector& devices, HWND _hwnd) { - hwnd = _hwnd; + m_hwnd = _hwnd; // mouse and keyboard are a combined device, to allow shift+click and stuff // if that's dumb, I will make a VirtualDevice class that just uses ranges of inputs/outputs from other devices @@ -124,10 +124,11 @@ void GetMousePos(ControlState* const x, ControlState* const y) { POINT point = { 1, 1 }; GetCursorPos(&point); - // Get the cursor position relative to the upper left corner of the rendering window + // Get the cursor position relative to the upper left corner of the current window (separate or render to main) + HWND hwnd = WindowFromPoint(point); ScreenToClient(hwnd, &point); - // Get the size of the rendering window. (In my case Rect.top and Rect.left was zero.) + // Get the size of the current window. (In my case Rect.top and Rect.left was zero.) RECT rect; GetClientRect(hwnd, &rect); // Width and height is the size of the rendering window