diff --git a/bitrise.yml b/bitrise.yml index bb692e150..dffb28fe4 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -16,6 +16,10 @@ workflows: steps: - activate-ssh-key@4.0.3: run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}' + - brew-install + title: Install SDL2 + inputs: + - packages: "sdl2" - git-clone@4.0.14: {} - cache-pull@2.0.1: {} - script@1.1.5: diff --git a/core/sdl/sdl.cpp b/core/sdl/sdl.cpp index d8e206cb4..7277a225e 100644 --- a/core/sdl/sdl.cpp +++ b/core/sdl/sdl.cpp @@ -30,13 +30,6 @@ static SDLKeyboardDevice* sdl_keyboard = NULL; extern void dc_exit(); -#ifdef TARGET_PANDORA - extern char OSD_Info[128]; - extern int OSD_Delay; - extern char OSD_Counters[256]; - extern int OSD_Counter; -#endif - extern u32 mo_buttons; extern s32 mo_x_abs; extern s32 mo_y_abs; @@ -80,11 +73,13 @@ void input_sdl_init() SDL_SetRelativeMouseMode(SDL_FALSE); +#if HOST_OS != OS_DARWIN sdl_keyboard = new SDLKeyboardDevice(0); sdl_kb_gamepad = std::make_shared(0); GamepadDevice::Register(sdl_kb_gamepad); sdl_mouse_gamepad = std::make_shared(0); GamepadDevice::Register(sdl_mouse_gamepad); +#endif } static int mouse_prev_x = -1; @@ -124,6 +119,7 @@ void input_sdl_handle(u32 port) case SDL_QUIT: dc_exit(); break; +#if HOST_OS != OS_DARWIN case SDL_KEYDOWN: case SDL_KEYUP: sdl_kb_gamepad->gamepad_btn_input(event.key.keysym.sym, event.type == SDL_KEYDOWN); @@ -140,7 +136,7 @@ void input_sdl_handle(u32 port) for (int i = 0; event.text.text[i] != '\0'; i++) sdl_keyboard->keyboard_character(event.text.text[i]); break; - +#endif case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: { @@ -157,6 +153,7 @@ void input_sdl_handle(u32 port) } break; +#if HOST_OS != OS_DARWIN case SDL_MOUSEMOTION: set_mouse_position(event.motion.x, event.motion.y); SET_FLAG(mo_buttons, 1 << 2, event.motion.state & SDL_BUTTON_LMASK); @@ -185,7 +182,7 @@ void input_sdl_handle(u32 port) case SDL_MOUSEWHEEL: mo_wheel_delta -= event.wheel.y * 35; break; - +#endif case SDL_JOYDEVICEADDED: sdl_open_joystick(event.jdevice.which); break; @@ -199,16 +196,13 @@ void input_sdl_handle(u32 port) void sdl_window_set_text(const char* text) { - #ifdef TARGET_PANDORA - strncpy(OSD_Counters, text, 256); - #else - if(window) - { - SDL_SetWindowTitle(window, text); // *TODO* Set Icon also... - } - #endif + if (window) + { + SDL_SetWindowTitle(window, text); // *TODO* Set Icon also... + } } +#if HOST_OS != OS_DARWIN void sdl_window_create() { if (SDL_WasInit(SDL_INIT_VIDEO) == 0) @@ -291,3 +285,5 @@ void gl_term() { SDL_GL_DeleteContext(glcontext); } +#endif + diff --git a/core/sdl/sdl_gamepad.h b/core/sdl/sdl_gamepad.h index 489d10055..0ca8b0461 100644 --- a/core/sdl/sdl_gamepad.h +++ b/core/sdl/sdl_gamepad.h @@ -1,6 +1,7 @@ #include "../input/gamepad_device.h" #include "oslib/oslib.h" #include "sdl.h" +#include "rend/gui.h" class DefaultInputMapping : public InputMapping { diff --git a/shell/apple/emulator-osx/emulator-osx/osx-main.mm b/shell/apple/emulator-osx/emulator-osx/osx-main.mm index 82f89bcb4..cea1cdd6f 100644 --- a/shell/apple/emulator-osx/emulator-osx/osx-main.mm +++ b/shell/apple/emulator-osx/emulator-osx/osx-main.mm @@ -16,6 +16,9 @@ #include "rend/gui.h" #include "osx_keyboard.h" #include "osx_gamepad.h" +#if defined(USE_SDL) +#include "sdl/sdl.h" +#endif OSXKeyboardDevice keyboard(0); static std::shared_ptr kb_gamepad(0); @@ -48,19 +51,27 @@ void os_SetWindowText(const char * text) { } void os_DoEvents() { - } - void UpdateInputState(u32 port) { - +#if defined(USE_SDL) + input_sdl_handle(port); +#endif } void os_CreateWindow() { - } -void os_SetupInput() { +void os_SetupInput() +{ +#if defined(USE_SDL) + if (SDL_Init(0) != 0) + { + die("SDL: Initialization failed!"); + } + input_sdl_init(); +#endif + kb_gamepad = std::make_shared(0); GamepadDevice::Register(kb_gamepad); mouse_gamepad = std::make_shared(0); @@ -73,7 +84,6 @@ void* libPvr_GetRenderTarget() { void* libPvr_GetRenderSurface() { return 0; - } bool gl_init(void*, void*) { @@ -81,7 +91,6 @@ bool gl_init(void*, void*) { } void gl_term() { - } void common_linux_setup(); diff --git a/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj b/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj index 0e6b9ffbf..46c52c769 100644 --- a/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj +++ b/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj @@ -256,6 +256,8 @@ AE8C274221122E2500D4D8F4 /* License.txt in Resources */ = {isa = PBXBuildFile; fileRef = AE8C273C21122E2500D4D8F4 /* License.txt */; }; AE8C274321122E2500D4D8F4 /* xbrz.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE8C273D21122E2500D4D8F4 /* xbrz.cpp */; }; AED73BAE22FC0E9600ECDB64 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = AED73BAD22FC0E9600ECDB64 /* README.md */; }; + AED73DC42303E19200ECDB64 /* sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AED73DC02303E19100ECDB64 /* sdl.cpp */; }; + AED73DC72303E57C00ECDB64 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AED73DC62303E57C00ECDB64 /* libSDL2.a */; }; AEE62768220D7B4400EC7E89 /* cue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEE62767220D7B4300EC7E89 /* cue.cpp */; }; AEE6276B220D7B5500EC7E89 /* gui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEE6276A220D7B5500EC7E89 /* gui.cpp */; }; AEE6277A220D7B7E00EC7E89 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEE6276E220D7B7E00EC7E89 /* imgui.cpp */; }; @@ -790,6 +792,11 @@ AE8C273F21122E2500D4D8F4 /* xbrz_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xbrz_config.h; sourceTree = ""; }; AE8C274021122E2500D4D8F4 /* xbrz_tools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xbrz_tools.h; sourceTree = ""; }; AED73BAD22FC0E9600ECDB64 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../../../core/README.md; sourceTree = ""; }; + AED73DC02303E19100ECDB64 /* sdl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sdl.cpp; sourceTree = ""; }; + AED73DC12303E19100ECDB64 /* sdl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sdl.h; sourceTree = ""; }; + AED73DC22303E19100ECDB64 /* sdl_gamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sdl_gamepad.h; sourceTree = ""; }; + AED73DC32303E19100ECDB64 /* sdl_keyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sdl_keyboard.h; sourceTree = ""; }; + AED73DC62303E57C00ECDB64 /* libSDL2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDL2.a; path = /usr/local/lib/libSDL2.a; sourceTree = ""; }; AEE62767220D7B4300EC7E89 /* cue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cue.cpp; sourceTree = ""; }; AEE62769220D7B5500EC7E89 /* gui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gui.h; sourceTree = ""; }; AEE6276A220D7B5500EC7E89 /* gui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gui.cpp; sourceTree = ""; }; @@ -925,6 +932,7 @@ files = ( EBDF37531BB969F8001191B5 /* AudioUnit.framework in Frameworks */, EBDF37511BB969EE001191B5 /* CoreAudio.framework in Frameworks */, + AED73DC72303E57C00ECDB64 /* libSDL2.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -947,6 +955,7 @@ 84A388B51B1CDD3E000166C0 /* reicast-osx */, 84A388C61B1CDD3F000166C0 /* reicast-osxTests */, 84A388B41B1CDD3E000166C0 /* Products */, + AED73DC52303E57C00ECDB64 /* Frameworks */, ); sourceTree = ""; }; @@ -1023,6 +1032,7 @@ AE1E293E20A96B0B00FC6BA2 /* rec-x64 */, 84B7BE8F1B72720200F9733F /* reios */, 84B7BE981B72720200F9733F /* rend */, + AED73DBF2303E19100ECDB64 /* sdl */, AED73BAD22FC0E9600ECDB64 /* README.md */, 84B7BD121B72720100F9733F /* build.h */, 84B7BE6E1B72720200F9733F /* nullDC.cpp */, @@ -1962,6 +1972,26 @@ path = xbrz; sourceTree = ""; }; + AED73DBF2303E19100ECDB64 /* sdl */ = { + isa = PBXGroup; + children = ( + AED73DC02303E19100ECDB64 /* sdl.cpp */, + AED73DC12303E19100ECDB64 /* sdl.h */, + AED73DC22303E19100ECDB64 /* sdl_gamepad.h */, + AED73DC32303E19100ECDB64 /* sdl_keyboard.h */, + ); + name = sdl; + path = ../../../core/sdl; + sourceTree = ""; + }; + AED73DC52303E57C00ECDB64 /* Frameworks */ = { + isa = PBXGroup; + children = ( + AED73DC62303E57C00ECDB64 /* libSDL2.a */, + ); + name = Frameworks; + sourceTree = ""; + }; AEE6276C220D7B7E00EC7E89 /* imgui */ = { isa = PBXGroup; children = ( @@ -2404,6 +2434,7 @@ 84B7BF6A1B72720200F9733F /* audiobackend_pulseaudio.cpp in Sources */, 84B7BF3F1B72720200F9733F /* ta.cpp in Sources */, AE2A24DA22AE7EB600DD3034 /* ssa.cpp in Sources */, + AED73DC42303E19200ECDB64 /* sdl.cpp in Sources */, 84B7BF751B72720200F9733F /* gdrom_hle.cpp in Sources */, 84B7BEFF1B72720200F9733F /* zip_name_locate.c in Sources */, AE649BFD218C552500EF4A81 /* lpc_intrin_avx2.c in Sources */, @@ -2600,6 +2631,7 @@ _7ZIP_ST, CHD5_FLAC, "HAVE_CONFIG_H=1", + "USE_SDL=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -2652,6 +2684,7 @@ CHD5_FLAC, "HAVE_CONFIG_H=1", RELEASE, + "USE_SDL=1", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; @@ -2692,9 +2725,15 @@ "../../../core/deps/picotcp/**", ../../../core/deps/flac/include, ../../../core/deps/flac/src/libFLAC/include, + /usr/local/include, ); INFOPLIST_FILE = "emulator-osx/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + OTHER_LDFLAGS = ( + "-L", + /usr/local/lib, + ); + OTHER_LIBTOOLFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.flyinghead.Flycast; PRODUCT_NAME = "$(REI_APP_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "emulator-osx/emulator-osx-Bridging-Header.h"; @@ -2726,9 +2765,15 @@ "../../../core/deps/picotcp/**", ../../../core/deps/flac/include, ../../../core/deps/flac/src/libFLAC/include, + /usr/local/include, ); INFOPLIST_FILE = "emulator-osx/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + OTHER_LDFLAGS = ( + "-L", + /usr/local/lib, + ); + OTHER_LIBTOOLFLAGS = ""; PRODUCT_NAME = "$(REI_APP_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "emulator-osx/emulator-osx-Bridging-Header.h"; SWIFT_VERSION = 3.0; @@ -2854,9 +2899,15 @@ "../../../core/deps/picotcp/**", ../../../core/deps/flac/include, ../../../core/deps/flac/src/libFLAC/include, + /usr/local/include, ); INFOPLIST_FILE = "emulator-osx/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + OTHER_LDFLAGS = ( + "-L", + /usr/local/lib, + ); + OTHER_LIBTOOLFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.flyinghead.Flycast; PRODUCT_NAME = "$(REI_APP_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "emulator-osx/emulator-osx-Bridging-Header.h"; @@ -2960,9 +3011,15 @@ "../../../core/deps/picotcp/**", ../../../core/deps/flac/include, ../../../core/deps/flac/src/libFLAC/include, + /usr/local/include, ); INFOPLIST_FILE = "emulator-osx/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + OTHER_LDFLAGS = ( + "-L", + /usr/local/lib, + ); + OTHER_LIBTOOLFLAGS = ""; PRODUCT_NAME = "$(REI_APP_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "emulator-osx/emulator-osx-Bridging-Header.h"; SWIFT_VERSION = 3.0;