trunk/src/osd/sdl/input.c
| r243424 | r243425 | |
| 41 | 41 | #undef DELETE |
| 42 | 42 | #endif |
| 43 | 43 | |
| 44 | | // Emscripten requires the SDL2 API for keyboard inputs, but nothing else |
| 45 | | #ifdef SDLMAME_EMSCRIPTEN |
| 46 | | #undef SDLMAME_SDL2 |
| 47 | | #define SDLMAME_SDL2 1 |
| 48 | | #endif |
| 49 | | |
| 50 | 44 | //============================================================ |
| 51 | 45 | // PARAMETERS |
| 52 | 46 | //============================================================ |
| r243424 | r243425 | |
| 498 | 492 | }; |
| 499 | 493 | #endif |
| 500 | 494 | |
| 501 | | #if defined(SDLMAME_EMSCRIPTEN) |
| 502 | | #undef GET_WINDOW |
| 503 | | #undef GET_FOCUS_WINDOW |
| 504 | | #define GET_WINDOW(ev) sdl_window_list |
| 505 | | #define GET_FOCUS_WINDOW(ev) sdl_window_list |
| 506 | | #endif |
| 507 | | |
| 508 | 495 | struct key_lookup_table |
| 509 | 496 | { |
| 510 | 497 | int code; |
| r243424 | r243425 | |
| 731 | 718 | { |
| 732 | 719 | char *joy_name; |
| 733 | 720 | |
| 734 | | #if (SDLMAME_SDL2) && (!defined(SDLMAME_EMSCRIPTEN)) |
| 721 | #if (SDLMAME_SDL2) |
| 735 | 722 | joy = SDL_JoystickOpen(physical_stick); |
| 736 | 723 | joy_name = remove_spaces(machine, SDL_JoystickName(joy)); |
| 737 | 724 | SDL_JoystickClose(joy); |
| r243424 | r243425 | |
| 1538 | 1525 | // sdlinput_poll |
| 1539 | 1526 | //============================================================ |
| 1540 | 1527 | |
| 1541 | | #if (SDLMAME_SDL2) && (!defined(SDLMAME_EMSCRIPTEN)) |
| 1528 | #if (SDLMAME_SDL2) |
| 1542 | 1529 | INLINE sdl_window_info * window_from_id(Uint32 windowID) |
| 1543 | 1530 | { |
| 1544 | 1531 | sdl_window_info *w; |
| r243424 | r243425 | |
| 1931 | 1918 | devinfo->joystick.balls[event.jball.ball * 2] = event.jball.xrel * INPUT_RELATIVE_PER_PIXEL; |
| 1932 | 1919 | devinfo->joystick.balls[event.jball.ball * 2 + 1] = event.jball.yrel * INPUT_RELATIVE_PER_PIXEL; |
| 1933 | 1920 | break; |
| 1934 | | #if (!SDLMAME_SDL2) || defined(SDLMAME_EMSCRIPTEN) |
| 1921 | #if (!SDLMAME_SDL2) |
| 1935 | 1922 | case SDL_APPMOUSEFOCUS: |
| 1936 | 1923 | app_has_mouse_focus = event.active.gain; |
| 1937 | 1924 | if (!event.active.gain) |
| r243424 | r243425 | |
| 2017 | 2004 | #endif |
| 2018 | 2005 | } |
| 2019 | 2006 | } |
| 2020 | | #if (SDLMAME_SDL2) && (!defined(SDLMAME_EMSCRIPTEN)) |
| 2007 | #if (SDLMAME_SDL2) |
| 2021 | 2008 | resize_all_windows(); |
| 2022 | 2009 | #endif |
| 2023 | 2010 | } |
trunk/src/osd/sdl/sdl.mak
| r243424 | r243425 | |
| 92 | 92 | # add a define identifying the target osd |
| 93 | 93 | DEFS += -DOSD_SDL |
| 94 | 94 | |
| 95 | | # default to SDL2 for non-OS/2, non-Emscripten builds now |
| 95 | # default to SDL2 for non-OS/2 builds now |
| 96 | 96 | ifndef SDL_LIBVER |
| 97 | 97 | ifneq ($(TARGETOS),os2) |
| 98 | | ifneq ($(TARGETOS),emscripten) |
| 99 | 98 | SDL_LIBVER = sdl2 |
| 100 | 99 | else |
| 101 | 100 | SDL_LIBVER = sdl |
| 102 | 101 | endif |
| 103 | | else |
| 104 | | SDL_LIBVER = sdl |
| 105 | 102 | endif |
| 106 | | endif |
| 107 | 103 | |
| 108 | 104 | ifndef NO_USE_QTDEBUG |
| 109 | 105 | OBJDIRS += $(OSDOBJ)/modules/debugger/qt |
| r243424 | r243425 | |
| 579 | 575 | NO_DEBUGGER = 1 |
| 580 | 576 | endif |
| 581 | 577 | |
| 582 | | # Don't pull in the system includes if we are compiling for Emscripten, which has its own headers |
| 583 | | ifneq ($(TARGETOS),emscripten) |
| 584 | 578 | INCPATH += `$(SDL_CONFIG) --cflags | sed -e 's:/SDL[2]*::' -e 's:\(-D[^ ]*\)::g'` |
| 585 | | endif |
| 586 | 579 | CCOMFLAGS += `$(SDL_CONFIG) --cflags | sed -e 's:/SDL[2]*::' -e 's:\(-I[^ ]*\)::g'` |
| 587 | 580 | |
| 588 | 581 | BASELIBS += `$(SDL_CONFIG) --libs` |
| r243424 | r243425 | |
| 663 | 656 | OSDCOREOBJS += $(SDLMAIN) |
| 664 | 657 | |
| 665 | 658 | ifdef SDL_INSTALL_ROOT |
| 666 | | ifneq ($(TARGETOS),emscripten) |
| 667 | 659 | INCPATH += -I$(SDL_INSTALL_ROOT)/include |
| 668 | | endif |
| 669 | 660 | LIBS += -L$(SDL_INSTALL_ROOT)/lib |
| 670 | 661 | #-Wl,-rpath,$(SDL_INSTALL_ROOT)/lib |
| 671 | 662 | endif |
trunk/src/osd/sdl/sdlmain.c
| r243424 | r243425 | |
| 38 | 38 | #include <os2.h> |
| 39 | 39 | #endif |
| 40 | 40 | |
| 41 | | #ifdef SDLMAME_EMSCRIPTEN |
| 42 | | #include <emscripten.h> |
| 43 | | #endif |
| 44 | | |
| 45 | 41 | #include "sdlinc.h" |
| 46 | 42 | |
| 47 | 43 | // MAME headers |
| r243424 | r243425 | |
| 295 | 291 | MorphToPM(); |
| 296 | 292 | #endif |
| 297 | 293 | |
| 298 | | #ifdef SDLMAME_EMSCRIPTEN |
| 299 | | EM_ASM("SDL.defaults.copyOnLock = false; SDL.defaults.discardOnLock = true;"); |
| 300 | | #endif |
| 301 | | |
| 302 | 294 | #if defined(SDLMAME_X11) && (SDL_MAJOR_VERSION == 1) && (SDL_MINOR_VERSION == 2) |
| 303 | 295 | if (SDL_Linked_Version()->patch < 10) |
| 304 | 296 | /* workaround for SDL choosing a 32-bit ARGB visual */ |
| r243424 | r243425 | |
| 619 | 611 | if (!SDLMAME_INIT_IN_WORKER_THREAD) |
| 620 | 612 | { |
| 621 | 613 | #if (SDLMAME_SDL2) |
| 614 | #ifdef SDLMAME_EMSCRIPTEN |
| 615 | // timer brings in threads which are not supported in Emscripten |
| 616 | if (SDL_InitSubSystem(SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { |
| 617 | #else |
| 622 | 618 | if (SDL_InitSubSystem(SDL_INIT_TIMER| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { |
| 619 | #endif |
| 623 | 620 | #else |
| 624 | 621 | if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { |
| 625 | 622 | #endif |
| r243424 | r243425 | |
| 655 | 652 | } |
| 656 | 653 | |
| 657 | 654 | #if (SDLMAME_SDL2) |
| 655 | #ifdef SDLMAME_EMSCRIPTEN |
| 656 | SDL_EventState(SDL_TEXTINPUT, SDL_FALSE); |
| 657 | #else |
| 658 | 658 | SDL_EventState(SDL_TEXTINPUT, SDL_TRUE); |
| 659 | #endif |
| 659 | 660 | #else |
| 660 | 661 | SDL_EnableUNICODE(SDL_TRUE); |
| 661 | 662 | #endif |