Skip to content

Commit

Permalink
(UWP) Start adding some Windows Phone 8.1 ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Dec 31, 2018
1 parent 6b35e8d commit c6ba5d9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libretro-common/include/retro_timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 13 additions & 3 deletions uwp/uwp_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -257,19 +259,21 @@ void App::SetWindow(CoreWindow^ window)
window->PointerWheelChanged +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointer);

#if _MSC_VER >= 1800
DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView();

currentDisplayInformation->DpiChanged +=
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnDpiChanged);

currentDisplayInformation->OrientationChanged +=
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnOrientationChanged);

DisplayInformation::DisplayContentsInvalidated +=
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnDisplayContentsInvalidated);

currentDisplayInformation->OrientationChanged +=
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnOrientationChanged);

Windows::UI::Core::SystemNavigationManager::GetForCurrentView()->BackRequested +=
ref new EventHandler<Windows::UI::Core::BackRequestedEventArgs^>(this, &App::OnBackRequested);
#endif
}

// Initializes scene resources, or loads a previously saved app state.
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -477,13 +485,15 @@ extern "C" {
{
if (App::GetInstance()->IsInitialized())
{
#if _MSC_VER >= 1800
if (fullscreen != ApplicationView::GetForCurrentView()->IsFullScreenMode)
{
if (fullscreen)
ApplicationView::GetForCurrentView()->TryEnterFullScreenMode();
else
ApplicationView::GetForCurrentView()->ExitFullScreenMode();
}
#endif
ApplicationView::GetForCurrentView()->TryResizeView(Size(width, height));
}
else
Expand Down
4 changes: 4 additions & 0 deletions uwp/uwp_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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; }
Expand Down

0 comments on commit c6ba5d9

Please sign in to comment.