Debian Codegraph @

Source/Core/DolphinQt/GBAWidget.h

raw symbols SCIP
1 // Copyright 2021 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #ifdef HAS_LIBMGBA
7
8 #include <memory>
9 #include <optional>
10 #include <span>
11 #include <string>
12 #include <string_view>
13 #include <vector>
14
15 #include <QImage>
16 #include <QPoint>
17 #include <QWidget>
18
19 #include "Common/CommonTypes.h"
20 #include "Core/HW/GBACore.h"
21
22 class QCloseEvent;
23 class QContextMenuEvent;
24 class QDragEnterEvent;
25 class QDropEvent;
26 class QMouseEvent;
27 class QPaintEvent;
28
29 namespace NetPlay
30 {
31 struct PadDetails;
32 } // namespace NetPlay
33
34 class GBAWidget : public QWidget
35 {
36 Q_OBJECT
37 public:
38 explicit GBAWidget(std::weak_ptr<HW::GBA::Core> core, const HW::GBA::CoreInfo& info,
39 const std::optional<NetPlay::PadDetails>& netplay_pad);
40 ~GBAWidget() override;
41
42 void GameChanged(const HW::GBA::CoreInfo& info);
43 void SetVideoBuffer(std::span<const u32> video_buffer);
44
45 void SetVolume(int volume);
46 void VolumeDown();
47 void VolumeUp();
48 bool IsMuted();
49 void ToggleMute();
50 void ToggleDisconnect();
51
52 void LoadROM();
53 void UnloadROM();
54 void PromptForEReaderCards();
55 void ResetCore();
56 void DoState(bool export_state);
57 void ImportExportSave(bool export_save);
58 void Resize(int scale);
59
60 bool IsBorderless() const;
61 void SetBorderless(bool enable);
62
63 bool IsAlwaysOnTop() const;
64 void SetAlwaysOnTop(bool enable);
65
66 private:
67 void UpdateTitle();
68 void UpdateVolume();
69
70 static Qt::WindowFlags LoadWindowFlags(int device_number);
71 void LoadSettings();
72 void SaveSettings();
73
74 bool CanControlCore();
75 bool CanResetCore();
76
77 void closeEvent(QCloseEvent* event) override;
78 void contextMenuEvent(QContextMenuEvent* event) override;
79 void mouseDoubleClickEvent(QMouseEvent* event) override;
80 void mousePressEvent(QMouseEvent* event) override;
81 void mouseReleaseEvent(QMouseEvent* event) override;
82 void mouseMoveEvent(QMouseEvent* event) override;
83 void paintEvent(QPaintEvent* event) override;
84
85 void dragEnterEvent(QDragEnterEvent* event) override;
86 void dropEvent(QDropEvent* event) override;
87
88 std::weak_ptr<HW::GBA::Core> m_core;
89 HW::GBA::CoreInfo m_core_info;
90 QImage m_last_frame;
91 QImage m_previous_frame;
92 int m_local_pad;
93 bool m_is_local_pad;
94 std::string m_netplayer_name;
95 int m_volume;
96 bool m_muted;
97 bool m_force_disconnect;
98 bool m_moving;
99 QPoint m_move_pos;
100 bool m_interframe_blending;
101 };
102
103 class GBAWidgetController : public QObject
104 {
105 Q_OBJECT
106 public:
107 explicit GBAWidgetController() = default;
108 ~GBAWidgetController() override;
109
110 void Create(std::weak_ptr<HW::GBA::Core> core, const HW::GBA::CoreInfo& info);
111 void GameChanged(const HW::GBA::CoreInfo& info);
112 void FrameEnded(std::span<const u32> video_buffer);
113
114 private:
115 GBAWidget* m_widget{};
116 };
117 #endif // HAS_LIBMGBA