From 67389f4cbdd00e1b139590325d5fbae47d0e62d0 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Tue, 26 Oct 2021 11:28:11 +0200 Subject: [PATCH] Remove uwp specific sources --- scripts/src/osd/modules.lua | 1 - src/osd/modules/input/input_uwp.cpp | 652 --------------- src/osd/modules/lib/osdlib_uwp.cpp | 207 ----- src/osd/modules/lib/osdobj_common.cpp | 2 - src/osd/uwp/uwpcompat.cpp | 103 --- src/osd/uwp/uwpcompat.h | 139 ---- src/osd/uwp/video.cpp | 209 ----- src/osd/uwp/video.h | 19 - src/osd/uwp/window.cpp | 1076 ------------------------- src/osd/uwp/window.h | 151 ---- 10 files changed, 2559 deletions(-) delete mode 100644 src/osd/modules/input/input_uwp.cpp delete mode 100644 src/osd/modules/lib/osdlib_uwp.cpp delete mode 100644 src/osd/uwp/uwpcompat.cpp delete mode 100644 src/osd/uwp/uwpcompat.h delete mode 100644 src/osd/uwp/video.cpp delete mode 100644 src/osd/uwp/video.h delete mode 100644 src/osd/uwp/window.cpp delete mode 100644 src/osd/uwp/window.h diff --git a/scripts/src/osd/modules.lua b/scripts/src/osd/modules.lua index 7ee20732784..48f83e126cd 100644 --- a/scripts/src/osd/modules.lua +++ b/scripts/src/osd/modules.lua @@ -104,7 +104,6 @@ function osdmodulesbuild() MAME_DIR .. "src/osd/modules/input/input_xinput.cpp", MAME_DIR .. "src/osd/modules/input/input_xinput.h", MAME_DIR .. "src/osd/modules/input/input_winhybrid.cpp", - MAME_DIR .. "src/osd/modules/input/input_uwp.cpp", MAME_DIR .. "src/osd/modules/input/input_mac.cpp", MAME_DIR .. "src/osd/modules/output/output_module.h", MAME_DIR .. "src/osd/modules/output/none.cpp", diff --git a/src/osd/modules/input/input_uwp.cpp b/src/osd/modules/input/input_uwp.cpp deleted file mode 100644 index 111ff0e0784..00000000000 --- a/src/osd/modules/input/input_uwp.cpp +++ /dev/null @@ -1,652 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Brad Hughes -//============================================================ -// -// input_uwp.cpp - UWP input implementation -// -//============================================================ - -#include "input_module.h" -#include "modules/osdmodule.h" - -#if defined(OSD_UWP) - -#include -#include -#include -#undef interface - -// MAME headers -#include "emu.h" -#include "uiinput.h" -#include "strconv.h" - -// MAMEOS headers -#include "winmain.h" -#include "input_common.h" -#include "input_windows.h" - - -namespace { - -#define UWP_BUTTON_COUNT 32 - -using namespace concurrency; -using namespace Windows::UI::Core; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Gaming::Input; - -//============================================================ -// UWP Base device/module implementation -//============================================================ - -//============================================================ -// UwpInputDevice - base class for implementing an input -// device in C++/CX. To be used with uwp_input_device -//============================================================ - -private ref class UwpInputDevice -{ -private: - running_machine & m_machine; - std::string m_name; - std::string m_id; - input_device_class m_devclass; - input_module & m_module; - input_device *m_inputdevice; - -internal: - UwpInputDevice(running_machine &machine, std::string &&name, std::string &&id, input_device_class deviceclass, input_module &module) : - m_machine(machine), - m_name(std::move(name)), - m_id(std::move(id)), - m_devclass(deviceclass), - m_module(module), - m_inputdevice(nullptr) - { - } - - property running_machine & Machine - { - running_machine & get() { return m_machine; } - } - - property const std::string & Name - { - const std::string & get() { return m_name; } - } - - property const std::string & Id - { - const std::string & get() { return m_id; } - } - - property input_device_class DeviceClass - { - input_device_class get() { return m_devclass; } - } - - property input_module & Module - { - input_module & get() { return m_module; } - } - - property input_device* InputDevice - { - input_device* get() { return m_inputdevice; } - void set(input_device* value) { m_inputdevice = value; } - } - - virtual void Poll() - { - } - - virtual void Reset() - { - } -}; - -//============================================================ -// uwp_input_device - a device that can be used to wrap a -// C++/CX ref class for an input device implementation -//============================================================ - -class uwp_input_device : public device_info -{ -private: - UwpInputDevice ^m_wrapped_device; - -public: - uwp_input_device(UwpInputDevice ^device) : - device_info(device->Machine, std::string(device->Name), std::string(device->Id), device->DeviceClass, device->Module), - m_wrapped_device(device) - { - } - - void poll() override - { - m_wrapped_device->Poll(); - } - - void reset() override - { - m_wrapped_device->Reset(); - } -}; - -//============================================================ -// UwpInputModule - a base class that can be used to -// implement an input module with a C++/CX class. -// normally used with uwp_wininput_module -//============================================================ - -class uwp_input_module; - -private ref class UwpInputModule -{ -private: - const std::string m_type; - const std::string m_name; - uwp_input_module *m_module; - -internal: - UwpInputModule(std::string &&type, std::string &&name) : - m_type(std::move(type)), - m_name(std::move(name)), - m_module(nullptr) - { - } - - property const std::string & Type - { - const std::string & get() { return m_type; } - } - - property const std::string & Name - { - const std::string & get() { return m_name; } - } - - property uwp_input_module * NativeModule - { - uwp_input_module * get() { return m_module; } - void set(uwp_input_module * value) { m_module = value; } - } - - virtual void input_init(running_machine &machine) - { - } -}; - -//============================================================ -// uwp_input_module - an input module that can be -// used to create an input module with a C++/CX ref class -//============================================================ - -class uwp_input_module : public wininput_module -{ -private: - UwpInputModule^ m_refmodule; - -public: - uwp_input_module(UwpInputModule^ refmodule) : - wininput_module(refmodule->Type.c_str(), refmodule->Name.c_str()), - m_refmodule(refmodule) - { - refmodule->NativeModule = this; - } - - void input_init(running_machine &machine) override - { - m_refmodule->input_init(machine); - } -}; - -//============================================================ -// UWP Keyboard Implementation -//============================================================ - -//============================================================ -// UwpKeyboardDevice -//============================================================ - -private ref class UwpKeyboardDevice : public UwpInputDevice -{ -private: - keyboard_state keyboard; - Platform::Agile m_coreWindow; - std::mutex m_state_lock; - -internal: - UwpKeyboardDevice(Platform::Agile coreWindow, running_machine& machine, std::string &&name, std::string &&id, input_module &module) : - UwpInputDevice(machine, std::move(name), std::move(id), DEVICE_CLASS_KEYBOARD, module), - keyboard({{0}}), - m_coreWindow(coreWindow) - { - coreWindow->Dispatcher->AcceleratorKeyActivated += ref new TypedEventHandler(this, &UwpKeyboardDevice::OnAcceleratorKeyActivated); - coreWindow->KeyDown += ref new TypedEventHandler(this, &UwpKeyboardDevice::OnKeyDown); - coreWindow->KeyUp += ref new TypedEventHandler(this, &UwpKeyboardDevice::OnKeyUp); - coreWindow->CharacterReceived += ref new TypedEventHandler(this, &UwpKeyboardDevice::OnCharacterReceived); - } - - void Reset() override - { - std::lock_guard scope_lock(m_state_lock); - memset(&keyboard, 0, sizeof(keyboard)); - } - - void Configure() - { - keyboard_trans_table &table = keyboard_trans_table::instance(); - - // populate it indexed by the scancode - for (int keynum = KEY_UNKNOWN + 1; keynum < MAX_KEYS; keynum++) - { - input_item_id itemid = table.map_di_scancode_to_itemid(keynum); - const char *keyname = table.ui_label_for_mame_key(itemid); - - char temp[256]; - if (!keyname) - { - snprintf(temp, std::size(temp), "Scan%03d", keynum); - keyname = temp; - } - - // add the item to the device - this->InputDevice->add_item(keyname, itemid, generic_button_get_state, &keyboard.state[keynum]); - } - } - - void OnKeyDown(CoreWindow^ win, KeyEventArgs^ args) - { - std::lock_guard scope_lock(m_state_lock); - CorePhysicalKeyStatus status = args->KeyStatus; - int discancode = (status.ScanCode & 0x7f) | (status.IsExtendedKey ? 0x80 : 0x00); - keyboard.state[discancode] = 0x80; - } - - void OnKeyUp(CoreWindow^ win, KeyEventArgs^ args) - { - std::lock_guard scope_lock(m_state_lock); - CorePhysicalKeyStatus status = args->KeyStatus; - int discancode = (status.ScanCode & 0x7f) | (status.IsExtendedKey ? 0x80 : 0x00); - keyboard.state[discancode] = 0; - } - - void OnCharacterReceived(CoreWindow ^sender, CharacterReceivedEventArgs ^args) - { - this->Machine.ui_input().push_char_event(osd_common_t::s_window_list.front()->target(), args->KeyCode); - } - - void OnAcceleratorKeyActivated(CoreDispatcher ^sender, AcceleratorKeyEventArgs ^args) - { - std::lock_guard scope_lock(m_state_lock); - auto eventType = args->EventType; - if (eventType == CoreAcceleratorKeyEventType::SystemKeyDown || - eventType == CoreAcceleratorKeyEventType::SystemKeyUp) - { - CorePhysicalKeyStatus status = args->KeyStatus; - int discancode = (status.ScanCode & 0x7f) | (status.IsExtendedKey ? 0x80 : 0x00); - keyboard.state[discancode] = - eventType == CoreAcceleratorKeyEventType::SystemKeyDown ? 0x80 : 0; - } - } -}; - -//============================================================ -// UwpKeyboardModule -//============================================================ - -private ref class UwpKeyboardModule : public UwpInputModule -{ -private: - running_machine *m_machine; - -internal: - UwpKeyboardModule() : UwpInputModule(OSD_KEYBOARDINPUT_PROVIDER, "uwp") - { - } - - void input_init(running_machine &machine) override - { - auto first_window = std::static_pointer_cast(osd_common_t::s_window_list.front()); - auto coreWindow = first_window->platform_window(); - - // allocate the UWP implementation of the device object - UwpKeyboardDevice ^refdevice = ref new UwpKeyboardDevice(coreWindow, machine, "UWP Keyboard 1", "UWP Keyboard 1", *this->NativeModule); - - // Allocate the wrapper and add it to the list - auto created_devinfo = std::make_unique(refdevice); - uwp_input_device &devinfo = NativeModule->devicelist()->add_device(machine, std::move(created_devinfo)); - - // Give the UWP implementation a handle to the input_device - refdevice->InputDevice = devinfo.device(); - - // Configure the device - refdevice->Configure(); - } -}; - -//============================================================ -// uwp_keyboard_module -//============================================================ - -class uwp_keyboard_module : public uwp_input_module -{ -public: - uwp_keyboard_module() - : uwp_input_module(ref new UwpKeyboardModule()) - { - } -}; - -// default axis names -static const char *const uwp_axis_name[] = -{ - "LSX", - "LSY", - "RSX", - "RSY" -}; - -static const input_item_id uwp_axis_ids[] = -{ - ITEM_ID_XAXIS, - ITEM_ID_YAXIS, - ITEM_ID_RXAXIS, - ITEM_ID_RYAXIS -}; - -struct gamepad_state -{ - BYTE buttons[UWP_BUTTON_COUNT]; - LONG left_trigger; - LONG right_trigger; - LONG left_thumb_x; - LONG left_thumb_y; - LONG right_thumb_x; - LONG right_thumb_y; -}; - -// Maps different UWP GameControllerButtonLabels to a halfway-sane input_item_id in many cases -static input_item_id buttonlabel_to_itemid[] = -{ - input_item_id::ITEM_ID_INVALID, // GameControllerButtonLabel::None - input_item_id::ITEM_ID_SELECT, // GameControllerButtonLabel::XboxBack - input_item_id::ITEM_ID_START, // GameControllerButtonLabel::XboxStart - input_item_id::ITEM_ID_START, // GameControllerButtonLabel::XboxMenu - input_item_id::ITEM_ID_SELECT, // GameControllerButtonLabel::XboxView - input_item_id::ITEM_ID_HAT1UP, // GameControllerButtonLabel::XboxUp - input_item_id::ITEM_ID_HAT1DOWN, // GameControllerButtonLabel::XboxDown - input_item_id::ITEM_ID_HAT1LEFT, // GameControllerButtonLabel::XboxLeft - input_item_id::ITEM_ID_HAT1RIGHT, // GameControllerButtonLabel::XboxRight - input_item_id::ITEM_ID_BUTTON1, // GameControllerButtonLabel::XboxA - input_item_id::ITEM_ID_BUTTON2, // GameControllerButtonLabel::XboxB - input_item_id::ITEM_ID_BUTTON3, // GameControllerButtonLabel::XboxX - input_item_id::ITEM_ID_BUTTON4, // GameControllerButtonLabel::XboxY - input_item_id::ITEM_ID_BUTTON5, // GameControllerButtonLabel::XboxLeftBumper - input_item_id::ITEM_ID_ZAXIS, // GameControllerButtonLabel::XboxLeftTrigger - input_item_id::ITEM_ID_BUTTON7, // GameControllerButtonLabel::XboxLeftStickButton - input_item_id::ITEM_ID_BUTTON6, // GameControllerButtonLabel::XboxRightBumper - input_item_id::ITEM_ID_RZAXIS, // GameControllerButtonLabel::XboxRightTrigger - input_item_id::ITEM_ID_BUTTON8, // GameControllerButtonLabel::XboxRightStickButton - input_item_id::ITEM_ID_BUTTON9, // GameControllerButtonLabel::XboxPaddle1 - input_item_id::ITEM_ID_BUTTON10, // GameControllerButtonLabel::XboxPaddle2 - input_item_id::ITEM_ID_BUTTON11, // GameControllerButtonLabel::XboxPaddle3 - input_item_id::ITEM_ID_BUTTON12, // GameControllerButtonLabel::XboxPaddle4 - input_item_id::ITEM_ID_INVALID, // GameControllerButtonLabel_Mode - input_item_id::ITEM_ID_SELECT, // GameControllerButtonLabel_Select - input_item_id::ITEM_ID_START, // GameControllerButtonLabel_Menu - input_item_id::ITEM_ID_SELECT, // GameControllerButtonLabel_View - input_item_id::ITEM_ID_SELECT, // GameControllerButtonLabel_Back - input_item_id::ITEM_ID_START, // GameControllerButtonLabel_Start - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Options - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Share - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Up - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Down - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Left - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Right - input_item_id::ITEM_ID_BUTTON1, // GameControllerButtonLabel_LetterA - input_item_id::ITEM_ID_BUTTON2, // GameControllerButtonLabel_LetterB - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_LetterC - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_LetterL - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_LetterR - input_item_id::ITEM_ID_BUTTON3, // GameControllerButtonLabel_LetterX - input_item_id::ITEM_ID_BUTTON4, // GameControllerButtonLabel_LetterY - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_LetterZ - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Cross - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Circle - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Square - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Triangle - input_item_id::ITEM_ID_BUTTON5, // GameControllerButtonLabel_LeftBumper - input_item_id::ITEM_ID_ZAXIS, // GameControllerButtonLabel_LeftTrigger - input_item_id::ITEM_ID_BUTTON7, // GameControllerButtonLabel_LeftStickButton - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Left1 - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Left2 - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Left3 - input_item_id::ITEM_ID_BUTTON6, // GameControllerButtonLabel_RightBumper - input_item_id::ITEM_ID_RZAXIS, // GameControllerButtonLabel_RightTrigger - input_item_id::ITEM_ID_BUTTON8, // GameControllerButtonLabel_RightStickButton - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Right1 - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Right2 - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Right3 - input_item_id::ITEM_ID_BUTTON9, // GameControllerButtonLabel_Paddle1 - input_item_id::ITEM_ID_BUTTON10, // GameControllerButtonLabel_Paddle2 - input_item_id::ITEM_ID_BUTTON11, // GameControllerButtonLabel_Paddle3 - input_item_id::ITEM_ID_BUTTON12, // GameControllerButtonLabel_Paddle4 - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Plus - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Minus - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_DownLeftArrow - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_DialLeft - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_DialRight - input_item_id::ITEM_ID_OTHER_SWITCH, // GameControllerButtonLabel_Suspension -}; - -//============================================================ -// UwpJoystickDevice -//============================================================ - -private ref class UwpJoystickDevice : public UwpInputDevice -{ -private: - Gamepad ^m_pad; - bool m_configured; - gamepad_state state; - -internal: - UwpJoystickDevice(Gamepad^ pad, running_machine &machine, const char *name, const char *id, input_module &module) - : UwpInputDevice(machine, name, id, DEVICE_CLASS_JOYSTICK, module), - m_pad(pad), - m_configured(false), - state({0}) - {} - - void Poll() override - { - // If the device hasn't been configured, don't poll - if (!m_configured) - return; - - GamepadReading reading = m_pad->GetCurrentReading(); - - for (int butnum = 0; butnum < UWP_BUTTON_COUNT; butnum++) - { - GamepadButtons currentButton = GamepadButtons(1 << butnum); - state.buttons[butnum] = (reading.Buttons & currentButton) != GamepadButtons::None ? 0xFF : 0; - } - - // Now grab the axis values - // Each of the thumbstick axis members is a signed value between -32768 and 32767 describing the position of the thumbstick - // However, the Y axis values are inverted from what MAME expects, so negate the value - state.left_thumb_x = normalize_absolute_axis(reading.LeftThumbstickX, -1, 1); - state.left_thumb_y = -normalize_absolute_axis(reading.LeftThumbstickY, -1, 1); - state.right_thumb_x = normalize_absolute_axis(reading.RightThumbstickX, -1, 1); - state.right_thumb_y = -normalize_absolute_axis(reading.RightThumbstickY, -1, 1); - - // Get the trigger values - state.left_trigger = normalize_absolute_axis(reading.LeftTrigger, 0.0, 1.0); - state.right_trigger = normalize_absolute_axis(reading.RightTrigger, 0.0, 1.0); - - // For the UI, triggering UI_CONFIGURE is odd. It requires a EVENT_CHAR first - static constexpr int menuhotkey = (int)(GamepadButtons::View | GamepadButtons::X); - if (((int)reading.Buttons & menuhotkey) == menuhotkey) - { - ui_event uiev; - memset(&uiev, 0, sizeof(uiev)); - uiev.event_type = ui_event::IME_CHAR; - this->Machine.ui_input().push_event(uiev); - } - } - - void Reset() override - { - memset(&state, 0, sizeof(state)); - } - - void Configure() - { - // If the device has already been configured, don't do it again - if (m_configured) - return; - - GamepadReading r = m_pad->GetCurrentReading(); - - // Add the axes - for (int axisnum = 0; axisnum < 4; axisnum++) - { - this->InputDevice->add_item( - uwp_axis_name[axisnum], - uwp_axis_ids[axisnum], - generic_axis_get_state, - &state.left_thumb_x + axisnum); - } - - // populate the buttons - for (int butnum = 0; butnum < UWP_BUTTON_COUNT; butnum++) - { - GamepadButtons button = GamepadButtons(1 << butnum); - auto label = m_pad->GetButtonLabel(button); - if (label != GameControllerButtonLabel::None) - { - std::string desc = osd::text::from_wstring(label.ToString()->Data()); - this->InputDevice->add_item( - desc.c_str(), - buttonlabel_to_itemid[static_cast(label)], - generic_button_get_state, - &state.buttons[butnum]); - } - } - - this->InputDevice->add_item( - "Left Trigger", - ITEM_ID_ZAXIS, - generic_axis_get_state, - &state.left_trigger); - - this->InputDevice->add_item( - "Right Trigger", - ITEM_ID_RZAXIS, - generic_axis_get_state, - &state.right_trigger); - - m_configured = true; - } -}; - -//============================================================ -// UwpJoystickModule -//============================================================ - -private ref class UwpJoystickModule : public UwpInputModule -{ -private: - boolean m_joysticks_discovered; - -internal: - UwpJoystickModule() - : UwpInputModule(OSD_JOYSTICKINPUT_PROVIDER, "uwp"), - m_joysticks_discovered(false) - { - } - - void input_init(running_machine &machine) override - { - PerformGamepadDiscovery(); - - auto pads = Gamepad::Gamepads; - - int padindex = 0; - std::for_each(begin(pads), end(pads), [&](Gamepad^ pad) - { - std::ostringstream namestream; - namestream << "UWP Gamepad " << (padindex + 1); - - auto name = namestream.str(); - - // allocate the UWP implementation of the device object - UwpJoystickDevice ^refdevice = ref new UwpJoystickDevice(pad, machine, name.c_str(), name.c_str(), *this->NativeModule); - - // Allocate the wrapper and add it to the list - auto created_devinfo = std::make_unique(refdevice); - auto &devinfo = NativeModule->devicelist()->add_device(machine, std::move(created_devinfo)); - - // Give the UWP implementation a handle to the input_device - refdevice->InputDevice = devinfo->device(); - - // Configure the device - refdevice->Configure(); - - padindex++; - }); - } - -private: - void PerformGamepadDiscovery() - { - Gamepad::GamepadAdded += ref new EventHandler(this, &UwpJoystickModule::OnGamepadAdded); - auto start = std::chrono::system_clock::now(); - - // We need to pause a bit and pump events so gamepads get discovered - while (std::chrono::system_clock::now() - start < std::chrono::milliseconds(1000)) - CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); - - m_joysticks_discovered = true; - } - - void OnGamepadAdded(Platform::Object ^sender, Gamepad ^pad) - { - if (m_joysticks_discovered) - { - osd_printf_error("Input: UWP Compatible %s gamepad plugged in AFTER discovery complete!\n", pad->IsWireless ? "Wireless" : "Wired"); - } - else - { - osd_printf_verbose("Input: UWP Compatible %s gamepad discovered.\n", pad->IsWireless ? "Wireless" : "Wired"); - } - } -}; - -//============================================================ -// uwp_joystick_module -//============================================================ - -class uwp_joystick_module : public uwp_input_module -{ -public: - uwp_joystick_module() : uwp_input_module(ref new UwpJoystickModule()) - { - } -}; - -} // anonymous namespace - -#else // defined(OSD_UWP) - -MODULE_NOT_SUPPORTED(uwp_keyboard_module, OSD_KEYBOARDINPUT_PROVIDER, "uwp") -MODULE_NOT_SUPPORTED(uwp_joystick_module, OSD_JOYSTICKINPUT_PROVIDER, "uwp") - -#endif // defined(OSD_UWP) - -MODULE_DEFINITION(KEYBOARDINPUT_UWP, uwp_keyboard_module) -MODULE_DEFINITION(JOYSTICKINPUT_UWP, uwp_joystick_module) diff --git a/src/osd/modules/lib/osdlib_uwp.cpp b/src/osd/modules/lib/osdlib_uwp.cpp deleted file mode 100644 index 87035e9db97..00000000000 --- a/src/osd/modules/lib/osdlib_uwp.cpp +++ /dev/null @@ -1,207 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert, R. Belmont, Brad Hughes -//============================================================ -// -// sdlos_*.c - OS specific low level code -// -// SDLMAME by Olivier Galibert and R. Belmont -// -//============================================================ - -// MAME headers -#include "osdlib.h" -#include "osdcomm.h" -#include "osdcore.h" -#include "strconv.h" - -#include -#include -#include -#include - -#include -#include - -#include - - -using namespace Platform; -using namespace Windows::ApplicationModel::DataTransfer; -using namespace Windows::Foundation; - - -//============================================================ -// GLOBAL VARIABLES -//============================================================ - -std::map> g_runtime_environment; - -//============================================================ -// osd_getenv -//============================================================ - -const char *osd_getenv(const char *name) -{ - for (auto iter = g_runtime_environment.begin(); iter != g_runtime_environment.end(); iter++) - { - if (stricmp(iter->first, name) == 0) - { - osd_printf_debug("ENVIRONMENT: Get %s = value: '%s'", name, iter->second.get()); - return iter->second.get(); - } - } - - return nullptr; -} - - -//============================================================ -// osd_setenv -//============================================================ - -int osd_setenv(const char *name, const char *value, int overwrite) -{ - if (!overwrite) - { - if (osd_getenv(name) != nullptr) - return 0; - } - - auto buf = std::make_unique(strlen(name) + strlen(value) + 2); - sprintf(buf.get(), "%s=%s", name, value); - - g_runtime_environment[name] = std::move(buf); - osd_printf_debug("ENVIRONMENT: Set %s to value: '%s'", name, buf.get()); - - return 0; -} - -//============================================================ -// osd_process_kill -//============================================================ - -void osd_process_kill() -{ - TerminateProcess(GetCurrentProcess(), -1); -} - -//============================================================ -// osd_break_into_debugger -//============================================================ - -void osd_break_into_debugger(const char *message) -{ - if (IsDebuggerPresent()) - { - OutputDebugStringA(message); - __debugbreak(); - } -} - -//============================================================ -// get_clipboard_text_by_format -//============================================================ - -static bool get_clipboard_text_by_format(std::string &result_text, UINT format, std::string (*convert)(LPCVOID data)) -{ - DataPackageView^ dataPackageView; - IAsyncOperation^ getTextOp; - String^ clipboardText; - - dataPackageView = Clipboard::GetContent(); - getTextOp = dataPackageView->GetTextAsync(); - clipboardText = getTextOp->GetResults(); - - result_text = convert(clipboardText->Data()); - return !result_text.empty(); -} - -//============================================================ -// convert_wide -//============================================================ - -static std::string convert_wide(LPCVOID data) -{ - return osd::text::from_wstring((LPCWSTR) data); -} - -//============================================================ -// convert_ansi -//============================================================ - -static std::string convert_ansi(LPCVOID data) -{ - return osd::text::from_astring((LPCSTR) data); -} - -//============================================================ -// osd_get_clipboard_text -//============================================================ - -std::string osd_get_clipboard_text() -{ - std::string result; - - // try to access unicode text - if (!get_clipboard_text_by_format(result, CF_UNICODETEXT, convert_wide)) - { - // try to access ANSI text - get_clipboard_text_by_format(result, CF_TEXT, convert_ansi); - } - - return result; -} - -//============================================================ -// osd_getpid -//============================================================ - -int osd_getpid() -{ - return GetCurrentProcessId(); -} - - -namespace osd { - -bool invalidate_instruction_cache(void const *start, std::size_t size) -{ - return FlushInstructionCache(GetCurrentProcess(), start, size) != 0; -} - - -void *virtual_memory_allocation::do_alloc(std::initializer_list blocks, unsigned intent, std::size_t &size, std::size_t &page_size) -{ - SYSTEM_INFO info; - GetSystemInfo(&info); - SIZE_T s(0); - for (std::size_t b : blocks) - s += (b + info.dwPageSize - 1) / info.dwPageSize; - s *= info.dwPageSize; - if (!s) - return nullptr; - LPVOID const result(VirtualAllocFromApp(nullptr, s, MEM_COMMIT, PAGE_NOACCESS)); - if (result) - { - size = s; - page_size = info.dwPageSize; - } - return result; -} - -void virtual_memory_allocation::do_free(void *start, std::size_t size) -{ - VirtualFree(start, 0, MEM_RELEASE); -} - -bool virtual_memory_allocation::do_set_access(void *start, std::size_t size, unsigned access) -{ - ULONG p, o; - if (access & EXECUTE) - p = (access & WRITE) ? PAGE_EXECUTE_READWRITE : (access & READ) ? PAGE_EXECUTE_READ : PAGE_EXECUTE; - else - p = (access & WRITE) ? PAGE_READWRITE : (access & READ) ? PAGE_READONLY : PAGE_NOACCESS; - return VirtualProtectFromApp(start, size, p, &o) != 0; -} - -} // namespace osd diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp index a8ed943f18b..be06da29767 100644 --- a/src/osd/modules/lib/osdobj_common.cpp +++ b/src/osd/modules/lib/osdobj_common.cpp @@ -260,7 +260,6 @@ void osd_common_t::register_options() REGISTER_MODULE(m_mod_man, KEYBOARDINPUT_RAWINPUT); REGISTER_MODULE(m_mod_man, KEYBOARDINPUT_DINPUT); REGISTER_MODULE(m_mod_man, KEYBOARDINPUT_WIN32); - REGISTER_MODULE(m_mod_man, KEYBOARDINPUT_UWP); REGISTER_MODULE(m_mod_man, KEYBOARD_NONE); REGISTER_MODULE(m_mod_man, MOUSEINPUT_SDL); @@ -278,7 +277,6 @@ void osd_common_t::register_options() REGISTER_MODULE(m_mod_man, JOYSTICKINPUT_WINHYBRID); REGISTER_MODULE(m_mod_man, JOYSTICKINPUT_DINPUT); REGISTER_MODULE(m_mod_man, JOYSTICKINPUT_XINPUT); - REGISTER_MODULE(m_mod_man, JOYSTICKINPUT_UWP); REGISTER_MODULE(m_mod_man, JOYSTICK_NONE); REGISTER_MODULE(m_mod_man, OUTPUT_NONE); diff --git a/src/osd/uwp/uwpcompat.cpp b/src/osd/uwp/uwpcompat.cpp deleted file mode 100644 index e4e1149f72c..00000000000 --- a/src/osd/uwp/uwpcompat.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Brad Hughes, Miodrag Milanovic -//============================================================ -// -// uwpcompat.h - Universal Windows Platform compat forced includes -// -//============================================================ - -#include "uwpcompat.h" - -#include -#include - -#undef interface - -#include "emu.h" - -extern "C" { - - BOOL WINAPI GetVersionEx( - _Inout_ LPOSVERSIONINFO lpVersionInfo - ) - { - lpVersionInfo->dwMajorVersion = 10; - return TRUE; - } - - HANDLE - WINAPI - CreateFileW( - _In_ LPCWSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile - ) - { - // TODO: Handle other arguments that go into last param (pCreateExParams) - return CreateFile2((wchar_t*)lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); - } - - HANDLE - WINAPI - CreateFileA( - _In_ LPCSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile - ) - { - wchar_t filepath[MAX_PATH + 1]; - if (MultiByteToWideChar(CP_ACP, 0, lpFileName, strlen(lpFileName), filepath, MAX_PATH)) - return CreateFileW(filepath, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); - - SetLastError(E_FAIL); - return INVALID_HANDLE_VALUE; - } - - DWORD WINAPI GetTickCount(void) - { - return osd_ticks(); - } - - // This is only in here so callers get an error - HMODULE WINAPI LoadLibraryExA( - _In_ LPCSTR lpLibFileName, - _Reserved_ HANDLE hFile, - _In_ DWORD dwFlags - ) - { - SetLastError(ERROR_FILE_NOT_FOUND); - return nullptr; - } - - HMODULE WINAPI LoadLibraryExW( - _In_ LPCWSTR lpLibFileName, - _Reserved_ HANDLE hFile, - _In_ DWORD dwFlags - ) - { - SetLastError(ERROR_FILE_NOT_FOUND); - return nullptr; - } - - DWORD WINAPI GetFileSize( - _In_ HANDLE hFile, - _Out_opt_ LPDWORD lpFileSizeHigh - ) - { - FILE_STANDARD_INFO file_info; - GetFileInformationByHandleEx(hFile, FileStandardInfo, &file_info, sizeof(file_info)); - if(lpFileSizeHigh!=nullptr) - { - *lpFileSizeHigh = file_info.EndOfFile.HighPart; - } - return file_info.EndOfFile.LowPart; - } -} diff --git a/src/osd/uwp/uwpcompat.h b/src/osd/uwp/uwpcompat.h deleted file mode 100644 index 5d0dbb07dcb..00000000000 --- a/src/osd/uwp/uwpcompat.h +++ /dev/null @@ -1,139 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Brad Hughes, Miodrag Milanovic -//============================================================ -// -// uwpcompat.h - Universal Windows Platform compat forced includes -// -//============================================================ - -#ifndef __UWPCOMPAT_H__ -#define __UWPCOMPAT_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef NOGDI -#define NOGDI -#endif -#include -#include - -int system(const char *command); - -const char *getenv(const char *varname); - -HANDLE -WINAPI -CreateFileA( - _In_ LPCSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile - ); - -HANDLE -WINAPI -CreateFileW( - _In_ LPCWSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile - ); - -#ifdef UNICODE -#define CreateFile CreateFileW -#else -#define CreateFile CreateFileA -#endif // !UNICODE - -BOOL WINAPI GetVersionEx( - _Inout_ LPOSVERSIONINFO lpVersionInfo -); - -DWORD WINAPI GetTickCount(void); - -FILE *_popen( - const char *command, - const char *mode - ); - -int _pclose( - FILE *stream); - -_Ret_maybenull_ -HMODULE WINAPI LoadLibraryA( - _In_ LPCSTR lpFileName -); - -_Ret_maybenull_ -HMODULE WINAPI LoadLibraryW( - _In_ LPCWSTR lpFileName -); - -#ifdef UNICODE -#define LoadLibrary LoadLibraryW -#else -#define LoadLibrary LoadLibraryA -#endif // !UNICODE - -_Ret_maybenull_ -HMODULE WINAPI GetModuleHandleA( - _In_ LPCSTR lpModuleName -); - -_Ret_maybenull_ -HMODULE WINAPI GetModuleHandleW( - _In_ LPCWSTR lpModuleName -); - -#ifdef UNICODE -#define GetModuleHandle GetModuleHandleW -#else -#define GetModuleHandle GetModuleHandleA -#endif // !UNICODE - -_Ret_maybenull_ -HMODULE -WINAPI -LoadLibraryExA( - _In_ LPCSTR lpLibFileName, - _Reserved_ HANDLE hFile, - _In_ DWORD dwFlags -); - -_Ret_maybenull_ -HMODULE -WINAPI -LoadLibraryExW( - _In_ LPCWSTR lpLibFileName, - _Reserved_ HANDLE hFile, - _In_ DWORD dwFlags -); - -#ifdef UNICODE -#define LoadLibraryEx LoadLibraryExW -#else -#define LoadLibraryEx LoadLibraryExA -#endif // !UNICODE - -DWORD -WINAPI -GetFileSize( - _In_ HANDLE hFile, - _Out_opt_ LPDWORD lpFileSizeHigh -); - -#ifdef __cplusplus -} -#endif - -#endif // __UWPCOMPAT_H__ - - diff --git a/src/osd/uwp/video.cpp b/src/osd/uwp/video.cpp deleted file mode 100644 index 8ca19c75af0..00000000000 --- a/src/osd/uwp/video.cpp +++ /dev/null @@ -1,209 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Brad Hughes, Aaron Giles -//============================================================ -// -// video.c - UWP video handling -// -//============================================================ - -#include - -// standard windows headers -#include -#include -#include -#undef interface - -// MAME headers -#include "emu.h" -#include "emuopts.h" -#include "render.h" -#include "uiinput.h" - -// MAMEOS headers -#include "winmain.h" -#include "video.h" -#include "window.h" -#include "strconv.h" - -#include "modules/osdwindow.h" - -using namespace Platform; -using namespace Microsoft::WRL; -using namespace Windows::UI::Core; - -//============================================================ -// GLOBAL VARIABLES -//============================================================ - -osd_video_config video_config; - - -//============================================================ -// PROTOTYPES -//============================================================ - -static void get_resolution(const char *defdata, const char *data, osd_window_config *config, int report_error); - - -//============================================================ -// video_init -//============================================================ - -// FIXME: Temporary workaround -static osd_window_config windows[MAX_VIDEO_WINDOWS]; // configuration data per-window - -bool windows_osd_interface::video_init() -{ - // extract data from the options - extract_video_config(); - - // initialize the window system so we can make windows - window_init(); - - // create the windows - windows_options &options = downcast(machine().options()); - for (int index = 0; index < video_config.numscreens; index++) - { - uwp_window_info::create(machine(), index, m_monitor_module->pick_monitor(options, index), &windows[index]); - } - - if (video_config.mode != VIDEO_MODE_NONE) - { - auto win = std::static_pointer_cast(osd_common_t::s_window_list.front()); - win->platform_window()->Activate(); - } - - return true; -} - -//============================================================ -// video_exit -//============================================================ - -void windows_osd_interface::video_exit() -{ - window_exit(); -} - -//============================================================ -// update -//============================================================ - -void windows_osd_interface::update(bool skip_redraw) -{ - osd_common_t::update(skip_redraw); - - // if we're not skipping this redraw, update all windows - if (!skip_redraw) - { -// profiler_mark(PROFILER_BLIT); - for (auto window : osd_common_t::s_window_list) - window->update(); -// profiler_mark(PROFILER_END); - } - - // if we're running, disable some parts of the debugger - if ((machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) - debugger_update(); -} - -//============================================================ -// input_update -//============================================================ - -void windows_osd_interface::input_update() -{ - // poll the joystick values here - winwindow_process_events(machine(), true, false); - poll_input(machine()); - check_osd_inputs(); -} - -//============================================================ -// check_osd_inputs -//============================================================ - -void windows_osd_interface::check_osd_inputs() -{ -} - - - -//============================================================ -// extract_video_config -//============================================================ - -void windows_osd_interface::extract_video_config() -{ - const char *stemp; - - // global options: extract the data - video_config.windowed = options().window(); - video_config.prescale = options().prescale(); - video_config.filter = options().filter(); - video_config.numscreens = options().numscreens(); - - // if we are in debug mode, never go full screen - if (machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) - video_config.windowed = TRUE; - - // per-window options: extract the data - const char *default_resolution = options().resolution(); - get_resolution(default_resolution, options().resolution(0), &windows[0], TRUE); - get_resolution(default_resolution, options().resolution(1), &windows[1], TRUE); - get_resolution(default_resolution, options().resolution(2), &windows[2], TRUE); - get_resolution(default_resolution, options().resolution(3), &windows[3], TRUE); - - // video options: extract the data - stemp = options().video(); - if (strcmp(stemp, "auto") == 0) - video_config.mode = VIDEO_MODE_BGFX; - else if (strcmp(stemp, "bgfx") == 0) - video_config.mode = VIDEO_MODE_BGFX; - else if (strcmp(stemp, "none") == 0) - { - video_config.mode = VIDEO_MODE_NONE; - if (!emulator_info::standalone() && options().seconds_to_run() == 0) - osd_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n"); - } - else - { - osd_printf_warning("Invalid video value %s; reverting to gdi\n", stemp); - video_config.mode = VIDEO_MODE_GDI; - } - video_config.waitvsync = options().wait_vsync(); - video_config.syncrefresh = options().sync_refresh(); - video_config.triplebuf = options().triple_buffer(); - video_config.switchres = options().switch_res(); - - if (video_config.prescale < 1 || video_config.prescale > 8) - { - osd_printf_warning("Invalid prescale option, reverting to '1'\n"); - video_config.prescale = 1; - } -} - - -//============================================================ -// get_resolution -//============================================================ - -static void get_resolution(const char *defdata, const char *data, osd_window_config *config, int report_error) -{ - config->width = config->height = config->depth = config->refresh = 0; - if (strcmp(data, OSDOPTVAL_AUTO) == 0) - { - if (strcmp(defdata, OSDOPTVAL_AUTO) == 0) - return; - data = defdata; - } - - if (sscanf(data, "%dx%dx%d", &config->width, &config->height, &config->depth) < 2 && report_error) - osd_printf_error("Illegal resolution value = %s\n", data); - - const char * at_pos = strchr(data, '@'); - if (at_pos) - if (sscanf(at_pos + 1, "%d", &config->refresh) < 1 && report_error) - osd_printf_error("Illegal refresh rate in resolution value = %s\n", data); -} diff --git a/src/osd/uwp/video.h b/src/osd/uwp/video.h deleted file mode 100644 index 5725a2bb0d4..00000000000 --- a/src/osd/uwp/video.h +++ /dev/null @@ -1,19 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles -//============================================================ -// -// video.h - UWP implementation of MAME video routines -// -//============================================================ - -#ifndef __UWP_VIDEO__ -#define __UWP_VIDEO__ - -#include "modules/osdhelper.h" - -inline osd_rect RECT_to_osd_rect(const RECT &r) -{ - return osd_rect(r.left, r.top, r.right - r.left, r.bottom - r.top); -} - -#endif diff --git a/src/osd/uwp/window.cpp b/src/osd/uwp/window.cpp deleted file mode 100644 index ae89ac7cac8..00000000000 --- a/src/osd/uwp/window.cpp +++ /dev/null @@ -1,1076 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles -//============================================================ -// -// window.c - Win32 window handling -// -//============================================================ - -#define LOG_TEMP_PAUSE 0 - -// Needed for RAW Input -#define WM_INPUT 0x00FF - -// standard C headers -#include - -#include -#include -#include -#include - -// MAME headers -#include "emu.h" -#include "uiinput.h" -#include "ui/uimain.h" - -// MAMEOS headers -#include "winmain.h" -#include "window.h" -#include "video.h" -#include "winutf8.h" - -#include "winutil.h" - -#include "modules/monitor/monitor_common.h" - -#include -using namespace Windows::UI::Core; - -#include "modules/render/drawbgfx.h" -#include "modules/render/drawnone.h" - -#define NOT_ALREADY_DOWN(x) (x & 0x40000000) == 0 -#define SCAN_CODE(x) ((x >> 16) & 0xff) -#define IS_EXTENDED(x) (0x01000000 & x) -#define MAKE_DI_SCAN(scan, isextended) (scan & 0x7f) | (isextended ? 0x80 : 0x00) -#define WINOSD(machine) downcast(&machine.osd()) - -//============================================================ -// PARAMETERS -//============================================================ - -// window styles -#define WINDOW_STYLE WS_OVERLAPPEDWINDOW -#define WINDOW_STYLE_EX 0 - -// debugger window styles -#define DEBUG_WINDOW_STYLE WS_OVERLAPPED -#define DEBUG_WINDOW_STYLE_EX 0 - -// full screen window styles -#define FULLSCREEN_STYLE WS_POPUP -#define FULLSCREEN_STYLE_EX WS_EX_TOPMOST - -// minimum window dimension -#define MIN_WINDOW_DIM 200 - -// custom window messages -#define WM_USER_REDRAW (WM_USER + 2) -#define WM_USER_SET_FULLSCREEN (WM_USER + 3) -#define WM_USER_SET_MAXSIZE (WM_USER + 4) -#define WM_USER_SET_MINSIZE (WM_USER + 5) - - - -//============================================================ -// GLOBAL VARIABLES -//============================================================ - -static DWORD main_threadid; - -// actual physical resolution -static int win_physical_width; -static int win_physical_height; - - - -//============================================================ -// LOCAL VARIABLES -//============================================================ - -// event handling -static std::chrono::system_clock::time_point last_event_check; - -// debugger -static int in_background; - -static int ui_temp_pause; -static int ui_temp_was_paused; - -static HANDLE window_thread; -static DWORD window_threadid; - -static std::chrono::time_point last_update_time; - -static HANDLE ui_pause_event; - -//============================================================ -// window_init -// (main thread) -//============================================================ - -bool windows_osd_interface::window_init() -{ - // get the main thread ID before anything else - main_threadid = GetCurrentThreadId(); - - // create an event to signal UI pausing - ui_pause_event = CreateEvent(nullptr, TRUE, FALSE, nullptr); - if (!ui_pause_event) - fatalerror("Failed to create pause event\n"); - - window_thread = GetCurrentThread(); - window_threadid = main_threadid; - - const int fallbacks[VIDEO_MODE_COUNT] = { - -1, // NONE -> no fallback - VIDEO_MODE_NONE, // GDI -> NONE - -1 // No SOFT on Windows OSD - }; - - int current_mode = video_config.mode; - while (current_mode != VIDEO_MODE_NONE) - { - bool error = false; - switch(current_mode) - { - case VIDEO_MODE_NONE: - error = renderer_none::init(machine()); - break; - case VIDEO_MODE_BGFX: - error = renderer_bgfx::init(machine()); - break; - default: - fatalerror("Unknown video mode."); - break; - } - if (error) - { - current_mode = fallbacks[current_mode]; - } - else - { - break; - } - } - video_config.mode = current_mode; - - return true; -} - -void windows_osd_interface::update_slider_list() -{ - for (auto window : osd_common_t::s_window_list) - { - // check if any window has dirty sliders - if (window->has_renderer() && window->renderer().sliders_dirty()) - { - build_slider_list(); - return; - } - } -} - -int windows_osd_interface::window_count() -{ - return osd_common_t::s_window_list.size(); -} - -void windows_osd_interface::build_slider_list() -{ - m_sliders.clear(); - - for (auto window : osd_common_t::s_window_list) - { - if (window->has_renderer()) - { - // take the sliders of the first window - std::vector window_sliders = window->renderer().get_slider_list(); - m_sliders.insert(m_sliders.end(), window_sliders.begin(), window_sliders.end()); - } - } -} - -void windows_osd_interface::add_audio_to_recording(const int16_t *buffer, int samples_this_frame) -{ - auto window = osd_common_t::s_window_list.front(); // We only record on the first window - if (window != nullptr) - { - window->renderer().add_audio_to_recording(buffer, samples_this_frame); - } -} - -//============================================================ -// winwindow_exit -// (main thread) -//============================================================ - -void windows_osd_interface::window_exit() -{ - assert(GetCurrentThreadId() == main_threadid); - - // if we hid the cursor during the emulation, show it - if (!osd_common_t::s_window_list.empty()) - osd_common_t::s_window_list.front()->show_pointer(); - - // free all the windows - while (!osd_common_t::s_window_list.empty()) - { - auto window = osd_common_t::s_window_list.front(); - - // Destroy removes it from the list also - window->destroy(); - } - - switch(video_config.mode) - { - case VIDEO_MODE_NONE: - renderer_none::exit(); - break; - case VIDEO_MODE_BGFX: - renderer_bgfx::exit(); - break; - default: - break; - } - - // kill the UI pause event - if (ui_pause_event) - CloseHandle(ui_pause_event); -} - -uwp_window_info::uwp_window_info( - running_machine &machine, - int index, - std::shared_ptr monitor, - const osd_window_config *config) : osd_window_t(machine, index, std::move(monitor), *config), - m_init_state(0), - m_startmaximized(0), - m_isminimized(0), - m_ismaximized(0), - m_fullscreen_safe(0), - m_aspect(0), - m_targetview(0), - m_targetorient(0), - m_targetvismask(0), - m_lastclicktime(std::chrono::system_clock::time_point::min()), - m_lastclickx(0), - m_lastclicky(0) -{ - m_non_fullscreen_bounds.left = 0; - m_non_fullscreen_bounds.top = 0; - m_non_fullscreen_bounds.right = 0; - m_non_fullscreen_bounds.bottom = 0; - - m_fullscreen = !video_config.windowed; - m_prescale = video_config.prescale; -} - -POINT uwp_window_info::s_saved_cursor_pos = { -1, -1 }; - -CoreCursor^ uwp_window_info::s_cursor = nullptr; - -void uwp_window_info::capture_pointer() -{ - platform_window()->SetPointerCapture(); -} - -void uwp_window_info::release_pointer() -{ - platform_window()->ReleasePointerCapture(); -} - -void uwp_window_info::hide_pointer() -{ - auto window = platform_window(); - uwp_window_info::s_cursor = window->PointerCursor; - window->PointerCursor = nullptr; -} - -void uwp_window_info::show_pointer() -{ - auto window = platform_window(); - window->PointerCursor = uwp_window_info::s_cursor; -} - -//============================================================ -// winwindow_process_events_periodic -// (main thread) -//============================================================ - -void winwindow_process_events_periodic(running_machine &machine) -{ - auto currticks = std::chrono::system_clock::now(); - - assert(GetCurrentThreadId() == main_threadid); - - // update once every 1/8th of a second - if (currticks - last_event_check < std::chrono::milliseconds(1000 / 8)) - return; - winwindow_process_events(machine, true, false); -} - -//============================================================ -// winwindow_has_focus -// (main or window thread) -//============================================================ - -bool winwindow_has_focus(void) -{ - // For now always act like we have focus - return true; -} - -//============================================================ -// winwindow_process_events -// (main thread) -//============================================================ - -void winwindow_process_events(running_machine &machine, bool ingame, bool nodispatch) -{ -// MSG message; - - assert(GetCurrentThreadId() == main_threadid); - - // remember the last time we did this - last_event_check = std::chrono::system_clock::now(); - - try - { - CoreWindow^ window = CoreWindow::GetForCurrentThread(); - window->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); - } - catch (Platform::DisconnectedException^) - { - // This can get thrown when the window is being destroyed - } -} - - -//============================================================ -// winwindow_video_window_create -// (main thread) -//============================================================ - -void uwp_window_info::create(running_machine &machine, int index, std::shared_ptr monitor, const osd_window_config *config) -{ - assert(GetCurrentThreadId() == main_threadid); - - // allocate a new window object - auto window = std::make_shared(machine, index, monitor, config); - - // set main window - if (window->index() > 0) - { - for (auto w : osd_common_t::s_window_list) - { - if (w->index() == 0) - { - window->set_main_window(std::static_pointer_cast(w)); - break; - } - } - } - else - { - // We must be the main window - window->set_main_window(window); - } - - // see if we are safe for fullscreen - window->m_fullscreen_safe = TRUE; - for (auto win : osd_common_t::s_window_list) - if (win->monitor() == monitor.get()) - window->m_fullscreen_safe = FALSE; - - window->create_target(); - - // remember the current values in case they change - window->m_targetview = window->target()->view(); - window->m_targetorient = window->target()->orientation(); - window->m_targetlayerconfig = window->target()->layer_config(); - window->m_targetvismask = window->target()->visibility_mask(); - - // set the initial maximized state - window->m_startmaximized = downcast(machine.options()).maximize(); - - window->m_init_state = window->complete_create() ? -1 : 1; - - // handle error conditions - if (window->m_init_state == -1) - fatalerror("Unable to complete window creation\n"); -} - -//============================================================ -// winwindow_video_window_destroy -// (main thread) -//============================================================ - -void uwp_window_info::complete_destroy() -{ - assert(GetCurrentThreadId() == main_threadid); - - // destroy the window -// if (platform_window() != nullptr) - // DestroyWindow(platform_window()); -} - - - -//============================================================ -// winwindow_video_window_update -// (main thread) -//============================================================ - -void uwp_window_info::update() -{ - assert(GetCurrentThreadId() == main_threadid); - - // see if the target has changed significantly in window mode - unsigned const targetview = target()->view(); - int const targetorient = target()->orientation(); - render_layer_config const targetlayerconfig = target()->layer_config(); - u32 const targetvismask = target()->visibility_mask(); - if (targetview != m_targetview || targetorient != m_targetorient || targetlayerconfig != m_targetlayerconfig || targetvismask != m_targetvismask) - { - m_targetview = targetview; - m_targetorient = targetorient; - m_targetlayerconfig = targetlayerconfig; - m_targetvismask = targetvismask; - - // in window mode, reminimize/maximize - if (!fullscreen()) - { - //if (m_isminimized) - //SendMessage(platform_window(), WM_USER_SET_MINSIZE, 0, 0); - //if (m_ismaximized) -// SendMessage(platform_window(), WM_USER_SET_MAXSIZE, 0, 0); - } - } - - // if we're visible and running and not in the middle of a resize, draw - if (platform_window() != nullptr && target() != nullptr && has_renderer()) - { - bool got_lock = true; - auto clock = std::chrono::high_resolution_clock(); - - // only block if we're throttled - if (machine().video().throttled() || clock.now() - last_update_time > std::chrono::milliseconds(250)) - m_render_lock.lock(); - else - got_lock = m_render_lock.try_lock(); - - // only render if we were able to get the lock - if (got_lock) - { - render_primitive_list *primlist; - - // don't hold the lock; we just used it to see if rendering was still happening - m_render_lock.unlock(); - - // ensure the target bounds are up-to-date, and then get the primitives - primlist = renderer().get_primitives(); - - // post a redraw request with the primitive list as a parameter - last_update_time = clock.now(); - - // Actually perform the redraw - m_primlist = primlist; - draw_video_contents(false); - } - } -} - -//============================================================ -// draw_video_contents -// (window thread) -//============================================================ - -void uwp_window_info::draw_video_contents(bool update) -{ - assert(GetCurrentThreadId() == window_threadid); - - std::lock_guard lock(m_render_lock); - - // if we're iconic, don't bother - if (platform_window() != nullptr) - { - // if no bitmap, just fill - if (m_primlist == nullptr) - { - // For now do nothing, eventually we need to clear the window - } - - // otherwise, render with our drawing system - else - { - renderer().draw(update); - } - } -} - - -//============================================================ -// winwindow_ui_pause -// (main thread) -//============================================================ - -void winwindow_ui_pause(running_machine &machine, int pause) -{ - int old_temp_pause = ui_temp_pause; - - assert(GetCurrentThreadId() == main_threadid); - - // if we're pausing, increment the pause counter - if (pause) - { - // if we're the first to pause, we have to actually initiate it - if (ui_temp_pause++ == 0) - { - // only call mame_pause if we weren't already paused due to some external reason - ui_temp_was_paused = machine.paused(); - if (!ui_temp_was_paused) - machine.pause(); - - SetEvent(ui_pause_event); - } - } - - // if we're resuming, decrement the pause counter - else - { - // if we're the last to resume, unpause MAME - if (--ui_temp_pause == 0) - { - // but only do it if we were the ones who initiated it - if (!ui_temp_was_paused) - machine.resume(); - - ResetEvent(ui_pause_event); - } - } - - if (LOG_TEMP_PAUSE) - osd_printf_verbose("winwindow_ui_pause(): %d --> %d\n", old_temp_pause, ui_temp_pause); -} - - - -//============================================================ -// winwindow_ui_is_paused -//============================================================ - -int winwindow_ui_is_paused(running_machine &machine) -{ - return machine.paused() && ui_temp_was_paused; -} - - - -//============================================================ -// wnd_extra_width -// (window thread) -//============================================================ - -int uwp_window_info::wnd_extra_width() -{ - RECT temprect = { 100, 100, 200, 200 }; - if (fullscreen()) - return 0; - //AdjustWindowRectEx(&temprect, WINDOW_STYLE, win_has_menu(), WINDOW_STYLE_EX); - return rect_width(&temprect) - 100; -} - - - -//============================================================ -// wnd_extra_height -// (window thread) -//============================================================ - -int uwp_window_info::wnd_extra_height() -{ - RECT temprect = { 100, 100, 200, 200 }; - if (fullscreen()) - return 0; - //AdjustWindowRectEx(&temprect, WINDOW_STYLE, win_has_menu(), WINDOW_STYLE_EX); - return rect_height(&temprect) - 100; -} - - -//============================================================ -// complete_create -// (window thread) -//============================================================ - -int uwp_window_info::complete_create() -{ - int tempwidth, tempheight; - - assert(GetCurrentThreadId() == window_threadid); - - // get the monitor bounds - osd_rect monitorbounds = monitor()->position_size(); - - auto coreWindow = Platform::Agile(CoreWindow::GetForCurrentThread()); - set_platform_window(coreWindow); - - // skip the positioning stuff for -video none */ - if (video_config.mode == VIDEO_MODE_NONE) - { - set_renderer(osd_renderer::make_for_type(video_config.mode, shared_from_this())); - renderer().create(); - return 0; - } - - // adjust the window position to the initial width/height - tempwidth = (m_win_config.width != 0) ? m_win_config.width : 640; - tempheight = (m_win_config.height != 0) ? m_win_config.height : 480; - - // maximum or minimize as appropriate - if (m_startmaximized) - maximize_window(); - else - minimize_window(); - adjust_window_position_after_major_change(); - - // show the window - if (!fullscreen() || m_fullscreen_safe) - { - set_renderer(osd_renderer::make_for_type(video_config.mode, shared_from_this())); - if (renderer().create()) - return 1; - - } - - return 0; -} - - -//============================================================ -// constrain_to_aspect_ratio -// (window thread) -//============================================================ - -osd_rect uwp_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int adjustment) -{ - assert(GetCurrentThreadId() == window_threadid); - - int32_t extrawidth = wnd_extra_width(); - int32_t extraheight = wnd_extra_height(); - int32_t propwidth, propheight; - int32_t minwidth, minheight; - int32_t maxwidth, maxheight; - int32_t viswidth, visheight; - int32_t adjwidth, adjheight; - float pixel_aspect; - - auto monitor = monitor_from_rect(&rect); - - // Sometimes this gets called when monitors have already been torn down - // In that the case, just return the unmodified rect - if (monitor == nullptr) - return rect; - - // do not constrain aspect ratio for integer scaled views - if (target()->scale_mode() != SCALE_FRACTIONAL) - return rect; - - // get the pixel aspect ratio for the target monitor - pixel_aspect = monitor->pixel_aspect(); - - // determine the proposed width/height - propwidth = rect.width() - extrawidth; - propheight = rect.height() - extraheight; - - // based on which edge we are adjusting, take either the width, height, or both as gospel - // and scale to fit using that as our parameter - switch (adjustment) - { - case WMSZ_BOTTOM: - case WMSZ_TOP: - target()->compute_visible_area(10000, propheight, pixel_aspect, target()->orientation(), propwidth, propheight); - break; - - case WMSZ_LEFT: - case WMSZ_RIGHT: - target()->compute_visible_area(propwidth, 10000, pixel_aspect, target()->orientation(), propwidth, propheight); - break; - - default: - target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), propwidth, propheight); - break; - } - - // get the minimum width/height for the current layout - target()->compute_minimum_size(minwidth, minheight); - - // clamp against the absolute minimum - propwidth = std::max(propwidth, MIN_WINDOW_DIM); - propheight = std::max(propheight, MIN_WINDOW_DIM); - - // clamp against the minimum width and height - propwidth = std::max(propwidth, minwidth); - propheight = std::max(propheight, minheight); - - // clamp against the maximum (fit on one screen for full screen mode) - if (fullscreen()) - { - maxwidth = monitor->position_size().width() - extrawidth; - maxheight = monitor->position_size().height() - extraheight; - } - else - { - maxwidth = monitor->usuable_position_size().width() - extrawidth; - maxheight = monitor->usuable_position_size().height() - extraheight; - - // further clamp to the maximum width/height in the window - if (m_win_config.width != 0) - maxwidth = std::min(maxwidth, m_win_config.width + extrawidth); - if (m_win_config.height != 0) - maxheight = std::min(maxheight, m_win_config.height + extraheight); - } - - // clamp to the maximum - propwidth = std::min(propwidth, maxwidth); - propheight = std::min(propheight, maxheight); - - // compute the visible area based on the proposed rectangle - target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), viswidth, visheight); - - // compute the adjustments we need to make - adjwidth = (viswidth + extrawidth) - rect.width(); - adjheight = (visheight + extraheight) - rect.height(); - - // based on which corner we're adjusting, constrain in different ways - osd_rect ret(rect); - - switch (adjustment) - { - case WMSZ_BOTTOM: - case WMSZ_BOTTOMRIGHT: - case WMSZ_RIGHT: - ret = rect.resize(rect.width() + adjwidth, rect.height() + adjheight); - break; - - case WMSZ_BOTTOMLEFT: - ret = rect.move_by(-adjwidth, 0).resize(rect.width() + adjwidth, rect.height() + adjheight); - break; - - case WMSZ_LEFT: - case WMSZ_TOPLEFT: - case WMSZ_TOP: - ret = rect.move_by(-adjwidth, -adjheight).resize(rect.width() + adjwidth, rect.height() + adjheight); - break; - - case WMSZ_TOPRIGHT: - ret = rect.move_by(0, -adjheight).resize(rect.width() + adjwidth, rect.height() + adjheight); - break; - } - return ret; -} - - - -//============================================================ -// get_min_bounds -// (window thread) -//============================================================ - -osd_dim uwp_window_info::get_min_bounds(int constrain) -{ - int32_t minwidth, minheight; - - //assert(GetCurrentThreadId() == window_threadid); - - // get the minimum target size - target()->compute_minimum_size(minwidth, minheight); - - // expand to our minimum dimensions - if (minwidth < MIN_WINDOW_DIM) - minwidth = MIN_WINDOW_DIM; - if (minheight < MIN_WINDOW_DIM) - minheight = MIN_WINDOW_DIM; - - // account for extra window stuff - minwidth += wnd_extra_width(); - minheight += wnd_extra_height(); - - // if we want it constrained, figure out which one is larger - if (constrain && target()->scale_mode() == SCALE_FRACTIONAL) - { - // first constrain with no height limit - osd_rect test1(0,0,minwidth,10000); - test1 = constrain_to_aspect_ratio(test1, WMSZ_BOTTOMRIGHT); - - // then constrain with no width limit - osd_rect test2(0,0,10000,minheight); - test2 = constrain_to_aspect_ratio(test2, WMSZ_BOTTOMRIGHT); - - // pick the larger - if (test1.width() > test2.width()) - { - minwidth = test1.width(); - minheight = test1.height(); - } - else - { - minwidth = test2.width(); - minheight = test2.height(); - } - } - - return osd_dim(minwidth, minheight); -} - - - -//============================================================ -// get_max_bounds -// (window thread) -//============================================================ - -osd_dim uwp_window_info::get_max_bounds(int constrain) -{ - //assert(GetCurrentThreadId() == window_threadid); - - // compute the maximum client area - //monitor()->refresh(); - osd_rect maximum = monitor()->usuable_position_size(); - - // clamp to the window's max - int tempw = maximum.width(); - int temph = maximum.height(); - if (m_win_config.width != 0) - { - int temp = m_win_config.width + wnd_extra_width(); - if (temp < maximum.width()) - tempw = temp; - } - if (m_win_config.height != 0) - { - int temp = m_win_config.height + wnd_extra_height(); - if (temp < maximum.height()) - temph = temp; - } - - maximum = maximum.resize(tempw, temph); - - // constrain to fit - if (constrain && target()->scale_mode() == SCALE_FRACTIONAL) - maximum = constrain_to_aspect_ratio(maximum, WMSZ_BOTTOMRIGHT); - - return maximum.dim(); -} - - - -//============================================================ -// update_minmax_state -// (window thread) -//============================================================ - -void uwp_window_info::update_minmax_state() -{ - assert(GetCurrentThreadId() == window_threadid); - - if (!fullscreen()) - { - RECT bounds; - - // compare the maximum bounds versus the current bounds - const bool keep_aspect = keepaspect(); - osd_dim minbounds = get_min_bounds(keep_aspect); - osd_dim maxbounds = get_max_bounds(keep_aspect); - //GetWindowRect(platform_window(), &bounds); - - // if either the width or height matches, we were maximized - m_isminimized = (rect_width(&bounds) == minbounds.width()) || - (rect_height(&bounds) == minbounds.height()); - m_ismaximized = (rect_width(&bounds) == maxbounds.width()) || - (rect_height(&bounds) == maxbounds.height()); - } - else - { - m_isminimized = FALSE; - m_ismaximized = TRUE; - } -} - - - -//============================================================ -// minimize_window -// (window thread) -//============================================================ - -void uwp_window_info::minimize_window() -{ - assert(GetCurrentThreadId() == window_threadid); - - osd_dim newsize = get_min_bounds(keepaspect()); - - // get the window rect - //RECT bounds; - //GetWindowRect(platform_window(), &bounds); - - //osd_rect newrect(bounds.left, bounds.top, newsize ); - - - //SetWindowPos(platform_window(), nullptr, newrect.left(), newrect.top(), newrect.width(), newrect.height(), SWP_NOZORDER); -} - -//============================================================ -// maximize_window -// (window thread) -//============================================================ - -void uwp_window_info::maximize_window() -{ - assert(GetCurrentThreadId() == window_threadid); - - osd_dim newsize = get_max_bounds(keepaspect()); - - // center within the work area - osd_rect work = monitor()->usuable_position_size(); - osd_rect newrect = osd_rect(work.left() + (work.width() - newsize.width()) / 2, - work.top() + (work.height() - newsize.height()) / 2, - newsize); - - //SetWindowPos(platform_window(), nullptr, newrect.left(), newrect.top(), newrect.width(), newrect.height(), SWP_NOZORDER); -} - - - -//============================================================ -// adjust_window_position_after_major_change -// (window thread) -//============================================================ - -void uwp_window_info::adjust_window_position_after_major_change() -{ - RECT oldrect; - - assert(GetCurrentThreadId() == window_threadid); - - // get the current size - //GetWindowRect(platform_window(), &oldrect); - osd_rect newrect = RECT_to_osd_rect(oldrect); - - // adjust the window size so the client area is what we want - if (!fullscreen()) - { - // constrain the existing size to the aspect ratio - if (keepaspect()) - newrect = constrain_to_aspect_ratio(newrect, WMSZ_BOTTOMRIGHT); - } - - // in full screen, make sure it covers the primary display - else - { - std::shared_ptr monitor = monitor_from_rect(nullptr); - newrect = monitor->position_size(); - } - - // adjust the position if different - if (oldrect.left != newrect.left() || oldrect.top != newrect.top() || - oldrect.right != newrect.right() || oldrect.bottom != newrect.bottom()) - //SetWindowPos(platform_window(), fullscreen() ? HWND_TOPMOST : HWND_TOP, - // newrect.left(), newrect.top(), - //newrect.width(), newrect.height(), 0); - - // take note of physical window size (used for lightgun coordinate calculation) - if (index() == 0) - { - win_physical_width = newrect.width(); - win_physical_height = newrect.height(); - osd_printf_verbose("Physical width %d, height %d\n",win_physical_width,win_physical_height); - } -} - - -//============================================================ -// set_fullscreen -// (window thread) -//============================================================ - -void uwp_window_info::set_fullscreen(int fullscreen) -{ - assert(GetCurrentThreadId() == window_threadid); - - // if we're in the right state, punt - if (this->fullscreen() == fullscreen) - return; - m_fullscreen = fullscreen; - - // reset UI to main menu - machine().ui().menu_reset(); - - // kill off the drawers - renderer_reset(); - - // hide ourself - //ShowWindow(platform_window(), SW_HIDE); - - // configure the window if non-fullscreen - if (!fullscreen) - { - // adjust the style - //SetWindowLong(platform_window(), GWL_STYLE, WINDOW_STYLE); - //SetWindowLong(platform_window(), GWL_EXSTYLE, WINDOW_STYLE_EX); - //SetWindowPos(platform_window(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); - - // force to the bottom, then back on top - //SetWindowPos(platform_window(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - //SetWindowPos(platform_window(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - - //// if we have previous non-fullscreen bounds, use those - //if (m_non_fullscreen_bounds.right != m_non_fullscreen_bounds.left) - //{ - // SetWindowPos(platform_window(), HWND_TOP, m_non_fullscreen_bounds.left, m_non_fullscreen_bounds.top, - // rect_width(&m_non_fullscreen_bounds), rect_height(&m_non_fullscreen_bounds), - // SWP_NOZORDER); - //} - // - //// otherwise, set a small size and maximize from there - //else - //{ - // SetWindowPos(platform_window(), HWND_TOP, 0, 0, MIN_WINDOW_DIM, MIN_WINDOW_DIM, SWP_NOZORDER); - // maximize_window(); - //} - } - - // configure the window if fullscreen - else - { - // save the bounds - //GetWindowRect(platform_window(), &m_non_fullscreen_bounds); - // - //// adjust the style - //SetWindowLong(platform_window(), GWL_STYLE, FULLSCREEN_STYLE); - //SetWindowLong(platform_window(), GWL_EXSTYLE, FULLSCREEN_STYLE_EX); - //SetWindowPos(platform_window(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); - // - //// set topmost - //SetWindowPos(platform_window(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - } - - // adjust the window to compensate for the change - adjust_window_position_after_major_change(); - - // show ourself - if (!this->fullscreen() || m_fullscreen_safe) - { - //if (video_config.mode != VIDEO_MODE_NONE) - //ShowWindow(platform_window(), SW_SHOW); - - set_renderer(osd_renderer::make_for_type(video_config.mode, shared_from_this())); - if (renderer().create()) - exit(1); - } - - // ensure we're still adjusted correctly - adjust_window_position_after_major_change(); -} - diff --git a/src/osd/uwp/window.h b/src/osd/uwp/window.h deleted file mode 100644 index e581ec71246..00000000000 --- a/src/osd/uwp/window.h +++ /dev/null @@ -1,151 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles, Brad Hughes -//============================================================ -// -// window.h - UWP window handling -// -//============================================================ - -#ifndef __UWP_WINDOW__ -#define __UWP_WINDOW__ - -// standard windows headers -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "render.h" - -#include "modules/osdwindow.h" - -//============================================================ -// PARAMETERS -//============================================================ - - -//============================================================ -// CONSTANTS -//============================================================ - -#define RESIZE_STATE_NORMAL 0 -#define RESIZE_STATE_RESIZING 1 -#define RESIZE_STATE_PENDING 2 - - - -//============================================================ -// TYPE DEFINITIONS -//============================================================ - -class uwp_window_info : public osd_window_t> -{ -public: - uwp_window_info(running_machine &machine, int index, std::shared_ptr monitor, const osd_window_config *config); - - void update() override; - - virtual osd_dim get_size() override - { - auto bounds = platform_window()->Bounds; - return osd_dim(bounds.Width, bounds.Height); - } - - bool win_has_menu() override - { - return false; - } - - void capture_pointer() override; - void release_pointer() override; - void show_pointer() override; - void hide_pointer() override; - - void complete_destroy() override; - - // static - - static void create(running_machine &machine, int index, std::shared_ptr monitor, const osd_window_config *config); - - // member variables - - volatile int m_init_state; - - // window handle and info - RECT m_non_fullscreen_bounds; - int m_startmaximized; - int m_isminimized; - int m_ismaximized; - - // monitor info - int m_fullscreen_safe; - float m_aspect; - - // rendering info - std::mutex m_render_lock; - unsigned m_targetview; - int m_targetorient; - render_layer_config m_targetlayerconfig; - u32 m_targetvismask; - - // input info - std::chrono::system_clock::time_point m_lastclicktime; - int m_lastclickx; - int m_lastclicky; - -private: - int complete_create(); - void draw_video_contents(bool update); - int wnd_extra_width(); - int wnd_extra_height(); - osd_rect constrain_to_aspect_ratio(const osd_rect &rect, int adjustment); - osd_dim get_min_bounds(int constrain); - osd_dim get_max_bounds(int constrain); - void update_minmax_state(); - void minimize_window(); - void maximize_window(); - void adjust_window_position_after_major_change(); - void set_fullscreen(int fullscreen); - - static POINT s_saved_cursor_pos; - - static Windows::UI::Core::CoreCursor^ s_cursor; -}; - -struct osd_draw_callbacks -{ - osd_renderer *(*create)(osd_window *window); - void (*exit)(void); -}; - - -//============================================================ -// PROTOTYPES -//============================================================ - -bool winwindow_has_focus(void); -void winwindow_process_events(running_machine &machine, bool ingame, bool nodispatch); -void winwindow_process_events_periodic(running_machine &machine); - -//============================================================ -// rect_width / rect_height -//============================================================ - -static inline int rect_width(const RECT *rect) -{ - return rect->right - rect->left; -} - - -static inline int rect_height(const RECT *rect) -{ - return rect->bottom - rect->top; -} - -#endif