Skip to content

Commit

Permalink
Files for 266.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbbert committed May 30, 2024
1 parent efc4184 commit ba197c2
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 77 deletions.
2 changes: 1 addition & 1 deletion docs/release/build/uprel.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\goto end
git fetch upstream
git merge upstream/release0265
git merge upstream/release0266
git checkout master
:end
pause
29 changes: 26 additions & 3 deletions docs/release/src/osd/modules/lib/osdobj_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ void osd_common_t::register_options()
REGISTER_MODULE(m_mod_man, MOUSEINPUT_WIN32);
REGISTER_MODULE(m_mod_man, MOUSE_NONE);

REGISTER_MODULE(m_mod_man, LIGHTGUNINPUT_SDL);
REGISTER_MODULE(m_mod_man, LIGHTGUN_X11);
REGISTER_MODULE(m_mod_man, LIGHTGUNINPUT_RAWINPUT);
REGISTER_MODULE(m_mod_man, LIGHTGUNINPUT_WIN32);
Expand Down Expand Up @@ -462,9 +463,6 @@ void osd_common_t::update(bool skip_redraw)
//
if (m_watchdog != nullptr)
m_watchdog->reset();

update_slider_list();

}


Expand Down Expand Up @@ -567,6 +565,31 @@ void osd_common_t::customize_input_type_list(std::vector<input_type_entry> &type

std::vector<ui::menu_item> osd_common_t::get_slider_list()
{
// check if any window has dirty sliders
bool dirty = false;
for (const auto &window : window_list())
{
if (window->has_renderer() && window->renderer().sliders_dirty())
{
dirty = true;
break;
}
}

if (dirty)
{
m_sliders.clear();

for (const auto &window : osd_common_t::window_list())
{
if (window->has_renderer())
{
std::vector<ui::menu_item> window_sliders = window->renderer().get_slider_list();
m_sliders.insert(m_sliders.end(), window_sliders.begin(), window_sliders.end());
}
}
}

return m_sliders;
}

Expand Down
111 changes: 48 additions & 63 deletions docs/release/src/osd/windows/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,46 +146,20 @@ bool windows_osd_interface::window_init()
return true;
}

void windows_osd_interface::update_slider_list()
{
for (const auto &window : osd_common_t::window_list())
{
// check if any window has dirty sliders
if (window->has_renderer() && window->renderer().sliders_dirty())
{
build_slider_list();
return;
}
}
}

int windows_osd_interface::window_count()
{
return osd_common_t::window_list().size();
}

void windows_osd_interface::build_slider_list()
{
m_sliders.clear();

for (const auto &window : osd_common_t::window_list())
{
if (window->has_renderer())
{
// take the sliders of the first window
std::vector<ui::menu_item> window_sliders = window->renderer().get_slider_list();
m_sliders.insert(m_sliders.end(), window_sliders.begin(), window_sliders.end());
}
}
}

void windows_osd_interface::add_audio_to_recording(const int16_t *buffer, int samples_this_frame)
{
auto const &window = osd_common_t::window_list().front(); // We only record on the first window
if (window)
window->renderer().add_audio_to_recording(buffer, samples_this_frame);
}


//============================================================
// winwindow_exit
// (main thread)
Expand Down Expand Up @@ -297,7 +271,7 @@ void win_window_info::show_pointer()
s_saved_cursor_pos.x = s_saved_cursor_pos.y = -1;
}

while (ShowCursor(TRUE) < 1) {};
while (ShowCursor(TRUE) < 1) { }
ShowCursor(FALSE);
}

Expand Down Expand Up @@ -342,7 +316,7 @@ void windows_osd_interface::process_events()
// is_mame_window
//============================================================

static bool is_mame_window(HWND hwnd)
inline bool is_mame_window(HWND hwnd)
{
for (const auto &window : osd_common_t::window_list())
if (dynamic_cast<win_window_info &>(*window).platform_window() == hwnd)
Expand All @@ -351,50 +325,50 @@ static bool is_mame_window(HWND hwnd)
return false;
}

