src/osd/sdl/output.c
| r0 | r3074 | |
| 1 | //============================================================ |
| 2 | // |
| 3 | // output.c - Generic implementation of MAME output routines |
| 4 | // |
| 5 | // Copyright Nicola Salmoria and the MAME Team. |
| 6 | // Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | // |
| 8 | //============================================================ |
| 9 | |
| 10 | #if !defined(SDLMAME_WIN32) |
| 11 | |
| 12 | #include <stdio.h> |
| 13 | #include <fcntl.h> |
| 14 | #include <unistd.h> |
| 15 | |
| 16 | // MAME headers |
| 17 | #include "osdepend.h" |
| 18 | #include "driver.h" |
| 19 | #include "deprecat.h" |
| 20 | |
| 21 | // MAMEOS headers |
| 22 | #include "output.h" |
| 23 | |
| 24 | |
| 25 | |
| 26 | //============================================================ |
| 27 | // CONSTANTS |
| 28 | //============================================================ |
| 29 | |
| 30 | #define SDLMAME_OUTPUT "/tmp/sdlmame_out" |
| 31 | |
| 32 | //============================================================ |
| 33 | // TYPEDEFS |
| 34 | //============================================================ |
| 35 | |
| 36 | //============================================================ |
| 37 | // PRIVATE VARIABLES |
| 38 | //============================================================ |
| 39 | |
| 40 | static FILE *output; |
| 41 | |
| 42 | //============================================================ |
| 43 | // FUNCTION PROTOTYPES |
| 44 | //============================================================ |
| 45 | |
| 46 | static void sdloutput_exit(running_machine *machine); |
| 47 | static void notifier_callback(const char *outname, INT32 value, void *param); |
| 48 | |
| 49 | //============================================================ |
| 50 | // sdloutput_init |
| 51 | //============================================================ |
| 52 | |
| 53 | void sdloutput_init(running_machine *machine) |
| 54 | { |
| 55 | int fildes; |
| 56 | |
| 57 | add_exit_callback(machine, sdloutput_exit); |
| 58 | |
| 59 | fildes = open(SDLMAME_OUTPUT, O_RDWR | O_NONBLOCK); |
| 60 | |
| 61 | if (fildes < 0) |
| 62 | { |
| 63 | output = NULL; |
| 64 | mame_printf_verbose("ouput: unable to open output notifier file %s\n", SDLMAME_OUTPUT); |
| 65 | } |
| 66 | else |
| 67 | { |
| 68 | output = fdopen(fildes, "w"); |
| 69 | |
| 70 | mame_printf_verbose("ouput: opened output notifier file %s\n", SDLMAME_OUTPUT); |
| 71 | fprintf(output, "MAME %d START %s\n", getpid(), machine->gamedrv->name); |
| 72 | fflush(output); |
| 73 | } |
| 74 | |
| 75 | output_set_notifier(NULL, notifier_callback, NULL); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | //============================================================ |
| 80 | // winoutput_exit |
| 81 | //============================================================ |
| 82 | |
| 83 | static void sdloutput_exit(running_machine *machine) |
| 84 | { |
| 85 | if (output != NULL) |
| 86 | { |
| 87 | fprintf(output, "MAME %d STOP %s\n", getpid(), machine->gamedrv->name); |
| 88 | fflush(output); |
| 89 | fclose(output); |
| 90 | output = NULL; |
| 91 | mame_printf_verbose("ouput: closed output notifier file\n"); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | //============================================================ |
| 96 | // notifier_callback |
| 97 | //============================================================ |
| 98 | |
| 99 | static void notifier_callback(const char *outname, INT32 value, void *param) |
| 100 | { |
| 101 | if (output != NULL) |
| 102 | { |
| 103 | fprintf(output, "OUT %d %s %d\n", getpid(), outname, value); |
| 104 | fflush(output); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | #else /* SDLMAME_WIN32 */ |
| 109 | |
| 110 | #include "driver.h" |
| 111 | |
| 112 | //============================================================ |
| 113 | // Stub for win32 |
| 114 | //============================================================ |
| 115 | |
| 116 | void sdloutput_init(running_machine *machine) |
| 117 | { |
| 118 | } |
| 119 | |
| 120 | #endif /* SDLMAME_WIN32 */ |
src/osd/sdl/sdl.mak
| r3073 | r3074 | |
| 44 | 44 | # There is no need to play with this option unless you are doing |
| 45 | 45 | # active development on sdlmame or SDL. |
| 46 | 46 | |
| 47 | | SDL_INSTALL_ROOT = /usr/local/sdl13 |
| 47 | # SDL_INSTALL_ROOT = /usr/local/sdl13 |
| 48 | 48 | |
| 49 | 49 | ########################################################################### |
| 50 | 50 | ################## END USER-CONFIGURABLE OPTIONS ###################### |
| r3073 | r3074 | |
| 166 | 166 | OSDOBJS = $(SDLOBJ)/sdlmain.o \ |
| 167 | 167 | $(SDLOBJ)/input.o \ |
| 168 | 168 | $(SDLOBJ)/sound.o $(SDLOBJ)/video.o \ |
| 169 | | $(SDLOBJ)/drawsdl.o $(SDLOBJ)/window.o $(SDLOBJ)/keybled.o |
| 169 | $(SDLOBJ)/drawsdl.o $(SDLOBJ)/window.o $(SDLOBJ)/output.o |
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | ifndef NO_OPENGL |
| r3073 | r3074 | |
| 216 | 216 | LIBS += -lm `sdl-config --libs` $(LIBGL) |
| 217 | 217 | else |
| 218 | 218 | CFLAGS += -I$(SDL_INSTALL_ROOT)/include |
| 219 | #LIBS += -L/opt/intel/cce/9.1.051/lib -limf -L$(SDL_INSTALL_ROOT)/lib -Wl,-rpath,$(SDL_INSTALL_ROOT)/lib -lSDL $(LIBGL) |
| 219 | 220 | LIBS += -lm -L$(SDL_INSTALL_ROOT)/lib -Wl,-rpath,$(SDL_INSTALL_ROOT)/lib -lSDL $(LIBGL) |
| 220 | 221 | endif |
| 221 | 222 | |
| r3073 | r3074 | |
| 289 | 290 | |
| 290 | 291 | # OS2: add the necessary libraries |
| 291 | 292 | ifeq ($(TARGETOS),os2) |
| 293 | OSDCOREOBJS += $(SDLOBJ)/debugwin.o |
| 294 | |
| 292 | 295 | CFLAGS += `sdl-config --cflags` |
| 293 | 296 | LIBS += `sdl-config --libs` |
| 294 | 297 | endif # OS2 |
src/osd/sdl/ledutil.sh
| r0 | r3074 | |
| 1 | #!/bin/sh |
| 2 | |
| 3 | # ============================================================ |
| 4 | # |
| 5 | # ledutil.sh - Example script for output notifiers |
| 6 | # |
| 7 | # Copyright Nicola Salmoria and the MAME Team. |
| 8 | # Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | # |
| 10 | # This is a very basic implementation which |
| 11 | # |
| 12 | # a) Sets kbd leds if led0, led1, led2 is received |
| 13 | # b) Beeps if led0 is set to on (state=1) |
| 14 | # c) Writes a message when pause is received |
| 15 | # |
| 16 | # use "sh ledutil.sh -h" to get more information |
| 17 | # |
| 18 | # ============================================================ |
| 19 | |
| 20 | SDLMAME_OUTPUT=/tmp/sdlmame_out |
| 21 | |
| 22 | verbose=0 |
| 23 | autoclose=0 |
| 24 | myname=`basename $0` |
| 25 | paused=0 |
| 26 | |
| 27 | while [ $# -gt 0 ]; do |
| 28 | case $1 in |
| 29 | -v) |
| 30 | verbose=1 |
| 31 | ;; |
| 32 | -a) |
| 33 | autoclose=1 |
| 34 | ;; |
| 35 | -h) |
| 36 | echo "Usage: $myname [-a] [-v]" |
| 37 | echo "" |
| 38 | echo " -a Automatically close when sdlmame ends game" |
| 39 | echo " -v LOG all messages received" |
| 40 | echo " -h Get help" |
| 41 | echo "" |
| 42 | exit |
| 43 | ;; |
| 44 | *) |
| 45 | echo "$myname: invalid option $1" |
| 46 | echo "Try \`$myname -h' for more information." |
| 47 | exit |
| 48 | ;; |
| 49 | esac |
| 50 | shift |
| 51 | done |
| 52 | |
| 53 | if [ ! -e ${SDLMAME_OUTPUT} ]; then |
| 54 | mkfifo ${SDLMAME_OUTPUT} |
| 55 | fi |
| 56 | |
| 57 | while true; do |
| 58 | cat ${SDLMAME_OUTPUT} | while read class pidnum what state; do |
| 59 | [ $verbose = 1 ] && echo LOG: $class $pidnum $what $state |
| 60 | if [ "$class" = "MAME" ]; then |
| 61 | case "$what" in |
| 62 | START) |
| 63 | echo Process $pidnum starting game $state |
| 64 | paused=0 |
| 65 | ;; |
| 66 | STOP) |
| 67 | echo Process $pidnum stopping game $state |
| 68 | ;; |
| 69 | esac |
| 70 | fi |
| 71 | if [ "$class" = "OUT" ]; then |
| 72 | case "$what" in |
| 73 | led0) |
| 74 | [ "$state" = 1 ] && beep |
| 75 | [ "$state" = 1 ] && xset led 1 |
| 76 | [ "$state" = 0 ] && xset -led 1 |
| 77 | ;; |
| 78 | led1) |
| 79 | [ "$state" = 1 ] && xset led 2 |
| 80 | [ "$state" = 0 ] && xset -led 2 |
| 81 | ;; |
| 82 | led2) |
| 83 | [ "$state" = 1 ] && xset led 3 |
| 84 | [ "$state" = 0 ] && xset -led 3 |
| 85 | ;; |
| 86 | pause) |
| 87 | paused=$state |
| 88 | echo Pause $paused! |
| 89 | ;; |
| 90 | esac |
| 91 | fi |
| 92 | done |
| 93 | [ $autoclose = 1 ] && break; |
| 94 | done |
| 95 | |
| 96 | rm -f ${SDLMAME_OUTPUT} |
| 97 | |
src/osd/sdl/input.c
| r3073 | r3074 | |
| 139 | 139 | static device_info * keyboard_list; |
| 140 | 140 | |
| 141 | 141 | // mouse states |
| 142 | static UINT8 app_has_mouse_focus; |
| 142 | 143 | static UINT8 mouse_enabled; |
| 143 | 144 | static device_info * mouse_list; |
| 144 | 145 | |
| r3073 | r3074 | |
| 895 | 896 | joystick_list = NULL; |
| 896 | 897 | mouse_list = NULL; |
| 897 | 898 | lightgun_list = NULL; |
| 899 | |
| 900 | app_has_mouse_focus = 1; |
| 898 | 901 | |
| 899 | 902 | // get Sixaxis special mode info |
| 900 | 903 | sixaxis_mode = options_get_bool(mame_options(), SDLOPTION_SIXAXIS); |
| r3073 | r3074 | |
| 943 | 946 | // SDL 1.2 has only 1 mouse - 1.3+ will also change that, so revisit this then |
| 944 | 947 | devinfo = generic_device_alloc(&mouse_list, "System mouse"); |
| 945 | 948 | devinfo->device = input_device_add(DEVICE_CLASS_MOUSE, devinfo->name, devinfo); |
| 949 | |
| 946 | 950 | mouse_enabled = options_get_bool(mame_options(), OPTION_MOUSE); |
| 951 | |
| 952 | #ifdef MAME_DEBUG |
| 953 | if (mouse_enabled) |
| 954 | { |
| 955 | mame_printf_warning("Debug Build: Disabling input grab in window mode ...\n"); |
| 956 | mouse_enabled = 0; |
| 957 | } |
| 958 | #endif |
| 947 | 959 | |
| 948 | 960 | // add the axes |
| 949 | 961 | input_device_item_add(devinfo->device, "X", &devinfo->mouse.lX, ITEM_ID_XAXIS, generic_axis_get_state); |
| r3073 | r3074 | |
| 1218 | 1230 | } |
| 1219 | 1231 | break; |
| 1220 | 1232 | #if (!SDL_VERSION_ATLEAST(1,3,0)) |
| 1233 | case SDL_APPMOUSEFOCUS: |
| 1234 | app_has_mouse_focus = event.active.gain; |
| 1235 | if (!event.active.gain) |
| 1236 | { |
| 1237 | sdl_window_info *window = GET_WINDOW(&event.motion); |
| 1238 | ui_input_push_mouse_leave_event(machine, window->target); |
| 1239 | } |
| 1240 | break; |
| 1221 | 1241 | case SDL_QUIT: |
| 1222 | 1242 | mame_schedule_exit(machine); |
| 1223 | 1243 | break; |
| r3073 | r3074 | |
| 1252 | 1272 | case SDL_WINDOWEVENT_LEAVE: |
| 1253 | 1273 | { |
| 1254 | 1274 | ui_input_push_mouse_leave_event(machine, window->target); |
| 1275 | app_has_mouse_focus = 0; |
| 1255 | 1276 | break; |
| 1256 | 1277 | |
| 1257 | 1278 | } |
| 1258 | 1279 | case SDL_WINDOWEVENT_RESIZED: |
| 1259 | 1280 | if (event.window.data1 != window->width || event.window.data2 != window->height) |
| 1260 | 1281 | sdlwindow_resize(window, event.window.data1, event.window.data2); |
| 1261 | | /* fall through break; */ |
| 1282 | focus_window = window; |
| 1283 | break; |
| 1284 | case SDL_WINDOWEVENT_ENTER: |
| 1285 | app_has_mouse_focus = 1; |
| 1286 | /* fall through */ |
| 1262 | 1287 | case SDL_WINDOWEVENT_FOCUS_GAINED: |
| 1263 | | case SDL_WINDOWEVENT_ENTER: |
| 1264 | 1288 | case SDL_WINDOWEVENT_EXPOSED: |
| 1265 | 1289 | case SDL_WINDOWEVENT_MAXIMIZED: |
| 1266 | 1290 | case SDL_WINDOWEVENT_RESTORED: |
| r3073 | r3074 | |
| 1306 | 1330 | if (!mouse_enabled && !lightgun_enabled) |
| 1307 | 1331 | return FALSE; |
| 1308 | 1332 | |
| 1333 | if (!app_has_mouse_focus) |
| 1334 | return FALSE; |
| 1335 | |
| 1309 | 1336 | // otherwise, yes |
| 1310 | 1337 | return TRUE; |
| 1311 | 1338 | } |
src/osd/sdl/window.c
| r3073 | r3074 | |
| 723 | 723 | // the possibility of losing control |
| 724 | 724 | if (!options_get_bool(mame_options(), OPTION_DEBUG)) |
| 725 | 725 | { |
| 726 | | if (!window->fullscreen && !sdlinput_should_hide_mouse(machine)) |
| 726 | if ( window->fullscreen || sdlinput_should_hide_mouse(machine) ) |
| 727 | 727 | { |
| 728 | | SDL_ShowCursor(SDL_ENABLE); |
| 729 | | if (SDL_WM_GrabInput(SDL_GRAB_QUERY)) |
| 728 | SDL_ShowCursor(SDL_DISABLE); |
| 729 | if (!SDL_WM_GrabInput(SDL_GRAB_QUERY)) |
| 730 | 730 | { |
| 731 | | SDL_WM_GrabInput(SDL_GRAB_OFF); |
| 731 | SDL_WM_GrabInput(SDL_GRAB_ON); |
| 732 | 732 | } |
| 733 | 733 | } |
| 734 | 734 | else |
| 735 | 735 | { |
| 736 | | SDL_ShowCursor(SDL_DISABLE); |
| 737 | | if (!SDL_WM_GrabInput(SDL_GRAB_QUERY)) |
| 736 | SDL_ShowCursor(SDL_ENABLE); |
| 737 | if (SDL_WM_GrabInput(SDL_GRAB_QUERY)) |
| 738 | 738 | { |
| 739 | | SDL_WM_GrabInput(SDL_GRAB_ON); |
| 739 | SDL_WM_GrabInput(SDL_GRAB_OFF); |
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | 742 | } |
| r3073 | r3074 | |
| 922 | 922 | minimum_height -= 4; |
| 923 | 923 | } |
| 924 | 924 | |
| 925 | #if defined(SDLMAME_WIN32) && !SDL_VERSION_ATLEAST(1,3,0) |
| 926 | /* |
| 927 | * We need to do this here. If SDL_ListModes is |
| 928 | * called in init_monitors, the call will crash |
| 929 | * on win32 |
| 930 | */ |
| 931 | modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_DOUBLEBUF); |
| 932 | #else |
| 925 | 933 | modes = window->monitor->modes; |
| 934 | #endif |
| 926 | 935 | |
| 927 | 936 | if (modes == (SDL_Rect **)0) |
| 928 | 937 | { |
src/osd/sdl/sdlsync.c
| r3073 | r3074 | |
| 36 | 36 | #include <errno.h> |
| 37 | 37 | #include <sys/time.h> |
| 38 | 38 | #else |
| 39 | #define INCL_DOS |
| 40 | #include <os2.h> |
| 41 | |
| 39 | 42 | #include <stdlib.h> |
| 40 | 43 | #define pthread_t int |
| 41 | 44 | #define pthread_self _gettid |
| r3073 | r3074 | |
| 70 | 73 | INT8 padding[48]; // A bit more padding |
| 71 | 74 | #endif |
| 72 | 75 | }; |
| 76 | #else |
| 77 | struct _osd_event { |
| 78 | HMTX hmtx; |
| 79 | HEV hev; |
| 80 | volatile INT32 autoreset; |
| 81 | INT8 padding[52]; // Fill a 64-byte cache line |
| 82 | }; |
| 73 | 83 | #endif |
| 74 | 84 | |
| 75 | 85 | struct _osd_thread { |
| r3073 | r3074 | |
| 314 | 324 | } |
| 315 | 325 | #endif |
| 316 | 326 | |
| 327 | #ifndef SDLMAME_OS2 |
| 317 | 328 | //============================================================ |
| 318 | 329 | // osd_num_processors |
| 319 | 330 | //============================================================ |
| 320 | 331 | |
| 321 | | #ifndef SDLMAME_OS2 |
| 322 | 332 | int osd_num_processors(void) |
| 323 | 333 | { |
| 324 | 334 | int processors = 1; |
| r3073 | r3074 | |
| 614 | 624 | free(thread); |
| 615 | 625 | } |
| 616 | 626 | |
| 627 | #else |
| 628 | |
| 629 | //============================================================ |
| 630 | // osd_num_processors |
| 631 | //============================================================ |
| 632 | |
| 633 | int osd_num_processors(void) |
| 634 | { |
| 635 | ULONG numprocs = 1; |
| 636 | |
| 637 | DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &numprocs, sizeof(numprocs)); |
| 638 | |
| 639 | return numprocs; |
| 640 | } |
| 641 | |
| 642 | //============================================================ |
| 643 | // osd_event_alloc |
| 644 | //============================================================ |
| 645 | |
| 646 | osd_event *osd_event_alloc(int manualreset, int initialstate) |
| 647 | { |
| 648 | osd_event *ev; |
| 649 | |
| 650 | ev = (osd_event *)calloc(1, sizeof(osd_event)); |
| 651 | |
| 652 | DosCreateMutexSem(NULL, &ev->hmtx, 0, FALSE); |
| 653 | DosCreateEventSem(NULL, &ev->hev, 0, initialstate); |
| 654 | ev->autoreset = !manualreset; |
| 655 | |
| 656 | return ev; |
| 657 | } |
| 658 | |
| 659 | //============================================================ |
| 660 | // osd_event_free |
| 661 | //============================================================ |
| 662 | |
| 663 | void osd_event_free(osd_event *event) |
| 664 | { |
| 665 | DosCloseMutexSem(event->hmtx); |
| 666 | DosCloseEventSem(event->hev); |
| 667 | free(event); |
| 668 | } |
| 669 | |
| 670 | //============================================================ |
| 671 | // osd_event_set |
| 672 | //============================================================ |
| 673 | |
| 674 | void osd_event_set(osd_event *event) |
| 675 | { |
| 676 | DosPostEventSem(event->hev); |
| 677 | } |
| 678 | |
| 679 | //============================================================ |
| 680 | // osd_event_reset |
| 681 | //============================================================ |
| 682 | |
| 683 | void osd_event_reset(osd_event *event) |
| 684 | { |
| 685 | ULONG ulCount; |
| 686 | |
| 687 | DosResetEventSem(event->hev, &ulCount); |
| 688 | } |
| 689 | |
| 690 | //============================================================ |
| 691 | // osd_event_wait |
| 692 | //============================================================ |
| 693 | |
| 694 | int osd_event_wait(osd_event *event, osd_ticks_t timeout) |
| 695 | { |
| 696 | ULONG rc; |
| 697 | |
| 698 | if(event->autoreset) |
| 699 | DosRequestMutexSem(event->hmtx, -1); |
| 700 | |
| 701 | rc = DosWaitEventSem(event->hev, timeout * 1000 / osd_ticks_per_second()); |
| 702 | |
| 703 | if(event->autoreset) |
| 704 | { |
| 705 | ULONG ulCount; |
| 706 | |
| 707 | DosResetEventSem(event->hev, &ulCount); |
| 708 | DosReleaseMutexSem(event->hmtx); |
| 709 | } |
| 710 | |
| 711 | return (rc == 0); |
| 712 | } |
| 713 | |
| 714 | //============================================================ |
| 715 | // osd_thread_create |
| 716 | //============================================================ |
| 717 | |
| 718 | osd_thread *osd_thread_create(osd_thread_callback callback, void *cbparam) |
| 719 | { |
| 720 | osd_thread *thread; |
| 721 | |
| 722 | thread = (osd_thread *)calloc(1, sizeof(osd_thread)); |
| 723 | thread->thread = _beginthread(callback, NULL, 65535, cbparam); |
| 724 | if ( thread->thread == -1 ) |
| 725 | { |
| 726 | free(thread); |
| 727 | return NULL; |
| 728 | } |
| 729 | return thread; |
| 730 | } |
| 731 | |
| 732 | //============================================================ |
| 733 | // osd_thread_adjust_priority |
| 734 | //============================================================ |
| 735 | |
| 736 | int osd_thread_adjust_priority(osd_thread *thread, int adjust) |
| 737 | { |
| 738 | PTIB ptib; |
| 739 | |
| 740 | DosGetInfoBlocks(&ptib, NULL); |
| 741 | |
| 742 | if ( DosSetPriority(PRTYS_THREAD, PRTYC_NOCHANGE, |
| 743 | ((BYTE)ptib->tib_ptib2->tib2_ulpri) + adjust, thread->thread )) |
| 744 | return FALSE; |
| 745 | |
| 746 | |
| 747 | return TRUE; |
| 748 | } |
| 749 | |
| 750 | //============================================================ |
| 751 | // osd_thread_cpu_affinity |
| 752 | //============================================================ |
| 753 | |
| 754 | int osd_thread_cpu_affinity(osd_thread *thread, UINT32 mask) |
| 755 | { |
| 756 | return TRUE; |
| 757 | } |
| 758 | |
| 759 | //============================================================ |
| 760 | // osd_thread_wait_free |
| 761 | //============================================================ |
| 762 | |
| 763 | void osd_thread_wait_free(osd_thread *thread) |
| 764 | { |
| 765 | TID tid = thread->thread; |
| 766 | |
| 767 | DosWaitThread(&tid, 0); |
| 768 | free(thread); |
| 769 | } |
| 770 | |
| 617 | 771 | #endif /* SDLMAME_OS2 */ |
| 618 | 772 | #else // SDLMAME_WIN32 |
| 619 | 773 | #include "../windows/winsync.c" |
src/osd/sdl/sdlsync.h
| r3073 | r3074 | |
| 14 | 14 | |
| 15 | 15 | #ifndef SDLMAME_WIN32 |
| 16 | 16 | |
| 17 | | #ifndef SDLMAME_OS2 |
| 18 | | |
| 19 | | #if (defined SDLMAME_MACOSX) || (defined SDLMAME_FREEBSD) || (defined SDLMAME_SOLARIS) |
| 17 | #if (defined SDLMAME_MACOSX) || (defined SDLMAME_FREEBSD) || (defined SDLMAME_SOLARIS) || (defined SDLMAME_OS2) |
| 20 | 18 | #define THREAD_COOPERATIVE (0) |
| 21 | 19 | #else |
| 22 | 20 | #define THREAD_COOPERATIVE (1) |
| r3073 | r3074 | |
| 191 | 189 | -----------------------------------------------------------------------------*/ |
| 192 | 190 | int osd_num_processors(void); |
| 193 | 191 | |
| 194 | | #endif /* SDLMAME_OS2 */ |
| 192 | #else |
| 195 | 193 | |
| 194 | // standard windows headers |
| 195 | #define WIN32_LEAN_AND_MEAN |
| 196 | #include <windows.h> |
| 197 | #include <process.h> |
| 198 | |
| 199 | /*----------------------------------------------------------------------------- |
| 200 | INLINE implementation of WIN events |
| 201 | -----------------------------------------------------------------------------*/ |
| 202 | |
| 203 | typedef void osd_event; |
| 204 | |
| 205 | INLINE osd_event *osd_event_alloc(int manualreset, int initialstate) |
| 206 | { |
| 207 | return (void *) CreateEvent(NULL, manualreset, initialstate, NULL); |
| 208 | } |
| 209 | |
| 210 | INLINE int osd_event_wait(osd_event *event, osd_ticks_t timeout) |
| 211 | { |
| 212 | return WaitForSingleObject((HANDLE) event, timeout * 1000 / osd_ticks_per_second()); |
| 213 | } |
| 214 | |
| 215 | INLINE void osd_event_reset(osd_event *event) |
| 216 | { |
| 217 | ResetEvent((HANDLE) event); |
| 218 | } |
| 219 | |
| 220 | INLINE void osd_event_set(osd_event *event) |
| 221 | { |
| 222 | SetEvent((HANDLE) event); |
| 223 | } |
| 224 | |
| 225 | INLINE void osd_event_free(osd_event *event) |
| 226 | { |
| 227 | CloseHandle((HANDLE) event); |
| 228 | } |
| 229 | |
| 230 | |
| 196 | 231 | #endif /* SDLMAME_WIN32 */ |
| 197 | 232 | |
| 198 | 233 | #endif /* __SDLSYNC__ */ |
src/osd/sdl/sdlmain.c
| r3073 | r3074 | |
| 22 | 22 | // OSD headers |
| 23 | 23 | #include "video.h" |
| 24 | 24 | #include "input.h" |
| 25 | #include "output.h" |
| 25 | 26 | #include "osdsdl.h" |
| 26 | 27 | |
| 27 | 28 | // we override SDL's normal startup on Win32 |
| r3073 | r3074 | |
| 220 | 221 | { NULL } |
| 221 | 222 | }; |
| 222 | 223 | |
| 224 | #ifdef SDLMAME_WIN32 |
| 225 | |
| 226 | /* mingw has no setenv */ |
| 227 | |
| 228 | int setenv(const char *name, const char *value, int overwrite) |
| 229 | { |
| 230 | char *buf; |
| 231 | int result; |
| 232 | |
| 233 | if (!overwrite) |
| 234 | { |
| 235 | if (getenv(name) != NULL) |
| 236 | return 0; |
| 237 | } |
| 238 | buf = malloc(strlen(name)+strlen(value)+2); |
| 239 | sprintf(buf, "%s=%s", name, value); |
| 240 | result = putenv(buf); |
| 241 | |
| 242 | /* will be referenced by environment |
| 243 | * Therefore it is not freed here |
| 244 | */ |
| 245 | |
| 246 | return result; |
| 247 | } |
| 248 | |
| 249 | #endif |
| 250 | |
| 223 | 251 | //============================================================ |
| 224 | 252 | // main |
| 225 | 253 | //============================================================ |
| r3073 | r3074 | |
| 499 | 527 | fflush(stdout); |
| 500 | 528 | exit(-1); |
| 501 | 529 | } |
| 502 | | if (osd_use_unsupported()) |
| 503 | | sdlled_init(); |
| 504 | 530 | |
| 505 | 531 | sdlinput_init(machine); |
| 506 | 532 | |
| 507 | 533 | sdlaudio_init(machine); |
| 508 | 534 | |
| 535 | sdloutput_init(machine); |
| 536 | |
| 509 | 537 | if (options_get_bool(mame_options(), SDLOPTION_OSLOG)) |
| 510 | 538 | add_logerror_callback(machine, output_oslog); |
| 511 | 539 | |
src/osd/sdl/osdsdl.h
| r3073 | r3074 | |
| 12 | 12 | * Need to submit the directfb driver to the SDL team |
| 13 | 13 | * SDL1.3: sdlvideofps does not take -numscreens>1 into account. |
| 14 | 14 | |
| 15 | - For DEBUG=1 builds, disable input grapping while windowed |
| 16 | - Fixed WIN32 compile |
| 17 | Wrote setenv function since mingw does not provide one. |
| 18 | Implemented osd_event_* as inline functions for win32 build. |
| 19 | We should at some point merge sdlwork.c and winwork.c and push it |
| 20 | to the core, letting sdlsync.c provide the necessary details. |
| 21 | - Removed keybled.c and references |
| 22 | - Added output.c and output.h. These will look for a fifo or file |
| 23 | /tmp/sdlmame_out and write output notifiers to it. |
| 24 | Added a sample client ledutil.sh to src/osd/sdl which turns |
| 25 | leds on and off and provides a debug (log) facility. |
| 26 | - removed os2work.c |
| 27 | |
| 15 | 28 | - replaced window->render_lock with event window->rendered_event |
| 16 | | for multiple windows and "-mt", the old code would allow filling up |
| 29 | For multiple windows and "-mt", the old code would allow filling up |
| 17 | 30 | the workqueue with 1000s of entries, since the lock would not block while |
| 18 | 31 | another window is rendered. The osd_event establishes a barrier which |
| 19 | 32 | is only freed if the last window blit operation has finished. |
| r3073 | r3074 | |
| 274 | 287 | |
| 275 | 288 | void sdlaudio_init(running_machine *machine); |
| 276 | 289 | |
| 277 | | //============================================================ |
| 278 | | // keybled.c |
| 279 | | //============================================================ |
| 280 | | |
| 281 | | void sdlled_init(void); |
| 282 | | |
| 283 | | |
| 284 | 290 | #endif |