Skip to content

Commit e22aae6

Browse files
committed
-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.
1 parent 5b2280f commit e22aae6

File tree

8 files changed

+132
-26
lines changed

8 files changed

+132
-26
lines changed

docs/source/techspecs/layout_script.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,8 @@ providing what’s needed:
495495
* ``emu.print_verbose``, ``emu.print_error``, ``emu.print_warning``,
496496
``emu.print_info`` and ``emu.print_debug`` functions for diagnostic output.
497497
* Standard Lua ``tonumber``, ``tostring``, ``pairs`` and ``ipairs`` functions,
498-
and ``table`` and ``string`` objects for manipulating strings, tables and
499-
other containers.
498+
and ``math``, ``table`` and ``string`` objects for manipulating numbers,r
499+
strings, tables and other containers.
500500
* Standard Lua ``print`` function for text output to the console.
501501

502502

plugins/layout/init.lua

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function layout.startplugin()
4141
print_info = emu.print_info,
4242
print_debug = emu.print_debug },
4343
file = file,
44+
math = math,
4445
print = print,
4546
pairs = pairs,
4647
ipairs = ipairs,

src/frontend/mame/ui/tapectrl.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ menu_tape_control::menu_tape_control(mame_ui_manager &mui, render_container &con
6969

7070
if (device)
7171
{
72-
m_notifier = device->add_media_change_notifier(
73-
[this] (device_image_interface::media_change_event ev)
74-
{
75-
// repopulate the menu if an image is mounted or unmounted
76-
reset(reset_options::REMEMBER_POSITION);
77-
});
7872
}
7973
}
8074

@@ -94,9 +88,17 @@ menu_tape_control::~menu_tape_control()
9488

9589
void menu_tape_control::populate()
9690
{
91+
m_notifier.reset();
9792
m_slider_item_index = -1;
9893
if (current_device())
9994
{
95+
// repopulate the menu if an image is mounted or unmounted
96+
m_notifier = current_device()->add_media_change_notifier(
97+
[this] (device_image_interface::media_change_event ev)
98+
{
99+
reset(reset_options::REMEMBER_POSITION);
100+
});
101+
100102
// name of tape
101103
item_append(current_display_name(), current_device()->exists() ? current_device()->filename() : "No Tape Image loaded", current_display_flags(), TAPECMD_SELECT);
102104

src/mame/layout/mtouchxl.lay

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
license:CC0-1.0
4+
-->
5+
<mamelayout version="2">
6+
<view name="Touch-Enabled" showpointers="yes">
7+
<screen id="screen" index="0">
8+
<bounds left="0" top="0" right="4" bottom="3" />
9+
</screen>
10+
</view>
11+
12+
<script><![CDATA[
13+
file:set_resolve_tags_callback(
14+
function ()
15+
-- get the touchscreen I/O port fields
16+
local tsdev = file.device:subdevice('microtouch')
17+
local btn_field = tsdev:ioport('TOUCH'):field(0x01)
18+
local x_field = tsdev:ioport('TOUCH_X'):field(0x3fff)
19+
local y_field = tsdev:ioport('TOUCH_Y'):field(0x3fff)
20+
21+
-- for mapping coordinates
22+
local view = file.views['Touch-Enabled']
23+
local scr_item = view.items['screen']
24+
local floor = math.floor
25+
local l, r, t, b
26+
local x_scale, y_scale
27+
28+
-- pointer state
29+
local ptr_id = nil
30+
local inside = false
31+
32+
local function release_touch()
33+
btn_field:clear_value()
34+
x_field:clear_value()
35+
y_field:clear_value()
36+
end
37+
38+
local function recomputed()
39+
local bounds = scr_item.bounds
40+
l = bounds.x0
41+
r = bounds.x1
42+
t = bounds.y0
43+
b = bounds.y1
44+
x_scale = 0x3fff / bounds.width
45+
y_scale = 0x3fff / bounds.height
46+
end
47+
48+
local function check_pointer(x, y)
49+
if (x >= l) and (x < r) and (y >= t) and (y < b) then
50+
inside = true
51+
btn_field:set_value(1)
52+
x_field:set_value(floor((x - l) * x_scale))
53+
y_field:set_value(floor((y - t) * y_scale))
54+
elseif inside then
55+
inside = false
56+
release_touch()
57+
end
58+
end
59+
60+
local function forget_pointer()
61+
if inside then
62+
release_touch()
63+
end
64+
ptr_id = nil
65+
inside = false
66+
end
67+
68+
local function pointer_updated(type, id, dev, x, y, btn, dn, up, cnt)
69+
if ptr_id == id then
70+
if (btn & 0x01) == 0 then
71+
forget_pointer()
72+
else
73+
check_pointer(x, y)
74+
end
75+
elseif (not ptr_id) and ((dn & 0x01) ~= 0) then
76+
ptr_id = id
77+
check_pointer(x, y)
78+
end
79+
end
80+
81+
local function pointer_lost(type, id, dev, x, y, up, cnt)
82+
if ptr_id == id then
83+
forget_pointer()
84+
end
85+
end
86+
87+
-- attach callbacks to view
88+
view:set_recomputed_callback(recomputed)
89+
view:set_pointer_updated_callback(pointer_updated)
90+
view:set_pointer_left_callback(pointer_lost)
91+
view:set_pointer_aborted_callback(pointer_lost)
92+
view:set_forget_pointers_callback(forget_pointer)
93+
end)
94+
]]></script>
95+
</mamelayout>

src/mame/merit/mtouchxl.cpp

+15-7
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,30 @@
3030
//#define REAL_PCI_CHIPSET
3131

3232
#include "emu.h"
33+
3334
#include "bus/ata/atapicdr.h"
3435
#include "bus/ata/hdd.h"
3536
#include "bus/isa/isa_cards.h"
3637
#include "cpu/i386/i386.h"
37-
#include "machine/at.h"
38-
#include "machine/ram.h"
3938
#include "machine/8042kbdc.h"
40-
#include "machine/nvram.h"
41-
#include "machine/ins8250.h"
42-
#include "machine/microtch.h"
39+
#include "machine/at.h"
4340
#include "machine/bankdev.h"
44-
#include "machine/intelfsh.h"
45-
#include "machine/ds128x.h"
4641
#include "machine/ds1205.h"
42+
#include "machine/ds128x.h"
43+
#include "machine/ins8250.h"
44+
#include "machine/intelfsh.h"
45+
#include "machine/microtch.h"
46+
#include "machine/nvram.h"
47+
#include "machine/ram.h"
4748
#ifdef REAL_PCI_CHIPSET
4849
#include "machine/sis85c496.h"
4950
#endif
5051
#include "sound/ad1848.h"
52+
5153
#include "speaker.h"
5254

55+
#include "mtouchxl.lh"
56+
5357

5458
namespace {
5559

@@ -287,6 +291,8 @@ void mtxl_state::at486(machine_config &config)
287291
// FIXME: This MCFG fragment does not compile. -R
288292
//MCFG_SIS85C496_ADD(":pci:05.0", ":maincpu", 32*1024*1024)
289293
#endif
294+
295+
config.set_default_layout(layout_mtouchxl);
290296
}
291297

292298
void mtxl_state::at486hd(machine_config &config)
@@ -346,6 +352,8 @@ void mtxl_state::at486hd(machine_config &config)
346352
// FIXME: This MCFG fragment does not compile. -R
347353
//MCFG_SIS85C496_ADD(":pci:05.0", ":maincpu", 32*1024*1024)
348354
#endif
355+
356+
config.set_default_layout(layout_mtouchxl);
349357
}
350358

351359
#ifdef REAL_PCI_CHIPSET

src/osd/modules/debugger/debugwin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void debugger_windows::wait_for_debugger(device_t &device, bool firststop)
214214

215215
// process everything else
216216
default:
217-
winwindow_dispatch_message(*m_machine, &message);
217+
winwindow_dispatch_message(*m_machine, message);
218218
break;
219219
}
220220