inline static BOOL handle_mouse_button(windows_osd_interface *osd, int button, int down, int x, int y)
inline BOOL handle_mouse_button(windows_osd_interface &osd, int button, int down, LPARAM lparam)
{
MouseUpdateEventArgs args;
args.pressed = (down ? 1 : 0) << button;
args.released = (down ? 0 : 1) << button;
args.vdelta = 0;
args.hdelta = 0;
args.xpos = x;
args.ypos = y;
args.xpos = GET_X_LPARAM(lparam);
args.ypos = GET_Y_LPARAM(lparam);

bool handled = osd->handle_input_event(INPUT_EVENT_MOUSE_BUTTON, &args);
bool const handled = osd.handle_input_event(INPUT_EVENT_MOUSE_BUTTON, &args);

// When in lightgun mode or mouse mode, the mouse click may be routed to the input system
// because the mouse interactions in the UI are routed from the video_window_proc below
// we need to make sure they aren't suppressed in these cases.
return handled && !osd->options().lightgun() && !osd->options().mouse();
return handled && !osd.options().lightgun() && !osd.options().mouse();
}

inline static BOOL handle_mouse_wheel(windows_osd_interface *osd, int v, int h, int x, int y)
inline BOOL handle_mouse_wheel(windows_osd_interface &osd, int v, int h, LPARAM lparam)
{
MouseUpdateEventArgs args;
args.pressed = 0;
args.released = 0;
args.vdelta = v;
args.hdelta = h;
args.xpos = x;
args.ypos = y;
args.xpos = GET_X_LPARAM(lparam);
args.ypos = GET_Y_LPARAM(lparam);

bool handled = osd->handle_input_event(INPUT_EVENT_MOUSE_WHEEL, &args);
bool const handled = osd.handle_input_event(INPUT_EVENT_MOUSE_WHEEL, &args);

// When in lightgun mode or mouse mode, the mouse wheel may be routed to the input system
// because the mouse interactions in the UI are routed from the video_window_proc below
// we need to make sure they aren't suppressed in these cases.
return handled && !osd->options().lightgun() && !osd->options().mouse();
return handled && !osd.options().lightgun() && !osd.options().mouse();
}

inline static BOOL handle_keypress(windows_osd_interface *osd, int vkey, int down, int scancode, BOOL extended_key)
inline BOOL handle_keypress(windows_osd_interface &osd, int vkey, int down, LPARAM lparam)
{
KeyPressEventArgs args;
args.event_id = down ? INPUT_EVENT_KEYDOWN : INPUT_EVENT_KEYUP;
args.scancode = MAKE_DI_SCAN(scancode, extended_key);
args.scancode = MAKE_DI_SCAN(SCAN_CODE(lparam), IS_EXTENDED(lparam));
args.vkey = vkey;

return osd->handle_input_event(args.event_id, &args);
return osd.handle_input_event(args.event_id, &args);
}

//============================================================
Expand Down Expand Up @@ -435,61 +409,62 @@ void windows_osd_interface::process_events(bool ingame, bool nodispatch)

