mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Qt: Implement "Free look"
This commit is contained in:
parent
e51cf8870e
commit
bc51c34a96
@ -6,12 +6,16 @@
|
||||
#include <QDesktopWidget>
|
||||
#include <QGuiApplication>
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QPalette>
|
||||
#include <QScreen>
|
||||
#include <QTimer>
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "VideoCommon/VertexShaderManager.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
#include "DolphinQt2/Host.h"
|
||||
#include "DolphinQt2/RenderWidget.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
@ -120,6 +124,10 @@ bool RenderWidget::event(QEvent* event)
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseMove:
|
||||
if (g_Config.bFreeLook)
|
||||
OnFreeLookMouseMove(static_cast<QMouseEvent*>(event));
|
||||
|
||||
// [[fallthrough]]
|
||||
case QEvent::MouseButtonPress:
|
||||
if (!Settings::Instance().GetHideCursor() && isActiveWindow())
|
||||
{
|
||||
@ -162,3 +170,22 @@ bool RenderWidget::event(QEvent* event)
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void RenderWidget::OnFreeLookMouseMove(QMouseEvent* event)
|
||||
{
|
||||
if (event->buttons() & Qt::MidButton)
|
||||
{
|
||||
// Mouse Move
|
||||
VertexShaderManager::TranslateView((event->x() - m_last_mouse[0]) / 50.0f,
|
||||
(event->y() - m_last_mouse[1]) / 50.0f);
|
||||
}
|
||||
else if (event->buttons() & Qt::RightButton)
|
||||
{
|
||||
// Mouse Look
|
||||
VertexShaderManager::RotateView((event->x() - m_last_mouse[0]) / 200.0f,
|
||||
(event->y() - m_last_mouse[1]) / 200.0f);
|
||||
}
|
||||
|
||||
m_last_mouse[0] = event->x();
|
||||
m_last_mouse[1] = event->y();
|
||||
}
|
||||
|
@ -4,9 +4,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QWidget>
|
||||
|
||||
class QMouseEvent;
|
||||
class QTimer;
|
||||
|
||||
class RenderWidget final : public QWidget
|
||||
@ -31,7 +34,9 @@ private:
|
||||
void OnHideCursorChanged();
|
||||
void OnKeepOnTopChanged(bool top);
|
||||
void SetFillBackground(bool fill);
|
||||
void OnFreeLookMouseMove(QMouseEvent* event);
|
||||
|
||||
static constexpr int MOUSE_HIDE_DELAY = 3000;
|
||||
QTimer* m_mouse_timer;
|
||||
std::array<float, 2> m_last_mouse{};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user