Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Haiku support #893

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Comment on lines +230 to +237

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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()
if (NOT HAIKU)
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})
else()
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)
endif()

I think the default condition should come first.


add_subdirectory(docs)

Expand Down
27 changes: 23 additions & 4 deletions libgamestream/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Comment on lines +9 to +11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (NOT HAIKU)
pkg_check_modules(AVAHI REQUIRED avahi-client)
endif()
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)
Expand All @@ -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()
Comment on lines +39 to +45

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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()
if(NOT HAIKU)
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})
else()
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})
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})

Expand Down
3 changes: 3 additions & 0 deletions libgamestream/discover.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __HAIKU__

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifndef __HAIKU__
#ifndef __HAIKU__

For consistency.


#include "errors.h"

Expand Down Expand Up @@ -116,3 +117,5 @@ void gs_discover_server(char* dest, unsigned short* port) {
if (simple_poll)
avahi_simple_poll_free(simple_poll);
}

#endif
4 changes: 4 additions & 0 deletions src/input/evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __HAIKU__

#include "evdev.h"

#include "keyboard.h"
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/input/udev.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __HAIKU__

#include "../loop.h"

#include "udev.h"
Expand Down Expand Up @@ -99,3 +101,5 @@ void udev_destroy() {
udev_monitor_unref(udev_mon);
udev_unref(udev);
}

#endif
2 changes: 2 additions & 0 deletions src/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __HAIKU__

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifndef __HAIKU__
#ifndef __HAIKU__


#include "loop.h"

Expand Down Expand Up @@ -114,3 +115,4 @@ void loop_main() {
}
}
}
#endif
22 changes: 22 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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();

Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down