Files
eden/src/yuzu/bootmanager.h
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

192 lines
5.3 KiB
C++
Raw Normal View History

// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
2022-05-15 02:06:02 +02:00
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2015-01-04 09:36:57 -08:00
#pragma once
2023-05-02 16:54:19 -04:00
#include <cstddef>
#include <memory>
2023-05-02 16:54:19 -04:00
#include <utility>
2023-05-02 16:54:19 -04:00
#include <QByteArray>
2018-08-31 14:16:16 +08:00
#include <QImage>
2023-05-02 16:54:19 -04:00
#include <QObject>
#include <QPoint>
#include <QString>
#include <QStringList>
2015-09-11 00:23:00 -04:00
#include <QThread>
#include <QTimer>
2019-01-11 21:06:34 -07:00
#include <QWidget>
2023-05-02 16:54:19 -04:00
#include <qglobal.h>
#include <qnamespace.h>
#include <qobjectdefs.h>
2023-05-02 16:54:19 -04:00
#include "common/common_types.h"
2016-12-23 13:37:40 +00:00
#include "core/frontend/emu_window.h"
2014-03-31 22:26:50 -04:00
class MainWindow;
2022-06-18 23:34:28 -05:00
class QCamera;
class QImageCapture;
class QMediaCaptureSession;
2023-05-02 16:54:19 -04:00
class QCloseEvent;
class QFocusEvent;
2014-03-31 22:26:50 -04:00
class QKeyEvent;
2023-05-02 16:54:19 -04:00
class QMouseEvent;
class QObject;
class QResizeEvent;
class QShowEvent;
class QTouchEvent;
class QWheelEvent;
2014-03-31 22:26:50 -04:00
class EmuThread;
namespace Core {
class System;
} // namespace Core
2020-08-27 15:16:47 -04:00
namespace InputCommon {
class InputSubsystem;
2021-02-23 20:39:02 -06:00
enum class MouseButton;
2021-09-20 19:39:08 -05:00
} // namespace InputCommon
2021-02-23 20:39:02 -06:00
2021-11-21 22:37:50 -06:00
namespace InputCommon::TasInput {
enum class TasState;
} // namespace InputCommon::TasInput
namespace VideoCore {
enum class LoadCallbackStage;
} // namespace VideoCore
2018-08-11 20:20:19 -04:00
class GRenderWindow : public QWidget, public Core::Frontend::EmuWindow {
2014-08-25 00:47:00 +10:00
Q_OBJECT
2014-03-31 22:26:50 -04:00
public:
explicit GRenderWindow(MainWindow* parent,
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_);
~GRenderWindow() override;
2014-03-31 22:26:50 -04:00
// EmuWindow implementation.
void OnFrameDisplayed() override;
2020-01-21 16:40:53 -03:00
bool IsShown() const override;
2019-01-11 21:06:34 -07:00
std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;
2014-03-31 22:26:50 -04:00
void BackupGeometry();
void RestoreGeometry();
2022-05-26 19:57:35 -04:00
void restoreGeometry(const QByteArray& geometry_); // overridden
QByteArray saveGeometry(); // overridden
2014-03-31 22:26:50 -04:00
qreal windowPixelRatio() const;
2023-02-19 17:52:44 -06:00
std::pair<u32, u32> ScaleTouch(const QPointF& pos) const;
2015-09-05 12:29:44 +02:00
void closeEvent(QCloseEvent* event) override;
void leaveEvent(QEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
2024-01-15 23:26:53 +00:00
/// Converts a Qt keyboard key into NativeKeyboard key
static int QtKeyToSwitchKey(Qt::Key qt_keys);
/// Converts a Qt modifier keys into NativeKeyboard modifier keys
static int QtModifierToSwitchModifier(Qt::KeyboardModifiers qt_modifiers);
void keyPressEvent(QKeyEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override;
2021-02-23 20:39:02 -06:00
/// Converts a Qt mouse button into MouseInput mouse button
2021-09-20 19:39:08 -05:00
static InputCommon::MouseButton QtButtonToMouseButton(Qt::MouseButton button);
2021-02-23 20:39:02 -06:00
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
2021-11-14 14:09:29 -06:00
void wheelEvent(QWheelEvent* event) override;
2022-06-18 23:34:28 -05:00
void InitializeCamera();
void FinalizeCamera();
2018-10-01 22:42:49 +03:00
bool event(QEvent* event) override;
void focusOutEvent(QFocusEvent* event) override;
2020-01-21 16:40:53 -03:00
bool InitRenderTarget();
/// Destroy the previous run's child_widget which should also destroy the child_window
void ReleaseRenderTarget();
bool IsLoadingComplete() const;
void CaptureScreenshot(const QString& screenshot_path);
2018-08-31 14:16:16 +08:00
/**
* Instructs the window to re-launch the application using the specified program_index.
* @param program_index Specifies the index within the application of the program to launch.
*/
void ExecuteProgram(std::size_t program_index);
2021-09-25 23:18:14 -04:00
/// Instructs the window to exit the application.
void Exit();
public slots:
2015-09-04 15:55:48 +02:00
void OnFramebufferSizeChanged();
2015-09-05 12:29:44 +02:00
signals:
/// Emitted when the window is closed
void Closed();
void FirstFrameDisplayed();
void ExecuteProgramSignal(std::size_t program_index);
2021-09-25 23:18:14 -04:00
void ExitSignal();
void MouseActivity();
2021-11-21 17:28:47 -08:00
void TasPlaybackStateChanged();
2015-09-05 12:29:44 +02:00
2014-03-31 22:26:50 -04:00
private:
2018-10-01 22:42:49 +03:00
void TouchBeginEvent(const QTouchEvent* event);
void TouchUpdateEvent(const QTouchEvent* event);
void TouchEndEvent();
void ConstrainMouse();
2018-10-01 22:42:49 +03:00
2022-06-18 23:34:28 -05:00
void RequestCameraCapture();
void OnCameraCapture(int requestId, const QImage& img);
2019-05-29 02:02:36 -04:00
void OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) override;
2020-01-21 16:40:53 -03:00
bool InitializeOpenGL();
bool InitializeVulkan();
2022-11-27 20:37:37 -05:00
void InitializeNull();
2020-01-21 16:40:53 -03:00
bool LoadOpenGL();
QStringList GetUnsupportedGLExtensions() const;
2014-03-31 22:26:50 -04:00
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem;
2020-03-24 20:58:49 -06:00
// Main context that will be shared with all other contexts that are requested.
// If this is used in a shared context setting, then this should not be used directly, but
// should instead be shared from
std::shared_ptr<Core::Frontend::GraphicsContext> main_context;
2015-09-04 15:55:48 +02:00
2018-08-31 14:16:16 +08:00
/// Temporary storage of the screenshot taken
QImage screenshot_image;
2020-01-21 16:40:53 -03:00
QByteArray geometry;
QWidget* child_widget = nullptr;
bool first_frame = false;
2021-11-21 22:37:50 -06:00
InputCommon::TasInput::TasState last_tas_state;
#if YUZU_USE_QT_MULTIMEDIA
2022-12-17 23:54:47 -06:00
bool is_virtual_camera;
int pending_camera_snapshots;
std::vector<u32> camera_data;
2022-12-17 23:54:47 -06:00
std::unique_ptr<QCamera> camera;
std::unique_ptr<QImageCapture> camera_capture;
std::unique_ptr<QMediaCaptureSession> capture_session;
2022-06-18 23:34:28 -05:00
std::unique_ptr<QTimer> camera_timer;
2022-12-17 23:54:47 -06:00
#endif
2022-06-18 23:34:28 -05:00
QTimer mouse_constrain_timer;
2015-09-04 15:55:48 +02:00
protected:
void showEvent(QShowEvent* event) override;
bool eventFilter(QObject* object, QEvent* event) override;
2014-03-31 22:26:50 -04:00
};