diff options
author | 2015-02-07 20:41:47 +0000 | |
---|---|---|
committer | 2015-02-07 20:41:47 +0000 | |
commit | 2756a23b1a37c5f7d5f9b7b834e80af0ac6cccab (patch) | |
tree | 6bce051ec14d501700476880f940b23fca6eeea8 /src/osd | |
parent | 3cbfac80cb9ff034e7b0ac04c9a6caf165bd14b7 (diff) |
Emscripten target now uses SDL2. [Justin Kerk]
Diffstat (limited to 'src/osd')
-rw-r--r-- | src/osd/sdl/input.c | 21 | ||||
-rw-r--r-- | src/osd/sdl/osdsdl.h | 2 | ||||
-rw-r--r-- | src/osd/sdl/sdl.mak | 11 | ||||
-rw-r--r-- | src/osd/sdl/sdlmain.c | 17 |
4 files changed, 15 insertions, 36 deletions
diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c index 20043f66761..32b98f45be3 100644 --- a/src/osd/sdl/input.c +++ b/src/osd/sdl/input.c @@ -41,12 +41,6 @@ #undef DELETE #endif -// Emscripten requires the SDL2 API for keyboard inputs, but nothing else -#ifdef SDLMAME_EMSCRIPTEN -#undef SDLMAME_SDL2 -#define SDLMAME_SDL2 1 -#endif - //============================================================ // PARAMETERS //============================================================ @@ -498,13 +492,6 @@ static kt_table sdl_key_trans_table[] = }; #endif -#if defined(SDLMAME_EMSCRIPTEN) -#undef GET_WINDOW -#undef GET_FOCUS_WINDOW -#define GET_WINDOW(ev) sdl_window_list -#define GET_FOCUS_WINDOW(ev) sdl_window_list -#endif - struct key_lookup_table { int code; @@ -731,7 +718,7 @@ static void sdlinput_register_joysticks(running_machine &machine) { char *joy_name; -#if (SDLMAME_SDL2) && (!defined(SDLMAME_EMSCRIPTEN)) +#if (SDLMAME_SDL2) joy = SDL_JoystickOpen(physical_stick); joy_name = remove_spaces(machine, SDL_JoystickName(joy)); SDL_JoystickClose(joy); @@ -1538,7 +1525,7 @@ INT32 normalize_absolute_axis(INT32 raw, INT32 rawmin, INT32 rawmax) // sdlinput_poll //============================================================ -#if (SDLMAME_SDL2) && (!defined(SDLMAME_EMSCRIPTEN)) +#if (SDLMAME_SDL2) INLINE sdl_window_info * window_from_id(Uint32 windowID) { sdl_window_info *w; @@ -1931,7 +1918,7 @@ void sdlinput_poll(running_machine &machine) devinfo->joystick.balls[event.jball.ball * 2] = event.jball.xrel * INPUT_RELATIVE_PER_PIXEL; devinfo->joystick.balls[event.jball.ball * 2 + 1] = event.jball.yrel * INPUT_RELATIVE_PER_PIXEL; break; -#if (!SDLMAME_SDL2) || defined(SDLMAME_EMSCRIPTEN) +#if (!SDLMAME_SDL2) case SDL_APPMOUSEFOCUS: app_has_mouse_focus = event.active.gain; if (!event.active.gain) @@ -2017,7 +2004,7 @@ void sdlinput_poll(running_machine &machine) #endif } } -#if (SDLMAME_SDL2) && (!defined(SDLMAME_EMSCRIPTEN)) +#if (SDLMAME_SDL2) resize_all_windows(); #endif } diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index 31afd7baff6..42b88f4ed39 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -14,7 +14,7 @@ //============================================================ // Process events in worker thread -#if defined(SDLMAME_WIN32) || (SDLMAME_SDL2) +#if defined(SDLMAME_WIN32) || ((SDLMAME_SDL2) && (!defined(SDLMAME_EMSCRIPTEN))) #define SDLMAME_EVENTS_IN_WORKER_THREAD (1) #else #define SDLMAME_EVENTS_IN_WORKER_THREAD (0) diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index 8adab97289b..62b5453f533 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -92,17 +92,13 @@ OSDOBJ = $(OBJ)/osd # add a define identifying the target osd DEFS += -DOSD_SDL -# default to SDL2 for non-OS/2, non-Emscripten builds now +# default to SDL2 for non-OS/2 builds now ifndef SDL_LIBVER ifneq ($(TARGETOS),os2) -ifneq ($(TARGETOS),emscripten) SDL_LIBVER = sdl2 else SDL_LIBVER = sdl endif -else -SDL_LIBVER = sdl -endif endif ifndef NO_USE_QTDEBUG @@ -579,10 +575,7 @@ ifeq ($(NO_X11),1) NO_DEBUGGER = 1 endif -# Don't pull in the system includes if we are compiling for Emscripten, which has its own headers -ifneq ($(TARGETOS),emscripten) INCPATH += `$(SDL_CONFIG) --cflags | sed -e 's:/SDL[2]*::' -e 's:\(-D[^ ]*\)::g'` -endif CCOMFLAGS += `$(SDL_CONFIG) --cflags | sed -e 's:/SDL[2]*::' -e 's:\(-I[^ ]*\)::g'` BASELIBS += `$(SDL_CONFIG) --libs` @@ -663,9 +656,7 @@ ifeq ($(BASE_TARGETOS),win32) OSDCOREOBJS += $(SDLMAIN) ifdef SDL_INSTALL_ROOT -ifneq ($(TARGETOS),emscripten) INCPATH += -I$(SDL_INSTALL_ROOT)/include -endif LIBS += -L$(SDL_INSTALL_ROOT)/lib #-Wl,-rpath,$(SDL_INSTALL_ROOT)/lib endif diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index 2510e77a475..221a3f0dad6 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -38,10 +38,6 @@ #include <os2.h> #endif -#ifdef SDLMAME_EMSCRIPTEN -#include <emscripten.h> -#endif - #include "sdlinc.h" // MAME headers @@ -295,10 +291,6 @@ int main(int argc, char *argv[]) MorphToPM(); #endif - #ifdef SDLMAME_EMSCRIPTEN - EM_ASM("SDL.defaults.copyOnLock = false; SDL.defaults.discardOnLock = true;"); - #endif - #if defined(SDLMAME_X11) && (SDL_MAJOR_VERSION == 1) && (SDL_MINOR_VERSION == 2) if (SDL_Linked_Version()->patch < 10) /* workaround for SDL choosing a 32-bit ARGB visual */ @@ -619,7 +611,12 @@ void sdl_osd_interface::init(running_machine &machine) if (!SDLMAME_INIT_IN_WORKER_THREAD) { #if (SDLMAME_SDL2) +#ifdef SDLMAME_EMSCRIPTEN + // timer brings in threads which are not supported in Emscripten + if (SDL_InitSubSystem(SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { +#else if (SDL_InitSubSystem(SDL_INIT_TIMER| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { +#endif #else if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { #endif @@ -655,7 +652,11 @@ void sdl_osd_interface::init(running_machine &machine) } #if (SDLMAME_SDL2) +#ifdef SDLMAME_EMSCRIPTEN + SDL_EventState(SDL_TEXTINPUT, SDL_FALSE); +#else SDL_EventState(SDL_TEXTINPUT, SDL_TRUE); +#endif #else SDL_EnableUNICODE(SDL_TRUE); #endif |