src/core/winrt/SDL_winrtapp_direct3d.cpp
changeset 8621 5252788cb448
parent 8616 ec011c16e2fd
child 8664 565698ab1c40
     1.1 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp	Sat Mar 15 13:27:18 2014 -0400
     1.2 +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp	Sat Mar 15 14:54:23 2014 -0400
     1.3 @@ -163,7 +163,11 @@
     1.4      // for details.  Microsoft's "Display orientation sample" also gives an
     1.5      // outline of how Windows treats device rotation
     1.6      // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
     1.7 +#if NTDDI_VERSION > NTDDI_WIN8
     1.8 +    DisplayInformation::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
     1.9 +#else
    1.10      DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
    1.11 +#endif
    1.12  }
    1.13  
    1.14  static void
    1.15 @@ -283,20 +287,13 @@
    1.16  
    1.17      CoreApplication::Exiting +=
    1.18          ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnExiting);
    1.19 -
    1.20 -    DisplayProperties::OrientationChanged +=
    1.21 -        ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
    1.22 -
    1.23 -    // Register the hint, SDL_HINT_ORIENTATIONS, with SDL.  This needs to be
    1.24 -    // done before the hint's callback is registered (as of Feb 22, 2013),
    1.25 -    // otherwise the hint callback won't get registered.
    1.26 -    //
    1.27 -    // TODO, WinRT: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
    1.28 -    //SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight Portrait PortraitUpsideDown");   // DavidL: this is no longer needed (for SDL_AddHintCallback)
    1.29 -    SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
    1.30  }
    1.31  
    1.32 +#if NTDDI_VERSION > NTDDI_WIN8
    1.33 +void SDL_WinRTApp::OnOrientationChanged(DisplayInformation^ sender, Object^ args)
    1.34 +#else
    1.35  void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
    1.36 +#endif
    1.37  {
    1.38  #if LOG_ORIENTATION_EVENTS==1
    1.39      CoreWindow^ window = CoreWindow::GetForCurrentThread();
    1.40 @@ -379,6 +376,18 @@
    1.41          ref new EventHandler<BackPressedEventArgs^>(this, &SDL_WinRTApp::OnBackButtonPressed);
    1.42  #endif
    1.43  
    1.44 +#if NTDDI_VERSION > NTDDI_WIN8
    1.45 +    DisplayInformation::GetForCurrentView()->OrientationChanged +=
    1.46 +        ref new TypedEventHandler<Windows::Graphics::Display::DisplayInformation^, Object^>(this, &SDL_WinRTApp::OnOrientationChanged);
    1.47 +#else
    1.48 +    DisplayProperties::OrientationChanged +=
    1.49 +        ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
    1.50 +#endif
    1.51 +
    1.52 +    // Register the hint, SDL_HINT_ORIENTATIONS, with SDL.
    1.53 +    // TODO, WinRT: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
    1.54 +    SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
    1.55 +
    1.56  #if WINAPI_FAMILY == WINAPI_FAMILY_APP  // for Windows 8/8.1/RT apps... (and not Phone apps)
    1.57      // Make sure we know when a user has opened the app's settings pane.
    1.58      // This is needed in order to display a privacy policy, which needs