Skip to content

Commit

Permalink
Added SDL_WinRTGetDeviceFamily() to find out what type of device your…
Browse files Browse the repository at this point in the history
… application is running on (thanks Daniel Knobe!)
  • Loading branch information
slouken committed Dec 10, 2017
1 parent 3ae9768 commit baae74c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
10 changes: 10 additions & 0 deletions WhatsNew.txt
Expand Up @@ -9,6 +9,16 @@ General:
* Added SDL_fmod()
* Each of the SDL math functions now has the corresponding float version

Windows:
* Implemented WASAPI support on Windows UWP and removed the deprecated XAudio2 implementation

Windows UWP:
* Added SDL_WinRTGetDeviceFamily() to find out what type of device your application is running on

Mac OSX / iOS / tvOS:
* Added a Metal 2D render implementation
* Added SDL_RenderGetMetalLayer() and SDL_RenderGetMetalCommandEncoder() to insert your own drawing into SDL rendering when using the Metal implementation


---------------------------------------------------------------------------
2.0.7:
Expand Down
26 changes: 26 additions & 0 deletions include/SDL_system.h
Expand Up @@ -169,6 +169,25 @@ typedef enum
} SDL_WinRT_Path;


/**
* \brief WinRT Device Family
*/
typedef enum
{
/** \brief Unknown family */
SDL_WINRT_DEVICEFAMILY_UNKNOWN,

/** \brief Desktop family*/
SDL_WINRT_DEVICEFAMILY_DESKTOP,

/** \brief Mobile family (for example smartphone) */
SDL_WINRT_DEVICEFAMILY_MOBILE,

/** \brief XBox family */
SDL_WINRT_DEVICEFAMILY_XBOX,
} SDL_WinRT_DeviceFamily;


/**
* \brief Retrieves a WinRT defined path on the local file system
*
Expand Down Expand Up @@ -203,6 +222,13 @@ extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path
*/
extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);

/**
* \brief Detects the device family of WinRT plattform on runtime
*
* \return Device family
*/
extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily();

#endif /* __WINRT__ */

/* Ends C function definitions when using C++ */
Expand Down
22 changes: 22 additions & 0 deletions src/core/winrt/SDL_winrtapp_common.cpp
Expand Up @@ -40,3 +40,25 @@ SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel)
return SDL_WinRTInitNonXAMLApp(mainFunction);
}
}


extern "C" DECLSPEC SDL_WinRT_DeviceFamily
SDL_WinRTGetDeviceFamily()
{
Platform::String^ deviceFamily = Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamily;

if (deviceFamily->Equals("Windows.Desktop"))
{
return SDL_WINRT_DEVICEFAMILY_DESKTOP;
}
else if (deviceFamily->Equals("Windows.Mobile"))
{
return SDL_WINRT_DEVICEFAMILY_MOBILE;
}
else if (deviceFamily->Equals("Windows.Xbox"))
{
return SDL_WINRT_DEVICEFAMILY_XBOX;
}

return SDL_WINRT_DEVICEFAMILY_UNKNOWN;
}

0 comments on commit baae74c

Please sign in to comment.