diff options
Diffstat (limited to 'src/osd/windows')
-rw-r--r-- | src/osd/windows/input.cpp | 39 | ||||
-rw-r--r-- | src/osd/windows/output.cpp | 4 | ||||
-rw-r--r-- | src/osd/windows/video.cpp | 7 | ||||
-rw-r--r-- | src/osd/windows/video.h | 6 | ||||
-rw-r--r-- | src/osd/windows/window.cpp | 62 | ||||
-rw-r--r-- | src/osd/windows/window.h | 3 | ||||
-rw-r--r-- | src/osd/windows/winmain.cpp | 1 | ||||
-rw-r--r-- | src/osd/windows/winmain.h | 2 |
8 files changed, 49 insertions, 75 deletions
diff --git a/src/osd/windows/input.cpp b/src/osd/windows/input.cpp index 0165e4820f0..6a9d534a2f6 100644 --- a/src/osd/windows/input.cpp +++ b/src/osd/windows/input.cpp @@ -39,6 +39,7 @@ #include "config.h" #include "winutil.h" +#include <mutex> //============================================================ // PARAMETERS @@ -166,7 +167,7 @@ typedef /*WINUSERAPI*/ BOOL (WINAPI *register_rawinput_devices_ptr)(IN PCRAWINPU // global states static bool input_enabled; -static osd_lock * input_lock; +static std::mutex input_lock; static bool input_paused; static DWORD last_poll; @@ -469,10 +470,6 @@ static inline INT32 normalize_absolute_axis(INT32 raw, INT32 rawmin, INT32 rawma bool windows_osd_interface::input_init() { - // allocate a lock for input synchronizations, since messages sometimes come from another thread - input_lock = osd_lock_alloc(); - assert_always(input_lock != NULL, "Failed to allocate input_lock"); - // decode the options lightgun_shared_axis_mode = downcast<windows_options &>(machine().options()).dual_lightgun(); @@ -512,15 +509,8 @@ void windows_osd_interface::input_resume() void windows_osd_interface::input_exit() { // acquire the lock and turn off input (this ensures everyone is done) - if (input_lock != NULL) - { - osd_lock_acquire(input_lock); - input_enabled = false; - osd_lock_release(input_lock); - - // free the lock - osd_lock_free(input_lock); - } + std::lock_guard<std::mutex> lock(input_lock); + input_enabled = false; } @@ -613,7 +603,7 @@ BOOL wininput_handle_mouse_button(int button, int down, int x, int y) } // take the lock - osd_lock_acquire(input_lock); + std::lock_guard<std::mutex> lock(input_lock); // set the button state devinfo->mouse.state.rgbButtons[button] = down ? 0x80 : 0x00; @@ -632,9 +622,6 @@ BOOL wininput_handle_mouse_button(int button, int down, int x, int y) devinfo->mouse.state.lX = normalize_absolute_axis(mousepos.x, client_rect.left, client_rect.right); devinfo->mouse.state.lY = normalize_absolute_axis(mousepos.y, client_rect.top, client_rect.bottom); } - - // release the lock - osd_lock_release(input_lock); return TRUE; } @@ -661,7 +648,7 @@ BOOL wininput_handle_raw(HANDLE device) // if necessary, allocate a temporary buffer and fetch the data if (size > sizeof(small_buffer)) { - data = global_alloc_array(BYTE, size); + data = global_alloc_array_nothrow(BYTE, size); if (data == NULL) return result; } @@ -675,18 +662,16 @@ BOOL wininput_handle_raw(HANDLE device) // handle keyboard input if (input->header.dwType == RIM_TYPEKEYBOARD) { - osd_lock_acquire(input_lock); + std::lock_guard<std::mutex> lock(input_lock); rawinput_keyboard_update(input->header.hDevice, &input->data.keyboard); - osd_lock_release(input_lock); result = TRUE; } // handle mouse input else if (input->header.dwType == RIM_TYPEMOUSE) { - osd_lock_acquire(input_lock); + std::lock_guard<std::mutex> lock(input_lock); rawinput_mouse_update(input->header.hDevice, &input->data.mouse); - osd_lock_release(input_lock); result = TRUE; } } @@ -804,6 +789,11 @@ void windows_osd_interface::customize_input_type_list(simple_list<input_type_ent entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_F12, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_LALT); break; + // add a NOT-lalt to write timecode file + case IPT_UI_TIMECODE: // emu/input.c: input_seq(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT) + entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_LALT); + break; + // lctrl-lalt-F5 to toggle post-processing case IPT_OSD_4: entry->configure_osd("POST_PROCESS", "Toggle Post-Processing"); @@ -2201,14 +2191,13 @@ static void rawinput_mouse_poll(device_info *devinfo) poll_if_necessary(devinfo->machine()); // copy the accumulated raw state to the actual state - osd_lock_acquire(input_lock); + std::lock_guard<std::mutex> lock(input_lock); devinfo->mouse.state.lX = devinfo->mouse.raw_x; devinfo->mouse.state.lY = devinfo->mouse.raw_y; devinfo->mouse.state.lZ = devinfo->mouse.raw_z; devinfo->mouse.raw_x = 0; devinfo->mouse.raw_y = 0; devinfo->mouse.raw_z = 0; - osd_lock_release(input_lock); } diff --git a/src/osd/windows/output.cpp b/src/osd/windows/output.cpp index 3b390b1f3a1..ef3c563e3ac 100644 --- a/src/osd/windows/output.cpp +++ b/src/osd/windows/output.cpp @@ -313,8 +313,8 @@ static void notifier_callback(const char *outname, INT32 value, void *param) // loop over clients and notify them for (client = clientlist; client != nullptr; client = client->next) { - printf("there are clients\n"); - if (param == nullptr || param == client) + if (param == nullptr || param == client->machine) { PostMessage(client->hwnd, om_mame_update_state, client->machine->output().name_to_id(outname), value); + } } } diff --git a/src/osd/windows/video.cpp b/src/osd/windows/video.cpp index b4f665a2135..b441121f1ca 100644 --- a/src/osd/windows/video.cpp +++ b/src/osd/windows/video.cpp @@ -373,14 +373,10 @@ void windows_osd_interface::extract_video_config() video_config.mode = VIDEO_MODE_D3D; else if (strcmp(stemp, "auto") == 0) video_config.mode = VIDEO_MODE_D3D; - else if (strcmp(stemp, "ddraw") == 0) - video_config.mode = VIDEO_MODE_DDRAW; else if (strcmp(stemp, "gdi") == 0) video_config.mode = VIDEO_MODE_GDI; -#if defined (USE_BGFX) else if (strcmp(stemp, "bgfx") == 0) video_config.mode = VIDEO_MODE_BGFX; -#endif else if (strcmp(stemp, "none") == 0) { video_config.mode = VIDEO_MODE_NONE; @@ -401,9 +397,6 @@ void windows_osd_interface::extract_video_config() video_config.triplebuf = options().triple_buffer(); video_config.switchres = options().switch_res(); - // ddraw options: extract the data - video_config.hwstretch = options().hwstretch(); - if (video_config.prescale < 1 || video_config.prescale > 3) { osd_printf_warning("Invalid prescale option, reverting to '1'\n"); diff --git a/src/osd/windows/video.h b/src/osd/windows/video.h index 9215dc189bf..87612fb51fe 100644 --- a/src/osd/windows/video.h +++ b/src/osd/windows/video.h @@ -21,10 +21,7 @@ enum { VIDEO_MODE_NONE, VIDEO_MODE_GDI, - VIDEO_MODE_DDRAW, -#if defined (USE_BGFX) VIDEO_MODE_BGFX, -#endif #if (USE_OPENGL) VIDEO_MODE_OPENGL, #endif @@ -180,9 +177,6 @@ struct osd_video_config int fullstretch; // FXIME: implement in windows! - // ddraw options - int hwstretch; // stretch using the hardware - // d3d, accel, opengl int filter; // enable filtering //int filter; // enable filtering, disabled if glsl_filter>0 diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index 6111859a255..0fbfae9c481 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -36,11 +36,8 @@ extern int drawnone_init(running_machine &machine, osd_draw_callbacks *callbacks); extern int drawgdi_init(running_machine &machine, osd_draw_callbacks *callbacks); -extern int drawdd_init(running_machine &machine, osd_draw_callbacks *callbacks); extern int drawd3d_init(running_machine &machine, osd_draw_callbacks *callbacks); -#if defined(USE_BGFX) extern int drawbgfx_init(running_machine &machine, osd_draw_callbacks *callbacks); -#endif #if (USE_OPENGL) extern int drawogl_init(running_machine &machine, osd_draw_callbacks *callbacks); #endif @@ -133,11 +130,11 @@ struct mtlog }; static mtlog mtlog[100000]; -static volatile LONG mtlogindex; +static volatile INT32 mtlogindex; void mtlog_add(const char *event) { - int index = atomic_increment32((LONG *) &mtlogindex) - 1; + int index = atomic_increment32((INT32 *) &mtlogindex) - 1; if (index < ARRAY_LENGTH(mtlog)) { mtlog[index].timestamp = osd_ticks(); @@ -221,17 +218,10 @@ bool windows_osd_interface::window_init() if (drawd3d_init(machine(), &draw)) video_config.mode = VIDEO_MODE_GDI; } - if (video_config.mode == VIDEO_MODE_DDRAW) - { - if (drawdd_init(machine(), &draw)) - video_config.mode = VIDEO_MODE_GDI; - } if (video_config.mode == VIDEO_MODE_GDI) drawgdi_init(machine(), &draw); -#if defined(USE_BGFX) if (video_config.mode == VIDEO_MODE_BGFX) drawbgfx_init(machine(), &draw); -#endif if (video_config.mode == VIDEO_MODE_NONE) drawnone_init(machine(), &draw); #if (USE_OPENGL) @@ -262,7 +252,6 @@ void windows_osd_interface::window_exit() win_window_list = temp->m_next; temp->destroy(); global_free(temp); - } // kill the drawers @@ -300,7 +289,6 @@ win_window_info::win_window_info(running_machine &machine) m_fullscreen(0), m_fullscreen_safe(0), m_aspect(0), - m_render_lock(NULL), m_target(NULL), m_targetview(0), m_targetorient(0), @@ -661,7 +649,20 @@ void win_window_info::create(running_machine &machine, int index, osd_monitor_in window->m_win_config = *config; window->m_monitor = monitor; window->m_fullscreen = !video_config.windowed; + window->m_index = index; + // set main window + if (index > 0) + { + for (auto w = win_window_list; w != NULL; w = w->m_next) + { + if (w->m_index == 0) + { + window->m_main = w; + break; + } + } + } // see if we are safe for fullscreen window->m_fullscreen_safe = TRUE; for (win = win_window_list; win != NULL; win = win->m_next) @@ -672,9 +673,6 @@ void win_window_info::create(running_machine &machine, int index, osd_monitor_in *last_window_ptr = window; last_window_ptr = &window->m_next; - // create a lock that we can use to skip blitting - window->m_render_lock = osd_lock_alloc(); - // load the layout window->m_target = machine.render().target_alloc(); @@ -746,11 +744,6 @@ void win_window_info::destroy() // free the render target machine().render().target_free(m_target); - - // FIXME: move to destructor - // free the lock - osd_lock_free(m_render_lock); - } @@ -792,15 +785,15 @@ void win_window_info::update() // if we're visible and running and not in the middle of a resize, draw if (m_hwnd != NULL && m_target != NULL && m_renderer != NULL) { - int got_lock = TRUE; + bool got_lock = true; mtlog_add("winwindow_video_window_update: try lock"); // only block if we're throttled if (machine().video().throttled() || timeGetTime() - last_update_time > 250) - osd_lock_acquire(m_render_lock); + m_render_lock.lock(); else - got_lock = osd_lock_try(m_render_lock); + got_lock = m_render_lock.try_lock(); // only render if we were able to get the lock if (got_lock) @@ -810,7 +803,7 @@ void win_window_info::update() mtlog_add("winwindow_video_window_update: got lock"); // don't hold the lock; we just used it to see if rendering was still happening - osd_lock_release(m_render_lock); + m_render_lock.unlock(); // ensure the target bounds are up-to-date, and then get the primitives primlist = m_renderer->get_primitives(); @@ -1329,6 +1322,14 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR window->machine().ui_input().push_char_event(window->m_target, (unicode_char) wparam); break; + case WM_MOUSEWHEEL: + { + UINT ucNumLines = 3; // default + SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &ucNumLines, 0); + window->machine().ui_input().push_mouse_wheel_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), GET_WHEEL_DELTA_WPARAM(wparam), ucNumLines); + break; + } + // pause the system when we start a menu or resize case WM_ENTERSIZEMOVE: window->m_resize_state = RESIZE_STATE_RESIZING; @@ -1411,9 +1412,9 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR case WM_DESTROY: if (!(window->m_renderer == NULL)) { - window->m_renderer->destroy(); - global_free(window->m_renderer); - window->m_renderer = NULL; + window->m_renderer->destroy(); + global_free(window->m_renderer); + window->m_renderer = NULL; } window->m_hwnd = NULL; return DefWindowProc(wnd, message, wparam, lparam); @@ -1492,7 +1493,7 @@ void win_window_info::draw_video_contents(HDC dc, int update) mtlog_add("draw_video_contents: begin"); mtlog_add("draw_video_contents: render lock acquire"); - osd_lock_acquire(m_render_lock); + std::lock_guard<std::mutex> lock(m_render_lock); mtlog_add("draw_video_contents: render lock acquired"); // if we're iconic, don't bother @@ -1516,7 +1517,6 @@ void win_window_info::draw_video_contents(HDC dc, int update) } } - osd_lock_release(m_render_lock); mtlog_add("draw_video_contents: render lock released"); mtlog_add("draw_video_contents: end"); diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h index 62d4f57db55..6a925494f93 100644 --- a/src/osd/windows/window.h +++ b/src/osd/windows/window.h @@ -9,6 +9,7 @@ #ifndef __WIN_WINDOW__ #define __WIN_WINDOW__ +#include <mutex> #include "video.h" #include "render.h" @@ -92,7 +93,7 @@ public: float m_aspect; // rendering info - osd_lock * m_render_lock; + std::mutex m_render_lock; render_target * m_target; int m_targetview; int m_targetorient; diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp index 08c988e2311..a7fda58c835 100644 --- a/src/osd/windows/winmain.cpp +++ b/src/osd/windows/winmain.cpp @@ -524,7 +524,6 @@ windows_osd_interface::~windows_osd_interface() void windows_osd_interface::video_register() { video_options_add("gdi", NULL); - video_options_add("ddraw", NULL); video_options_add("d3d", NULL); video_options_add("bgfx", NULL); //video_options_add("auto", NULL); // making d3d video default one diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 63dd907d3b3..a17f3a77f1f 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -110,8 +110,6 @@ #define WINOPTION_GLOBAL_INPUTS "global_inputs" #define WINOPTION_DUAL_LIGHTGUN "dual_lightgun" - - //============================================================ // TYPE DEFINITIONS //============================================================ |