Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/EmuScreen.h
3185 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
UI::EventReturn OnDevTools(UI::EventParams &params);
77
UI::EventReturn OnChat(UI::EventParams &params);
78
79
void HandleFlip();
80
void ProcessGameBoot(const Path &filename);
81
bool bootAllowStorage(const Path &filename);
82
void bootComplete();
83
bool hasVisibleUI();
84
void renderUI();
85
void runImDebugger();
86
void renderImDebugger();
87
88
void onVKey(VirtKey virtualKeyCode, bool down);
89
void onVKeyAnalog(VirtKey virtualKeyCode, float value);
90
91
void AutoLoadSaveState();
92
bool checkPowerDown();
93
94
void ProcessQueuedVKeys();
95
void ProcessVKey(VirtKey vkey);
96
97
UI::Event OnDevMenu;
98
UI::Event OnChatMenu;
99
bool bootPending_ = true;
100
Path gamePath_;
101
102
bool quit_ = false;
103
std::string errorMessage_;
104
105
// If set, pauses at the end of the frame.
106
bool pauseTrigger_ = false;
107
108
// The last read chat message count, and how many new ones there are.
109
int chatMessages_ = 0;
110
int newChatMessages_ = 0;
111
112
// In-memory save state used for freezeFrame, which is useful for debugging.
113
std::vector<u8> freezeState_;
114
115
std::string tag_;
116
117
double saveStatePreviewShownTime_ = 0.0;
118
AsyncImageFileView *saveStatePreview_ = nullptr;
119
int saveStateSlot_;
120
121
UI::CallbackColorTween *loadingViewColor_ = nullptr;
122
UI::VisibilityTween *loadingViewVisible_ = nullptr;
123
UI::Spinner *loadingSpinner_ = nullptr;
124
UI::Button *resumeButton_ = nullptr;
125
UI::Button *resetButton_ = nullptr;
126
UI::Button *backButton_ = nullptr;
127
UI::View *chatButton_ = nullptr;
128
ChatMenu *chatMenu_ = nullptr;
129
130
UI::Button *cardboardDisableButton_ = nullptr;
131
132
std::string extraAssertInfoStr_;
133
134
ControlMapper controlMapper_;
135
136
std::unique_ptr<ImDebugger> imDebugger_ = nullptr;
137
ImCommand imCmd_{}; // needed to buffer commands in case imgui wasn't created yet.
138
139
bool imguiInited_ = false;
140
// For ImGui modifier tracking
141
bool keyCtrlLeft_ = false;
142
bool keyCtrlRight_ = false;
143
bool keyShiftLeft_ = false;
144
bool keyShiftRight_ = false;
145
bool keyAltLeft_ = false;
146
bool keyAltRight_ = false;
147
148
bool lastImguiEnabled_ = false;
149
150
std::vector<VirtKey> queuedVirtKeys_;
151
152
ImGuiContext *ctx_ = nullptr;
153
154
bool frameStep_ = false;
155
#ifndef MOBILE_DEVICE
156
bool startDumping_ = false;
157
#endif
158
bool autoLoadFailed_ = false; // to prevent repeat reloads
159
};
160
161
bool MustRunBehind();
162
bool ShouldRunBehind();
163
164