UWP builds again but by no means working (nw)

This commit is contained in:
Brad Hughes 2016-11-10 16:26:05 -05:00
parent 0f877e08b3
commit bcabf45f08
13 changed files with 101 additions and 328 deletions

View File

@ -68,6 +68,8 @@ project ("osd_" .. _OPTIONS["osd"])
MAME_DIR .. "src/osd/uwp/video.h", MAME_DIR .. "src/osd/uwp/video.h",
MAME_DIR .. "src/osd/uwp/window.cpp", MAME_DIR .. "src/osd/uwp/window.cpp",
MAME_DIR .. "src/osd/uwp/window.h", MAME_DIR .. "src/osd/uwp/window.h",
MAME_DIR .. "src/osd/windows/winutf8.cpp",
MAME_DIR .. "src/osd/windows/winutf8.h",
MAME_DIR .. "src/osd/modules/osdwindow.cpp", MAME_DIR .. "src/osd/modules/osdwindow.cpp",
MAME_DIR .. "src/osd/modules/osdwindow.h", MAME_DIR .. "src/osd/modules/osdwindow.h",
MAME_DIR .. "src/osd/windows/winmain.cpp", MAME_DIR .. "src/osd/windows/winmain.cpp",
@ -76,8 +78,6 @@ project ("osd_" .. _OPTIONS["osd"])
MAME_DIR .. "src/osd/modules/render/drawnone.h", MAME_DIR .. "src/osd/modules/render/drawnone.h",
MAME_DIR .. "src/osd/uwp/uwpcompat.cpp", MAME_DIR .. "src/osd/uwp/uwpcompat.cpp",
MAME_DIR .. "src/osd/uwp/uwpcompat.h", MAME_DIR .. "src/osd/uwp/uwpcompat.h",
MAME_DIR .. "src/osd/uwp/uwpmain.cpp",
MAME_DIR .. "src/osd/uwp/uwpmain.h",
MAME_DIR .. "src/osd/osdepend.h", MAME_DIR .. "src/osd/osdepend.h",
} }

View File

@ -8,8 +8,6 @@
#include "input_module.h" #include "input_module.h"
#if defined(OSD_WINDOWS)
// MAME headers // MAME headers
#include "emu.h" #include "emu.h"
#include "osdepend.h" #include "osdepend.h"
@ -151,4 +149,3 @@ void windows_osd_interface::customize_input_type_list(simple_list<input_type_ent
} }
} }
#endif

View File

@ -25,8 +25,6 @@
#ifdef OSD_SDL #ifdef OSD_SDL
// forward declaration // forward declaration
struct SDL_Window; struct SDL_Window;
#elif defined(OSD_UWP)
#include <Agile.h>
#endif #endif
#undef min #undef min
#undef max #undef max
@ -138,15 +136,13 @@ public:
virtual void update() = 0; virtual void update() = 0;
virtual void destroy() = 0; virtual void destroy() = 0;
#if defined(OSD_WINDOWS) || defined(OSD_UWP)
virtual bool win_has_menu() = 0;
#endif
#ifdef OSD_WINDOWS #ifdef OSD_WINDOWS
virtual bool win_has_menu() = 0;
HDC m_dc; // only used by GDI renderer! HDC m_dc; // only used by GDI renderer!
int m_resize_state; int m_resize_state;
#elif defined(OSD_UWP)
virtual bool win_has_menu() = 0;
Platform::Agile<Windows::UI::Core::CoreWindow^> m_window;
#endif #endif
render_primitive_list *m_primlist; render_primitive_list *m_primlist;
osd_window_config m_win_config; osd_window_config m_win_config;

View File

