SDL  2.0
SDL_winrtapp_common.cpp
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2018 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_system.h"
24 #include "SDL_winrtapp_direct3d.h"
25 #include "SDL_winrtapp_xaml.h"
26 
27 #include <wrl.h>
28 
29 int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL;
30 
31 extern "C" DECLSPEC int
32 SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel)
33 {
34  if (xamlBackgroundPanel) {
35  return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel);
36  } else {
37  if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) {
38  return 1;
39  }
40  return SDL_WinRTInitNonXAMLApp(mainFunction);
41  }
42 }
43 
44 
45 extern "C" DECLSPEC SDL_WinRT_DeviceFamily
47 {
48 #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. */
49  Platform::String^ deviceFamily = Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamily;
50 
51  if (deviceFamily->Equals("Windows.Desktop"))
52  {
53  return SDL_WINRT_DEVICEFAMILY_DESKTOP;
54  }
55  else if (deviceFamily->Equals("Windows.Mobile"))
56  {
57  return SDL_WINRT_DEVICEFAMILY_MOBILE;
58  }
59  else if (deviceFamily->Equals("Windows.Xbox"))
60  {
61  return SDL_WINRT_DEVICEFAMILY_XBOX;
62  }
63 #endif
64 
65  return SDL_WINRT_DEVICEFAMILY_UNKNOWN;
66 }
int SDL_WinRTInitNonXAMLApp(int(*mainFunction)(int, char **))
#define FAILED(x)
Definition: SDL_directx.h:54
#define DECLSPEC
Definition: SDL_internal.h:44
int SDL_WinRTInitXAMLApp(int(*mainFunction)(int, char **), void *backgroundPanelAsIInspectable)
SDL_WinRT_DeviceFamily SDL_WinRTGetDeviceFamily()
#define NULL
Definition: begin_code.h:164
int(* WINRT_SDLAppEntryPoint)(int, char **)
int SDL_WinRTRunApp(int(*mainFunction)(int, char **), void *xamlBackgroundPanel)