From c6ba5d9ebc252ec6b4e6fbc8c8ce0c228a4b5039 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 31 Dec 2018 01:38:45 +0100 Subject: [PATCH] (UWP) Start adding some Windows Phone 8.1 ifdefs --- libretro-common/include/retro_timers.h | 2 +- uwp/uwp_main.cpp | 16 +++++++++++++--- uwp/uwp_main.h | 4 ++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/libretro-common/include/retro_timers.h b/libretro-common/include/retro_timers.h index d11e67e7c24..60bf221e36c 100644 --- a/libretro-common/include/retro_timers.h +++ b/libretro-common/include/retro_timers.h @@ -95,7 +95,7 @@ static INLINE void retro_sleep(unsigned msec) SDL_Delay(msec); #elif defined(_3DS) svcSleepThread(1000000 * (s64)msec); -#elif defined(__WINRT__) +#elif defined(__WINRT__) || (_MSC_VER && _MSC_VER <= 1800) /* TODO/FIXME */ #elif defined(_WIN32) Sleep(msec); diff --git a/uwp/uwp_main.cpp b/uwp/uwp_main.cpp index 85fc4372158..edfd27bfa22 100644 --- a/uwp/uwp_main.cpp +++ b/uwp/uwp_main.cpp @@ -36,7 +36,9 @@ using namespace Windows::UI::Input; using namespace Windows::UI::ViewManagement; using namespace Windows::Devices::Input; using namespace Windows::System; +#if _MSC_VER >= 1800 using namespace Windows::System::Profile; +#endif using namespace Windows::Foundation; using namespace Windows::Graphics::Display; @@ -257,19 +259,21 @@ void App::SetWindow(CoreWindow^ window) window->PointerWheelChanged += ref new TypedEventHandler(this, &App::OnPointer); +#if _MSC_VER >= 1800 DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); currentDisplayInformation->DpiChanged += ref new TypedEventHandler(this, &App::OnDpiChanged); - currentDisplayInformation->OrientationChanged += - ref new TypedEventHandler(this, &App::OnOrientationChanged); - DisplayInformation::DisplayContentsInvalidated += ref new TypedEventHandler(this, &App::OnDisplayContentsInvalidated); + currentDisplayInformation->OrientationChanged += + ref new TypedEventHandler(this, &App::OnOrientationChanged); + Windows::UI::Core::SystemNavigationManager::GetForCurrentView()->BackRequested += ref new EventHandler(this, &App::OnBackRequested); +#endif } // Initializes scene resources, or loads a previously saved app state. @@ -359,11 +363,13 @@ void App::OnResuming(Platform::Object^ sender, Platform::Object^ args) // does not occur if the app was previously terminated. } +#if _MSC_VER >= 1800 void App::OnBackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args) { /* Prevent the B controller button on Xbox One from quitting the app */ args->Handled = true; } +#endif // Window event handlers. @@ -443,6 +449,7 @@ void App::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args) // DisplayInformation event handlers. +#if _MSC_VER >= 1800 void App::OnDpiChanged(DisplayInformation^ sender, Object^ args) { m_windowResized = true; @@ -457,6 +464,7 @@ void App::OnDisplayContentsInvalidated(DisplayInformation^ sender, Object^ args) { // Probably can be ignored? } +#endif // Taken from DirectX UWP samples - on Xbox, everything is scaled 200% so getting the DPI calculation correct is crucial static inline float ConvertDipsToPixels(float dips, float dpi) @@ -477,6 +485,7 @@ extern "C" { { if (App::GetInstance()->IsInitialized()) { +#if _MSC_VER >= 1800 if (fullscreen != ApplicationView::GetForCurrentView()->IsFullScreenMode) { if (fullscreen) @@ -484,6 +493,7 @@ extern "C" { else ApplicationView::GetForCurrentView()->ExitFullScreenMode(); } +#endif ApplicationView::GetForCurrentView()->TryResizeView(Size(width, height)); } else diff --git a/uwp/uwp_main.h b/uwp/uwp_main.h index 623d922161e..8f1f123561f 100644 --- a/uwp/uwp_main.h +++ b/uwp/uwp_main.h @@ -38,7 +38,9 @@ namespace RetroArchUWP void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args); void OnResuming(Platform::Object^ sender, Platform::Object^ args); +#if _MSC_VER >= 1800 void OnBackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args); +#endif // Window event handlers. void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args); @@ -49,9 +51,11 @@ namespace RetroArchUWP void OnPointer(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); // DisplayInformation event handlers. +#if _MSC_VER >= 1800 void OnDpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); void OnDisplayContentsInvalidated(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); +#endif public: bool IsInitialized() { return m_initialized; }