diff options
| author | 2015-10-20 21:34:36 +0200 | |
|---|---|---|
| committer | 2015-10-20 21:34:36 +0200 | |
| commit | a7b8acbe3eebcf17367baa642375cfa47ae4ea85 (patch) | |
| tree | 854b859d6176802c0278f4b00de3f7c774e02dda /src/osd | |
| parent | 4610935e796661874bb4ee7ec6536d9423aeb7be (diff) | |
| parent | 74aae76c4e3e257f99d139c4febb5d86d1419e50 (diff) | |
Merge pull request #6 from mamedev/master
Sync to base master
Diffstat (limited to 'src/osd')
36 files changed, 278 insertions, 101 deletions
diff --git a/src/osd/modules/debugger/osx/debugview.m b/src/osd/modules/debugger/osx/debugview.m index 27f1fd35f22..c5b0a1c5431 100644 --- a/src/osd/modules/debugger/osx/debugview.m +++ b/src/osd/modules/debugger/osx/debugview.m @@ -260,6 +260,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; + if (view != NULL) machine->debug_view().free_view(*view); if (font != nil) [font release]; if (text != nil) [text release]; [super dealloc]; @@ -403,7 +404,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) [text addAttribute:NSFontAttributeName value:font range:run]; NSPasteboard *const board = [NSPasteboard generalPasteboard]; [board declareTypes:[NSArray arrayWithObject:NSRTFPboardType] owner:nil]; - [board setData:[text RTFFromRange:run documentAttributes:nil] forType:NSRTFPboardType]; + [board setData:[text RTFFromRange:run documentAttributes:@{}] forType:NSRTFPboardType]; [text deleteCharactersInRange:run]; } diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.m b/src/osd/modules/debugger/osx/debugwindowhandler.m index 5eb5060d462..a8e92bd6f5f 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.m +++ b/src/osd/modules/debugger/osx/debugwindowhandler.m @@ -166,7 +166,10 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD [[NSNotificationCenter defaultCenter] removeObserver:self]; if (window != nil) + { + [window orderOut:self]; [window release]; + } [super dealloc]; } diff --git a/src/osd/modules/debugger/osx/pointsviewer.m b/src/osd/modules/debugger/osx/pointsviewer.m index 14bb2f32775..c9301eb2894 100644 --- a/src/osd/modules/debugger/osx/pointsviewer.m +++ b/src/osd/modules/debugger/osx/pointsviewer.m @@ -74,7 +74,7 @@ [breakScroll setBorderType:NSNoBorder]; [breakScroll setDocumentView:breakView]; [breakView release]; - breakTab = [[NSTabViewItem alloc] initWithIdentifier:nil]; + breakTab = [[NSTabViewItem alloc] initWithIdentifier:@""]; [breakTab setView:breakScroll]; [breakScroll release]; @@ -89,7 +89,7 @@ [watchScroll setBorderType:NSNoBorder]; [watchScroll setDocumentView:watchView]; [watchView release]; - watchTab = [[NSTabViewItem alloc] initWithIdentifier:nil]; + watchTab = [[NSTabViewItem alloc] initWithIdentifier:@""]; [watchTab setView:watchScroll]; [watchScroll release]; diff --git a/src/osd/modules/debugger/win/debugviewinfo.c b/src/osd/modules/debugger/win/debugviewinfo.c index f3c12a09f2e..55b806b0056 100644 --- a/src/osd/modules/debugger/win/debugviewinfo.c +++ b/src/osd/modules/debugger/win/debugviewinfo.c @@ -15,6 +15,8 @@ #include "strconv.h" +#include "winutil.h" + // debugger view styles #define DEBUG_VIEW_STYLE WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN @@ -48,15 +50,15 @@ debugview_info::debugview_info(debugger_windows_interface &debugger, debugwin_in // create the child view m_wnd = CreateWindowEx(DEBUG_VIEW_STYLE_EX, TEXT("MAMEDebugView"), NULL, DEBUG_VIEW_STYLE, - 0, 0, 100, 100, parent, NULL, GetModuleHandle(NULL), this); + 0, 0, 100, 100, parent, NULL, GetModuleHandleUni(), this); if (m_wnd == NULL) goto cleanup; // create the scroll bars m_hscroll = CreateWindowEx(HSCROLL_STYLE_EX, TEXT("SCROLLBAR"), NULL, HSCROLL_STYLE, - 0, 0, 100, CW_USEDEFAULT, m_wnd, NULL, GetModuleHandle(NULL), this); + 0, 0, 100, CW_USEDEFAULT, m_wnd, NULL, GetModuleHandleUni(), this); m_vscroll = CreateWindowEx(VSCROLL_STYLE_EX, TEXT("SCROLLBAR"), NULL, VSCROLL_STYLE, - 0, 0, CW_USEDEFAULT, 100, m_wnd, NULL, GetModuleHandle(NULL), this); + 0, 0, CW_USEDEFAULT, 100, m_wnd, NULL, GetModuleHandleUni(), this); if ((m_hscroll == NULL) || (m_vscroll == NULL)) goto cleanup; @@ -68,9 +70,6 @@ debugview_info::debugview_info(debugger_windows_interface &debugger, debugwin_in return; cleanup: - if (m_view != NULL) - machine().debug_view().free_view(*m_view); - m_view = NULL; if (m_hscroll != NULL) DestroyWindow(m_hscroll); m_hscroll = NULL; @@ -80,15 +79,18 @@ cleanup: if (m_wnd != NULL) DestroyWindow(m_wnd); m_wnd = NULL; + if (m_view != NULL) + machine().debug_view().free_view(*m_view); + m_view = NULL; } debugview_info::~debugview_info() { - if (m_view) - machine().debug_view().free_view(*m_view); if (m_wnd != NULL) DestroyWindow(m_wnd); + if (m_view) + machine().debug_view().free_view(*m_view); } @@ -254,7 +256,7 @@ HWND debugview_info::create_source_combobox(HWND parent, LONG_PTR userdata) { // create a combo box HWND const result = CreateWindowEx(COMBO_BOX_STYLE_EX, TEXT("COMBOBOX"), NULL, COMBO_BOX_STYLE, - 0, 0, 100, 1000, parent, NULL, GetModuleHandle(NULL), NULL); + 0, 0, 100, 1000, parent, NULL, GetModuleHandleUni(), NULL); SetWindowLongPtr(result, GWLP_USERDATA, userdata); SendMessage(result, WM_SETFONT, (WPARAM)metrics().debug_font(), (LPARAM)FALSE); @@ -789,7 +791,7 @@ void debugview_info::register_window_class() // initialize the description of the window class wc.lpszClassName = TEXT("MAMEDebugView"); - wc.hInstance = GetModuleHandle(NULL); + wc.hInstance = GetModuleHandleUni(); wc.lpfnWndProc = &debugview_info::static_view_proc; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(wc.hInstance, MAKEINTRESOURCE(2)); @@ -799,6 +801,8 @@ void debugview_info::register_window_class() wc.cbClsExtra = 0; wc.cbWndExtra = 0; + UnregisterClass(wc.lpszClassName, wc.hInstance); + // register the class; fail if we can't if (!RegisterClass(&wc)) fatalerror("Unable to register debug view class\n"); diff --git a/src/osd/modules/debugger/win/debugwininfo.c b/src/osd/modules/debugger/win/debugwininfo.c index 1a3258c1cab..078a87c15c7 100644 --- a/src/osd/modules/debugger/win/debugwininfo.c +++ b/src/osd/modules/debugger/win/debugwininfo.c @@ -17,6 +17,8 @@ #include "window.h" #include "winutf8.h" +#include "winutil.h" + bool debugwin_info::s_window_class_registered = false; @@ -36,7 +38,7 @@ debugwin_info::debugwin_info(debugger_windows_interface &debugger, bool is_main_ register_window_class(); m_wnd = win_create_window_ex_utf8(DEBUG_WINDOW_STYLE_EX, "MAMEDebugWindow", title, DEBUG_WINDOW_STYLE, - 0, 0, 100, 100, win_window_list->m_hwnd, create_standard_menubar(), GetModuleHandle(NULL), this); + 0, 0, 100, 100, win_window_list->m_hwnd, create_standard_menubar(), GetModuleHandleUni(), this); if (m_wnd == NULL) return; @@ -580,7 +582,7 @@ void debugwin_info::register_window_class() // initialize the description of the window class wc.lpszClassName = TEXT("MAMEDebugWindow"); - wc.hInstance = GetModuleHandle(NULL); + wc.hInstance = GetModuleHandleUni(); wc.lpfnWndProc = &debugwin_info::static_window_proc; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(wc.hInstance, MAKEINTRESOURCE(2)); @@ -590,6 +592,8 @@ void debugwin_info::register_window_class() wc.cbClsExtra = 0; wc.cbWndExtra = 0; + UnregisterClass(wc.lpszClassName, wc.hInstance); + // register the class; fail if we can't if (!RegisterClass(&wc)) fatalerror("Unable to register debug window class\n"); diff --git a/src/osd/modules/debugger/win/editwininfo.c b/src/osd/modules/debugger/win/editwininfo.c index 1ccd96ff7aa..279bc68fbe3 100644 --- a/src/osd/modules/debugger/win/editwininfo.c +++ b/src/osd/modules/debugger/win/editwininfo.c @@ -13,6 +13,8 @@ #include "strconv.h" +#include "winutil.h" + // edit box styles #define EDIT_BOX_STYLE WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL @@ -32,7 +34,7 @@ editwin_info::editwin_info(debugger_windows_interface &debugger, bool is_main_co // create an edit box and override its key handling m_editwnd = CreateWindowEx(EDIT_BOX_STYLE_EX, TEXT("EDIT"), NULL, EDIT_BOX_STYLE, - 0, 0, 100, 100, window(), NULL, GetModuleHandle(NULL), NULL); + 0, 0, 100, 100, window(), NULL, GetModuleHandleUni(), NULL); m_original_editproc = (WNDPROC)(FPTR)GetWindowLongPtr(m_editwnd, GWLP_WNDPROC); SetWindowLongPtr(m_editwnd, GWLP_USERDATA, (LONG_PTR)this); SetWindowLongPtr(m_editwnd, GWLP_WNDPROC, (LONG_PTR)&editwin_info::static_edit_proc); diff --git a/src/osd/modules/netdev/pcap.c b/src/osd/modules/netdev/pcap.c index b69ef56074b..49b2c6bda3d 100644 --- a/src/osd/modules/netdev/pcap.c +++ b/src/osd/modules/netdev/pcap.c @@ -125,6 +125,8 @@ private: static void netdev_pcap_handler(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes) { struct netdev_pcap_context *ctx = (struct netdev_pcap_context*)user; + if(!ctx->p) return; + if(OSAtomicCompareAndSwapInt((ctx->head+1) & 0x1F, ctx->tail, &ctx->tail)) { printf("buffer full, dropping packet\n"); return; @@ -137,7 +139,7 @@ static void netdev_pcap_handler(u_char *user, const struct pcap_pkthdr *h, const static void *netdev_pcap_blocker(void *arg) { struct netdev_pcap_context *ctx = (struct netdev_pcap_context*)arg; - while(1) { + while(ctx && ctx->p) { pcap_dispatch_dl(ctx->p, 1, netdev_pcap_handler, (u_char*)ctx); } @@ -232,6 +234,11 @@ int netdev_pcap::recv_dev(UINT8 **buf) netdev_pcap::~netdev_pcap() { +#ifdef SDLMAME_MACOSX + m_ctx.p = NULL; + pthread_cancel(m_thread); + pthread_join(m_thread, NULL); +#endif if(m_p) pcap_close_dl(m_p); m_p = NULL; } diff --git a/src/osd/modules/render/d3d/d3dhlsl.c b/src/osd/modules/render/d3d/d3dhlsl.c index 3a3c80ce46c..f3dad935d3e 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.c +++ b/src/osd/modules/render/d3d/d3dhlsl.c @@ -562,7 +562,7 @@ void shaders::begin_avi_recording(const char *name) // build up information about this new movie avi_movie_info info; info.video_format = 0; - info.video_timescale = 1000 * ((machine->first_screen() != NULL) ? ATTOSECONDS_TO_HZ(machine->first_screen()->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE); + info.video_timescale = 1000 * ((machine->first_screen() != NULL) ? ATTOSECONDS_TO_HZ(machine->first_screen()->frame_period().m_attoseconds) : screen_device::DEFAULT_FRAME_RATE); info.video_sampletime = 1000; info.video_numsamples = 0; info.video_width = snap_width; diff --git a/src/osd/modules/render/drawbgfx.c b/src/osd/modules/render/drawbgfx.c index 14dc7a33db0..1920aa94684 100644 --- a/src/osd/modules/render/drawbgfx.c +++ b/src/osd/modules/render/drawbgfx.c @@ -28,8 +28,8 @@ #include "emu.h" #include "window.h" -#include <bgfxplatform.h> -#include <bgfx.h> +#include <bgfx/bgfxplatform.h> +#include <bgfx/bgfx.h> //============================================================ // DEBUGGING @@ -241,7 +241,7 @@ int renderer_bgfx::draw(int update) #endif // This dummy draw call is here to make sure that view 0 is cleared // if no other draw calls are submitted to view 0. - bgfx::submit(0); + bgfx::touch(0); window().m_primlist->acquire_lock(); diff --git a/src/osd/modules/render/drawogl.c b/src/osd/modules/render/drawogl.c index f071428972f..5a139c4054b 100644 --- a/src/osd/modules/render/drawogl.c +++ b/src/osd/modules/render/drawogl.c @@ -3117,7 +3117,8 @@ void sdl_info_ogl::texture_mpass_flip(ogl_texture_info *texture, int shaderIdx) GL_CHECK_ERROR_NORMAL(); glViewport(0.0, 0.0, (GLsizei)texture->rawwidth, (GLsizei)texture->rawheight); } - else if ( shaderIdx==m_glsl_program_mb2sc ) + + if ( shaderIdx==m_glsl_program_mb2sc ) { assert ( m_glsl_program_mb2sc < m_glsl_program_num-1 ); glPopAttrib(); // glViewport(0.0, 0.0, (GLsizei)window().width, (GLsizei)window().height) diff --git a/src/osd/osdcomm.h b/src/osd/osdcomm.h index 2df16b8db02..4ec625878ab 100644 --- a/src/osd/osdcomm.h +++ b/src/osd/osdcomm.h @@ -225,6 +225,7 @@ typedef UINT32 FPTR; #ifdef _MSC_VER #include <malloc.h> +typedef ptrdiff_t ssize_t; #if _MSC_VER == 1900 // < VS2015 #define __LINE__Var 0 #endif @@ -239,6 +240,7 @@ typedef UINT32 FPTR; static __inline double fmin(double x, double y){ return (x < y) ? x : y; } static __inline double fmax(double x, double y){ return (x > y) ? x : y; } static __inline double log2(double x) { return log(x) * M_LOG2E; } +#define __func__ __FUNCTION__ #endif // VS2013 #else // VS2015 #define _CRT_STDIO_LEGACY_WIDE_SPECIFIERS diff --git a/src/osd/osdcore.h b/src/osd/osdcore.h index c7ae389db03..982cfbf2234 100644 --- a/src/osd/osdcore.h +++ b/src/osd/osdcore.h @@ -165,6 +165,25 @@ file_error osd_read(osd_file *file, void *buffer, UINT64 offset, UINT32 length, -----------------------------------------------------------------------------*/ file_error osd_write(osd_file *file, const void *buffer, UINT64 offset, UINT32 length, UINT32 *actual); +/*----------------------------------------------------------------------------- + osd_openpty: create a new PTY pair + + Parameters: + + file - pointer to an osd_file * to receive the handle of the master + side of the newly-created PTY; this is only valid if the function + returns FILERR_NONE + + name - pointer to memory where slave filename will be stored + + name_len - space allocated for name + + Return value: + + a file_error describing any error that occurred while creating the + PTY, or FILERR_NONE if no error occurred +-----------------------------------------------------------------------------*/ +file_error osd_openpty(osd_file **file, char *name, size_t name_len); /*----------------------------------------------------------------------------- osd_truncate: change the size of an open file diff --git a/src/osd/osdmini/minifile.c b/src/osd/osdmini/minifile.c index f2f899744fc..2883b81c731 100644 --- a/src/osd/osdmini/minifile.c +++ b/src/osd/osdmini/minifile.c @@ -8,6 +8,7 @@ #include "osdcore.h" #include <stdlib.h> +#include <unistd.h> //============================================================ @@ -100,6 +101,33 @@ file_error osd_write(osd_file *file, const void *buffer, UINT64 offset, UINT32 l return FILERR_NONE; } +//============================================================ +// osd_openpty +//============================================================ + +file_error osd_openpty(osd_file **file, char *name, size_t name_len) +{ + return FILERR_FAILURE; +} + +//============================================================ +// osd_truncate +//============================================================ + +file_error osd_truncate(osd_file *file, UINT64 offset) +{ + UINT32 result; + + if (!file) + return FILERR_FAILURE; + + result = ftruncate(fileno((FILE *)file), offset); + if (result) + return FILERR_FAILURE; + + return FILERR_NONE; +} + //============================================================ // osd_rmfile diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c index 8f70ba1e0ee..1bfde78ee8b 100644 --- a/src/osd/sdl/input.c +++ b/src/osd/sdl/input.c @@ -1730,13 +1730,6 @@ void sdlinput_poll(running_machine &machine) if (!SDL_PollEvent(&event)) break; } - - if (event.type == SDL_KEYUP && - event.key.keysym.sym == SDLK_CAPSLOCK) - { - /* more caps-lock hack */ - event.type = SDL_KEYDOWN; - } switch(event.type) { case SDL_KEYDOWN: #ifdef SDL2_MULTIAPI diff --git a/src/osd/sdl/man/castool.1 b/src/osd/sdl/man/castool.1 index 81a3cbdad5e..1dd96b6eb3f 100644 --- a/src/osd/sdl/man/castool.1 +++ b/src/osd/sdl/man/castool.1 @@ -6,7 +6,7 @@ .\" Cesare Falco <c.falco@ubuntu.com>, February 2011 .\" .\" -.TH CASTOOL 1 2015-05-20 0.162 "MESS Generic cassette manipulation tool" +.TH CASTOOL 1 2015-07-22 0.164 "MESS Generic cassette manipulation tool" .\" .\" .\" NAME chapter diff --git a/src/osd/sdl/man/chdman.1 b/src/osd/sdl/man/chdman.1 index 99b45645515..f81b48abdea 100644 --- a/src/osd/sdl/man/chdman.1 +++ b/src/osd/sdl/man/chdman.1 @@ -6,7 +6,7 @@ .\" Ashley T. Howes <debiandev@ashleyhowes.com>, February 2005 .\" updated by Cesare Falco <c.falco@ubuntu.com>, February 2007 .\" -.TH CHDMAN 1 2015-05-20 0.162 "MAME Compressed Hunks of Data (CHD) manager" +.TH CHDMAN 1 2015-07-22 0.164 "MAME Compressed Hunks of Data (CHD) manager" .\" .\" NAME chapter .SH NAME diff --git a/src/osd/sdl/man/floptool.1 b/src/osd/sdl/man/floptool.1 index 6b17f52cbf6..24d8e97c46a 100644 --- a/src/osd/sdl/man/floptool.1 +++ b/src/osd/sdl/man/floptool.1 @@ -6,7 +6,7 @@ .\" Cesare Falco <c.falco@ubuntu.com>, April 2014 .\" .\" -.TH FLOPTOOL 1 2015-05-20 0.162 "MESS Generic floppy manipulation tool" +.TH FLOPTOOL 1 2015-07-22 0.164 "MESS Generic floppy manipulation tool" .\" .\" .\" NAME chapter diff --git a/src/osd/sdl/man/imgtool.1 b/src/osd/sdl/man/imgtool.1 index 4f80ecb5414..819da84de06 100644 --- a/src/osd/sdl/man/imgtool.1 +++ b/src/osd/sdl/man/imgtool.1 @@ -6,7 +6,7 @@ .\" Cesare Falco <c.falco@ubuntu.com>, February 2011 .\" .\" -.TH IMGTOOL 1 2015-05-20 0.162 "MESS media image manipulation tool" +.TH IMGTOOL 1 2015-07-22 0.164 "MESS media image manipulation tool" .\" .\" .\" NAME chapter diff --git a/src/osd/sdl/man/jedutil.1 b/src/osd/sdl/man/jedutil.1 index 23b48b280e1..e93d07a8e22 100644 --- a/src/osd/sdl/man/jedutil.1 +++ b/src/osd/sdl/man/jedutil.1 @@ -8,7 +8,7 @@ .\" References .\" http://aarongiles.com/?p=159 .\" -.TH JEDUTIL 1 2015-05-20 0.162 "MAME JEDEC file utilities" +.TH JEDUTIL 1 2015-07-22 0.164 "MAME JEDEC file utilities" .\" .\" NAME chapter .SH NAME diff --git a/src/osd/sdl/man/ldresample.1 b/src/osd/sdl/man/ldresample.1 index 79c6b7ef391..c56b8af2c06 100644 --- a/src/osd/sdl/man/ldresample.1 +++ b/src/osd/sdl/man/ldresample.1 @@ -3,7 +3,7 @@ .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .\" -.TH LDRESAMPLE 1 2015-05-20 0.162 "MAME laserdisc audio manipulation tool" +.TH LDRESAMPLE 1 2015-07-22 0.164 "MAME laserdisc audio manipulation tool" .\" .\" Please adjust this date whenever revising the manpage. .\" diff --git a/src/osd/sdl/man/ldverify.1 b/src/osd/sdl/man/ldverify.1 index 3fc2b471cee..aae404164cb 100644 --- a/src/osd/sdl/man/ldverify.1 +++ b/src/osd/sdl/man/ldverify.1 @@ -5,7 +5,7 @@ .\" Man page created from source and usage information by .\" Cesare Falco <c.falco@ubuntu.com>, August 2008 .\" -.TH LDVERIFY 1 2015-05-20 0.162 "MAME laserdisc data checker" +.TH LDVERIFY 1 2015-07-22 0.164 "MAME laserdisc data checker" .\" .\" NAME chapter .SH NAME diff --git a/src/osd/sdl/man/mame.6 b/src/osd/sdl/man/mame.6 index 736b0a2f8d4..de5b6216041 100644 --- a/src/osd/sdl/man/mame.6 +++ b/src/osd/sdl/man/mame.6 @@ -13,7 +13,7 @@ .\" and updated by Andrew Burton <burtona@gol.com>, July 2003 .\" .\" -.TH MAME 6 2015-05-20 0.162 "MAME \- The Multiple Arcade Machine Emulator" +.TH MAME 6 2015-07-22 0.164 "MAME \- The Multiple Arcade Machine Emulator" .\" .\" .\" NAME chapter diff --git a/src/osd/sdl/man/romcmp.1 b/src/osd/sdl/man/romcmp.1 index 16328e2086c..d7a89f92e80 100644 --- a/src/osd/sdl/man/romcmp.1 +++ b/src/osd/sdl/man/romcmp.1 @@ -9,7 +9,7 @@ .\" References .\" http://www.mame.net/mamefaq.html .\" -.TH ROMCMP 1 2015-05-20 0.162 "MAME romset checking tool" +.TH ROMCMP 1 2015-07-22 0.164 "MAME romset checking tool" .\" .\" NAME chapter .SH NAME diff --git a/src/osd/sdl/man/testkeys.1 b/src/osd/sdl/man/testkeys.1 index a357e81cfd0..91ddd1eb93d 100644 --- a/src/osd/sdl/man/testkeys.1 +++ b/src/osd/sdl/man/testkeys.1 @@ -5,7 +5,7 @@ .\" Man page created from source and usage information .\" Cesare Falco <c.falco@ubuntu.com>, February 2007 .\" -.TH TESTKEYS 1 2015-05-20 0.162 "MAME SDL keycode scanner" +.TH TESTKEYS 1 2015-07-22 0.164 "MAME SDL keycode scanner" .\" .\" NAME chapter .SH NAME diff --git a/src/osd/sdl/sdlfile.c b/src/osd/sdl/sdlfile.c index 74779252641..a93d5623412 100644 --- a/src/osd/sdl/sdlfile.c +++ b/src/osd/sdl/sdlfile.c @@ -359,6 +359,25 @@ file_error osd_write(osd_file *file, const void *buffer, UINT64 offset, UINT32 c } } +//============================================================ +// osd_openpty +//============================================================ + +file_error osd_openpty(osd_file **file, char *name, size_t name_len) +{ + file_error res; + UINT64 filesize; + + if ((res = osd_open(sdlfile_ptty_identifier , 0 , file , &filesize)) != FILERR_NONE) { + return res; + } + + if ((res = sdl_slave_name_ptty(*file , name , name_len)) != FILERR_NONE) { + osd_close(*file); + } + + return res; +} //============================================================ // osd_truncate diff --git a/src/osd/sdl/sdlfile.h b/src/osd/sdl/sdlfile.h index d5f72bfc2ca..4bd1b2a6292 100644 --- a/src/osd/sdl/sdlfile.h +++ b/src/osd/sdl/sdlfile.h @@ -46,5 +46,6 @@ file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UI file_error sdl_read_ptty(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual); file_error sdl_write_ptty(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual); file_error sdl_close_ptty(osd_file *file); +file_error sdl_slave_name_ptty(osd_file *file , char *name , size_t name_len); file_error error_to_file_error(UINT32 error); diff --git a/src/osd/sdl/sdlptty_os2.c b/src/osd/sdl/sdlptty_os2.c index 800b3d9a16b..e7d76965238 100644 --- a/src/osd/sdl/sdlptty_os2.c +++ b/src/osd/sdl/sdlptty_os2.c @@ -32,3 +32,8 @@ file_error sdl_close_ptty(osd_file *file) { return FILERR_ACCESS_DENIED; } + +file_error sdl_slave_name_ptty(osd_file *file) +{ + return FILERR_ACCESS_DENIED; +} diff --git a/src/osd/sdl/sdlptty_unix.c b/src/osd/sdl/sdlptty_unix.c index 804b0ddae3e..6b618314d72 100644 --- a/src/osd/sdl/sdlptty_unix.c +++ b/src/osd/sdl/sdlptty_unix.c @@ -2,7 +2,7 @@ // copyright-holders:Olivier Galibert, R. Belmont //============================================================ // -// sdlptty_unix.c - SDL psuedo tty access functions +// sdlptty_unix.c - SDL pseudo tty access functions // // SDLMAME by Olivier Galibert and R. Belmont // @@ -28,6 +28,7 @@ #elif defined(SDLMAME_HAIKU) # include <bsd/pty.h> #endif +#include <stdlib.h> #include "sdlfile.h" @@ -39,68 +40,91 @@ const char *sdlfile_ptty_identifier = "/dev/pts"; file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize) { - int master; - int aslave; - char name[100]; - - if (openpty(&master, &aslave, name, NULL, NULL) >= 0) - { - printf("Slave of device %s is %s\n", path, name ); - fcntl(master, F_SETFL, O_NONBLOCK); - (*file)->handle = master; - *filesize = 0; - } - else - { - return FILERR_ACCESS_DENIED; - } - - return FILERR_NONE; + int master; + int aslave; + struct termios tios; + int oldflags; + + memset(&tios , 0 , sizeof(tios)); + cfmakeraw(&tios); + + if (openpty(&master, &aslave, NULL, &tios, NULL) >= 0) + { + oldflags = fcntl(master, F_GETFL, 0); + if (oldflags == -1) { + close(master); + return FILERR_FAILURE; + } + + fcntl(master, F_SETFL, oldflags | O_NONBLOCK); + close(aslave); + (*file)->handle = master; + *filesize = 0; + } + else + { + return FILERR_ACCESS_DENIED; + } + + return FILERR_NONE; } file_error sdl_read_ptty(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) { - ssize_t result; + ssize_t result; - result = read(file->handle, buffer, count); + result = read(file->handle, buffer, count); - if (result < 0) - { - return error_to_file_error(errno); - } + if (result < 0) + { + return error_to_file_error(errno); + } - if (actual != NULL ) - { - *actual = result; - } + if (actual != NULL ) + { + *actual = result; + } - return FILERR_NONE; + return FILERR_NONE; } file_error sdl_write_ptty(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) { - ssize_t result; - result = write(file->handle, buffer, count); + ssize_t result; + result = write(file->handle, buffer, count); - if (result < 0) - { - return error_to_file_error(errno); - } + if (result < 0) + { + return error_to_file_error(errno); + } - if (actual != NULL ) - { - *actual = result; - } + if (actual != NULL ) + { + *actual = result; + } - return FILERR_NONE; + return FILERR_NONE; } file_error sdl_close_ptty(osd_file *file) { - close(file->handle); - osd_free(file); + close(file->handle); + osd_free(file); - return FILERR_NONE; + return FILERR_NONE; +} + +file_error sdl_slave_name_ptty(osd_file *file , char *name , size_t name_len) +{ + const char *slave_name = ptsname(file->handle); + + if (slave_name == NULL || strlen(slave_name) >= name_len) { + return FILERR_INVALID_ACCESS; + } + + strcpy(name , slave_name); + + return FILERR_NONE; } #else @@ -110,21 +134,27 @@ const char *sdlfile_ptty_identifier = ""; file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize) { - return FILERR_ACCESS_DENIED; + return FILERR_ACCESS_DENIED; } file_error sdl_read_ptty(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) { - return FILERR_ACCESS_DENIED; + return FILERR_ACCESS_DENIED; } file_error sdl_write_ptty(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) { - return FILERR_ACCESS_DENIED; + return FILERR_ACCESS_DENIED; } file_error sdl_close_ptty(osd_file *file) { - return FILERR_ACCESS_DENIED; + return FILERR_ACCESS_DENIED; } + +file_error sdl_slave_name_ptty(osd_file *file) +{ + return FILERR_ACCESS_DENIED; +} + #endif diff --git a/src/osd/windows/input.c b/src/osd/windows/input.c index ec08277bcf4..6afca302c27 100644 --- a/src/osd/windows/input.c +++ b/src/osd/windows/input.c @@ -38,6 +38,8 @@ #include "strconv.h" #include "config.h" +#include "winutil.h" + //============================================================ // PARAMETERS //============================================================ @@ -177,6 +179,7 @@ static get_rawinput_device_list_ptr get_rawinput_device_list; static get_rawinput_data_ptr get_rawinput_data; static get_rawinput_device_info_ptr get_rawinput_device_info; static register_rawinput_devices_ptr register_rawinput_devices; +static bool global_inputs_enabled; // keyboard states static bool keyboard_win32_reported_key_down; @@ -527,8 +530,6 @@ void windows_osd_interface::input_exit() void wininput_poll(running_machine &machine) { - bool hasfocus = winwindow_has_focus() && input_enabled; - // ignore if not enabled if (input_enabled) { @@ -544,8 +545,10 @@ void wininput_poll(running_machine &machine) lightgun_enabled = machine.input().device_class(DEVICE_CLASS_LIGHTGUN).enabled(); } + bool polldevices = input_enabled && (global_inputs_enabled || winwindow_has_focus()); + // poll all of the devices - if (hasfocus) + if (polldevices) { device_list_poll_devices(keyboard_list); device_list_poll_devices(mouse_list); @@ -1117,7 +1120,7 @@ static void dinput_init(running_machine &machine) int didevtype_joystick = DI8DEVCLASS_GAMECTRL; dinput_version = DIRECTINPUT_VERSION; - result = DirectInput8Create(GetModuleHandle(NULL), dinput_version, IID_IDirectInput8, (void **)&dinput, NULL); + result = DirectInput8Create(GetModuleHandleUni(), dinput_version, IID_IDirectInput8, (void **)&dinput, NULL); if (result != DI_OK) { dinput_version = 0; @@ -1130,17 +1133,17 @@ static void dinput_init(running_machine &machine) // first attempt to initialize DirectInput at the current version dinput_version = DIRECTINPUT_VERSION; - result = DirectInputCreate(GetModuleHandle(NULL), dinput_version, &dinput, NULL); + result = DirectInputCreate(GetModuleHandleUni(), dinput_version, &dinput, NULL); if (result != DI_OK) { // if that fails, try version 5 dinput_version = 0x0500; - result = DirectInputCreate(GetModuleHandle(NULL), dinput_version, &dinput, NULL); + result = DirectInputCreate(GetModuleHandleUni(), dinput_version, &dinput, NULL); if (result != DI_OK) { // if that fails, try version 3 dinput_version = 0x0300; - result = DirectInputCreate(GetModuleHandle(NULL), dinput_version, &dinput, NULL); + result = DirectInputCreate(GetModuleHandleUni(), dinput_version, &dinput, NULL); if (result != DI_OK) { dinput_version = 0; @@ -1742,13 +1745,28 @@ static void rawinput_init(running_machine &machine) rawinput_mouse_enum(machine, device); } + // don't enable global inputs when testing direct input or debugging + if (!FORCE_DIRECTINPUT && !machine.options().debug()) + { + global_inputs_enabled = downcast<windows_options &>(machine.options()).global_inputs(); + } + // finally, register to receive raw input WM_INPUT messages regcount = 0; if (keyboard_list != NULL) { reglist[regcount].usUsagePage = 0x01; reglist[regcount].usUsage = 0x06; - reglist[regcount].dwFlags = RIDEV_INPUTSINK; + + if (global_inputs_enabled) + { + reglist[regcount].dwFlags = 0x00000100; + } + else + { + reglist[regcount].dwFlags = 0; + } + reglist[regcount].hwndTarget = win_window_list->m_hwnd; regcount++; } @@ -1756,7 +1774,16 @@ static void rawinput_init(running_machine &machine) { reglist[regcount].usUsagePage = 0x01; reglist[regcount].usUsage = 0x02; - reglist[regcount].dwFlags = 0; + + if (global_inputs_enabled) + { + reglist[regcount].dwFlags = 0x00000100; + } + else + { + reglist[regcount].dwFlags = 0; + } + reglist[regcount].hwndTarget = win_window_list->m_hwnd; regcount++; } diff --git a/src/osd/windows/output.c b/src/osd/windows/output.c index 142488c3c15..f21818efab8 100644 --- a/src/osd/windows/output.c +++ b/src/osd/windows/output.c @@ -17,6 +17,8 @@ // MAMEOS headers #include "output.h" +#include "winutil.h" + //============================================================ @@ -101,7 +103,7 @@ bool windows_osd_interface::output_init() 1, 1, NULL, NULL, - GetModuleHandle(NULL), + GetModuleHandleUni(), NULL); assert(output_hwnd != NULL); @@ -167,9 +169,11 @@ static int create_window_class(void) // initialize the description of the window class wc.lpszClassName = OUTPUT_WINDOW_CLASS; - wc.hInstance = GetModuleHandle(NULL); + wc.hInstance = GetModuleHandleUni(); wc.lpfnWndProc = output_window_proc; + UnregisterClass(wc.lpszClassName, wc.hInstance); + // register the class; fail if we can't if (!RegisterClass(&wc)) return 1; diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c index 1bb225f3e0b..3c25e8e9ca5 100644 --- a/src/osd/windows/window.c +++ b/src/osd/windows/window.c @@ -35,6 +35,8 @@ #include "config.h" #include "winutf8.h" +#include "winutil.h" + 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); @@ -885,11 +887,13 @@ static void create_window_class(void) // initialize the description of the window class wc.lpszClassName = TEXT("MAME"); - wc.hInstance = GetModuleHandle(NULL); + wc.hInstance = GetModuleHandleUni(); wc.lpfnWndProc = winwindow_video_window_proc_ui; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(wc.hInstance, MAKEINTRESOURCE(2)); + UnregisterClass(wc.lpszClassName, wc.hInstance); + // register the class; fail if we can't if (!RegisterClass(&wc)) fatalerror("Failed to create window class\n"); @@ -1191,7 +1195,7 @@ int win_window_info::complete_create() monitorbounds.left() + 100, monitorbounds.top() + 100, NULL,//(win_window_list != NULL) ? win_window_list->m_hwnd : NULL, menu, - GetModuleHandle(NULL), + GetModuleHandleUni(), NULL); if (m_hwnd == NULL) return 1; diff --git a/src/osd/windows/winfile.c b/src/osd/windows/winfile.c index 3663a4a7c3e..2ac5cddaee3 100644 --- a/src/osd/windows/winfile.c +++ b/src/osd/windows/winfile.c @@ -235,6 +235,14 @@ file_error osd_write(osd_file *file, const void *buffer, UINT64 offset, UINT32 l return FILERR_NONE; } +//============================================================ +// osd_openpty +//============================================================ + +file_error osd_openpty(osd_file **file, char *name, size_t name_len) +{ + return FILERR_FAILURE; +} //============================================================ // osd_truncate diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index 1a7fe7fc6a3..a67617f6eaf 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -374,6 +374,7 @@ const options_entry windows_options::s_option_entries[] = // input options { NULL, NULL, OPTION_HEADER, "INPUT DEVICE OPTIONS" }, + { WINOPTION_GLOBAL_INPUTS ";global_inputs", "0", OPTION_BOOLEAN, "enable global inputs" }, { WINOPTION_DUAL_LIGHTGUN ";dual", "0", OPTION_BOOLEAN, "enable dual lightgun input" }, { NULL } @@ -1322,7 +1323,7 @@ FPTR symbol_manager::get_text_section_base() dynamic_bind<PIMAGE_NT_HEADERS (WINAPI *)(PVOID)> image_nt_header(TEXT("dbghelp.dll"), "ImageNtHeader"); // start with the image base - PVOID base = reinterpret_cast<PVOID>(GetModuleHandle(NULL)); + PVOID base = reinterpret_cast<PVOID>(GetModuleHandleUni()); assert(base != NULL); // make sure we have the functions we need diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 71f0056915b..ffbaadeba82 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -106,6 +106,7 @@ #define WINOPTION_FULLSCREENGAMMA "full_screen_gamma" // input options +#define WINOPTION_GLOBAL_INPUTS "global_inputs" #define WINOPTION_DUAL_LIGHTGUN "dual_lightgun" @@ -208,6 +209,7 @@ public: float full_screen_gamma() const { return float_value(WINOPTION_FULLSCREENGAMMA); } // input options + bool global_inputs() const { return bool_value(WINOPTION_GLOBAL_INPUTS); } bool dual_lightgun() const { return bool_value(WINOPTION_DUAL_LIGHTGUN); } private: diff --git a/src/osd/windows/winutil.c b/src/osd/windows/winutil.c index adc78c36c75..c34e358492b 100644 --- a/src/osd/windows/winutil.c +++ b/src/osd/windows/winutil.c @@ -92,7 +92,7 @@ BOOL win_is_gui_application(void) is_first_time = FALSE; // get the current module - module = GetModuleHandle(NULL); + module = GetModuleHandleUni(); if (!module) return FALSE; image_ptr = (BYTE*) module; @@ -122,3 +122,14 @@ BOOL win_is_gui_application(void) } return is_gui_frontend; } + +//------------------------------------------------- +// Universal way to get module handle +//------------------------------------------------- + +HMODULE WINAPI GetModuleHandleUni() +{ + MEMORY_BASIC_INFORMATION mbi; + VirtualQuery((LPCVOID)GetModuleHandleUni, &mbi, sizeof(mbi)); + return (HMODULE)mbi.AllocationBase; +} diff --git a/src/osd/windows/winutil.h b/src/osd/windows/winutil.h index 7a469a2807f..c8d1190b6a8 100644 --- a/src/osd/windows/winutil.h +++ b/src/osd/windows/winutil.h @@ -15,5 +15,6 @@ file_error win_error_to_file_error(DWORD error); osd_dir_entry_type win_attributes_to_entry_type(DWORD attributes); BOOL win_is_gui_application(void); +HMODULE WINAPI GetModuleHandleUni(); #endif // __WINUTIL__ |
