summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui/videoopt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/ui/videoopt.cpp')
-rw-r--r--src/frontend/mame/ui/videoopt.cpp110
1 files changed, 99 insertions, 11 deletions
diff --git a/src/frontend/mame/ui/videoopt.cpp b/src/frontend/mame/ui/videoopt.cpp
index 253271beb4f..a179a2ec16f 100644
--- a/src/frontend/mame/ui/videoopt.cpp
+++ b/src/frontend/mame/ui/videoopt.cpp
@@ -11,9 +11,12 @@
#include "emu.h"
#include "ui/videoopt.h"
+#include "rendfont.h"
#include "rendlay.h"
#include "rendutil.h"
+#include <chrono>
+
namespace ui {
@@ -23,6 +26,7 @@ constexpr uintptr_t ITEM_ROTATE = 0x00000100;
constexpr uintptr_t ITEM_ZOOM = 0x00000101;
constexpr uintptr_t ITEM_UNEVENSTRETCH = 0x00000102;
constexpr uintptr_t ITEM_KEEPASPECT = 0x00000103;
+constexpr uintptr_t ITEM_POINTERTIMEOUT = 0x00000104;
constexpr uintptr_t ITEM_TOGGLE_FIRST = 0x00000200;
constexpr uintptr_t ITEM_VIEW_FIRST = 0x00000300;
@@ -44,7 +48,7 @@ menu_video_targets::~menu_video_targets()
{
}
-void menu_video_targets::populate(float &customtop, float &custombottom)
+void menu_video_targets::populate()
{
// find the targets
for (unsigned targetnum = 0; ; targetnum++)
@@ -68,7 +72,7 @@ void menu_video_targets::populate(float &customtop, float &custombottom)
menu
-------------------------------------------------*/
-void menu_video_targets::handle(event const *ev)
+bool menu_video_targets::handle(event const *ev)
{
if (ev && (ev->iptkey == IPT_UI_SELECT))
{
@@ -80,6 +84,8 @@ void menu_video_targets::handle(event const *ev)
*target,
&machine().video().snapshot_target() == target);
}
+
+ return false;
}
@@ -111,7 +117,7 @@ menu_video_options::~menu_video_options()
{
}
-void menu_video_options::populate(float &customtop, float &custombottom)
+void menu_video_options::populate()
{
uintptr_t ref;
@@ -119,7 +125,7 @@ void menu_video_options::populate(float &customtop, float &custombottom)
if (!m_snapshot || !machine().video().snap_native())
{
for (char const *name = m_target.view_name(ref = 0); name; name = m_target.view_name(++ref))
- item_append(name, 0, reinterpret_cast<void *>(ITEM_VIEW_FIRST + ref));
+ item_append(name, convert_command_glyph(ref == m_target.view() ? "_>" : "_<"), 0, reinterpret_cast<void *>(ITEM_VIEW_FIRST + ref));
item_append(menu_item_type::SEPARATOR);
}
@@ -147,10 +153,10 @@ void menu_video_options::populate(float &customtop, float &custombottom)
// add a rotate item
switch (m_target.orientation())
{
- case ROT0: subtext = "None"; break;
- case ROT90: subtext = "CW 90" UTF8_DEGREES; break;
- case ROT180: subtext = "180" UTF8_DEGREES; break;
- case ROT270: subtext = "CCW 90" UTF8_DEGREES; break;
+ case ROT0: subtext = "None"; break;
+ case ROT90: subtext = u8"CW 90°"; break;
+ case ROT180: subtext = u8"180°"; break;
+ case ROT270: subtext = u8"CCW 90°"; break;
}
item_append(_("Rotate"), subtext, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, reinterpret_cast<void *>(ITEM_ROTATE));
@@ -189,6 +195,29 @@ void menu_video_options::populate(float &customtop, float &custombottom)
item_append_on_off(_("Maintain Aspect Ratio"), m_target.keepaspect(), 0, reinterpret_cast<void *>(ITEM_KEEPASPECT));
}
+ // add pointer display options
+ if (!m_target.hidden())
+ {
+ item_append(menu_item_type::SEPARATOR);
+
+ // use millisecond precision for timeout display
+ auto const timeout = std::chrono::duration_cast<std::chrono::milliseconds>(ui().pointer_activity_timeout(m_target.index()));
+ bool const hide = ui().hide_inactive_pointers(m_target.index());
+ if (hide)
+ {
+ int const precision = (timeout.count() % 10) ? 3 : (timeout.count() % 100) ? 2 : 1;
+ item_append(
+ _("Hide Inactive Pointers After Delay"),
+ util::string_format(_("%1$.*2$f s"), timeout.count() * 1e-3, precision),
+ ((timeout > std::chrono::milliseconds(100)) ? FLAG_LEFT_ARROW : 0) | FLAG_RIGHT_ARROW,
+ reinterpret_cast<void *>(ITEM_POINTERTIMEOUT));
+ }
+ else
+ {
+ item_append(_("Hide Inactive Pointers After Delay"), _("Never"), FLAG_LEFT_ARROW, reinterpret_cast<void *>(ITEM_POINTERTIMEOUT));
+ }
+ }
+
item_append(menu_item_type::SEPARATOR);
}
@@ -198,11 +227,17 @@ void menu_video_options::populate(float &customtop, float &custombottom)
menu
-------------------------------------------------*/
-void menu_video_options::handle(event const *ev)
+bool menu_video_options::handle(event const *ev)
{
- auto const lockout_popup([this] () { machine().popmessage(_("Cannot change options while recording!")); });
+ auto const lockout_popup(
+ [this] ()
+ {
+ machine().popmessage(_("Cannot change options while recording!"));
+ return true;
+ });
bool const snap_lockout(m_snapshot && machine().video().is_recording());
bool changed(false);
+ set_process_flags((reinterpret_cast<uintptr_t>(get_selection_ref()) == ITEM_POINTERTIMEOUT) ? PROCESS_LR_REPEAT : 0);
// process the menu
if (ev && uintptr_t(ev->itemref))
@@ -298,7 +333,7 @@ void menu_video_options::handle(event const *ev)
}
break;
- // keep aspect handles left/right keys the same (toggle)
+ // keep aspect handles left/right keys identically (toggle)
case ITEM_KEEPASPECT:
if ((ev->iptkey == IPT_UI_LEFT) || (ev->iptkey == IPT_UI_RIGHT))
{
@@ -309,6 +344,58 @@ void menu_video_options::handle(event const *ev)
}
break;
+ // 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)
+ {
+ if (!ui().hide_inactive_pointers(m_target.index()))
+ {
+ ui().set_hide_inactive_pointers(m_target.index(), true);
+ ui().set_pointer_activity_timeout(m_target.index(), std::chrono::milliseconds(10'000));
+ changed = true;
+ }
+ 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);
+ auto timeout = ui().pointer_activity_timeout(m_target.index());
+ auto const remainder = timeout % increment;
+ timeout -= remainder.count() ? remainder : increment;
+ if (std::chrono::milliseconds(100) <= timeout)
+ {
+ ui().set_pointer_activity_timeout(m_target.index(), timeout);
+ changed = true;
+ }
+ }
+ }
+ else if (ev->iptkey == IPT_UI_RIGHT)
+ {
+ if (ui().hide_inactive_pointers(m_target.index()))
+ {
+ auto const timeout = ui().pointer_activity_timeout(m_target.index());
+ if (std::chrono::milliseconds(10'000) <= timeout)
+ {
+ ui().set_hide_inactive_pointers(m_target.index(), false);
+ }
+ 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);
+ ui().set_pointer_activity_timeout(
+ m_target.index(),
+ std::chrono::milliseconds((1 + (timeout / std::chrono::milliseconds(increment))) * increment));
+ }
+ changed = true;
+ }
+ }
+ break;
+
// anything else is a view item
default:
if (reinterpret_cast<uintptr_t>(ev->itemref) >= ITEM_VIEW_FIRST)
@@ -338,6 +425,7 @@ void menu_video_options::handle(event const *ev)
// if something changed, rebuild the menu
if (changed)
reset(reset_options::REMEMBER_REF);
+ return false;
}
} // namespace ui