diff --git a/CMakeLists.txt b/CMakeLists.txt index e7247215..deaedbe7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,8 +29,11 @@ option(ENABLE_X11 "Compile X11 support (requires ENABLE_FFMPEG)" ON) option(ENABLE_CEC "Compile CEC support" ON) option(ENABLE_PULSE "Compile PulseAudio support" ON) -pkg_check_modules(EVDEV REQUIRED libevdev) -pkg_check_modules(UDEV REQUIRED libudev) +if(NOT HAIKU) + pkg_check_modules(EVDEV REQUIRED libevdev) + pkg_check_modules(UDEV REQUIRED libudev) +endif() + if (ENABLE_SDL) pkg_check_modules(SDL sdl2>=2.0.4) endif() @@ -223,8 +226,15 @@ endif() configure_file("./src/configuration.h.in" "${PROJECT_BINARY_DIR}/configuration.h") set_property(TARGET moonlight PROPERTY COMPILE_DEFINITIONS ${MOONLIGHT_DEFINITIONS}) -target_include_directories(moonlight PRIVATE ${GAMESTREAM_INCLUDE_DIR} ${MOONLIGHT_COMMON_INCLUDE_DIR} ${OPUS_INCLUDE_DIRS} ${EVDEV_INCLUDE_DIRS} ${UDEV_INCLUDE_DIRS}) -target_link_libraries(moonlight ${EVDEV_LIBRARIES} ${OPUS_LIBRARY} ${UDEV_LIBRARIES} ${CMAKE_DL_LIBS}) + +if (HAIKU) + target_include_directories(moonlight PRIVATE ${GAMESTREAM_INCLUDE_DIR} ${MOONLIGHT_COMMON_INCLUDE_DIR} ${OPUS_INCLUDE_DIRS}) + target_link_libraries(moonlight ${OPUS_LIBRARY} ${CMAKE_DL_LIBS}) + target_link_libraries(moonlight network) +else() + target_include_directories(moonlight PRIVATE ${GAMESTREAM_INCLUDE_DIR} ${MOONLIGHT_COMMON_INCLUDE_DIR} ${OPUS_INCLUDE_DIRS} ${EVDEV_INCLUDE_DIRS} ${UDEV_INCLUDE_DIRS}) + target_link_libraries(moonlight ${EVDEV_LIBRARIES} ${OPUS_LIBRARY} ${UDEV_LIBRARIES} ${CMAKE_DL_LIBS}) +endif() add_subdirectory(docs) diff --git a/libgamestream/CMakeLists.txt b/libgamestream/CMakeLists.txt index 3b026ded..89527098 100644 --- a/libgamestream/CMakeLists.txt +++ b/libgamestream/CMakeLists.txt @@ -6,7 +6,9 @@ find_package(CURL REQUIRED) find_package(OpenSSL 1.0.2 REQUIRED) find_package(EXPAT REQUIRED) +if (NOT HAIKU) pkg_check_modules(AVAHI REQUIRED avahi-client) +endif() aux_source_directory(./ GAMESTREAM_SRC_LIST) aux_source_directory(../third_party/h264bitstream GAMESTREAM_SRC_LIST) @@ -15,17 +17,34 @@ aux_source_directory(../third_party/moonlight-common-c/enet MOONLIGHT_COMMON_SRC aux_source_directory(../third_party/moonlight-common-c/src MOONLIGHT_COMMON_SRC_LIST) aux_source_directory(../third_party/moonlight-common-c/reedsolomon MOONLIGHT_COMMON_SRC_LIST) -add_library(moonlight-common SHARED ${MOONLIGHT_COMMON_SRC_LIST}) +# Build shared library by default, but allows user override +if (NOT DEFINED BUILD_SHARED_LIBS) + set(BUILD_SHARED_LIBS ON) + set(BUILD_SHARED_LIBS_OVERRIDE ON) +endif() + +add_library(moonlight-common ${MOONLIGHT_COMMON_SRC_LIST}) +add_library(gamestream ${GAMESTREAM_SRC_LIST}) + +if (BUILD_SHARED_LIBS_OVERRIDE) + unset(BUILD_SHARED_LIBS) + unset(BUILD_SHARED_LIBS_OVERRIDE) +endif() -add_library(gamestream SHARED ${GAMESTREAM_SRC_LIST}) target_link_libraries(gamestream moonlight-common) set_target_properties(gamestream PROPERTIES SOVERSION ${SO_VERSION} VERSION ${PROJECT_VERSION}) set_target_properties(moonlight-common PROPERTIES SOVERSION ${SO_VERSION} VERSION ${PROJECT_VERSION}) -target_include_directories(gamestream PRIVATE ../third_party/moonlight-common-c/src ../third_party/h264bitstream ${AVAHI_INCLUDE_DIRS} ${LibUUID_INCLUDE_DIRS}) +if(HAIKU) + target_include_directories(gamestream PRIVATE ../third_party/moonlight-common-c/src ../third_party/h264bitstream ${LibUUID_INCLUDE_DIRS}) + target_link_libraries(gamestream ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ${EXPAT_LIBRARIES} ${LibUUID_LIBRARIES}) +else() + target_include_directories(gamestream PRIVATE ../third_party/moonlight-common-c/src ../third_party/h264bitstream ${AVAHI_INCLUDE_DIRS} ${LibUUID_INCLUDE_DIRS}) + target_link_libraries(gamestream ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ${EXPAT_LIBRARIES} ${AVAHI_LIBRARIES} ${LibUUID_LIBRARIES}) +endif() + target_include_directories(moonlight-common PRIVATE ../third_party/moonlight-common-c/reedsolomon ../third_party/moonlight-common-c/enet/include) -target_link_libraries(gamestream ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ${EXPAT_LIBRARIES} ${AVAHI_LIBRARIES} ${LibUUID_LIBRARIES}) target_link_libraries(gamestream ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) diff --git a/libgamestream/discover.c b/libgamestream/discover.c index 28cc052d..1c1b42f0 100644 --- a/libgamestream/discover.c +++ b/libgamestream/discover.c @@ -16,6 +16,7 @@ * You should have received a copy of the GNU General Public License * along with Moonlight; if not, see . */ +#ifndef __HAIKU__ #include "errors.h" @@ -116,3 +117,5 @@ void gs_discover_server(char* dest, unsigned short* port) { if (simple_poll) avahi_simple_poll_free(simple_poll); } + +#endif diff --git a/src/input/evdev.c b/src/input/evdev.c index 1f567b26..d9466526 100644 --- a/src/input/evdev.c +++ b/src/input/evdev.c @@ -17,6 +17,8 @@ * along with Moonlight; if not, see . */ +#ifndef __HAIKU__ + #include "evdev.h" #include "keyboard.h" @@ -1123,3 +1125,5 @@ void evdev_rumble(unsigned short controller_id, unsigned short low_freq_motor, u write(device->fd, (const void*) &event, sizeof(event)); device->haptic_effect_id = effect.id; } + +#endif diff --git a/src/input/udev.c b/src/input/udev.c index 6541ff10..a8d82266 100644 --- a/src/input/udev.c +++ b/src/input/udev.c @@ -17,6 +17,8 @@ * along with Moonlight; if not, see . */ +#ifndef __HAIKU__ + #include "../loop.h" #include "udev.h" @@ -99,3 +101,5 @@ void udev_destroy() { udev_monitor_unref(udev_mon); udev_unref(udev); } + +#endif diff --git a/src/loop.c b/src/loop.c index d356b8aa..1c2e94ae 100644 --- a/src/loop.c +++ b/src/loop.c @@ -16,6 +16,7 @@ * You should have received a copy of the GNU General Public License * along with Moonlight; if not, see . */ +#ifndef __HAIKU__ #include "loop.h" @@ -114,3 +115,4 @@ void loop_main() { } } } +#endif diff --git a/src/main.c b/src/main.c index ac210828..4137c8a5 100644 --- a/src/main.c +++ b/src/main.c @@ -91,7 +91,9 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys } int gamepads = 0; + #ifndef __HAIKU__ gamepads += evdev_gamepads; + #endif #ifdef HAVE_SDL gamepads += sdl_gamepads; #endif @@ -139,12 +141,15 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys connection_debug = true; } +#ifndef __HAIKU__ if (IS_EMBEDDED(system)) loop_init(); +#endif platform_start(system); LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system, config->audio_device), NULL, drFlags, config->audio_device, 0); +#ifndef __HAIKU__ if (IS_EMBEDDED(system)) { if (!config->viewonly) evdev_start(); @@ -156,6 +161,14 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys else if (system == SDL) sdl_loop(); #endif + #endif + + #ifdef __HAIKU__ + #ifdef HAVE_SDL + if (system == SDL) + sdl_loop(); + #endif + #endif LiStopConnection(); @@ -251,8 +264,10 @@ int main(int argc, char* argv[]) { exit(-1); } +#ifndef __HAIKU__ evdev_create(config.inputs[0], NULL, config.debug_level > 0, config.rotate); evdev_map(config.inputs[0]); +#endif exit(0); } @@ -263,8 +278,13 @@ int main(int argc, char* argv[]) { exit(-1); } config.address[0] = 0; + #ifndef __HAIKU__ printf("Searching for server...\n"); gs_discover_server(config.address, &config.port); + #else + config.address[0] = 0; + printf("gs_discover_server not working in Haiku...\n"); + #endif if (config.address[0] == 0) { fprintf(stderr, "Autodiscovery failed. Specify an IP address next time.\n"); exit(-1); @@ -346,6 +366,7 @@ int main(int argc, char* argv[]) { printf("View-only mode enabled, no input will be sent to the host computer\n"); } else { if (IS_EMBEDDED(system)) { + #ifndef __HAIKU__ char* mapping_env = getenv("SDL_GAMECONTROLLERCONFIG"); if (config.mapping == NULL && mapping_env == NULL) { fprintf(stderr, "Please specify mapping file as default mapping could not be found.\n"); @@ -375,6 +396,7 @@ int main(int argc, char* argv[]) { #ifdef HAVE_LIBCEC cec_init(); #endif /* HAVE_LIBCEC */ + #endif /* Haiku */ } #ifdef HAVE_SDL else if (system == SDL) {