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 ...
This commit is contained in:
parent
95aeedec19
commit
69137cff4c
|
@ -1028,6 +1028,59 @@ void CFrame::OnMouse(wxMouseEvent& event)
|
||||||
event.GetPosition().x, event.GetPosition().y, event.ButtonDown());
|
event.GetPosition().x, event.GetPosition().y, event.ButtonDown());
|
||||||
}
|
}
|
||||||
#endif
|
#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();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "Host.h"
|
#include "Host.h"
|
||||||
#include "VideoConfig.h"
|
#include "VideoConfig.h"
|
||||||
#include "../GLInterface.h"
|
#include "../GLInterface.h"
|
||||||
#include "VertexShaderManager.h"
|
|
||||||
|
|
||||||
#if USE_EGL
|
#if USE_EGL
|
||||||
bool cXInterface::ServerConnect(void)
|
bool cXInterface::ServerConnect(void)
|
||||||
|
@ -166,10 +165,6 @@ void cX11Window::DestroyXWindow(void)
|
||||||
void cX11Window::XEventThread()
|
void cX11Window::XEventThread()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Free look variables
|
|
||||||
static bool mouseLookEnabled = false;
|
|
||||||
static bool mouseMoveEnabled = false;
|
|
||||||
static float lastMouse[2];
|
|
||||||
while (GLWin.win)
|
while (GLWin.win)
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
@ -177,58 +172,6 @@ void cX11Window::XEventThread()
|
||||||
{
|
{
|
||||||
XNextEvent(GLWin.evdpy, &event);
|
XNextEvent(GLWin.evdpy, &event);
|
||||||
switch(event.type) {
|
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:
|
case ConfigureNotify:
|
||||||
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "VideoConfig.h"
|
#include "VideoConfig.h"
|
||||||
#include "EmuWindow.h"
|
#include "EmuWindow.h"
|
||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
#include "VertexShaderManager.h"
|
|
||||||
#include "VideoBackendBase.h"
|
#include "VideoBackendBase.h"
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "Host.h"
|
#include "Host.h"
|
||||||
|
@ -41,60 +40,8 @@ HWND GetParentWnd()
|
||||||
return m_hParent;
|
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 )
|
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
||||||
{
|
{
|
||||||
if (g_ActiveConfig.bFreeLook)
|
|
||||||
FreeLookInput( iMsg, wParam );
|
|
||||||
|
|
||||||
switch( iMsg )
|
switch( iMsg )
|
||||||
{
|
{
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
|
|
Loading…
Reference in New Issue