mirror of
https://github.com/holub/mame
synced 2025-07-06 02:18:09 +03:00
osd: Cleaner way of dealing with input updates.
This commit is contained in:
parent
14d00bf2f7
commit
98131a6b9e
@ -148,12 +148,13 @@ void running_machine::start()
|
||||
// initialize UI input
|
||||
m_ui_input = std::make_unique<ui_input_manager>(*this);
|
||||
|
||||
// init the osd layer
|
||||
// init the OSD layer
|
||||
m_manager.osd().init(*this);
|
||||
|
||||
// create the video manager
|
||||
// create the video manager and UI manager
|
||||
m_video = std::make_unique<video_manager>(*this);
|
||||
m_ui = manager().create_ui(*this);
|
||||
m_ui->set_startup_text("Initializing...", true);
|
||||
|
||||
// initialize the base time (needed for doing record/playback)
|
||||
::time(&m_base_time);
|
||||
|
@ -247,6 +247,7 @@ void video_manager::frame_update(bool from_debugger)
|
||||
if (!from_debugger && !skipped_it && phase > machine_phase::INIT && m_low_latency && effective_throttle())
|
||||
update_throttle(current_time);
|
||||
|
||||
machine().osd().input_update();
|
||||
emulator_info::periodic_check();
|
||||
|
||||
if (!from_debugger)
|
||||
|
@ -353,8 +353,6 @@ ui_manager* mame_machine_manager::create_ui(running_machine& machine)
|
||||
|
||||
machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(&mame_machine_manager::reset, this));
|
||||
|
||||
m_ui->set_startup_text("Initializing...", true);
|
||||
|
||||
return m_ui.get();
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "rendutil.h"
|
||||
#include "uiinput.h"
|
||||
|
||||
#include "osdepend.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
@ -1250,6 +1252,9 @@ void menu::validate_selection(int scandir)
|
||||
|
||||
void menu::do_handle()
|
||||
{
|
||||
// let OSD do its thing
|
||||
machine().osd().check_osd_inputs();
|
||||
|
||||
// recompute metrics if necessary
|
||||
render_manager &render(machine().render());
|
||||
render_target &target(render.ui_target());
|
||||
|
@ -1239,6 +1239,9 @@ void mame_ui_manager::image_handler_ingame()
|
||||
|
||||
uint32_t mame_ui_manager::handler_ingame(render_container &container)
|
||||
{
|
||||
// let the OSD do its thing first
|
||||
machine().osd().check_osd_inputs();
|
||||
|
||||
bool is_paused = machine().paused();
|
||||
|
||||
// first draw the FPS counter
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "util/unicode.h"
|
||||
|
||||
#include "osdepend.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
@ -56,6 +58,9 @@ public:
|
||||
if (!is_relevant())
|
||||
return cancel(uistate);
|
||||
|
||||
// let the OSD do its thing
|
||||
mui.machine().osd().check_osd_inputs();
|
||||
|
||||
// always mark the bitmap dirty if not paused
|
||||
if (!m_machine.paused())
|
||||
m_bitmap_dirty = true;
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
virtual void init(running_machine &machine) override;
|
||||
virtual void update(bool skip_redraw) override;
|
||||
virtual void input_update() override;
|
||||
virtual void check_osd_inputs() override;
|
||||
|
||||
// input overridables
|
||||
virtual void customize_input_type_list(std::vector<input_type_entry> &typelist) override;
|
||||
|
@ -128,41 +128,40 @@ void mac_osd_interface::input_update()
|
||||
process_events_buf();
|
||||
MacPollInputs();
|
||||
poll_input_modules();
|
||||
check_osd_inputs(machine());
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// check_osd_inputs
|
||||
//============================================================
|
||||
|
||||
static void check_osd_inputs(running_machine &machine)
|
||||
void mac_osd_interface::check_osd_inputs()
|
||||
{
|
||||
// check for toggling fullscreen mode
|
||||
if (machine.ui_input().pressed(IPT_OSD_1))
|
||||
if (machine().ui_input().pressed(IPT_OSD_1))
|
||||
{
|
||||
// destroy the renderers first so that the render module can bounce if it depends on having a window handle
|
||||
for (auto it = osd_common_t::window_list().rbegin(); osd_common_t::window_list().rend() != it; ++it)
|
||||
for (auto it = window_list().rbegin(); window_list().rend() != it; ++it)
|
||||
(*it)->renderer_reset();
|
||||
for (auto const &curwin : osd_common_t::window_list())
|
||||
for (auto const &curwin : window_list())
|
||||
dynamic_cast<mac_window_info &>(*curwin).toggle_full_screen();
|
||||
}
|
||||
|
||||
auto const &window = osd_common_t::window_list().front();
|
||||
auto const &window = window_list().front();
|
||||
|
||||
//FIXME: on a per window basis
|
||||
if (machine.ui_input().pressed(IPT_OSD_5))
|
||||
if (machine().ui_input().pressed(IPT_OSD_5))
|
||||
{
|
||||
video_config.filter = !video_config.filter;
|
||||
machine.ui().popup_time(1, "Filter %s", video_config.filter? "enabled":"disabled");
|
||||
machine().ui().popup_time(1, "Filter %s", video_config.filter? "enabled":"disabled");
|
||||
}
|
||||
|
||||
if (machine.ui_input().pressed(IPT_OSD_6))
|
||||
if (machine().ui_input().pressed(IPT_OSD_6))
|
||||
dynamic_cast<mac_window_info &>(*window).modify_prescale(-1);
|
||||
|
||||
if (machine.ui_input().pressed(IPT_OSD_7))
|
||||
if (machine().ui_input().pressed(IPT_OSD_7))
|
||||
dynamic_cast<mac_window_info &>(*window).modify_prescale(1);
|
||||
|
||||
if (machine.ui_input().pressed(IPT_OSD_8))
|
||||
if (machine().ui_input().pressed(IPT_OSD_8))
|
||||
window->renderer().record();
|
||||
}
|
||||
|
||||
|
@ -230,8 +230,6 @@ void mac_window_info::toggle_full_screen()
|
||||
m_windowed_dim = get_size();
|
||||
}
|
||||
|
||||
// reset UI to main menu
|
||||
machine().ui().menu_reset();
|
||||
// kill off the drawers
|
||||
renderer_reset();
|
||||
if (fullscreen() && video_config.switchres)
|
||||
|
@ -397,7 +397,7 @@ class input_module_base : public osd_module, public input_module
|
||||
{
|
||||
private:
|
||||
// 10 milliseconds polling interval
|
||||
static constexpr inline unsigned MIN_POLLING_INTERVAL = 10;
|
||||
static constexpr inline unsigned MIN_POLLING_INTERVAL = 2;
|
||||
|
||||
using clock_type = std::chrono::high_resolution_clock;
|
||||
using timepoint_type = std::chrono::time_point<std::chrono::high_resolution_clock>;
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
virtual void init(running_machine &machine) = 0;
|
||||
virtual void update(bool skip_redraw) = 0;
|
||||
virtual void input_update() = 0;
|
||||
virtual void check_osd_inputs() = 0;
|
||||
virtual void set_verbose(bool print_verbose) = 0;
|
||||
|
||||
// debugger overridables
|
||||
|
@ -298,7 +298,6 @@ void sdl_osd_interface::input_update()
|
||||
{
|
||||
process_events_buf();
|
||||
poll_input_modules();
|
||||
check_osd_inputs();
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,6 +146,7 @@ public:
|
||||
virtual void init(running_machine &machine) override;
|
||||
virtual void update(bool skip_redraw) override;
|
||||
virtual void input_update() override;
|
||||
virtual void check_osd_inputs() override;
|
||||
|
||||
// input overridables
|
||||
virtual void customize_input_type_list(std::vector<input_type_entry> &typelist) override;
|
||||
@ -190,8 +191,6 @@ private:
|
||||
void process_window_event(SDL_Event const &event);
|
||||
void process_textinput_event(SDL_Event const &event);
|
||||
|
||||
void check_osd_inputs();
|
||||
|
||||
bool mouse_over_window() const { return m_mouse_over_window > 0; }
|
||||
template <typename T> sdl_window_info *focus_window(T const &event) const;
|
||||
|
||||
|
@ -239,8 +239,6 @@ void sdl_window_info::toggle_full_screen()
|
||||
m_windowed_dim = get_size();
|
||||
}
|
||||
|
||||
// reset UI to main menu
|
||||
machine().ui().menu_reset();
|
||||
// kill off the drawers
|
||||
renderer_reset();
|
||||
bool is_osx = false;
|
||||
|
@ -119,7 +119,6 @@ void windows_osd_interface::input_update()
|
||||
// poll the joystick values here
|
||||
process_events(true, false);
|
||||
poll_input_modules();
|
||||
check_osd_inputs();
|
||||
}
|
||||
|
||||
//============================================================
|
||||
|
@ -1727,11 +1727,6 @@ void win_window_info::set_fullscreen(int fullscreen)
|
||||
return;
|
||||
m_fullscreen = fullscreen;
|
||||
|
||||
// reset UI to main menu
|
||||
// FIXME: this cause crash if called when running_machine.m_ui not yet initialised. e.g. when trying to show error/warning messagebox at startup (during auto-switch from full screen to windowed mode).
|
||||
// the menus need to be able to survive a fullscreen toggle anyway
|
||||
machine().ui().menu_reset();
|
||||
|
||||
// kill off the renderer
|
||||
renderer_reset();
|
||||
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
virtual void init(running_machine &machine) override;
|
||||
virtual void update(bool skip_redraw) override;
|
||||
virtual void input_update() override;
|
||||
virtual void check_osd_inputs() override;
|
||||
|
||||
// input overrideables
|
||||
virtual void customize_input_type_list(std::vector<input_type_entry> &typelist) override;
|
||||
@ -92,8 +93,6 @@ protected:
|
||||
virtual void build_slider_list() override;
|
||||
virtual void update_slider_list() override;
|
||||
|
||||
void check_osd_inputs();
|
||||
|
||||
private:
|
||||
void process_events(bool ingame, bool nodispatch);
|
||||
virtual void osd_exit() override;
|
||||
|
Loading…
Reference in New Issue
Block a user