// forward mouse button downs to the input system
case WM_LBUTTONDOWN:
dispatch = !handle_mouse_button(this, 0, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = !handle_mouse_button(*this, 0, TRUE, message.lParam);
break;

case WM_RBUTTONDOWN:
dispatch = !handle_mouse_button(this, 1, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = !handle_mouse_button(*this, 1, TRUE, message.lParam);
break;

case WM_MBUTTONDOWN:
dispatch = !handle_mouse_button(this, 2, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = !handle_mouse_button(*this, 2, TRUE, message.lParam);
break;

case WM_XBUTTONDOWN:
dispatch = !handle_mouse_button(this, 3, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = !handle_mouse_button(*this, (GET_XBUTTON_WPARAM(message.wParam) == XBUTTON1) ? 3 : 4, TRUE, message.lParam);
break;

// forward mouse button ups to the input system
case WM_LBUTTONUP:
dispatch = !handle_mouse_button(this, 0, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = !handle_mouse_button(*this, 0, FALSE, message.lParam);
break;

case WM_RBUTTONUP:
dispatch = !handle_mouse_button(this, 1, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = !handle_mouse_button(*this, 1, FALSE, message.lParam);
break;

case WM_MBUTTONUP:
dispatch = !handle_mouse_button(this, 2, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = !handle_mouse_button(*this, 2, FALSE, message.lParam);
break;

case WM_XBUTTONUP:
dispatch = !handle_mouse_button(this, 3, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = !handle_mouse_button(*this, (GET_XBUTTON_WPARAM(message.wParam) == XBUTTON1) ? 3 : 4, FALSE, message.lParam);
break;

// forward mouse wheel movement to the input system
case WM_MOUSEWHEEL:
dispatch = !handle_mouse_wheel(this, GET_WHEEL_DELTA_WPARAM(message.wParam), 0, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = !handle_mouse_wheel(*this, GET_WHEEL_DELTA_WPARAM(message.wParam), 0, message.lParam);
break;

case WM_MOUSEHWHEEL:
dispatch = !handle_mouse_wheel(this, 0, GET_WHEEL_DELTA_WPARAM(message.wParam), GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam));
dispatch = !handle_mouse_wheel(*this, 0, GET_WHEEL_DELTA_WPARAM(message.wParam), message.lParam);
break;

// forward keystrokes to the input system
case WM_KEYDOWN:
if (NOT_ALREADY_DOWN(message.lParam))
dispatch = !handle_keypress(this, message.wParam, TRUE, SCAN_CODE(message.lParam), IS_EXTENDED(message.lParam));
dispatch = !handle_keypress(*this, message.wParam, TRUE, message.lParam);
break;

case WM_KEYUP:
dispatch = !handle_keypress(this, message.wParam, FALSE, SCAN_CODE(message.lParam), IS_EXTENDED(message.lParam));
dispatch = !handle_keypress(*this, message.wParam, FALSE, message.lParam);
break;
}
}

// dispatch if necessary
if (dispatch)
winwindow_dispatch_message(machine(), &message);
winwindow_dispatch_message(machine(), message);
}
}
while (ui_temp_pause > 0);
Expand All @@ -505,12 +480,12 @@ void windows_osd_interface::process_events(bool ingame, bool nodispatch)
// (main thread)
//============================================================

void winwindow_dispatch_message(running_machine &machine, MSG *message)
void winwindow_dispatch_message(running_machine &machine, MSG const &message)
{
assert(GetCurrentThreadId() == main_threadid);

// dispatch our special communication messages
switch (message->message)
switch (message.message)
{
// special case for quit
case WM_QUIT:
Expand All @@ -519,8 +494,8 @@ void winwindow_dispatch_message(running_machine &machine, MSG *message)

// everything else dispatches normally
default:
TranslateMessage(message);
DispatchMessage(message);
TranslateMessage(&message);
DispatchMessage(&message);
break;
}
}
Expand Down Expand Up @@ -1247,6 +1222,16 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
case WM_POINTERCAPTURECHANGED:
window->pointer_capture_changed(wparam, lparam);
break;
// TODO: other pointer events?
//case WM_POINTERACTIVATE:
//case WM_POINTERDEVICECHANGE:
//case WM_POINTERDEVICEINRANGE:
//case WM_POINTERDEVICEOUTOFRANGE:
//case WM_POINTERROUTEDAWAY:
//case WM_POINTERROUTEDRELEASED:
//case WM_POINTERROUTEDTO:
//case WM_POINTERWHEEL:
//case WM_POINTERHWHEEL:

// pause the system when we start a menu or resize
case WM_ENTERSIZEMOVE:
Expand Down Expand Up @@ -2335,17 +2320,17 @@ std::vector<win_window_info::win_pointer_info>::iterator win_window_info::find_m

bool winwindow_qt_filter(void *message)
{
MSG *msg = (MSG *)message;
MSG *const msg = reinterpret_cast<MSG *>(message);

if(is_mame_window(msg->hwnd) || (!msg->hwnd && (msg->message >= WM_USER)))
if (is_mame_window(msg->hwnd) || (!msg->hwnd && (msg->message >= WM_USER)))
{
LONG_PTR ptr;
if(msg->hwnd) // get the machine associated with this window
if (msg->hwnd) // get the machine associated with this window
ptr = GetWindowLongPtr(msg->hwnd, GWLP_USERDATA);
else // any one will have to do
ptr = (LONG_PTR)osd_common_t::window_list().front().get();

winwindow_dispatch_message(((win_window_info *)ptr)->machine(), msg);
winwindow_dispatch_message(reinterpret_cast<win_window_info *>(ptr)->machine(), *msg);
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion docs/release/src/osd/windows/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void winwindow_toggle_fsfx(void);
void winwindow_ui_pause(running_machine &machine, int pause);
int winwindow_ui_is_paused(running_machine &machine);

void winwindow_dispatch_message(running_machine &machine, MSG *message);
void winwindow_dispatch_message(running_machine &machine, MSG const &message);

extern int win_create_menu(running_machine &machine, HMENU *menus); // MESSUI
extern LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); // MESSUI
Expand Down
6 changes: 1 addition & 5 deletions docs/release/src/osd/windows/winmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class windows_osd_interface : public osd_common_t
void extract_video_config();

// windows OSD specific
bool handle_input_event(input_event eventid, void *eventdata) const;
bool handle_input_event(input_event eventid, const void *eventdata) const;
bool should_hide_mouse() const;

virtual bool has_focus() const override;
Expand All @@ -96,10 +96,6 @@ class windows_osd_interface : public osd_common_t

using osd_common_t::poll_input_modules; // Win32 debugger calls this directly, which it shouldn't

protected:
virtual void build_slider_list() override;
virtual void update_slider_list() override;

private:
void process_events(bool ingame, bool nodispatch);
virtual void osd_exit() override;
Expand Down
2 changes: 1 addition & 1 deletion docs/release/src/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
***************************************************************************/

#define BARE_BUILD_VERSION "0.265.0"
#define BARE_BUILD_VERSION "0.266.0"

extern const char bare_build_version[];
extern const char build_version[];
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ endif

ifeq (posix,$(SHELLTYPE))
$(GENDIR)/version.cpp: makefile $(GENDIR)/git_desc | $(GEN_FOLDERS)
@echo '#define BARE_BUILD_VERSION "0.265"' > $@
@echo '#define BARE_BUILD_VERSION "0.266.0"' > $@
@echo '#define BARE_VCS_REVISION "$(NEW_GIT_VERSION)"' >> $@
@echo 'extern const char bare_build_version[];' >> $@
@echo 'extern const char bare_vcs_revision[];' >> $@
Expand All @@ -1588,7 +1588,7 @@ $(GENDIR)/version.cpp: makefile $(GENDIR)/git_desc | $(GEN_FOLDERS)
@echo 'const char build_version[] = BARE_BUILD_VERSION " (" BARE_VCS_REVISION ")";' >> $@
else
$(GENDIR)/version.cpp: makefile $(GENDIR)/git_desc | $(GEN_FOLDERS)
@echo #define BARE_BUILD_VERSION "0.265.x" > $@
@echo #define BARE_BUILD_VERSION "0.266.0" > $@
@echo #define BARE_VCS_REVISION "$(NEW_GIT_VERSION)" >> $@
@echo extern const char bare_build_version[]; >> $@
@echo extern const char bare_vcs_revision[]; >> $@
Expand Down
2 changes: 1 addition & 1 deletion src/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
***************************************************************************/

#define BARE_BUILD_VERSION "0.265.x"
#define BARE_BUILD_VERSION "0.266.0"

extern const char bare_build_version[];
extern const char build_version[];
Expand Down

0 comments on commit ba197c2

Please sign in to comment.