Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/EmuScreen.h
5673 views
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include <list>
21
#include <string>
22
#include <vector>
23
24
#include "Common/File/Path.h"
25
#include "Common/Input/KeyCodes.h"
26
#include "Common/UI/Screen.h"
27
#include "Common/UI/UIScreen.h"
28
#include "Common/UI/Tween.h"
29
#include "Core/KeyMap.h"
30
#include "Core/ControlMapper.h"
31
32
#include "UI/ImDebugger/ImDebugger.h"
33
34
struct AxisInput;
35
36
class AsyncImageFileView;
37
class ChatMenu;
38
39
class EmuScreen : public UIScreen {
40
public:
41
EmuScreen(const Path &filename);
42
~EmuScreen();
43
44
const char *tag() const override { return "Emu"; }
45
46
void update() override;
47
ScreenRenderFlags render(ScreenRenderMode mode) override;
48
void dialogFinished(const Screen *dialog, DialogResult result) override;
49
void sendMessage(UIMessage message, const char *value) override;
50
void resized() override;
51
ScreenRenderRole renderRole(bool isTop) const override;
52
53
// Note: Unlike your average boring UIScreen, here we override the Unsync* functions
54
// to get minimal latency and full control. We forward to UIScreen when needed.
55
bool UnsyncTouch(const TouchInput &touch) override;
56
bool UnsyncKey(const KeyInput &key) override;
57
void UnsyncAxis(const AxisInput *axes, size_t count) override;
58
59
// We also need to do some special handling of queued UI events to handle closing the chat window.
60
bool key(const KeyInput &key) override;
61
void touch(const TouchInput &key) override;
62
63
void deviceLost() override;
64
void deviceRestored(Draw::DrawContext *draw) override;
65
66
void SendImDebuggerCommand(const ImCommand &command) {
67
imCmd_ = command;
68
}
69
70
protected:
71
void darken();
72
void focusChanged(ScreenFocusChange focusChange) override;
73
74
private:
75
void CreateViews() override;
76
ScreenRenderFlags RunEmulation(ScreenRenderMode mode, bool framebufferBound, bool skipBufferEffects);
77
void OnDevTools(UI::EventParams &params);
78
void OnChat(UI::EventParams &params);
79
80
void HandleFlip();
81
void ProcessGameBoot(const Path &filename);
82
bool bootAllowStorage(const Path &filename);
83
void bootComplete();
84
bool hasVisibleUI();
85
void renderUI();
86
void runImDebugger();
87
void renderImDebugger();
88
89
void onVKey(VirtKey virtualKeyCode, bool down);
90
void onVKeyAnalog(VirtKey virtualKeyCode, float value);
91
92
void AutoLoadSaveState();
93
bool checkPowerDown();
94
95
void ProcessQueuedVKeys();
96
void ProcessVKey(VirtKey vkey);
97
98
UI::Event OnDevMenu;
99
UI::Event OnChatMenu;
100
bool bootPending_ = true;
101
bool bootIsReset_ = false;
102
Path gamePath_;
103
104
bool quit_ = false;
105
std::string errorMessage_;
106
107
// If set, pauses at the end of the frame.
108
bool pauseTrigger_ = false;
109
110
// The last read chat message count, and how many new ones there are.
111
int chatMessages_ = 0;
112
int newChatMessages_ = 0;
113
114
// In-memory save state used for freezeFrame, which is useful for debugging.
115
std::vector<u8> freezeState_;
116
117
std::string tag_;
118
119
double saveStatePreviewShownTime_ = 0.0;
120
AsyncImageFileView *saveStatePreview_ = nullptr;
121
int saveStateSlot_;
122
123
UI::CallbackColorTween *loadingViewColor_ = nullptr;
124
UI::VisibilityTween *loadingViewVisible_ = nullptr;
125
UI::Spinner *loadingSpinner_ = nullptr;
126
UI::Button *resumeButton_ = nullptr;
127
UI::Button *resetButton_ = nullptr;
128
UI::Button *backButton_ = nullptr;
129
UI::View *chatButton_ = nullptr;
130
ChatMenu *chatMenu_ = nullptr;
131
132
UI::Button *cardboardDisableButton_ = nullptr;
133
134
std::string extraAssertInfoStr_;
135
136
ControlMapper controlMapper_;
137
138
std::unique_ptr<ImDebugger> imDebugger_ = nullptr;
139
ImCommand imCmd_{}; // needed to buffer commands in case imgui wasn't created yet.
140
141
bool imguiInited_ = false;
142
// For ImGui modifier tracking
143
bool keyCtrlLeft_ = false;
144
bool keyCtrlRight_ = false;
145
bool keyShiftLeft_ = false;
146
bool keyShiftRight_ = false;
147
bool keyAltLeft_ = false;
148
bool keyAltRight_ = false;
149
150
bool lastImguiEnabled_ = false;
151
152
std::vector<VirtKey> queuedVirtKeys_;
153
154
ImGuiContext *ctx_ = nullptr;
155
156
bool frameStep_ = false;
157
#ifndef MOBILE_DEVICE
158
bool startDumping_ = false;
159
#endif
160
bool autoLoadFailed_ = false; // to prevent repeat reloads
161
bool readyToFinishBoot_ = false;
162
};
163
164
bool MustRunBehind();
165
bool ShouldRunBehind();
166
167