diff --git a/scripts/src/main.lua b/scripts/src/main.lua index e231ffe065b..f1c33edd84b 100644 --- a/scripts/src/main.lua +++ b/scripts/src/main.lua @@ -233,8 +233,12 @@ if (STANDALONE~=true) then links { ext_lib("lua"), "lualibs", + } +if (_OPTIONS["osd"] ~= "uwp") then + links { "linenoise-ng", } +end end links { ext_lib("zlib"), diff --git a/src/osd/modules/osdwindow.cpp b/src/osd/modules/osdwindow.cpp index 16fc8817184..808318b58b8 100644 --- a/src/osd/modules/osdwindow.cpp +++ b/src/osd/modules/osdwindow.cpp @@ -13,10 +13,10 @@ #if (USE_OPENGL) #include "render/drawogl.h" #endif -#ifdef OSD_WINDOWS +#if defined(OSD_WINDOWS) #include "render/drawgdi.h" #include "render/drawd3d.h" -#else +#elif defined(OSD_SDL) #include "render/draw13.h" #include "render/drawsdl.h" #endif @@ -30,7 +30,7 @@ std::unique_ptr osd_renderer::make_for_type(int mode, std::shared_ { switch(mode) { -#ifdef OSD_WINDOWS +#if defined(OSD_WINDOWS) || defined(OSD_UWP) case VIDEO_MODE_NONE: return std::make_unique(window); #endif @@ -40,12 +40,12 @@ std::unique_ptr osd_renderer::make_for_type(int mode, std::shared_ case VIDEO_MODE_OPENGL: return std::make_unique(window); #endif -#ifdef OSD_WINDOWS +#if defined(OSD_WINDOWS) case VIDEO_MODE_GDI: return std::make_unique(window); case VIDEO_MODE_D3D: return std::make_unique(window); -#else +#elif defined(OSD_SDL) case VIDEO_MODE_SDL2ACCEL: return std::make_unique(window, extra_flags); case VIDEO_MODE_SOFT: diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h index 6fb97c339a1..028522bd327 100644 --- a/src/osd/modules/osdwindow.h +++ b/src/osd/modules/osdwindow.h @@ -21,13 +21,15 @@ #include #include #endif -#undef min -#undef max #ifdef OSD_SDL // forward declaration struct SDL_Window; +#elif defined(OSD_UWP) +#include #endif +#undef min +#undef max //============================================================ // TYPE DEFINITIONS @@ -71,7 +73,7 @@ class osd_window : public std::enable_shared_from_this public: osd_window(const osd_window_config &config) : -#ifndef OSD_SDL +#ifdef OSD_WINDOW m_dc(nullptr), m_resize_state(0), #endif m_primlist(nullptr), @@ -136,14 +138,16 @@ public: virtual void update() = 0; virtual void destroy() = 0; -#ifndef OSD_SDL +#ifdef OSD_WINDOWS virtual bool win_has_menu() = 0; HDC m_dc; // only used by GDI renderer! int m_resize_state; +#elif OSD_UWP + virtual bool win_has_menu() = 0; + Platform::Agile m_window; #endif - render_primitive_list *m_primlist; osd_window_config m_win_config; int m_index; diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp index 10de9a5cb68..97d4202d41f 100644 --- a/src/osd/modules/render/drawbgfx.cpp +++ b/src/osd/modules/render/drawbgfx.cpp @@ -5,7 +5,7 @@ // drawbgfx.cpp - BGFX renderer // //============================================================ -#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS) +#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS) || defined(OSD_UWP) // standard windows headers #define WIN32_LEAN_AND_MEAN #include @@ -133,7 +133,7 @@ inline void winSetHwnd(::HWND _window) pd.backBufferDS = NULL; bgfx::setPlatformData(pd); } -#else +#elif defined(OSD_SDL) static void* sdlNativeWindowHandle(SDL_Window* _window) { SDL_SysWMinfo wmi; @@ -186,6 +186,22 @@ inline bool sdlSetWindow(SDL_Window* _window) return true; } +#elif defined(OSD_UWP) +inline void winrtSetWindow(::IUnknown* _window) +{ + bgfx::PlatformData pd; + pd.ndt = NULL; + pd.nwh = _window; + pd.context = NULL; + pd.backBuffer = NULL; + pd.backBufferDS = NULL; + bgfx::setPlatformData(pd); +} + +IInspectable* AsInspectable(Platform::Object^ o) +{ + return reinterpret_cast(o); +} #endif int renderer_bgfx::create() @@ -211,6 +227,8 @@ int renderer_bgfx::create() } #ifdef OSD_WINDOWS winSetHwnd(win->platform_window()); +#elif defined(OSD_UWP) + winrtSetWindow(AsInspectable(win->m_window.Get())); #else sdlSetWindow(win->platform_window()); #endif @@ -260,6 +278,8 @@ int renderer_bgfx::create() { #ifdef OSD_WINDOWS m_framebuffer = m_targets->create_backbuffer(win->platform_window(), m_width[win->m_index], m_height[win->m_index]); +#elif defined(OSD_UWP) + m_framebuffer = m_targets->create_backbuffer(&win->m_window, m_width[win->m_index], m_height[win->m_index]); #else m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(win->platform_window()), m_width[win->m_index], m_height[win->m_index]); #endif @@ -899,6 +919,8 @@ bool renderer_bgfx::update_dimensions() delete m_framebuffer; #ifdef OSD_WINDOWS m_framebuffer = m_targets->create_backbuffer(win->platform_window(), width, height); +#elif defined(OSD_UWP) + m_framebuffer = m_targets->create_backbuffer(&win->m_window, width, height); #else m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(win->platform_window()), width, height); #endif diff --git a/src/osd/modules/render/drawnone.cpp b/src/osd/modules/render/drawnone.cpp index f6bde9d868f..7303dcfd8d3 100644 --- a/src/osd/modules/render/drawnone.cpp +++ b/src/osd/modules/render/drawnone.cpp @@ -26,7 +26,15 @@ render_primitive_list *renderer_none::get_primitives() return nullptr; RECT client; +#if defined(OSD_WINDOWS) GetClientRect(win->platform_window(), &client); +#elif defined(OSD_UWP) + auto bounds = win->m_window->Bounds; + client.left = bounds.Left; + client.right = bounds.Right; + client.top = bounds.Top; + client.bottom = bounds.Bottom; +#endif win->target()->set_bounds(rect_width(&client), rect_height(&client), win->pixel_aspect()); return &win->target()->get_primitives(); } diff --git a/src/osd/windows/winutil.cpp b/src/osd/windows/winutil.cpp index 42e3e84a03e..951ce803a7a 100644 --- a/src/osd/windows/winutil.cpp +++ b/src/osd/windows/winutil.cpp @@ -107,7 +107,11 @@ void osd_subst_env(std::string &dst, const std::string &src) TCHAR buffer[MAX_PATH]; osd::text::tstring t_src = osd::text::to_tstring(src); +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) ExpandEnvironmentStrings(t_src.c_str(), buffer, ARRAY_LENGTH(buffer)); +#else + wcsncpy(buffer, t_src.c_str(), ARRAY_LENGTH(buffer)); +#endif osd::text::from_tstring(dst, buffer); }