CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/UWP/App.h
Views: 1401
1
#pragma once
2
3
#include <set>
4
5
#include "pch.h"
6
#include "Common/DeviceResources.h"
7
#include "PPSSPP_UWPMain.h"
8
9
namespace UWP {
10
struct Touch {
11
bool inUse = false;
12
unsigned uid;
13
};
14
15
class TouchMapper {
16
public:
17
int TouchId(unsigned touch) {
18
for (int touchIx = 0; touchIx < maxTouches; touchIx++)
19
if (touches[touchIx].inUse && touches[touchIx].uid == touch)
20
return touchIx;
21
return -1;
22
}
23
24
int AddNewTouch(unsigned touch) {
25
for (int touchIx = 0; touchIx < maxTouches; touchIx++) {
26
if (!touches[touchIx].inUse) {
27
touches[touchIx].inUse = true;
28
touches[touchIx].uid = touch;
29
return touchIx;
30
}
31
}
32
return -1;
33
}
34
35
int RemoveTouch(unsigned touch) {
36
for (int touchIx = 0; touchIx < maxTouches; touchIx++) {
37
if (touches[touchIx].inUse && touches[touchIx].uid == touch) {
38
touches[touchIx].inUse = false;
39
return touchIx;
40
}
41
}
42
return -1;
43
}
44
45
private:
46
enum { maxTouches = 11 };
47
Touch touches[maxTouches]{};
48
};
49
50
enum class HardwareButton {
51
BACK,
52
};
53
54
// Main entry point for our app. Connects the app with the Windows shell and handles application lifecycle events.
55
ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView {
56
public:
57
App();
58
59
// IFrameworkView Methods.
60
virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
61
virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
62
virtual void Load(Platform::String^ entryPoint);
63
virtual void Run();
64
virtual void Uninitialize();
65
66
bool HasBackButton();
67
68
protected:
69
// Application lifecycle event handlers.
70
void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
71
void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
72
void OnResuming(Platform::Object^ sender, Platform::Object^ args);
73
74
// Window event handlers.
75
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
76
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
77
void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
78
79
// DisplayInformation event handlers.
80
void OnDpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
81
void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
82
void OnDisplayContentsInvalidated(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
83
84
// Input
85
void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
86
void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
87
void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args);
88
89
void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
90
void OnPointerEntered(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
91
void OnPointerExited(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
92
void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
93
void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
94
void OnPointerCaptureLost(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
95
void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
96
97
void App_BackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ e);
98
void InitialPPSSPP();
99
100
private:
101
std::shared_ptr<DX::DeviceResources> m_deviceResources;
102
std::set<HardwareButton> m_hardwareButtons;
103
std::unique_ptr<PPSSPP_UWPMain> m_main;
104
bool m_windowClosed;
105
bool m_windowVisible;
106
107
bool m_isPhone = false;
108
TouchMapper touchMap_;
109
};
110
}
111
112
ref class Direct3DApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
113
{
114
public:
115
virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
116
};
117
118