-merit/mtouchxl.cpp: Added touch-enabled layout.

-ui/tapectrl.cpp: Ensure device monitored for media change is up-to-date.

-osd/windows: Changed a pointer to a const reference in an API.
This commit is contained in:
Vas Crabb 2024-05-09 04:43:56 +10:00
parent 5b2280fa54
commit e22aae63a1
8 changed files with 132 additions and 26 deletions

View File

@ -495,8 +495,8 @@ providing whats needed:
* ``emu.print_verbose``, ``emu.print_error``, ``emu.print_warning``, * ``emu.print_verbose``, ``emu.print_error``, ``emu.print_warning``,
``emu.print_info`` and ``emu.print_debug`` functions for diagnostic output. ``emu.print_info`` and ``emu.print_debug`` functions for diagnostic output.
* Standard Lua ``tonumber``, ``tostring``, ``pairs`` and ``ipairs`` functions, * Standard Lua ``tonumber``, ``tostring``, ``pairs`` and ``ipairs`` functions,
and ``table`` and ``string`` objects for manipulating strings, tables and and ``math``, ``table`` and ``string`` objects for manipulating numbers,r
other containers. strings, tables and other containers.
* Standard Lua ``print`` function for text output to the console. * Standard Lua ``print`` function for text output to the console.

View File

@ -41,6 +41,7 @@ function layout.startplugin()
print_info = emu.print_info, print_info = emu.print_info,
print_debug = emu.print_debug }, print_debug = emu.print_debug },
file = file, file = file,
math = math,
print = print, print = print,
pairs = pairs, pairs = pairs,
ipairs = ipairs, ipairs = ipairs,

View File

@ -69,12 +69,6 @@ menu_tape_control::menu_tape_control(mame_ui_manager &mui, render_container &con
if (device) if (device)
{ {
m_notifier = device->add_media_change_notifier(
[this] (device_image_interface::media_change_event ev)
{
// repopulate the menu if an image is mounted or unmounted
reset(reset_options::REMEMBER_POSITION);
});
} }
} }
@ -94,9 +88,17 @@ menu_tape_control::~menu_tape_control()
void menu_tape_control::populate() void menu_tape_control::populate()
{ {
m_notifier.reset();
m_slider_item_index = -1; m_slider_item_index = -1;
if (current_device()) if (current_device())
{ {
// repopulate the menu if an image is mounted or unmounted
m_notifier = current_device()->add_media_change_notifier(
[this] (device_image_interface::media_change_event ev)
{
reset(reset_options::REMEMBER_POSITION);
});
// name of tape // name of tape
item_append(current_display_name(), current_device()->exists() ? current_device()->filename() : "No Tape Image loaded", current_display_flags(), TAPECMD_SELECT); item_append(current_display_name(), current_device()->exists() ? current_device()->filename() : "No Tape Image loaded", current_display_flags(), TAPECMD_SELECT);

View File

@ -0,0 +1,95 @@
<?xml version="1.0"?>
<!--
license:CC0-1.0
-->
<mamelayout version="2">
<view name="Touch-Enabled" showpointers="yes">
<screen id="screen" index="0">
<bounds left="0" top="0" right="4" bottom="3" />
</screen>
</view>
<script><![CDATA[
file:set_resolve_tags_callback(
function ()
-- get the touchscreen I/O port fields
local tsdev = file.device:subdevice('microtouch')
local btn_field = tsdev:ioport('TOUCH'):field(0x01)
local x_field = tsdev:ioport('TOUCH_X'):field(0x3fff)
local y_field = tsdev:ioport('TOUCH_Y'):field(0x3fff)
-- for mapping coordinates
local view = file.views['Touch-Enabled']
local scr_item = view.items['screen']
local floor = math.floor
local l, r, t, b
local x_scale, y_scale
-- pointer state
local ptr_id = nil
local inside = false
local function release_touch()
btn_field:clear_value()
x_field:clear_value()
y_field:clear_value()
end
local function recomputed()
local bounds = scr_item.bounds
l = bounds.x0
r = bounds.x1
t = bounds.y0
b = bounds.y1
x_scale = 0x3fff / bounds.width
y_scale = 0x3fff / bounds.height
end
local function check_pointer(x, y)
if (x >= l) and (x < r) and (y >= t) and (y < b) then
inside = true
btn_field:set_value(1)
x_field:set_value(floor((x - l) * x_scale))
y_field:set_value(floor((y - t) * y_scale))
elseif inside then
inside = false
release_touch()
end
end
local function forget_pointer()
if inside then
release_touch()
end
ptr_id = nil
inside = false
end
local function pointer_updated(type, id, dev, x, y, btn, dn, up, cnt)
if ptr_id == id then
if (btn & 0x01) == 0 then
forget_pointer()
else
check_pointer(x, y)
end
elseif (not ptr_id) and ((dn & 0x01) ~= 0) then
ptr_id = id
check_pointer(x, y)
end
end
local function pointer_lost(type, id, dev, x, y, up, cnt)
if ptr_id == id then
forget_pointer()
end
end
-- attach callbacks to view
view:set_recomputed_callback(recomputed)
view:set_pointer_updated_callback(pointer_updated)
view:set_pointer_left_callback(pointer_lost)
view:set_pointer_aborted_callback(pointer_lost)
view:set_forget_pointers_callback(forget_pointer)
end)
]]></script>
</mamelayout>

View File

@ -30,26 +30,30 @@
//#define REAL_PCI_CHIPSET //#define REAL_PCI_CHIPSET
#include "emu.h" #include "emu.h"
#include "bus/ata/atapicdr.h" #include "bus/ata/atapicdr.h"
#include "bus/ata/hdd.h" #include "bus/ata/hdd.h"
#include "bus/isa/isa_cards.h" #include "bus/isa/isa_cards.h"
#include "cpu/i386/i386.h" #include "cpu/i386/i386.h"
#include "machine/at.h"
#include "machine/ram.h"
#include "machine/8042kbdc.h" #include "machine/8042kbdc.h"
#include "machine/nvram.h" #include "machine/at.h"
#include "machine/ins8250.h"
#include "machine/microtch.h"
#include "machine/bankdev.h" #include "machine/bankdev.h"
#include "machine/intelfsh.h"
#include "machine/ds128x.h"
#include "machine/ds1205.h" #include "machine/ds1205.h"
#include "machine/ds128x.h"
#include "machine/ins8250.h"
#include "machine/intelfsh.h"
#include "machine/microtch.h"
#include "machine/nvram.h"
#include "machine/ram.h"
#ifdef REAL_PCI_CHIPSET #ifdef REAL_PCI_CHIPSET
#include "machine/sis85c496.h" #include "machine/sis85c496.h"
#endif #endif
#include "sound/ad1848.h" #include "sound/ad1848.h"
#include "speaker.h" #include "speaker.h"
#include "mtouchxl.lh"
namespace { namespace {
@ -287,6 +291,8 @@ void mtxl_state::at486(machine_config &config)
// FIXME: This MCFG fragment does not compile. -R // FIXME: This MCFG fragment does not compile. -R
//MCFG_SIS85C496_ADD(":pci:05.0", ":maincpu", 32*1024*1024) //MCFG_SIS85C496_ADD(":pci:05.0", ":maincpu", 32*1024*1024)
#endif #endif
config.set_default_layout(layout_mtouchxl);
} }
void mtxl_state::at486hd(machine_config &config) void mtxl_state::at486hd(machine_config &config)
@ -346,6 +352,8 @@ void mtxl_state::at486hd(machine_config &config)
// FIXME: This MCFG fragment does not compile. -R // FIXME: This MCFG fragment does not compile. -R
//MCFG_SIS85C496_ADD(":pci:05.0", ":maincpu", 32*1024*1024) //MCFG_SIS85C496_ADD(":pci:05.0", ":maincpu", 32*1024*1024)
#endif #endif
config.set_default_layout(layout_mtouchxl);
} }
#ifdef REAL_PCI_CHIPSET #ifdef REAL_PCI_CHIPSET

View File

@ -214,7 +214,7 @@ void debugger_windows::wait_for_debugger(device_t &device, bool firststop)
// process everything else // process everything else
default: default:
winwindow_dispatch_message(*m_machine, &message); winwindow_dispatch_message(*m_machine, message);
break; break;
} }

