mirror of
https://github.com/holub/mame
synced 2025-07-05 01:48:29 +03:00
osd: Don't pump events when reading inputs.
This was a drain on performance. If anything is trying to poll inputs in a loop, it needs to call input_update() to ensure it gets up-to-date state.
This commit is contained in:
parent
cf4310a1e7
commit
a72c02133f
@ -218,7 +218,8 @@ void video_manager::frame_update(bool from_debugger)
|
|||||||
bool const update_screens = (phase == machine_phase::RUNNING) && (!machine().paused() || machine().options().update_in_pause());
|
bool const update_screens = (phase == machine_phase::RUNNING) && (!machine().paused() || machine().options().update_in_pause());
|
||||||
bool anything_changed = update_screens && finish_screen_updates();
|
bool anything_changed = update_screens && finish_screen_updates();
|
||||||
|
|
||||||
// draw the user interface
|
// update inputs and draw the user interface
|
||||||
|
machine().osd().input_update();
|
||||||
emulator_info::draw_user_interface(machine());
|
emulator_info::draw_user_interface(machine());
|
||||||
|
|
||||||
// let plugins draw over the UI
|
// let plugins draw over the UI
|
||||||
@ -246,9 +247,6 @@ void video_manager::frame_update(bool from_debugger)
|
|||||||
if (!from_debugger && !skipped_it && phase > machine_phase::INIT && m_low_latency && effective_throttle())
|
if (!from_debugger && !skipped_it && phase > machine_phase::INIT && m_low_latency && effective_throttle())
|
||||||
update_throttle(current_time);
|
update_throttle(current_time);
|
||||||
|
|
||||||
// get most recent input now
|
|
||||||
machine().osd().input_update();
|
|
||||||
|
|
||||||
emulator_info::periodic_check();
|
emulator_info::periodic_check();
|
||||||
|
|
||||||
if (!from_debugger)
|
if (!from_debugger)
|
||||||
|
@ -58,7 +58,6 @@ public:
|
|||||||
virtual void window_exit() override;
|
virtual void window_exit() override;
|
||||||
|
|
||||||
// sdl specific
|
// sdl specific
|
||||||
void poll_inputs(running_machine &machine);
|
|
||||||
void release_keys();
|
void release_keys();
|
||||||
bool should_hide_mouse();
|
bool should_hide_mouse();
|
||||||
void process_events_buf();
|
void process_events_buf();
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "modules/lib/osdlib.h"
|
#include "modules/lib/osdlib.h"
|
||||||
#include "modules/monitor/monitor_module.h"
|
#include "modules/monitor/monitor_module.h"
|
||||||
|
|
||||||
|
extern void MacPollInputs(); // in windowcontroller.mm
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
//============================================================
|
//============================================================
|
||||||
@ -124,7 +126,8 @@ void mac_osd_interface::input_update()
|
|||||||
{
|
{
|
||||||
// poll the joystick values here
|
// poll the joystick values here
|
||||||
process_events_buf();
|
process_events_buf();
|
||||||
poll_inputs(machine());
|
MacPollInputs();
|
||||||
|
poll_input_modules();
|
||||||
check_osd_inputs(machine());
|
check_osd_inputs(machine());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ void debugger_windows::wait_for_debugger(device_t &device, bool firststop)
|
|||||||
show_all();
|
show_all();
|
||||||
|
|
||||||
// run input polling to ensure that our status is in sync
|
// run input polling to ensure that our status is in sync
|
||||||
downcast<windows_osd_interface&>(machine().osd()).poll_input(*m_machine);
|
downcast<windows_osd_interface&>(machine().osd()).poll_input_modules();
|
||||||
|
|
||||||
// get and process messages
|
// get and process messages
|
||||||
MSG message;
|
MSG message;
|
||||||
|
@ -507,24 +507,15 @@ private:
|
|||||||
template <class TItem>
|
template <class TItem>
|
||||||
int generic_button_get_state(void *device_internal, void *item_internal)
|
int generic_button_get_state(void *device_internal, void *item_internal)
|
||||||
{
|
{
|
||||||
device_info *devinfo = static_cast<device_info *>(device_internal);
|
|
||||||
TItem *itemdata = static_cast<TItem*>(item_internal);
|
|
||||||
|
|
||||||
// return the current state
|
// return the current state
|
||||||
devinfo->module().poll_if_necessary();
|
return *reinterpret_cast<TItem const *>(item_internal) >> 7;
|
||||||
return *itemdata >> 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class TItem>
|
template <class TItem>
|
||||||
int generic_axis_get_state(void *device_internal, void *item_internal)
|
int generic_axis_get_state(void *device_internal, void *item_internal)
|
||||||
{
|
{
|
||||||
device_info *devinfo = static_cast<device_info *>(device_internal);
|
return *reinterpret_cast<TItem const *>(item_internal);
|
||||||
TItem *axisdata = static_cast<TItem*>(item_internal);
|
|
||||||
|
|
||||||
// return the current state
|
|
||||||
devinfo->module().poll_if_necessary();
|
|
||||||
return *axisdata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1168,7 +1168,6 @@ int32_t dinput_joystick_device::pov_get_state(void *device_internal, void *item_
|
|||||||
int const povdir = uintptr_t(item_internal) % 4;
|
int const povdir = uintptr_t(item_internal) % 4;
|
||||||
|
|
||||||
// get the current state
|
// get the current state
|
||||||
devinfo->module().poll_if_necessary();
|
|
||||||
DWORD const pov = devinfo->m_joystick.state.rgdwPOV[povnum];
|
DWORD const pov = devinfo->m_joystick.state.rgdwPOV[povnum];
|
||||||
|
|
||||||
// if invalid, return 0
|
// if invalid, return 0
|
||||||
|
@ -31,17 +31,10 @@
|
|||||||
#include "../../mac/osdmac.h"
|
#include "../../mac/osdmac.h"
|
||||||
#include "input_common.h"
|
#include "input_common.h"
|
||||||
|
|
||||||
extern void MacPollInputs();
|
|
||||||
|
|
||||||
void mac_osd_interface::customize_input_type_list(std::vector<input_type_entry> &typelist)
|
void mac_osd_interface::customize_input_type_list(std::vector<input_type_entry> &typelist)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void mac_osd_interface::poll_inputs()
|
|
||||||
{
|
|
||||||
MacPollInputs();
|
|
||||||
}
|
|
||||||
|
|
||||||
void mac_osd_interface::release_keys()
|
void mac_osd_interface::release_keys()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1502,7 +1502,6 @@ public:
|
|||||||
button_item++,
|
button_item++,
|
||||||
[] (void *device_internal, void *item_internal) -> int
|
[] (void *device_internal, void *item_internal) -> int
|
||||||
{
|
{
|
||||||
static_cast<device_info *>(device_internal)->module().poll_if_necessary();
|
|
||||||
return (*reinterpret_cast<s32 const *>(item_internal) <= -16'384) ? 1 : 0;
|
return (*reinterpret_cast<s32 const *>(item_internal) <= -16'384) ? 1 : 0;
|
||||||
},
|
},
|
||||||
&m_controller.axes[axis]);
|
&m_controller.axes[axis]);
|
||||||
|
@ -65,14 +65,6 @@ bool windows_osd_interface::handle_input_event(input_event eventid, void *eventd
|
|||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void windows_osd_interface::poll_input(running_machine &machine) const
|
|
||||||
{
|
|
||||||
m_keyboard_input->poll_if_necessary();
|
|
||||||
m_mouse_input->poll_if_necessary();
|
|
||||||
m_lightgun_input->poll_if_necessary();
|
|
||||||
m_joystick_input->poll_if_necessary();
|
|
||||||
}
|
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// customize_input_type_list
|
// customize_input_type_list
|
||||||
//============================================================
|
//============================================================
|
||||||
|
@ -675,6 +675,14 @@ bool osd_common_t::input_init()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void osd_common_t::poll_input_modules()
|
||||||
|
{
|
||||||
|
m_keyboard_input->poll_if_necessary();
|
||||||
|
m_mouse_input->poll_if_necessary();
|
||||||
|
m_lightgun_input->poll_if_necessary();
|
||||||
|
m_joystick_input->poll_if_necessary();
|
||||||
|
}
|
||||||
|
|
||||||
void osd_common_t::exit_subsystems()
|
void osd_common_t::exit_subsystems()
|
||||||
{
|
{
|
||||||
video_exit();
|
video_exit();
|
||||||
|
@ -279,6 +279,8 @@ protected:
|
|||||||
virtual void build_slider_list() { }
|
virtual void build_slider_list() { }
|
||||||
virtual void update_slider_list() { }
|
virtual void update_slider_list() { }
|
||||||
|
|
||||||
|
void poll_input_modules();
|
||||||
|
|
||||||
static std::list<std::unique_ptr<osd_window> > s_window_list;
|
static std::list<std::unique_ptr<osd_window> > s_window_list;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -297,7 +297,7 @@ void sdl_osd_interface::init(running_machine &machine)
|
|||||||
void sdl_osd_interface::input_update()
|
void sdl_osd_interface::input_update()
|
||||||
{
|
{
|
||||||
process_events_buf();
|
process_events_buf();
|
||||||
poll_inputs();
|
poll_input_modules();
|
||||||
check_osd_inputs();
|
check_osd_inputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,15 +421,6 @@ void sdl_osd_interface::customize_input_type_list(std::vector<input_type_entry>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void sdl_osd_interface::poll_inputs()
|
|
||||||
{
|
|
||||||
m_keyboard_input->poll_if_necessary();
|
|
||||||
m_mouse_input->poll_if_necessary();
|
|
||||||
m_lightgun_input->poll_if_necessary();
|
|
||||||
m_joystick_input->poll_if_necessary();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void sdl_osd_interface::release_keys()
|
void sdl_osd_interface::release_keys()
|
||||||
{
|
{
|
||||||
auto const keybd = dynamic_cast<input_module_base *>(m_keyboard_input);
|
auto const keybd = dynamic_cast<input_module_base *>(m_keyboard_input);
|
||||||
|
@ -158,7 +158,6 @@ public:
|
|||||||
|
|
||||||
// SDL-specific
|
// SDL-specific
|
||||||
virtual bool has_focus() const override { return bool(m_focus_window); }
|
virtual bool has_focus() const override { return bool(m_focus_window); }
|
||||||
void poll_inputs();
|
|
||||||
void release_keys();
|
void release_keys();
|
||||||
bool should_hide_mouse();
|
bool should_hide_mouse();
|
||||||
void process_events_buf();
|
void process_events_buf();
|
||||||
|
@ -118,7 +118,7 @@ void windows_osd_interface::input_update()
|
|||||||
{
|
{
|
||||||
// poll the joystick values here
|
// poll the joystick values here
|
||||||
process_events(true, false);
|
process_events(true, false);
|
||||||
poll_input(machine());
|
poll_input_modules();
|
||||||
check_osd_inputs();
|
check_osd_inputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,6 @@ public:
|
|||||||
// windows OSD specific
|
// windows OSD specific
|
||||||
bool handle_input_event(input_event eventid, void *eventdata) const;
|
bool handle_input_event(input_event eventid, void *eventdata) const;
|
||||||
bool should_hide_mouse() const;
|
bool should_hide_mouse() const;
|
||||||
void poll_input(running_machine &machine) const;
|
|
||||||
|
|
||||||
virtual bool has_focus() const override;
|
virtual bool has_focus() const override;
|
||||||
virtual void process_events() override;
|
virtual void process_events() override;
|
||||||
@ -87,6 +86,8 @@ public:
|
|||||||
|
|
||||||
int window_count();
|
int window_count();
|
||||||
|
|
||||||
|
using osd_common_t::poll_input_modules; // Win32 debugger calls this directly, which it shouldn't
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void build_slider_list() override;
|
virtual void build_slider_list() override;
|
||||||
virtual void update_slider_list() override;
|
virtual void update_slider_list() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user