diff --git a/games/moonlight-embedded/Makefile b/games/moonlight-embedded/Makefile index 425304aa8102..cb5234b0b748 100644 --- a/games/moonlight-embedded/Makefile +++ b/games/moonlight-embedded/Makefile @@ -1,50 +1,46 @@ PORTNAME= moonlight-embedded -DISTVERSION= 2.5.3 -PORTREVISION= 2 +DISTVERSION= 2.6.0 CATEGORIES= games -MASTER_SITES= https://github.com/irtimmer/moonlight-embedded/releases/download/v${DISTVERSION}/ +MASTER_SITES= https://github.com/moonlight-stream/moonlight-embedded/releases/download/v${DISTVERSION}/ -MAINTAINER= ports@FreeBSD.org +MAINTAINER= lisp_25689@163.com COMMENT= Gamestream client -WWW= https://github.com/irtimmer/moonlight-embedded +WWW= https://github.com/moonlight-stream/moonlight-embedded LICENSE= GPLv3+ LICENSE_FILE= ${WRKSRC}/LICENSE BUILD_DEPENDS= ${LOCALBASE}/include/linux/input.h:devel/evdev-proto LIB_DEPENDS= libavahi-client.so:net/avahi-app \ libavcodec.so:multimedia/ffmpeg \ libcurl.so:ftp/curl \ - libenet.so:net/enet \ - libexpat.so:textproc/expat2 \ + libepoll-shim.so:devel/libepoll-shim \ libevdev.so:devel/libevdev \ + libexpat.so:textproc/expat2 \ libopus.so:audio/opus \ libudev.so:devel/libudev-devd \ - libuuid.so:misc/e2fsprogs-libuuid + libuuid.so:misc/e2fsprogs-libuuid \ + libvdpau.so:multimedia/libvdpau \ + libva.so:multimedia/libva -USES= cmake localbase:ldflags perl5 pkgconfig sdl ssl tar:xz +USES= cmake gl localbase:ldflags perl5 pkgconfig sdl ssl tar:xz xorg USE_LDCONFIG= yes +USE_GL= egl glesv2 USE_PERL5= build USE_SDL= sdl2 +USE_XORG= x11 NO_WRKSUBDIR= yes CFLAGS+= -DHAS_SOCKLEN_T=1 -I${LOCALBASE}/include/libepoll-shim/ LDFLAGS+= -lepoll-shim -post-patch: - @${REINPLACE_CMD} -e '/(ALSA)/d' \ - -e '/libpulse-simple/d' \ - -e '/libcec/d' \ - ${WRKSRC}/CMakeLists.txt - @${REINPLACE_CMD} -e 's@SHARED@STATIC@' \ - -e 's@OpenSSL 1.0.2@OpenSSL@' -e '/^install(/d' \ - ${WRKSRC}/libgamestream/CMakeLists.txt +pre-configure: @${REINPLACE_CMD} -e 's@/etc/moonlight/moonlight.conf@${PREFIX}/etc/moonlight.conf@' \ -e 's@moonligt@moonlight@g' \ ${WRKSRC}/docs/README.pod post-install: @${MV} ${STAGEDIR}${PREFIX}/etc/moonlight.conf \ ${STAGEDIR}${PREFIX}/etc/moonlight.conf.sample .include diff --git a/games/moonlight-embedded/distinfo b/games/moonlight-embedded/distinfo index 54aac4821a61..40634ce7451a 100644 --- a/games/moonlight-embedded/distinfo +++ b/games/moonlight-embedded/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1666188557 -SHA256 (moonlight-embedded-2.5.3.tar.xz) = 2fcd00049f58b0af882f0eec7077013c062bc35c8705f3d6bb7949d44e98fac0 -SIZE (moonlight-embedded-2.5.3.tar.xz) = 303180 +TIMESTAMP = 1695536824 +SHA256 (moonlight-embedded-2.6.0.tar.xz) = 71c883e10c65085c82a75c9affaef5e63f43d9074df74d48039d8c9b83120df7 +SIZE (moonlight-embedded-2.6.0.tar.xz) = 324572 diff --git a/games/moonlight-embedded/files/patch-CMakeLists.txt b/games/moonlight-embedded/files/patch-CMakeLists.txt new file mode 100644 index 000000000000..c5c6282c5376 --- /dev/null +++ b/games/moonlight-embedded/files/patch-CMakeLists.txt @@ -0,0 +1,45 @@ +--- CMakeLists.txt.orig 2023-09-01 23:40:56 UTC ++++ CMakeLists.txt +@@ -5,14 +5,11 @@ SET(CMAKE_C_STANDARD 99) + include(${CMAKE_ROOT}/Modules/GNUInstallDirs.cmake) + include(${CMAKE_SOURCE_DIR}/cmake/generate_version_header.cmake) + +-add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-pointer-sign -Wno-sign-compare -Wno-switch) +- + aux_source_directory(./src SRC_LIST) + list(APPEND SRC_LIST ./src/input/evdev.c ./src/input/mapping.c ./src/input/udev.c) + + set(MOONLIGHT_DEFINITIONS) + +-find_package(ALSA) + find_package(Opus REQUIRED) + find_package(Broadcom-OMX) + find_package(Freescale) +@@ -46,10 +43,8 @@ if (ENABLE_FFMPEG) + endif() + endif() + if (ENABLE_PULSE) +- pkg_check_modules(PULSE libpulse-simple) + endif() + if (ENABLE_CEC) +- pkg_check_modules(CEC libcec>=4) + endif() + + pkg_check_modules(MMAL mmal) +@@ -91,7 +86,6 @@ if (CEC_FOUND) + list(APPEND MOONLIGHT_DEFINITIONS HAVE_LIBCEC) + list(APPEND MOONLIGHT_OPTIONS CEC) + target_sources(moonlight PRIVATE ./src/input/cec.c) +- target_include_directories(moonlight PRIVATE ./third_party/libcec ${CEC_INCLUDE_DIRS}) + target_link_libraries(moonlight ${CEC_LIBRARIES}) + endif() + +@@ -158,7 +152,7 @@ if (SOFTWARE_FOUND) + if(X11_FOUND) + list(APPEND MOONLIGHT_DEFINITIONS HAVE_X11) + list(APPEND MOONLIGHT_OPTIONS X11) +- target_sources(moonlight PRIVATE ./src/video/x11.c ./src/video/egl.c ./src/input/x11.c) ++ target_sources(moonlight PRIVATE ./src/video/x11.c ./src/video/egl.c ./src/input/x11.c ./src/audio/oss.c) + target_include_directories(moonlight PRIVATE ${XLIB_INCLUDE_DIRS} ${EGL_INCLUDE_DIRS} ${GLES_INCLUDE_DIRS}) + target_link_libraries(moonlight ${XLIB_LIBRARIES} ${EGL_LIBRARIES} ${GLES_LIBRARIES}) + endif() diff --git a/games/moonlight-embedded/files/patch-docs_CMakeLists.txt b/games/moonlight-embedded/files/patch-docs_CMakeLists.txt new file mode 100644 index 000000000000..5e6b83654eba --- /dev/null +++ b/games/moonlight-embedded/files/patch-docs_CMakeLists.txt @@ -0,0 +1,8 @@ +--- docs/CMakeLists.txt.orig 2023-09-01 23:40:56 UTC ++++ docs/CMakeLists.txt +@@ -1,4 +1,4 @@ +-add_custom_command(OUTPUT moonlight.1 COMMAND pod2man --section=1 --center="Moonlight Embedded Manual" --name="MOONLIGHT" --release="moonlight 2.5.0" ${CMAKE_CURRENT_SOURCE_DIR}/README.pod > moonlight.1) ++add_custom_command(OUTPUT moonlight.1 COMMAND pod2man --section=1 --center="Moonlight Embedded Manual" --name="MOONLIGHT" --release="moonlight 2.6.0" ${CMAKE_CURRENT_SOURCE_DIR}/README.pod > moonlight.1) + add_custom_target(docs ALL DEPENDS moonlight.1) + + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/moonlight.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff --git a/games/moonlight-embedded/files/patch-docs_README.pod b/games/moonlight-embedded/files/patch-docs_README.pod new file mode 100644 index 000000000000..f19916d281e1 --- /dev/null +++ b/games/moonlight-embedded/files/patch-docs_README.pod @@ -0,0 +1,105 @@ +--- docs/README.pod.orig 2023-09-01 23:40:56 UTC ++++ docs/README.pod +@@ -27,6 +27,11 @@ Stream game from host to this computer. + + List all available games and application on host. + ++=item B ++ ++Discover moonlight server host.Need start avahi-daemon first. ++NOTE:It's not work under wifibox. ++ + =item B + + Quit the current running game or application on host. +@@ -99,9 +104,9 @@ By default, 1392 is used on LAN and 1024 on WAN. + =item B<-codec> [I] + + Select codec to use. +-Can be 'auto', 'h264', 'h265', 'hevc', or 'av1'. +-Not all video decoders support H.265/HEVC or AV1. +-Will still use H.264 if server doesn't support HEVC or AV1. ++Can be 'auto', 'h264', 'h265', 'hevc' or 'av1'. ++Not all video decoders do support H.265/HEVC. ++Will still use H.264 if server doesn't support HEVC. + + =item B<-remote> [I] + +@@ -138,8 +143,10 @@ By default the gamecontrollerdb.txt provided by Moonli + =item B<-platform> [I] + + Select platform for audio and video output and input. +- can be pi, imx, aml, x11, x11_vdpau, sdl or fake. ++ can be x11, x11_vaapi, x11_vdpau, sdl or fake. + ++NOTE:x11_vaapi need libva library be installed.For intel,install libva-intel-driver/libva-intel-media-driver ++ + =item B<-nounsupported> + + Don't stream if resolution is not officially supported by the server +@@ -170,11 +177,6 @@ Enable the I device. + By default all available input devices are enabled. + Only evdev devices /dev/input/event* are supported. + +-=item B<-audio> [I] +- +-Use as audio output device. +-The default value is 'sysdefault' for ALSA and 'hdmi' for OMX on the Raspberry Pi. +- + =item B<-windowed> + + Display the stream in a window instead of fullscreen. +@@ -182,22 +184,48 @@ Only available when X11 or SDL platform is used. + + =back + ++=head1 EXAMPLE ++ ++Pair: ++ # moonlight pair 192.168.0.1 ++ ++Connect: ++ The following cmd means to connect 192.168.0.1 with a resolution 2560x1600. ++ # moonlight stream -app Desktop -width 2560 -height 1600 192.168.0.1 ++ The following cmd means to connect 192.168.0.1 with a resolution 1080p and the fps 120.And try to decoding with GPU. ++ # moonlight stream -app Steam -width 1920 -height 1080 -fps 120 -platform 'x11_vaapi' 192.168.0.1 ++ + =head1 CONFIG FILE + +-Moonlight Embedded will load a confiuration file from: ++Moonlight Embedded will load a configuration file from: + +- $XDG_CONFIG_HOME/moonligt/moonlight.conf (fallback to ~/.config/moonligt/moonlight.conf) ++ $XDG_CONFIG_HOME/moonlight/moonlight.conf (fallback to ~/.config/moonlight/moonlight.conf) + + If no user specified configuration file is available the configuration will be loaded from: + + /etc/moonlight/moonlight.conf + +-A documented example configuration file can be found at /etc/moonlight/moonlight.conf. ++A documented example configuration file can be found at /usr/local/etc/moonlight.conf. + +-=head1 COMMENTS ++=head1 KEYBOARD SHORTCUTS + + Use Ctrl+Alt+Shift+Q or Play+Back+LeftShoulder+RightShoulder to quit the streaming session. + ++=head1 GAMEPAD ++ ++FreeBSD supports fewer controllers.Please see hgame(4) xb360gp(4) ps4dshock(4) and FreeBSD forums... ++SDL platforms have better compatibility for gamepad. ++ ++=head1 COMMENTS ++ ++Platform 'sdl' and 'x11' is soft decoding. ++Platform 'x11_vaapi' and 'x11_vdpau' is hard decoding. ++If you want to use GPU decoding,you must meet 3 conditions: ++ 1.Use platform 'x11_vaapi' or 'x11_vdpau'. ++ 2.Use Intel or AMD(not test) GPU driver in xorg.conf ++ 3.Install package:libva-intel-driver/libva-intel-media-driver or libva-vdpau-driver. ++ + =head1 AUTHOR + +-Iwan Timmer Eirtimmer@gmail.comE ++Thanks Iwan Timmer and every contributor! ++Armin Zhu Elisp_25689@163.comE diff --git a/games/moonlight-embedded/files/patch-libgamestream_CMakeLists.txt b/games/moonlight-embedded/files/patch-libgamestream_CMakeLists.txt new file mode 100644 index 000000000000..4b13c31dafa9 --- /dev/null +++ b/games/moonlight-embedded/files/patch-libgamestream_CMakeLists.txt @@ -0,0 +1,29 @@ +--- libgamestream/CMakeLists.txt.orig 2023-09-01 23:40:56 UTC ++++ libgamestream/CMakeLists.txt +@@ -3,7 +3,7 @@ set(SO_VERSION 4) + find_package(LibUUID REQUIRED) + find_package(Threads REQUIRED) + find_package(CURL REQUIRED) +-find_package(OpenSSL 1.0.2 REQUIRED) ++find_package(OpenSSL REQUIRED) + find_package(EXPAT REQUIRED) + + pkg_check_modules(AVAHI REQUIRED avahi-client) +@@ -15,9 +15,9 @@ aux_source_directory(../third_party/moonlight-common-c + 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}) ++add_library(moonlight-common STATIC ${MOONLIGHT_COMMON_SRC_LIST}) + +-add_library(gamestream SHARED ${GAMESTREAM_SRC_LIST}) ++add_library(gamestream STATIC ${GAMESTREAM_SRC_LIST}) + target_link_libraries(gamestream moonlight-common) + + set_target_properties(gamestream PROPERTIES SOVERSION ${SO_VERSION} VERSION ${PROJECT_VERSION}) +@@ -28,5 +28,3 @@ target_include_directories(moonlight-common PRIVATE .. + 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}) +- +-install(TARGETS gamestream moonlight-common DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/games/moonlight-embedded/files/patch-libgamestream_client.c b/games/moonlight-embedded/files/patch-libgamestream_client.c index 5ff36594aa01..700b97ea461e 100644 --- a/games/moonlight-embedded/files/patch-libgamestream_client.c +++ b/games/moonlight-embedded/files/patch-libgamestream_client.c @@ -1,14 +1,14 @@ ---- libgamestream/client.c.orig 2018-08-11 15:43:13 UTC +--- libgamestream/client.c.orig 2023-09-01 23:40:56 UTC +++ libgamestream/client.c -@@ -505,7 +505,11 @@ int gs_pair(PSERVER_DATA server, char* pin) { - RAND_bytes(client_secret_data, 16); +@@ -537,7 +537,11 @@ int gs_pair(PSERVER_DATA server, char* pin) { + RAND_bytes(client_secret_data, sizeof(client_secret_data)); const ASN1_BIT_STRING *asnSignature; +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) X509_get0_signature(&asnSignature, NULL, cert); +#else + asnSignature = cert->signature; +#endif - char challenge_response[16 + 256 + 16]; + char challenge_response[16 + SIGNATURE_LEN + sizeof(client_secret_data)]; char challenge_response_hash[32]; diff --git a/games/moonlight-embedded/files/patch-libgamestream_http.c b/games/moonlight-embedded/files/patch-libgamestream_http.c new file mode 100644 index 000000000000..636e06ffd888 --- /dev/null +++ b/games/moonlight-embedded/files/patch-libgamestream_http.c @@ -0,0 +1,12 @@ +--- libgamestream/http.c.orig 2023-09-01 23:40:56 UTC ++++ libgamestream/http.c +@@ -73,6 +73,9 @@ int http_init(const char* keyDirectory, int logLevel) + int http_request(char* url, PHTTP_DATA data) { + curl_easy_setopt(curl, CURLOPT_WRITEDATA, data); + curl_easy_setopt(curl, CURLOPT_URL, url); ++ curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L); ++ curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1); ++ curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1); + + if (debug) + printf("Request %s\n", url); diff --git a/games/moonlight-embedded/files/patch-src_audio_audio.h b/games/moonlight-embedded/files/patch-src_audio_audio.h new file mode 100644 index 000000000000..58f9452db2da --- /dev/null +++ b/games/moonlight-embedded/files/patch-src_audio_audio.h @@ -0,0 +1,7 @@ +--- src/audio/audio.h.orig 2023-09-01 23:40:56 UTC ++++ src/audio/audio.h +@@ -31,3 +31,4 @@ extern AUDIO_RENDERER_CALLBACKS audio_callbacks_sdl; + extern AUDIO_RENDERER_CALLBACKS audio_callbacks_pulse; + bool audio_pulse_init(char* audio_device); + #endif ++extern AUDIO_RENDERER_CALLBACKS audio_callbacks_oss; diff --git a/games/moonlight-embedded/files/patch-src_audio_oss.c b/games/moonlight-embedded/files/patch-src_audio_oss.c new file mode 100644 index 000000000000..dfd79dd889d4 --- /dev/null +++ b/games/moonlight-embedded/files/patch-src_audio_oss.c @@ -0,0 +1,105 @@ +--- src/audio/oss.c.orig 2023-09-24 06:52:39 UTC ++++ src/audio/oss.c +@@ -0,0 +1,102 @@ ++/* ++ * This file is part of Moonlight Embedded. ++ * ++ * Copyright (C) 2015-2017 Iwan Timmer ++ * ++ * Moonlight is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * Moonlight is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with Moonlight; if not, see . ++ */ ++ ++#include ++#include "audio.h" ++ ++#include ++#include ++ ++#include ++#include ++#include ++ ++static OpusMSDecoder* decoder; ++static short* pcmBuffer; ++static int samplesPerFrame; ++static int channelCount; ++static int fd; ++ ++static int oss_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int arFlags) { ++ int rc; ++ decoder = opus_multistream_decoder_create(opusConfig->sampleRate, opusConfig->channelCount, opusConfig->streams, opusConfig->coupledStreams, opusConfig->mapping, &rc); ++ ++ channelCount = opusConfig->channelCount; ++ samplesPerFrame = opusConfig->samplesPerFrame; ++ pcmBuffer = malloc(sizeof(short) * channelCount * samplesPerFrame); ++ if (pcmBuffer == NULL) ++ return -1; ++ ++ char* oss_name = "/dev/dsp"; ++ fd = open(oss_name, O_WRONLY); ++ // buffer size for fragment ,selector 12 is 4096;11 is 2048;10 is 1024; 13is 8192 ++ if (fd == -1) { ++ close(fd); ++ printf("Open audio device /dev/dsp faild!!!"); ++ return -1; ++ } ++ int frag = 12; ++ if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag) == -1) ++ printf("Set framgment for /dev/dsp faild."); ++ ++ int format = AFMT_S16_LE; ++ int channels = opusConfig->channelCount; ++ int rate = opusConfig->sampleRate; ++ if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) == -1) ++ printf("Set framgment for /dev/dsp faild."); ++ if (ioctl(fd, SNDCTL_DSP_CHANNELS, &channels) == -1) ++ printf("Set channels for /dev/dsp faild."); ++ if (ioctl(fd, SNDCTL_DSP_SPEED, &rate) == -1) ++ printf("Set sameple rate for /dev/dsp faild."); ++ ++ return 0; ++} ++ ++static void oss_renderer_cleanup() { ++ if (decoder != NULL) { ++ opus_multistream_decoder_destroy(decoder); ++ decoder = NULL; ++ } ++ ++ if (pcmBuffer != NULL) { ++ free(pcmBuffer); ++ pcmBuffer = NULL; ++ } ++ ++ if (fd != 0) { ++ close(fd); ++ fd = 0; ++ } ++} ++ ++static void oss_renderer_decode_and_play_sample(char* data, int length) { ++ int decodeLen = opus_multistream_decode(decoder, data, length, pcmBuffer, samplesPerFrame, 0); ++ if (decodeLen > 0) { ++ write(fd, pcmBuffer, decodeLen * channelCount * sizeof(short)); ++ } else { ++ printf("Opus error from decode: %d\n", decodeLen); ++ } ++} ++ ++AUDIO_RENDERER_CALLBACKS audio_callbacks_oss = { ++ .init = oss_renderer_init, ++ .cleanup = oss_renderer_cleanup, ++ .decodeAndPlaySample = oss_renderer_decode_and_play_sample, ++ .capabilities = CAPABILITY_DIRECT_SUBMIT | CAPABILITY_SUPPORTS_ARBITRARY_AUDIO_DURATION, ++}; diff --git a/games/moonlight-embedded/files/patch-src_input_evdev.c b/games/moonlight-embedded/files/patch-src_input_evdev.c index 2fbd4ff994f1..5daa32c63111 100644 --- a/games/moonlight-embedded/files/patch-src_input_evdev.c +++ b/games/moonlight-embedded/files/patch-src_input_evdev.c @@ -1,26 +1,60 @@ ---- src/input/evdev.c.orig 2021-12-20 00:24:48 UTC +--- src/input/evdev.c.orig 2023-09-01 23:40:56 UTC +++ src/input/evdev.c -@@ -38,10 +38,10 @@ +@@ -38,10 +38,12 @@ #include #include #include -#include +#include #include -#if __BYTE_ORDER == __LITTLE_ENDIAN ++bool iskeyboardgrab = true; ++ +#if _BYTE_ORDER == _LITTLE_ENDIAN #define int16_to_le(val) val #else #define int16_to_le(val) ((((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00)) -@@ -66,8 +66,8 @@ struct input_device { +@@ -66,8 +68,8 @@ struct input_device { int hats_state[3][2]; int fd; char modifiers; -- __s32 mouseDeltaX, mouseDeltaY, mouseScroll; +- __s32 mouseDeltaX, mouseDeltaY, mouseVScroll, mouseHScroll; - __s32 touchDownX, touchDownY, touchX, touchY; -+ int32_t mouseDeltaX, mouseDeltaY, mouseScroll; ++ int32_t mouseDeltaX, mouseDeltaY, mouseVScroll, mouseHScroll; + int32_t touchDownX, touchDownY, touchX, touchY; struct timeval touchDownTime; struct timeval btnDownTime; short controllerId; +@@ -343,7 +345,7 @@ static bool evdev_handle_event(struct input_event *ev, + if (dev->mouseHScroll != 0) { + LiSendHScrollEvent(dev->mouseHScroll); + dev->mouseHScroll = 0; +- } ++ } + if (dev->gamepadModified) { + if (dev->controllerId < 0) { + for (int i = 0; i < MAX_GAMEPADS; i++) { +@@ -813,7 +815,7 @@ void evdev_create(const char* device, struct mapping* + if (mappings == NULL && strstr(name, "Xbox 360 Wireless Receiver") != NULL) + mappings = xwc_mapping; + +- bool is_keyboard = libevdev_has_event_code(evdev, EV_KEY, KEY_Q); ++ bool is_keyboard = libevdev_has_event_code(evdev, EV_KEY, KEY_Q) && libevdev_get_id_version(evdev) < 500; + bool is_mouse = libevdev_has_event_type(evdev, EV_REL) || libevdev_has_event_code(evdev, EV_KEY, BTN_LEFT); + bool is_touchscreen = libevdev_has_event_code(evdev, EV_KEY, BTN_TOUCH); + +@@ -1055,8 +1057,12 @@ void evdev_start() { + // we're ready to take input events. Ctrl+C works up until + // this point. + for (int i = 0; i < numDevices; i++) { +- if ((devices[i].is_keyboard || devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) { ++ if ((devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) { + fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno); ++ } ++ if (devices[i].is_keyboard && libevdev_get_id_bustype(devices[i].dev) > 3) { ++ if (ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) ++ fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno); + } + } + diff --git a/games/moonlight-embedded/files/patch-src_main.c b/games/moonlight-embedded/files/patch-src_main.c new file mode 100644 index 000000000000..6589a8ab876a --- /dev/null +++ b/games/moonlight-embedded/files/patch-src_main.c @@ -0,0 +1,64 @@ +--- src/main.c.orig 2023-09-01 23:40:56 UTC ++++ src/main.c +@@ -42,6 +42,7 @@ + #include + #include + ++#include + #include + #include + #include +@@ -52,7 +53,6 @@ + #include + #include + #include +-#include + + static void applist(PSERVER_DATA server) { + PAPP_LIST list = NULL; +@@ -202,7 +202,6 @@ static void help() { + printf("\t-bitrate \tSpecify the bitrate in Kbps\n"); + printf("\t-packetsize \tSpecify the maximum packetsize in bytes\n"); + printf("\t-codec \t\tSelect used codec: auto/h264/h265/av1 (default auto)\n"); +- printf("\t-hdr\t\tEnable HDR streaming (experimental, requires host and device support)\n"); + printf("\t-remote \t\t\tEnable optimizations for WAN streaming (default auto)\n"); + printf("\t-app \t\tName of app to stream\n"); + printf("\t-nosops\t\t\tDon't allow GFE to modify game settings\n"); +@@ -322,19 +321,19 @@ int main(int argc, char* argv[]) { + config.stream.supportedVideoFormats = VIDEO_FORMAT_H264; + if (config.codec == CODEC_HEVC || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, CODEC_HEVC))) { + config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265; +- if (config.hdr) +- config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10; ++ //if (config.hdr) ++ // config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10; + } + if (config.codec == CODEC_AV1 || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, CODEC_AV1))) { + config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN8; +- if (config.hdr) +- config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10; ++ //if (config.hdr) ++ // config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10; + } + +- if (config.hdr && !(config.stream.supportedVideoFormats & VIDEO_FORMAT_MASK_10BIT)) { +- fprintf(stderr, "HDR streaming requires HEVC or AV1 codec\n"); +- exit(-1); +- } ++ //if (config.hdr && !(config.stream.supportedVideoFormats & VIDEO_FORMAT_MASK_10BIT)) { ++ // fprintf(stderr, "HDR streaming requires HEVC or AV1 codec\n"); ++ // exit(-1); ++ //} + + #ifdef HAVE_SDL + if (system == SDL) +@@ -398,7 +397,8 @@ int main(int argc, char* argv[]) { + if (config.pin > 0 && config.pin <= 9999) { + sprintf(pin, "%04d", config.pin); + } else { +- sprintf(pin, "%d%d%d%d", (unsigned)random() % 10, (unsigned)random() % 10, (unsigned)random() % 10, (unsigned)random() % 10); ++ srand((unsigned)time(NULL)); ++ sprintf(pin, "%04d", (unsigned)rand() % 9999 + 1); + } + printf("Please enter the following PIN on the target PC: %s\n", pin); + fflush(stdout); diff --git a/games/moonlight-embedded/files/patch-src_platform.c b/games/moonlight-embedded/files/patch-src_platform.c index d9cddad61b50..278ea160ccac 100644 --- a/games/moonlight-embedded/files/patch-src_platform.c +++ b/games/moonlight-embedded/files/patch-src_platform.c @@ -1,17 +1,40 @@ ---- src/platform.c.orig 2021-12-20 00:24:48 UTC +--- src/platform.c.orig 2023-09-01 23:40:56 UTC +++ src/platform.c -@@ -188,14 +188,6 @@ AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum plat - return (PAUDIO_RENDERER_CALLBACKS) dlsym(RTLD_DEFAULT, "audio_callbacks_omx"); +@@ -77,8 +77,8 @@ enum platform platform_check(char* name) { + bool x11 = strcmp(name, "x11") == 0; + bool vdpau = strcmp(name, "x11_vdpau") == 0; + bool vaapi = strcmp(name, "x11_vaapi") == 0; +- if (std || x11 || vdpau || vaapi) { +- int init = x11_init(std || vdpau, std || vaapi); ++ if (x11 || vdpau || vaapi) { ++ int init = x11_init(vdpau, vaapi); + #ifdef HAVE_VAAPI + if (init == INIT_VAAPI) + return X11_VAAPI; +@@ -87,11 +87,7 @@ enum platform platform_check(char* name) { + if (init == INIT_VDPAU) + return X11_VDPAU; + #endif +- #ifdef HAVE_SDL +- return SDL; +- #else + return X11; +- #endif + } + #endif + #ifdef HAVE_SDL +@@ -195,13 +191,7 @@ AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum plat // fall-through #endif -- default: + default: - #ifdef HAVE_PULSE - if (audio_pulse_init(audio_device)) - return &audio_callbacks_pulse; - #endif - #ifdef HAVE_ALSA - return &audio_callbacks_alsa; - #endif ++ return &audio_callbacks_oss; } return NULL; } diff --git a/games/moonlight-embedded/files/patch-src_video_ffmpeg__vaapi.c b/games/moonlight-embedded/files/patch-src_video_ffmpeg__vaapi.c new file mode 100644 index 000000000000..e91d34a4276e --- /dev/null +++ b/games/moonlight-embedded/files/patch-src_video_ffmpeg__vaapi.c @@ -0,0 +1,19 @@ +--- src/video/ffmpeg_vaapi.c.orig 2023-09-01 23:40:56 UTC ++++ src/video/ffmpeg_vaapi.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + #define MAX_SURFACES 16 + +@@ -59,7 +60,7 @@ static int va_get_buffer(AVCodecContext* context, AVFr + } + + int vaapi_init_lib() { +- return av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_VAAPI, ":0", NULL, 0); ++ return av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_VAAPI, getenv("DISPLAY") == NULL ? ":0" : getenv("DISPLAY"), NULL, 0); + } + + int vaapi_init(AVCodecContext* decoder_ctx) { diff --git a/games/moonlight-embedded/files/patch-third__party_moonlight-common-c_enet_CMakeLists.txt b/games/moonlight-embedded/files/patch-third__party_moonlight-common-c_enet_CMakeLists.txt new file mode 100644 index 000000000000..2569c15301b0 --- /dev/null +++ b/games/moonlight-embedded/files/patch-third__party_moonlight-common-c_enet_CMakeLists.txt @@ -0,0 +1,14 @@ +--- third_party/moonlight-common-c/enet/CMakeLists.txt.orig 2023-07-30 18:58:58 UTC ++++ third_party/moonlight-common-c/enet/CMakeLists.txt +@@ -107,11 +107,3 @@ target_include_directories(enet SYSTEM PUBLIC include) + if (MINGW) + target_link_libraries(enet winmm ws2_32) + endif() +- +-install(TARGETS enet +- RUNTIME DESTINATION bin +- ARCHIVE DESTINATION lib/static +- LIBRARY DESTINATION lib) +- +-install(DIRECTORY include/ +- DESTINATION include) diff --git a/games/moonlight-embedded/pkg-descr b/games/moonlight-embedded/pkg-descr index 03d3a44469c9..5678182a53b3 100644 --- a/games/moonlight-embedded/pkg-descr +++ b/games/moonlight-embedded/pkg-descr @@ -1,5 +1,10 @@ Moonlight Embedded is an open source implementation of NVIDIA's GameStream, as used by the NVIDIA Shield. Moonlight Embedded allows you to stream your full collection of games from your powerful Windows desktop to your FreeBSD system. + +First, pair: # moonlight pair 192.168.0.1 +Then, connect: # moonlight stream -app Desktop -1080 192.168.0.1 + +ENJOY!