View File

@ -464,7 +464,7 @@ void windows_osd_interface::process_events(bool ingame, bool nodispatch)
// dispatch if necessary // dispatch if necessary
if (dispatch) if (dispatch)
winwindow_dispatch_message(machine(), &message); winwindow_dispatch_message(machine(), message);
} }
} }
while (ui_temp_pause > 0); while (ui_temp_pause > 0);
@ -480,12 +480,12 @@ void windows_osd_interface::process_events(bool ingame, bool nodispatch)
// (main thread) // (main thread)
//============================================================ //============================================================
void winwindow_dispatch_message(running_machine &machine, MSG *message) void winwindow_dispatch_message(running_machine &machine, MSG const &message)
{ {
assert(GetCurrentThreadId() == main_threadid); assert(GetCurrentThreadId() == main_threadid);
// dispatch our special communication messages // dispatch our special communication messages
switch (message->message) switch (message.message)
{ {
// special case for quit // special case for quit
case WM_QUIT: case WM_QUIT:
@ -494,8 +494,8 @@ void winwindow_dispatch_message(running_machine &machine, MSG *message)
// everything else dispatches normally // everything else dispatches normally
default: default:
TranslateMessage(message); TranslateMessage(&message);
DispatchMessage(message); DispatchMessage(&message);
break; break;
} }
} }
@ -2293,17 +2293,17 @@ std::vector<win_window_info::win_pointer_info>::iterator win_window_info::find_m
bool winwindow_qt_filter(void *message) bool winwindow_qt_filter(void *message)
{ {
MSG *msg = (MSG *)message; MSG *const msg = reinterpret_cast<MSG *>(message);
if(is_mame_window(msg->hwnd) || (!msg->hwnd && (msg->message >= WM_USER))) if (is_mame_window(msg->hwnd) || (!msg->hwnd && (msg->message >= WM_USER)))
{ {
LONG_PTR ptr; LONG_PTR ptr;
if(msg->hwnd) // get the machine associated with this window if (msg->hwnd) // get the machine associated with this window
ptr = GetWindowLongPtr(msg->hwnd, GWLP_USERDATA); ptr = GetWindowLongPtr(msg->hwnd, GWLP_USERDATA);
else // any one will have to do else // any one will have to do
ptr = (LONG_PTR)osd_common_t::window_list().front().get(); ptr = (LONG_PTR)osd_common_t::window_list().front().get();
winwindow_dispatch_message(((win_window_info *)ptr)->machine(), msg); winwindow_dispatch_message(reinterpret_cast<win_window_info *>(ptr)->machine(), *msg);
return true; return true;
} }
return false; return false;

View File

@ -207,7 +207,7 @@ void winwindow_toggle_fsfx(void);
void winwindow_ui_pause(running_machine &machine, int pause); void winwindow_ui_pause(running_machine &machine, int pause);
int winwindow_ui_is_paused(running_machine &machine); int winwindow_ui_is_paused(running_machine &machine);
void winwindow_dispatch_message(running_machine &machine, MSG *message); void winwindow_dispatch_message(running_machine &machine, MSG const &message);