#pragma once #include "common/event.h" #include "common/window_info.h" #include "common/windows_headers.h" #include "core/host_display.h" #include "core/host_interface.h" #include "frontend-common/common_host_interface.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class INISettingsInterface; class UWPHostInterface : public CommonHostInterface, public winrt::implements { public: UWPHostInterface(); ~UWPHostInterface(); const char* GetFrontendName() const override; bool Initialize() override; void Shutdown() override; void ReportMessage(const char* message) override; void ReportError(const char* message) override; bool ConfirmMessage(const char* message) override; void RunLater(std::function callback) override; void OnDisplayInvalidated() override; void OnSystemPerformanceCountersUpdated() override; bool IsFullscreen() const override; bool SetFullscreen(bool enabled) override; winrt::Windows::ApplicationModel::Core::IFrameworkView CreateView(); void Initialize(const winrt::Windows::ApplicationModel::Core::CoreApplicationView&); void Load(const winrt::hstring&); void Uninitialize(); void Run(); void SetWindow(const winrt::Windows::UI::Core::CoreWindow& window); protected: enum : u32 { DEFAULT_WINDOW_WIDTH = 1280, DEFAULT_WINDOW_HEIGHT = 720 }; ALWAYS_INLINE bool IsEmulationThreadRunning() const { return m_emulation_thread.joinable(); } void SetDefaultSettings(SettingsInterface& si) override; bool AcquireHostDisplay() override; void ReleaseHostDisplay() override; void PollAndUpdate() override; void RequestExit() override; void SetMouseMode(bool relative, bool hide_cursor) override; bool CreateDisplay(bool fullscreen); void DestroyDisplay(); void RunCallbacks(); void EmulationThreadEntryPoint(); bool SetDirectories(); void OnSuspending(const IInspectable&, const winrt::Windows::ApplicationModel::SuspendingEventArgs& args); void OnResuming(const IInspectable&, const IInspectable&); void OnClosed(const IInspectable&, const winrt::Windows::UI::Core::CoreWindowEventArgs& args); void OnSizeChanged(const IInspectable&, const winrt::Windows::UI::Core::WindowSizeChangedEventArgs& args); void OnKeyDown(const IInspectable&, const winrt::Windows::UI::Core::KeyEventArgs& args); void OnKeyUp(const IInspectable&, const winrt::Windows::UI::Core::KeyEventArgs& args); void OnCharacterReceived(const IInspectable&, const winrt::Windows::UI::Core::CharacterReceivedEventArgs& args); void OnPointerPressed(const IInspectable&, const winrt::Windows::UI::Core::PointerEventArgs& args); void OnPointerReleased(const IInspectable&, const winrt::Windows::UI::Core::PointerEventArgs& args); void OnPointerMoved(const IInspectable&, const winrt::Windows::UI::Core::PointerEventArgs& args); void OnPointerWheelChanged(const IInspectable&, const winrt::Windows::UI::Core::PointerEventArgs& args); void UpdateMouseButtonState(const winrt::Windows::UI::Input::PointerPoint& point); std::optional GetHostKeyCode(const std::string_view key_code) const override; const char* GetKeyCodeName(int key_code); void SetImGuiKeyMap(); void SetDefaultSettingsForXbox(SettingsInterface& si); std::deque> m_queued_callbacks; std::mutex m_queued_callbacks_lock; winrt::Windows::UI::Core::CoreWindow m_window{nullptr}; winrt::Windows::UI::Core::CoreDispatcher m_dispatcher{nullptr}; winrt::Windows::UI::ViewManagement::ApplicationView m_appview{nullptr}; std::thread m_emulation_thread; std::atomic_bool m_shutdown_flag{false}; bool m_text_input_requested = false; Common::Event m_suspend_sync_event; std::atomic_bool m_was_running_on_suspend{false}; std::atomic_bool m_was_running_on_background{false}; };