@ -228,7 +228,7 @@ int renderer_bgfx::create()
#ifdef OSD_WINDOWS #ifdef OSD_WINDOWS
winSetHwnd(win->platform_window<HWND>()); winSetHwnd(win->platform_window<HWND>());
#elif defined(OSD_UWP) #elif defined(OSD_UWP)
winrtSetWindow(AsInspectable(win->m_window.Get())); winrtSetWindow(win->platform_window<IInspectable*>());
#else #else
sdlSetWindow(win->platform_window<SDL_Window*>()); sdlSetWindow(win->platform_window<SDL_Window*>());
#endif #endif
@ -279,7 +279,7 @@ int renderer_bgfx::create()
#ifdef OSD_WINDOWS #ifdef OSD_WINDOWS
m_framebuffer = m_targets->create_backbuffer(win->platform_window<HWND>(), m_width[win->m_index], m_height[win->m_index]); m_framebuffer = m_targets->create_backbuffer(win->platform_window<HWND>(), m_width[win->m_index], m_height[win->m_index]);
#elif defined(OSD_UWP) #elif defined(OSD_UWP)
m_framebuffer = m_targets->create_backbuffer(&win->m_window, m_width[win->m_index], m_height[win->m_index]); m_framebuffer = m_targets->create_backbuffer(win->platform_window<IInspectable*>(), m_width[win->m_index], m_height[win->m_index]);
#else #else
m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(win->platform_window<SDL_Window*>()), m_width[win->m_index], m_height[win->m_index]); m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(win->platform_window<SDL_Window*>()), m_width[win->m_index], m_height[win->m_index]);
#endif #endif
@ -920,7 +920,7 @@ bool renderer_bgfx::update_dimensions()
#ifdef OSD_WINDOWS #ifdef OSD_WINDOWS
m_framebuffer = m_targets->create_backbuffer(win->platform_window<HWND>(), width, height); m_framebuffer = m_targets->create_backbuffer(win->platform_window<HWND>(), width, height);
#elif defined(OSD_UWP) #elif defined(OSD_UWP)
m_framebuffer = m_targets->create_backbuffer(&win->m_window, width, height); m_framebuffer = m_targets->create_backbuffer(win->platform_window<IInspectable*>(), width, height);
#else #else
m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(win->platform_window<SDL_Window*>()), width, height); m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(win->platform_window<SDL_Window*>()), width, height);
#endif #endif

View File

@ -29,7 +29,7 @@ render_primitive_list *renderer_none::get_primitives()
#if defined(OSD_WINDOWS) #if defined(OSD_WINDOWS)
GetClientRect(win->platform_window<HWND>(), &client); GetClientRect(win->platform_window<HWND>(), &client);
#elif defined(OSD_UWP) #elif defined(OSD_UWP)
auto bounds = win->m_window->Bounds; auto bounds = std::static_pointer_cast<uwp_window_info>(win)->uwp_window()->Bounds;
client.left = bounds.Left; client.left = bounds.Left;
client.right = bounds.Right; client.right = bounds.Right;
client.top = bounds.Top; client.top = bounds.Top;

View File

@ -1,186 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
//============================================================
//
// main.c - Win32 main program
//
//============================================================
// standard windows headers
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include "uwpmain.h"
#include <wrl\client.h>
#undef interface
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::ApplicationModel::Activation;
using namespace Windows::UI::Core;
using namespace Windows::UI::Input;
using namespace Windows::System;
using namespace Windows::Foundation;
using namespace Windows::Graphics::Display;
using namespace MameUWP;
Platform::Array<Platform::String^>^ g_command_args;
// The main function is only used to initialize our IFrameworkView class.
[Platform::MTAThread]
int main(Platform::Array<Platform::String^>^ args)
{
g_command_args = args;
auto direct3DApplicationSource = ref new Direct3DApplicationSource();
CoreApplication::Run(direct3DApplicationSource);
return 0;
}
IFrameworkView^ Direct3DApplicationSource::CreateView()
{
return ref new App();
}
App::App() :
m_windowClosed(false),
m_windowVisible(true)
{
}
// The first method called when the IFrameworkView is being created.
void App::Initialize(CoreApplicationView^ applicationView)
{
// Register event handlers for app lifecycle. This example includes Activated, so that we
// can make the CoreWindow active and start rendering on the window.
applicationView->Activated +=
ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &App::OnActivated);
CoreApplication::Suspending +=
ref new EventHandler<SuspendingEventArgs^>(this, &App::OnSuspending);
CoreApplication::Resuming +=
ref new EventHandler<Platform::Object^>(this, &App::OnResuming);
}
// Called when the CoreWindow object is created (or re-created).
void App::SetWindow(CoreWindow^ window)
{
window->SizeChanged +=
ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &App::OnWindowSizeChanged);
window->VisibilityChanged +=
ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &App::OnVisibilityChanged);
window->Closed +=
ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &App::OnWindowClosed);
DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView();
currentDisplayInformation->DpiChanged +=
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnDpiChanged);
currentDisplayInformation->OrientationChanged +=
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnOrientationChanged);
DisplayInformation::DisplayContentsInvalidated +=
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnDisplayContentsInvalidated);
}
// Initializes scene resources, or loads a previously saved app state.
void App::Load(Platform::String^ entryPoint)
{
}
// This method is called after the window becomes active.
void App::Run()
{
// parse config and cmdline options
// DWORD result;
{
/* winrt_options options;
winrt_osd_interface osd(options);
char exe_path[MAX_PATH];
GetModuleFileNameA(NULL, exe_path, MAX_PATH);
char* args[2] = { exe_path, (char*)"-verbose" };
osd.register_options();
cli_frontend frontend(options, osd);
result = frontend.execute(ARRAY_LENGTH(args), args);*/
}
}
// Required for IFrameworkView.
// Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView
// class is torn down while the app is in the foreground.
void App::Uninitialize()
{
}
// Application lifecycle event handlers.
void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
{
// Run() won't start until the CoreWindow is activated.
}
void App::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
{
// Save app state asynchronously after requesting a deferral. Holding a deferral
// indicates that the application is busy performing suspending operations. Be
// aware that a deferral may not be held indefinitely. After about five seconds,
// the app will be forced to exit.
SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
//create_task([this, deferral]()
//{
// //m_deviceResources->Trim();
// // Insert your code here.
// deferral->Complete();
//});
}
void App::OnResuming(Platform::Object^ sender, Platform::Object^ args)
{
// Restore any data or state that was unloaded on suspend. By default, data
// and state are persisted when resuming from suspend. Note that this event
// does not occur if the app was previously terminated.
// Insert your code here.
}
// Window event handlers.
void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
{
}
void App::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
{
m_windowVisible = args->Visible;
}
void App::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
{
m_windowClosed = true;
}
// DisplayInformation event handlers.
void App::OnDpiChanged(DisplayInformation^ sender, Object^ args)
{
}
void App::OnOrientationChanged(DisplayInformation^ sender, Object^ args)
{
}
void App::OnDisplayContentsInvalidated(DisplayInformation^ sender, Object^ args)
{
}

