src/core/winrt/SDL_winrtapp_common.cpp
author Ryan C. Gordon <icculus@icculus.org>
Tue, 18 Feb 2020 01:44:07 -0500
changeset 13539 0d8343654eef
parent 13422 fd6a12de91c7
permissions -rw-r--r--
dynapi: Fixed build on non-Android platforms.
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 #include "../../SDL_internal.h"
    22 
    23 #include "SDL_main.h"
    24 #include "SDL_system.h"
    25 #include "SDL_winrtapp_direct3d.h"
    26 #include "SDL_winrtapp_xaml.h"
    27 
    28 #include <wrl.h>
    29 
    30 int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL;
    31 
    32 extern "C" DECLSPEC int
    33 SDL_WinRTRunApp(SDL_main_func mainFunction, void * xamlBackgroundPanel)
    34 {
    35     if (xamlBackgroundPanel) {
    36         return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel);
    37     } else {
    38         if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) {
    39             return 1;
    40         }
    41         return SDL_WinRTInitNonXAMLApp(mainFunction);
    42     }
    43 }
    44 
    45 
    46 extern "C" DECLSPEC SDL_WinRT_DeviceFamily
    47 SDL_WinRTGetDeviceFamily()
    48 {
    49 #if NTDDI_VERSION >= NTDDI_WIN10  /* !!! FIXME: I have no idea if this is the right test. This is a UWP API, I think. Older windows should...just return "mobile"? I don't know. --ryan. */
    50     Platform::String^ deviceFamily = Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamily;
    51 
    52     if (deviceFamily->Equals("Windows.Desktop"))
    53     {
    54         return SDL_WINRT_DEVICEFAMILY_DESKTOP;
    55     }
    56     else if (deviceFamily->Equals("Windows.Mobile"))
    57     {
    58         return SDL_WINRT_DEVICEFAMILY_MOBILE;
    59     }
    60     else if (deviceFamily->Equals("Windows.Xbox"))
    61     {
    62         return SDL_WINRT_DEVICEFAMILY_XBOX;
    63     }
    64 #endif
    65 
    66     return SDL_WINRT_DEVICEFAMILY_UNKNOWN;
    67 }