src/osd/windows/window.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ void windows_osd_interface::process_events(bool ingame, bool nodispatch)
464464

465465
// dispatch if necessary
466466
if (dispatch)
467-
winwindow_dispatch_message(machine(), &message);
467+
winwindow_dispatch_message(machine(), message);
468468
}
469469
}
470470
while (ui_temp_pause > 0);
@@ -480,12 +480,12 @@ void windows_osd_interface::process_events(bool ingame, bool nodispatch)
480480
// (main thread)
481481
//============================================================
482482

483-
void winwindow_dispatch_message(running_machine &machine, MSG *message)
483+
void winwindow_dispatch_message(running_machine &machine, MSG const &message)
484484
{
485485
assert(GetCurrentThreadId() == main_threadid);
486486

487487
// dispatch our special communication messages
488-
switch (message->message)
488+
switch (message.message)
489489
{
490490
// special case for quit
491491
case WM_QUIT:
@@ -494,8 +494,8 @@ void winwindow_dispatch_message(running_machine &machine, MSG *message)
494494

495495
// everything else dispatches normally
496496
default:
497-
TranslateMessage(message);
498-
DispatchMessage(message);
497+
TranslateMessage(&message);
498+
DispatchMessage(&message);
499499
break;
500500
}
501501
}
@@ -2293,17 +2293,17 @@ std::vector<win_window_info::win_pointer_info>::iterator win_window_info::find_m
22932293

22942294
bool winwindow_qt_filter(void *message)
22952295
{
2296-
MSG *msg = (MSG *)message;
2296+
MSG *const msg = reinterpret_cast<MSG *>(message);
22972297

2298-
if(is_mame_window(msg->hwnd) || (!msg->hwnd && (msg->message >= WM_USER)))
2298+
if (is_mame_window(msg->hwnd) || (!msg->hwnd && (msg->message >= WM_USER)))
22992299
{
23002300
LONG_PTR ptr;
2301-
if(msg->hwnd) // get the machine associated with this window
2301+
if (msg->hwnd) // get the machine associated with this window
23022302
ptr = GetWindowLongPtr(msg->hwnd, GWLP_USERDATA);
23032303
else // any one will have to do
23042304
ptr = (LONG_PTR)osd_common_t::window_list().front().get();
23052305

2306-
winwindow_dispatch_message(((win_window_info *)ptr)->machine(), msg);
2306+
winwindow_dispatch_message(reinterpret_cast<win_window_info *>(ptr)->machine(), *msg);
23072307
return true;
23082308
}
23092309
return false;

src/osd/windows/window.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void winwindow_toggle_fsfx(void);
207207
void winwindow_ui_pause(running_machine &machine, int pause);
208208
int winwindow_ui_is_paused(running_machine &machine);
209209

210-
void winwindow_dispatch_message(running_machine &machine, MSG *message);
210+
void winwindow_dispatch_message(running_machine &machine, MSG const &message);
211211

212212

213213

0 commit comments

Comments
 (0)