View File

@ -1,52 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Brad Hughes
//============================================================
//
// uwpmain.h - Universal Windows Paltform
//
//============================================================
#pragma once
namespace MameUWP
{
// Main entry point for our app. Connects the app with the Windows shell and handles application lifecycle events.
ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView
{
public:
App();
// IFrameworkView Methods.
virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
virtual void Load(Platform::String^ entryPoint);
virtual void Run();
virtual void Uninitialize();
protected:
// Application lifecycle event handlers.
void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
void OnResuming(Platform::Object^ sender, Platform::Object^ args);
// Window event handlers.
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
// DisplayInformation event handlers.
void OnDpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
void OnDisplayContentsInvalidated(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
private:
bool m_windowClosed;
bool m_windowVisible;
};
}
ref class Direct3DApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
{
public:
virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
};

View File

@ -65,11 +65,14 @@ bool windows_osd_interface::video_init()
windows_options &options = downcast<windows_options &>(machine().options()); windows_options &options = downcast<windows_options &>(machine().options());
for (int index = 0; index < video_config.numscreens; index++) for (int index = 0; index < video_config.numscreens; index++)
{ {
win_window_info::create(machine(), index, m_monitor_module->pick_monitor(options, index), &windows[index]); uwp_window_info::create(machine(), index, m_monitor_module->pick_monitor(options, index), &windows[index]);
} }
if (video_config.mode != VIDEO_MODE_NONE) if (video_config.mode != VIDEO_MODE_NONE)
osd_common_t::s_window_list.front()->platform_window<Platform::Agile<CoreWindow^>>()->Activate(); {
auto win = std::static_pointer_cast<uwp_window_info>(osd_common_t::s_window_list.front());
win->uwp_window()->Activate();
}
return true; return true;
} }

View File

