mirror of
https://github.com/holub/mame
synced 2025-04-21 16:01:56 +03:00
Fix SDL input focus tracking bug plus remove references to USE_OLD_SDL_INPUT compiler directive from the input refactor.
This commit is contained in:
parent
a8d9a097c3
commit
7a0a60d3c4
@ -443,7 +443,7 @@ public:
|
||||
|
||||
bool should_poll_devices(running_machine& machine) override
|
||||
{
|
||||
return sdl_event_manager::instance().app_has_mouse_focus() && input_enabled();
|
||||
return sdl_event_manager::instance().has_focus() && input_enabled();
|
||||
}
|
||||
|
||||
virtual void handle_event(SDL_Event &sdlevent) override
|
||||
|
@ -85,12 +85,13 @@ void sdl_event_manager::process_window_event(running_machine &machine, SDL_Event
|
||||
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
machine.ui_input().push_mouse_leave_event(window->target());
|
||||
m_app_has_mouse_focus = 0;
|
||||
m_mouse_over_window = 0;
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
window->notify_changed();
|
||||
m_focus_window = window;
|
||||
m_has_focus = true;
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
@ -105,16 +106,22 @@ void sdl_event_manager::process_window_event(running_machine &machine, SDL_Event
|
||||
window->resize(sdlevent.window.data1, sdlevent.window.data2);
|
||||
}
|
||||
m_focus_window = window;
|
||||
m_has_focus = true;
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_ENTER:
|
||||
m_app_has_mouse_focus = 1;
|
||||
m_mouse_over_window = 1;
|
||||
/* fall through */
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
m_focus_window = window;
|
||||
m_has_focus = true;
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
m_has_focus = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -268,7 +275,7 @@ bool sdl_osd_interface::should_hide_mouse()
|
||||
if (!options().mouse() && !options().lightgun())
|
||||
return false;
|
||||
|
||||
if (!sdl_event_manager::instance().app_has_mouse_focus())
|
||||
if (!sdl_event_manager::instance().mouse_over_window())
|
||||
return false;
|
||||
|
||||
// otherwise, yes
|
||||
|
@ -76,6 +76,10 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
virtual ~event_manager_t()
|
||||
{
|
||||
}
|
||||
|
||||
void subscribe(int* event_types, int num_event_types, TSubscriber *subscriber)
|
||||
{
|
||||
std::lock_guard<std::mutex> scope_lock(m_lock);
|
||||
@ -109,17 +113,20 @@ class sdl_window_info;
|
||||
class sdl_event_manager : public event_manager_t<sdl_event_subscriber>
|
||||
{
|
||||
private:
|
||||
bool m_app_has_mouse_focus;
|
||||
bool m_mouse_over_window;
|
||||
bool m_has_focus;
|
||||
sdl_window_info * m_focus_window;
|
||||
|
||||
sdl_event_manager()
|
||||
: m_app_has_mouse_focus(true),
|
||||
: m_mouse_over_window(true),
|
||||
m_has_focus(true),
|
||||
m_focus_window(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
bool app_has_mouse_focus() { return m_app_has_mouse_focus; }
|
||||
bool mouse_over_window() const { return m_mouse_over_window; }
|
||||
bool has_focus() const { return m_focus_window; }
|
||||
sdl_window_info * focus_window() { return m_focus_window; }
|
||||
|
||||
static sdl_event_manager& instance()
|
||||
|
@ -149,19 +149,11 @@ public:
|
||||
|
||||
virtual bool video_init() override;
|
||||
virtual bool window_init() override;
|
||||
#ifdef USE_OLD_SDL_INPUT
|
||||
virtual bool input_init() override;
|
||||
virtual void input_pause() override;
|
||||
virtual void input_resume() override;
|
||||
#endif
|
||||
virtual bool output_init() override;
|
||||
//virtual bool midi_init();
|
||||
|
||||
virtual void video_exit() override;
|
||||
virtual void window_exit() override;
|
||||
#ifdef USE_OLD_SDL_INPUT
|
||||
virtual void input_exit() override;
|
||||
#endif
|
||||
virtual void output_exit() override;
|
||||
//virtual void midi_exit();
|
||||
|
||||
|
@ -286,12 +286,7 @@ finishit:
|
||||
|
||||
static void check_osd_inputs(running_machine &machine)
|
||||
{
|
||||
#ifdef USE_OLD_SDL_INPUT
|
||||
sdl_window_info *window = sdlinput_get_focus_window();
|
||||
#else
|
||||
// BUG: TODO: Fix focus window support
|
||||
sdl_window_info *window = sdl_window_list;
|
||||
#endif
|
||||
|
||||
// check for toggling fullscreen mode
|
||||
if (machine.ui_input().pressed(IPT_OSD_1))
|
||||
|
@ -649,13 +649,8 @@ void sdl_window_info::update_cursor_state()
|
||||
// the possibility of losing control
|
||||
if (!(machine().debug_flags & DEBUG_FLAG_OSD_ENABLED))
|
||||
{
|
||||
//FIXME: SDL1.3: really broken: the whole SDL code
|
||||
// will only work correct with relative mouse movements ...
|
||||
#ifdef USE_OLD_SDL_INPUT
|
||||
bool should_hide_mouse = sdlinput_should_hide_mouse();
|
||||
#else
|
||||
bool should_hide_mouse = downcast<sdl_osd_interface&>(machine().osd()).should_hide_mouse();
|
||||
#endif
|
||||
|
||||
if (!fullscreen() && !should_hide_mouse)
|
||||
{
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
@ -780,12 +775,7 @@ OSDWORK_CALLBACK( sdl_window_info::sdlwindow_video_window_destroy_wt )
|
||||
}
|
||||
SDL_DestroyWindow(window->sdl_window());
|
||||
// release all keys ...
|
||||
#ifdef USE_OLD_SDL_INPUT
|
||||
sdlinput_release_keys();
|
||||
#else
|
||||
downcast<sdl_osd_interface &>(window->machine().osd()).release_keys();
|
||||
#endif
|
||||
|
||||
|
||||
osd_free(wp);
|
||||
return nullptr;
|
||||
@ -1203,11 +1193,7 @@ OSDWORK_CALLBACK( sdl_window_info::draw_video_contents_wt )
|
||||
ASSERT_REDRAW_THREAD();
|
||||
|
||||
// Some configurations require events to be polled in the worker thread
|
||||
#ifdef USE_OLD_SDL_INPUT
|
||||
sdlinput_process_events_buf();
|
||||
#else
|
||||
downcast< sdl_osd_interface& >(window->machine().osd()).process_events_buf();
|
||||
#endif
|
||||
|
||||
// Check whether window has vector screens
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user