Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/UWP/App.h
5756 views
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
struct App : winrt::implements<App, winrt::Windows::ApplicationModel::Core::IFrameworkView> {
56
public:
57
App();
58
59
// IFrameworkView Methods.
60
void Initialize(const winrt::Windows::ApplicationModel::Core::CoreApplicationView& applicationView);
61
void SetWindow(const winrt::Windows::UI::Core::CoreWindow& window);
62
void Load(const winrt::hstring& entryPoint);
63
void Run();
64
void Uninitialize();
65
66
bool HasBackButton();
67
68
private:
69
// Application lifecycle event handlers.
70
void OnActivated(const winrt::Windows::ApplicationModel::Core::CoreApplicationView& applicationView, const winrt::Windows::ApplicationModel::Activation::IActivatedEventArgs& args);
71
void OnSuspending(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::ApplicationModel::SuspendingEventArgs& args);
72
void OnResuming(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args);
73
74
// Window event handlers.
75
void OnWindowSizeChanged(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::WindowSizeChangedEventArgs& args);
76
void OnVisibilityChanged(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::VisibilityChangedEventArgs& args);
77
void OnWindowClosed(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::CoreWindowEventArgs& args);
78
79
// DisplayInformation event handlers.
80
void OnDpiChanged(const winrt::Windows::Graphics::Display::DisplayInformation& sender, const winrt::Windows::Foundation::IInspectable& args);
81
void OnOrientationChanged(const winrt::Windows::Graphics::Display::DisplayInformation& sender, const winrt::Windows::Foundation::IInspectable& args);
82
void OnDisplayContentsInvalidated(const winrt::Windows::Graphics::Display::DisplayInformation& sender, const winrt::Windows::Foundation::IInspectable& args);
83
84
// Input
85
void OnKeyDown(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::KeyEventArgs& args);
86
void OnKeyUp(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::KeyEventArgs& args);
87
void OnCharacterReceived(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::CharacterReceivedEventArgs& args);
88
89
void OnPointerMoved(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::PointerEventArgs& args);
90
void OnPointerEntered(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::PointerEventArgs& args);
91
void OnPointerExited(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::PointerEventArgs& args);
92
void OnPointerPressed(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::PointerEventArgs& args);
93
void OnPointerReleased(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::PointerEventArgs& args);
94
void OnPointerCaptureLost(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::PointerEventArgs& args);
95
void OnPointerWheelChanged(const winrt::Windows::UI::Core::CoreWindow& sender, const winrt::Windows::UI::Core::PointerEventArgs& args);
96
97
void App_BackRequested(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Core::BackRequestedEventArgs& e);
98
void InitialPPSSPP();
99
100
std::shared_ptr<DX::DeviceResources> m_deviceResources;
101
std::set<HardwareButton> m_hardwareButtons;
102
std::unique_ptr<PPSSPP_UWPMain> m_main;
103
bool m_windowClosed;
104
bool m_windowVisible;
105
106
bool m_isPhone = false;
107
TouchMapper touchMap_;
108
};
109
}
110
111
struct Direct3DApplicationSource : winrt::implements<Direct3DApplicationSource, winrt::Windows::ApplicationModel::Core::IFrameworkViewSource> {
112
winrt::Windows::ApplicationModel::Core::IFrameworkView CreateView();
113
};
114
115