From 69137cff4c58fbdfcb2b67ad51d2d68cc8ca0cbc Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 29 Nov 2013 06:09:54 +0100 Subject: [PATCH] Merge X11+D3D FreeLook feature into DolphinWX This removes the redundant code and also implements this feature for OSX and Wayland. But so it's dropped for non-wx builds... imo DolphinWX still isn't the best place for this, but now it's in the same file as all other hotkeys. Maybe they'll be moved to InputCommon sometimes at once ... --- Source/Core/DolphinWX/Src/Frame.cpp | 53 +++++++++++++++++ .../DolphinWX/Src/GLInterface/X11_Util.cpp | 57 ------------------- Source/Core/VideoCommon/Src/EmuWindow.cpp | 53 ----------------- 3 files changed, 53 insertions(+), 110 deletions(-) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 1ca16ff1ac..5a255567d5 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -1028,6 +1028,59 @@ void CFrame::OnMouse(wxMouseEvent& event) event.GetPosition().x, event.GetPosition().y, event.ButtonDown()); } #endif + + // next handlers are all for FreeLook, so we don't need to check them if disabled + if(!g_Config.bFreeLook) + { + event.Skip(); + return; + } + + // Free look variables + static bool mouseLookEnabled = false; + static bool mouseMoveEnabled = false; + static float lastMouse[2]; + + if(event.MiddleDown()) + { + lastMouse[0] = event.GetX(); + lastMouse[1] = event.GetY(); + mouseMoveEnabled = true; + } + else if(event.RightDown()) + { + lastMouse[0] = event.GetX(); + lastMouse[1] = event.GetY(); + mouseLookEnabled = true; + } + else if(event.MiddleUp()) + { + mouseMoveEnabled = false; + } + else if(event.RightUp()) + { + mouseLookEnabled = false; + } + // no button, so it's a move event + else if(event.GetButton() == wxMOUSE_BTN_NONE) + { + if (mouseLookEnabled) + { + VertexShaderManager::RotateView((event.GetX() - lastMouse[0]) / 200.0f, + (event.GetY() - lastMouse[1]) / 200.0f); + lastMouse[0] = event.GetX(); + lastMouse[1] = event.GetY(); + } + + if (mouseMoveEnabled) + { + VertexShaderManager::TranslateView((event.GetX() - lastMouse[0]) / 50.0f, + (event.GetY() - lastMouse[1]) / 50.0f); + lastMouse[0] = event.GetX(); + lastMouse[1] = event.GetY(); + } + } + event.Skip(); } diff --git a/Source/Core/DolphinWX/Src/GLInterface/X11_Util.cpp b/Source/Core/DolphinWX/Src/GLInterface/X11_Util.cpp index e57c095d86..e3ea3f3c90 100644 --- a/Source/Core/DolphinWX/Src/GLInterface/X11_Util.cpp +++ b/Source/Core/DolphinWX/Src/GLInterface/X11_Util.cpp @@ -18,7 +18,6 @@ #include "Host.h" #include "VideoConfig.h" #include "../GLInterface.h" -#include "VertexShaderManager.h" #if USE_EGL bool cXInterface::ServerConnect(void) @@ -166,10 +165,6 @@ void cX11Window::DestroyXWindow(void) void cX11Window::XEventThread() #endif { - // Free look variables - static bool mouseLookEnabled = false; - static bool mouseMoveEnabled = false; - static float lastMouse[2]; while (GLWin.win) { XEvent event; @@ -177,58 +172,6 @@ void cX11Window::XEventThread() { XNextEvent(GLWin.evdpy, &event); switch(event.type) { - case ButtonPress: - if (g_Config.bFreeLook) - { - switch (event.xbutton.button) - { - case 2: // Middle button - lastMouse[0] = event.xbutton.x; - lastMouse[1] = event.xbutton.y; - mouseMoveEnabled = true; - break; - case 3: // Right button - lastMouse[0] = event.xbutton.x; - lastMouse[1] = event.xbutton.y; - mouseLookEnabled = true; - break; - } - } - break; - case ButtonRelease: - if (g_Config.bFreeLook) - { - switch (event.xbutton.button) - { - case 2: // Middle button - mouseMoveEnabled = false; - break; - case 3: // Right button - mouseLookEnabled = false; - break; - } - } - break; - case MotionNotify: - if (g_Config.bFreeLook) - { - if (mouseLookEnabled) - { - VertexShaderManager::RotateView((event.xmotion.x - lastMouse[0]) / 200.0f, - (event.xmotion.y - lastMouse[1]) / 200.0f); - lastMouse[0] = event.xmotion.x; - lastMouse[1] = event.xmotion.y; - } - - if (mouseMoveEnabled) - { - VertexShaderManager::TranslateView((event.xmotion.x - lastMouse[0]) / 50.0f, - (event.xmotion.y - lastMouse[1]) / 50.0f); - lastMouse[0] = event.xmotion.x; - lastMouse[1] = event.xmotion.y; - } - } - break; case ConfigureNotify: GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height); break; diff --git a/Source/Core/VideoCommon/Src/EmuWindow.cpp b/Source/Core/VideoCommon/Src/EmuWindow.cpp index 9b8cde5178..7bb675789e 100644 --- a/Source/Core/VideoCommon/Src/EmuWindow.cpp +++ b/Source/Core/VideoCommon/Src/EmuWindow.cpp @@ -7,7 +7,6 @@ #include "VideoConfig.h" #include "EmuWindow.h" #include "Fifo.h" -#include "VertexShaderManager.h" #include "VideoBackendBase.h" #include "Core.h" #include "Host.h" @@ -41,60 +40,8 @@ HWND GetParentWnd() return m_hParent; } -void FreeLookInput( UINT iMsg, WPARAM wParam ) -{ - static bool mouseLookEnabled = false; - static bool mouseMoveEnabled = false; - static float lastMouse[2]; - POINT point; - - switch(iMsg) - { - case WM_MOUSEMOVE: - if (mouseLookEnabled) - { - GetCursorPos(&point); - VertexShaderManager::RotateView((point.x - lastMouse[0]) / 200.0f, (point.y - lastMouse[1]) / 200.0f); - lastMouse[0] = (float)point.x; - lastMouse[1] = (float)point.y; - } - - if (mouseMoveEnabled) - { - GetCursorPos(&point); - VertexShaderManager::TranslateView((point.x - lastMouse[0]) / 50.0f, (point.y - lastMouse[1]) / 50.0f); - lastMouse[0] = (float)point.x; - lastMouse[1] = (float)point.y; - } - break; - - case WM_RBUTTONDOWN: - GetCursorPos(&point); - lastMouse[0] = (float)point.x; - lastMouse[1] = (float)point.y; - mouseLookEnabled= true; - break; - case WM_MBUTTONDOWN: - GetCursorPos(&point); - lastMouse[0] = (float)point.x; - lastMouse[1] = (float)point.y; - mouseMoveEnabled= true; - break; - case WM_RBUTTONUP: - mouseLookEnabled = false; - break; - case WM_MBUTTONUP: - mouseMoveEnabled = false; - break; - } -} - - LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) { - if (g_ActiveConfig.bFreeLook) - FreeLookInput( iMsg, wParam ); - switch( iMsg ) { case WM_PAINT: