ui pointer options: set inc/dec to 1s (hold shift for shorter 0.1s), reset options to default when pressing Del

This commit is contained in:
hap 2024-08-06 11:33:43 +02:00
parent a421445453
commit f1b0eee723
5 changed files with 49 additions and 21 deletions

View file

@ -1978,7 +1978,7 @@ gngprot:
@:maincpu,program,00d0,4,00,00
diamond:
diamrun:
@:maincpu,program,1200,80,4b,00

View file

@ -191,11 +191,16 @@ struct mame_ui_manager::active_pointer
struct mame_ui_manager::pointer_options
{
pointer_options()
: timeout(std::chrono::seconds(3))
, hide_inactive(true)
, timeout_set(false)
, hide_inactive_set(false)
{
reset();
}
void reset()
{
timeout = std::chrono::seconds(3);
hide_inactive = true;
timeout_set = false;
hide_inactive_set = false;
}
bool options_set() const
@ -1773,7 +1778,6 @@ std::chrono::steady_clock::duration mame_ui_manager::pointer_activity_timeout(in
}
//-------------------------------------------------
// hide_inactive_pointers - get per-target hide
// inactive pointers setting
@ -1789,6 +1793,19 @@ bool mame_ui_manager::hide_inactive_pointers(int target) const noexcept
}
//-------------------------------------------------
// reset_pointer_options - reset per-target
// pointer options
//-------------------------------------------------
void mame_ui_manager::reset_pointer_options(int target) noexcept
{
assert((0 <= target) && (m_pointer_options.size() > target));
if ((0 <= target) && (m_pointer_options.size() > target))
m_pointer_options[target].reset();
}
/***************************************************************************
SLIDER CONTROLS

View file

@ -211,6 +211,7 @@ public:
void set_hide_inactive_pointers(int target, bool hide) noexcept;
std::chrono::steady_clock::duration pointer_activity_timeout(int target) const noexcept;
bool hide_inactive_pointers(int target) const noexcept;
void reset_pointer_options(int target) noexcept;
// drawing informational overlays
void draw_fps_counter(render_container &container);

View file

@ -346,14 +346,10 @@ bool menu_video_options::handle(event const *ev)
// pointer inactivity timeout
case ITEM_POINTERTIMEOUT:
if (ev->iptkey == IPT_UI_SELECT)
{
// toggle hide after delay
ui().set_hide_inactive_pointers(m_target.index(), !ui().hide_inactive_pointers(m_target.index()));
changed = true;
}
else if (ev->iptkey == IPT_UI_LEFT)
switch (ev->iptkey)
{
// decrease value
case IPT_UI_LEFT:
if (!ui().hide_inactive_pointers(m_target.index()))
{
ui().set_hide_inactive_pointers(m_target.index(), true);
@ -362,8 +358,8 @@ bool menu_video_options::handle(event const *ev)
}
else
{
bool const ctrl_pressed = machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL);
std::chrono::milliseconds const increment(ctrl_pressed ? 1'000 : 100);
bool const shift_pressed = machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT);
std::chrono::milliseconds const increment(shift_pressed ? 100 : 1'000);
auto timeout = ui().pointer_activity_timeout(m_target.index());
auto const remainder = timeout % increment;
timeout -= remainder.count() ? remainder : increment;
@ -373,9 +369,10 @@ bool menu_video_options::handle(event const *ev)
changed = true;
}
}
}
else if (ev->iptkey == IPT_UI_RIGHT)
{
break;
// increase value
case IPT_UI_RIGHT:
if (ui().hide_inactive_pointers(m_target.index()))
{
auto const timeout = ui().pointer_activity_timeout(m_target.index());
@ -385,14 +382,27 @@ bool menu_video_options::handle(event const *ev)
}
else
{
bool const ctrl_pressed = machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL);
int const increment(ctrl_pressed ? 1'000 : 100);
bool const shift_pressed = machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT);
int const increment(shift_pressed ? 100 : 1'000);
ui().set_pointer_activity_timeout(
m_target.index(),
std::chrono::milliseconds((1 + (timeout / std::chrono::milliseconds(increment))) * increment));
}
changed = true;
}
break;
// toggle hide after delay
case IPT_UI_SELECT:
ui().set_hide_inactive_pointers(m_target.index(), !ui().hide_inactive_pointers(m_target.index()));
changed = true;
break;
// restore default
case IPT_UI_CLEAR:
ui().reset_pointer_options(m_target.index());
changed = true;
break;
}
break;

View file

@ -514,7 +514,7 @@ static INPUT_PORTS_START( xmen )
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_SERVICE2 )
PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE3 )
PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_SERVICE4 )
PORT_BIT( 0x0030, IP_ACTIVE_LOW, IPT_UNKNOWN ) // unused
PORT_BIT( 0x0030, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_er5911_device, do_read)
PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_er5911_device, ready_read)
PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 )