From 46f7742afc04df9840138f6a08f8f29f15d440bc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 9 May 2018 16:12:52 +0200 Subject: [PATCH] Some early WinRT commits --- gfx/common/gdi_common.h | 4 +++ gfx/common/win32_common.c | 20 +++++++-------- gfx/common/win32_common.h | 22 ++++++---------- libretro-common/features/features_cpu.c | 2 +- libretro-common/include/retro_environment.h | 28 +++++++++++++++++++++ libretro-common/include/retro_timers.h | 2 ++ libretro-common/streams/stdin_stream.c | 4 +-- 7 files changed, 54 insertions(+), 28 deletions(-) diff --git a/gfx/common/gdi_common.h b/gfx/common/gdi_common.h index 0b7872ab4d..0f0b971018 100644 --- a/gfx/common/gdi_common.h +++ b/gfx/common/gdi_common.h @@ -18,9 +18,13 @@ #ifndef __GDI_COMMON_H #define __GDI_COMMON_H +#include + typedef struct gdi { +#ifndef __WINRT__ WNDCLASSEX wndclass; +#endif HDC winDC; HDC memDC; HBITMAP bmp; diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 39bd8bbdf6..f5028a213d 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -47,7 +47,7 @@ #include "../../tasks/tasks_internal.h" #include "../../core_info.h" -#if !defined(_XBOX) +#if !defined(_XBOX) && !defined(__WINRT__) #include #include @@ -1020,7 +1020,7 @@ bool win32_window_create(void *data, unsigned style, bool win32_get_metrics(void *data, enum display_metric_types type, float *value) { -#ifndef _XBOX +#if !defined(_XBOX) && !defined(__WINRT__) HDC monitor = GetDC(NULL); int pixels_x = GetDeviceCaps(monitor, HORZRES); int pixels_y = GetDeviceCaps(monitor, VERTRES); @@ -1053,7 +1053,7 @@ bool win32_get_metrics(void *data, void win32_monitor_init(void) { -#ifndef _XBOX +#if !defined(_XBOX) && !defined(__WINRT__) win32_monitor_count = 0; EnumDisplayMonitors(NULL, NULL, win32_monitor_enum_proc, 0); @@ -1066,7 +1066,7 @@ static bool win32_monitor_set_fullscreen( unsigned width, unsigned height, unsigned refresh, char *dev_name) { -#ifndef _XBOX +#if !defined(_XBOX) && !defined(__WINRT__) DEVMODE devmode; memset(&devmode, 0, sizeof(devmode)); @@ -1087,7 +1087,7 @@ static bool win32_monitor_set_fullscreen( void win32_show_cursor(bool state) { -#ifndef _XBOX +#if !defined(_XBOX) && !defined(__WINRT__) if (state) while (ShowCursor(TRUE) < 0); else @@ -1098,7 +1098,7 @@ void win32_show_cursor(bool state) void win32_check_window(bool *quit, bool *resize, unsigned *width, unsigned *height) { -#ifndef _XBOX +#if !defined(_XBOX) && !defined(__WINRT__) const ui_application_t *application = ui_companion_driver_get_application_ptr(); if (application) @@ -1117,7 +1117,7 @@ void win32_check_window(bool *quit, bool *resize, bool win32_suppress_screensaver(void *data, bool enable) { -#ifndef _XBOX +#if !defined(_XBOX) && !defined(__WINRT__) if (enable) { char tmp[PATH_MAX_LENGTH]; @@ -1188,7 +1188,7 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use, unsigned *width, unsigned *height, bool fullscreen, bool windowed_full, RECT *rect, RECT *mon_rect, DWORD *style) { -#ifndef _XBOX +#if !defined(_XBOX) && !defined(__WINRT__) if (fullscreen) { settings_t *settings = config_get_ptr(); @@ -1235,7 +1235,7 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use, void win32_set_window(unsigned *width, unsigned *height, bool fullscreen, bool windowed_full, void *rect_data) { -#ifndef _XBOX +#if !defined(_XBOX) && !defined(__WINRT__) RECT *rect = (RECT*)rect_data; if (!fullscreen || windowed_full) @@ -1274,7 +1274,7 @@ bool win32_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { -#ifndef _XBOX +#if !defined(_XBOX) && !defined(__WINRT__) DWORD style; MSG msg; RECT mon_rect; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 40fa4d3b39..1c7ef99100 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -45,7 +45,7 @@ RETRO_BEGIN_DECLS -#ifndef _XBOX +#if !defined(_XBOX) && !defined(__WINRT__) extern unsigned g_resize_width; extern unsigned g_resize_height; extern bool g_inited; @@ -66,6 +66,12 @@ void create_gdi_context(HWND hwnd, bool *quit); bool gdi_has_menu_frame(void); void shader_dlg_params_reload(void); + +bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen, const char *class_name); + +void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use, + unsigned *width, unsigned *height, bool fullscreen, bool windowed_full, + RECT *rect, RECT *mon_rect, DWORD *style); #endif void win32_monitor_from_window(void); @@ -76,14 +82,6 @@ bool win32_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen); -#ifndef _XBOX -RETRO_BEGIN_DECLS - -bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen, const char *class_name); - -RETRO_END_DECLS -#endif - bool win32_window_create(void *data, unsigned style, RECT *mon_rect, unsigned width, unsigned height, bool fullscreen); @@ -105,12 +103,6 @@ void win32_check_window(bool *quit, void win32_set_window(unsigned *width, unsigned *height, bool fullscreen, bool windowed_full, void *rect_data); -#ifndef _XBOX -void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use, - unsigned *width, unsigned *height, bool fullscreen, bool windowed_full, - RECT *rect, RECT *mon_rect, DWORD *style); -#endif - void win32_get_video_output_size( unsigned *width, unsigned *height); diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 3a32a46c64..0d46fbaffe 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -470,7 +470,7 @@ static void cpulist_read_from(CpuList* list, const char* filename) **/ unsigned cpu_features_get_core_amount(void) { -#if defined(_WIN32) && !defined(_XBOX) +#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) /* Win32 */ SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); diff --git a/libretro-common/include/retro_environment.h b/libretro-common/include/retro_environment.h index 1a18cd6f8c..0a40593e31 100644 --- a/libretro-common/include/retro_environment.h +++ b/libretro-common/include/retro_environment.h @@ -73,6 +73,34 @@ printf("This is C++, version %d.\n", __cplusplus); /* This is not standard C. __STDC__ is not defined. */ #endif +#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) +/* Try to find out if we're compiling for WinRT or non-WinRT */ +#if defined(_MSC_VER) && defined(__has_include) +#if __has_include() +#define HAVE_WINAPIFAMILY_H 1 +#else +#define HAVE_WINAPIFAMILY_H 0 +#endif +/* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */ +#elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */ +#define HAVE_WINAPIFAMILY_H 1 +#else +#define HAVE_WINAPIFAMILY_H 0 +#endif + +#if HAVE_WINAPIFAMILY_H +#include +#define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) +#else +#define WINAPI_FAMILY_WINRT 0 +#endif /* HAVE_WINAPIFAMILY_H */ + +#if WINAPI_FAMILY_WINRT +#undef __WINRT__ +#define __WINRT__ 1 +#endif #endif + +#endif \ No newline at end of file diff --git a/libretro-common/include/retro_timers.h b/libretro-common/include/retro_timers.h index e56e18fc38..6c164e65d0 100644 --- a/libretro-common/include/retro_timers.h +++ b/libretro-common/include/retro_timers.h @@ -91,6 +91,8 @@ static INLINE void retro_sleep(unsigned msec) sceKernelDelayThread(1000 * msec); #elif defined(_3DS) svcSleepThread(1000000 * (s64)msec); +#elif defined(__WINRT__) + /* TODO/FIXME */ #elif defined(_WIN32) Sleep(msec); #elif defined(XENON) diff --git a/libretro-common/streams/stdin_stream.c b/libretro-common/streams/stdin_stream.c index 6aedfae388..cf6fb0e331 100644 --- a/libretro-common/streams/stdin_stream.c +++ b/libretro-common/streams/stdin_stream.c @@ -35,10 +35,10 @@ #endif #include - +#include #include -#if (defined(_WIN32) && defined(_XBOX)) || defined(__CELLOS_LV2__) +#if (defined(_WIN32) && defined(_XBOX)) || defined(__CELLOS_LV2__) || defined(__WINRT__) size_t read_stdin(char *buf, size_t size) { /* Not implemented. */