@ -243,7 +243,7 @@ void windows_osd_interface::window_exit()
CloseHandle(ui_pause_event); CloseHandle(ui_pause_event);
} }
win_window_info::win_window_info( uwp_window_info::uwp_window_info(
running_machine &machine, running_machine &machine,
int index, int index,
std::shared_ptr<osd_monitor_info> monitor, std::shared_ptr<osd_monitor_info> monitor,
@ -273,11 +273,11 @@ win_window_info::win_window_info(
m_prescale = video_config.prescale; m_prescale = video_config.prescale;
} }
POINT win_window_info::s_saved_cursor_pos = { -1, -1 }; POINT uwp_window_info::s_saved_cursor_pos = { -1, -1 };
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
void win_window_info::capture_pointer() void uwp_window_info::capture_pointer()
{ {
RECT bounds; RECT bounds;
GetClientRect(platform_window<HWND>(), &bounds); GetClientRect(platform_window<HWND>(), &bounds);
@ -286,12 +286,12 @@ void win_window_info::capture_pointer()
ClipCursor(&bounds); ClipCursor(&bounds);
} }
void win_window_info::release_pointer() void uwp_window_info::release_pointer()
{ {
ClipCursor(nullptr); ClipCursor(nullptr);
} }
void win_window_info::hide_pointer() void uwp_window_info::hide_pointer()
{ {
GetCursorPos(&s_saved_cursor_pos); GetCursorPos(&s_saved_cursor_pos);
@ -299,7 +299,7 @@ void win_window_info::hide_pointer()
ShowCursor(TRUE); ShowCursor(TRUE);
} }
void win_window_info::show_pointer() void uwp_window_info::show_pointer()
{ {
if (s_saved_cursor_pos.x != -1 || s_saved_cursor_pos.y != -1) if (s_saved_cursor_pos.x != -1 || s_saved_cursor_pos.y != -1)
{ {
@ -313,29 +313,29 @@ void win_window_info::show_pointer()
#else #else
CoreCursor^ win_window_info::s_cursor = nullptr; CoreCursor^ uwp_window_info::s_cursor = nullptr;
void win_window_info::capture_pointer() void uwp_window_info::capture_pointer()
{ {
platform_window<Platform::Agile<CoreWindow^>>()->SetPointerCapture(); uwp_window()->SetPointerCapture();
} }
void win_window_info::release_pointer() void uwp_window_info::release_pointer()
{ {
platform_window<Platform::Agile<CoreWindow^>>()->ReleasePointerCapture(); uwp_window()->ReleasePointerCapture();
} }
void win_window_info::hide_pointer() void uwp_window_info::hide_pointer()
{ {
auto window = platform_window<Platform::Agile<CoreWindow^>>(); auto window = uwp_window();
win_window_info::s_cursor = window->PointerCursor; uwp_window_info::s_cursor = window->PointerCursor;
window->PointerCursor = nullptr; window->PointerCursor = nullptr;
} }
void win_window_info::show_pointer() void uwp_window_info::show_pointer()
{ {
auto window = platform_window<Platform::Agile<CoreWindow^>>(); auto window = uwp_window();
window->PointerCursor = win_window_info::s_cursor; window->PointerCursor = uwp_window_info::s_cursor;
} }
#endif #endif
@ -357,19 +357,15 @@ void winwindow_process_events_periodic(running_machine &machine)
winwindow_process_events(machine, TRUE, false); winwindow_process_events(machine, TRUE, false);
} }
//============================================================ //============================================================
// is_mame_window // winwindow_has_focus
// (main or window thread)
//============================================================ //============================================================
static bool is_mame_window(HWND hwnd) BOOL winwindow_has_focus(void)
{ {
//for (auto window : osd_common_t::s_window_list) // For now always act like we have focus
//if (window->platform_window<HWND>() == hwnd) return TRUE;
//return true;
return false;
} }
inline static BOOL handle_mouse_button(windows_osd_interface *osd, int button, int down, int x, int y) inline static BOOL handle_mouse_button(windows_osd_interface *osd, int button, int down, int x, int y)
@ -421,12 +417,12 @@ void winwindow_process_events(running_machine &machine, int ingame, bool nodispa
// (main thread) // (main thread)
//============================================================ //============================================================
void win_window_info::create(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config *config) void uwp_window_info::create(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config *config)
{ {
assert(GetCurrentThreadId() == main_threadid); assert(GetCurrentThreadId() == main_threadid);
// allocate a new window object // allocate a new window object
auto window = std::make_shared<win_window_info>(machine, index, monitor, config); auto window = std::make_shared<uwp_window_info>(machine, index, monitor, config);
// set main window // set main window
if (window->m_index > 0) if (window->m_index > 0)
@ -485,7 +481,7 @@ void win_window_info::create(running_machine &machine, int index, std::shared_pt
fatalerror("Unable to complete window creation\n"); fatalerror("Unable to complete window creation\n");
} }
std::shared_ptr<osd_monitor_info> win_window_info::monitor_from_rect(const osd_rect* proposed) const std::shared_ptr<osd_monitor_info> uwp_window_info::monitor_from_rect(const osd_rect* proposed) const
{ {
std::shared_ptr<osd_monitor_info> monitor; std::shared_ptr<osd_monitor_info> monitor;
@ -513,7 +509,7 @@ std::shared_ptr<osd_monitor_info> win_window_info::monitor_from_rect(const osd_r
// (main thread) // (main thread)
//============================================================ //============================================================
void win_window_info::destroy() void uwp_window_info::destroy()
{ {
assert(GetCurrentThreadId() == main_threadid); assert(GetCurrentThreadId() == main_threadid);
@ -535,7 +531,7 @@ void win_window_info::destroy()
// (main thread) // (main thread)
//============================================================ //============================================================
void win_window_info::update() void uwp_window_info::update()
{ {
int targetview, targetorient; int targetview, targetorient;
render_layer_config targetlayerconfig; render_layer_config targetlayerconfig;
@ -598,7 +594,7 @@ void win_window_info::update()
// (main thread) // (main thread)
//============================================================ //============================================================
void win_window_info::set_starting_view(int index, const char *defview, const char *view) void uwp_window_info::set_starting_view(int index, const char *defview, const char *view)
{ {
int viewindex; int viewindex;
@ -678,7 +674,7 @@ int winwindow_ui_is_paused(running_machine &machine)
// (window thread) // (window thread)
//============================================================ //============================================================
int win_window_info::wnd_extra_width() int uwp_window_info::wnd_extra_width()
{ {
RECT temprect = { 100, 100, 200, 200 }; RECT temprect = { 100, 100, 200, 200 };
if (fullscreen()) if (fullscreen())
@ -694,7 +690,7 @@ int win_window_info::wnd_extra_width()
// (window thread) // (window thread)
//============================================================ //============================================================
int win_window_info::wnd_extra_height() int uwp_window_info::wnd_extra_height()
{ {
RECT temprect = { 100, 100, 200, 200 }; RECT temprect = { 100, 100, 200, 200 };
if (fullscreen()) if (fullscreen())
@ -709,7 +705,7 @@ int win_window_info::wnd_extra_height()
// (window thread) // (window thread)
//============================================================ //============================================================
int win_window_info::complete_create() int uwp_window_info::complete_create()
{ {
int tempwidth, tempheight; int tempwidth, tempheight;
@ -718,7 +714,9 @@ int win_window_info::complete_create()
// get the monitor bounds // get the monitor bounds
osd_rect monitorbounds = m_monitor->position_size(); osd_rect monitorbounds = m_monitor->position_size();
m_window = Windows::UI::Core::CoreWindow::GetForCurrentThread(); IInspectable* raw_window = reinterpret_cast<IInspectable*>(Windows::UI::Core::CoreWindow::GetForCurrentThread());
raw_window->AddRef(); // TODO: Should probably figure out a way to auto-release
set_platform_window(raw_window);
// skip the positioning stuff for -video none */ // skip the positioning stuff for -video none */
if (video_config.mode == VIDEO_MODE_NONE) if (video_config.mode == VIDEO_MODE_NONE)
@ -757,7 +755,7 @@ int win_window_info::complete_create()
// (window thread) // (window thread)
//============================================================ //============================================================
osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int adjustment) osd_rect uwp_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int adjustment)
{ {
assert(GetCurrentThreadId() == window_threadid); assert(GetCurrentThreadId() == window_threadid);
@ -882,7 +880,7 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
// (window thread) // (window thread)
//============================================================ //============================================================
osd_dim win_window_info::get_min_bounds(int constrain) osd_dim uwp_window_info::get_min_bounds(int constrain)
{ {
int32_t minwidth, minheight; int32_t minwidth, minheight;
@ -935,7 +933,7 @@ osd_dim win_window_info::get_min_bounds(int constrain)
// (window thread) // (window thread)
//============================================================ //============================================================
osd_dim win_window_info::get_max_bounds(int constrain) osd_dim uwp_window_info::get_max_bounds(int constrain)
{ {
//assert(GetCurrentThreadId() == window_threadid); //assert(GetCurrentThreadId() == window_threadid);
@ -975,7 +973,7 @@ osd_dim win_window_info::get_max_bounds(int constrain)
// (window thread) // (window thread)
//============================================================ //============================================================
void win_window_info::update_minmax_state() void uwp_window_info::update_minmax_state()
{ {
assert(GetCurrentThreadId() == window_threadid); assert(GetCurrentThreadId() == window_threadid);
@ -1008,30 +1006,28 @@ void win_window_info::update_minmax_state()
// (window thread) // (window thread)
//============================================================ //============================================================
void win_window_info::minimize_window() void uwp_window_info::minimize_window()
{ {
assert(GetCurrentThreadId() == window_threadid); assert(GetCurrentThreadId() == window_threadid);
osd_dim newsize = get_min_bounds(video_config.keepaspect); osd_dim newsize = get_min_bounds(video_config.keepaspect);
// get the window rect // get the window rect
RECT bounds; //RECT bounds;
//GetWindowRect(platform_window<HWND>(), &bounds); //GetWindowRect(platform_window<HWND>(), &bounds);
osd_rect newrect(bounds.left, bounds.top, newsize ); //osd_rect newrect(bounds.left, bounds.top, newsize );
//SetWindowPos(platform_window<HWND>(), nullptr, newrect.left(), newrect.top(), newrect.width(), newrect.height(), SWP_NOZORDER); //SetWindowPos(platform_window<HWND>(), nullptr, newrect.left(), newrect.top(), newrect.width(), newrect.height(), SWP_NOZORDER);
} }
//============================================================ //============================================================
// maximize_window // maximize_window
// (window thread) // (window thread)
//============================================================ //============================================================
void win_window_info::maximize_window() void uwp_window_info::maximize_window()
{ {
assert(GetCurrentThreadId() == window_threadid); assert(GetCurrentThreadId() == window_threadid);
@ -1053,7 +1049,7 @@ void win_window_info::maximize_window()
// (window thread) // (window thread)
//============================================================ //============================================================
void win_window_info::adjust_window_position_after_major_change() void uwp_window_info::adjust_window_position_after_major_change()
{ {
RECT oldrect; RECT oldrect;
@ -1100,7 +1096,7 @@ void win_window_info::adjust_window_position_after_major_change()
// (window thread) // (window thread)
//============================================================ //============================================================
void win_window_info::set_fullscreen(int fullscreen) void uwp_window_info::set_fullscreen(int fullscreen)
{ {
assert(GetCurrentThreadId() == window_threadid); assert(GetCurrentThreadId() == window_threadid);

View File

@ -1,5 +1,5 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Aaron Giles // copyright-holders:Aaron Giles, Brad Hughes
//============================================================ //============================================================
// //
// window.h - Win32 window handling // window.h - Win32 window handling
@ -14,6 +14,9 @@
#include <windows.h> #include <windows.h>
#include <windowsx.h> #include <windowsx.h>
#include <mmsystem.h> #include <mmsystem.h>
#include <inspectable.h>
#undef min
#undef max
#include <chrono> #include <chrono>
#include <mutex> #include <mutex>
@ -43,10 +46,10 @@
// TYPE DEFINITIONS // TYPE DEFINITIONS
//============================================================ //============================================================
class win_window_info : public osd_window class uwp_window_info : public osd_window
{ {
public: public:
win_window_info(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config *config); uwp_window_info(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config *config);
running_machine &machine() const override { return m_machine; } running_machine &machine() const override { return m_machine; }
@ -55,24 +58,14 @@ public:
void update() override; void update() override;
virtual bool win_has_menu() override
{
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
return GetMenu(platform_window<HWND>()) ? true : false;
#else
return false;
#endif
}
virtual osd_dim get_size() override virtual osd_dim get_size() override
{ {
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
RECT client;
GetClientRect(platform_window<HWND>(), &client);
return osd_dim(client.right - client.left, client.bottom - client.top);
#else
throw ref new Platform::NotImplementedException(); throw ref new Platform::NotImplementedException();
#endif }
bool win_has_menu() override
{
return false;
} }
void capture_pointer() override; void capture_pointer() override;
@ -80,6 +73,12 @@ public:
void show_pointer() override; void show_pointer() override;
void hide_pointer() override; void hide_pointer() override;
Windows::UI::Core::CoreWindow^ uwp_window()
{
auto inspectable = platform_window<IInspectable*>();
return reinterpret_cast<Windows::UI::Core::CoreWindow^>(inspectable);
}
virtual osd_monitor_info *monitor() const override { return m_monitor.get(); } virtual osd_monitor_info *monitor() const override { return m_monitor.get(); }
void destroy() override; void destroy() override;
@ -94,7 +93,7 @@ public:
// member variables // member variables
win_window_info * m_next; uwp_window_info * m_next;
volatile int m_init_state; volatile int m_init_state;
// window handle and info // window handle and info
@ -157,7 +156,9 @@ struct osd_draw_callbacks
// PROTOTYPES // PROTOTYPES
//============================================================ //============================================================
BOOL winwindow_has_focus(void);
void winwindow_process_events(running_machine &machine, int ingame, bool nodispatch); void winwindow_process_events(running_machine &machine, int ingame, bool nodispatch);
void winwindow_process_events_periodic(running_machine &machine);
//============================================================ //============================================================
// rect_width / rect_height // rect_width / rect_height

View File

@ -24,6 +24,7 @@
// MAME headers // MAME headers
#include "emu.h" #include "emu.h"
#include "emuopts.h" #include "emuopts.h"
#include "strconv.h"
// MAMEOS headers // MAMEOS headers
#include "winmain.h" #include "winmain.h"
@ -99,10 +100,10 @@ public:
char buffer[1024]; char buffer[1024];
vsnprintf(buffer, ARRAY_LENGTH(buffer), msg, args); vsnprintf(buffer, ARRAY_LENGTH(buffer), msg, args);
osd_unique_wstr wcbuffer(osd::text::to_wstring(buffer)); std::wstring wcbuffer(osd::text::to_wstring(buffer));
osd_unique_wstr wcappname(osd::text::to_wstring(emulator_info::get_appname())); std::wstring wcappname(osd::text::to_wstring(emulator_info::get_appname()));
auto dlg = ref new MessageDialog(ref new Platform::String(wcbuffer.get()), ref new Platform::String(wcappname.get())); auto dlg = ref new MessageDialog(ref new Platform::String(wcbuffer.data()), ref new Platform::String(wcbuffer.data()));
dlg->ShowAsync(); dlg->ShowAsync();
} }
else else
@ -343,6 +344,15 @@ static BOOL WINAPI control_handler(DWORD type)
#else #else
// The main function is only used to initialize our IFrameworkView class.
[Platform::MTAThread]
int main(Platform::Array<Platform::String^>^ args)
{
auto direct3DApplicationSource = ref new MameViewSource();
CoreApplication::Run(direct3DApplicationSource);
return 0;
}
MameMainApp::MameMainApp() MameMainApp::MameMainApp()
{ {
} }
@ -373,7 +383,7 @@ void MameMainApp::Run()
// parse config and cmdline options // parse config and cmdline options
m_options = std::make_unique<windows_options>(); m_options = std::make_unique<windows_options>();
m_osd = std::make_unique<windows_osd_interface>(m_options); m_osd = std::make_unique<windows_osd_interface>(*m_options.get());
// Since we're a GUI app, out errors to message boxes // Since we're a GUI app, out errors to message boxes
// Initialize this after the osd interface so that we are first in the // Initialize this after the osd interface so that we are first in the

View File

@ -258,8 +258,10 @@ struct _EXCEPTION_POINTERS;
class windows_osd_interface : public osd_common_t class windows_osd_interface : public osd_common_t
{ {
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// Access to exception filter static method // Access to exception filter static method
friend int main(int argc, char *argv[]); friend int main(int argc, char *argv[]);
#endif
public: public:
// construction/destruction // construction/destruction

View File

@ -28,6 +28,7 @@ void win_output_debug_string_utf8(const char *string)
} }
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
//============================================================ //============================================================
// win_message_box_utf8 // win_message_box_utf8
@ -55,6 +56,8 @@ int win_message_box_utf8(HWND window, const char *text, const char *caption, UIN
return MessageBox(window, t_text, t_caption, type); return MessageBox(window, t_text, t_caption, type);
} }
#endif
//============================================================ //============================================================
@ -113,6 +116,7 @@ std::string win_get_window_text_utf8(HWND window)
} }
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
//============================================================ //============================================================
// win_create_window_ex_utf8 // win_create_window_ex_utf8
@ -135,3 +139,5 @@ HWND win_create_window_ex_utf8(DWORD exstyle, const char* classname, const char*
return CreateWindowEx(exstyle, ts_classname.c_str(), t_windowname, style, x, y, width, height, parent, return CreateWindowEx(exstyle, ts_classname.c_str(), t_windowname, style, x, y, width, height, parent,
menu, instance, param); menu, instance, param);
} }
#endif