git: 251a8452de9d - main - games/moonlight-embedded: Update to 2.6.2
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 14 Jan 2024 20:36:56 UTC
The branch main has been updated by diizzy:
URL: https://cgit.FreeBSD.org/ports/commit/?id=251a8452de9d0e60e294057899e992ed581077aa
commit 251a8452de9d0e60e294057899e992ed581077aa
Author: Armin Zhu <lisp_25689@163.com>
AuthorDate: 2024-01-14 08:45:36 +0000
Commit: Daniel Engberg <diizzy@FreeBSD.org>
CommitDate: 2024-01-14 20:35:24 +0000
games/moonlight-embedded: Update to 2.6.2
In addition to maintainers patch fix REINPLACE_CMD for docs/README.pod
Changelog:
https://github.com/moonlight-stream/moonlight-embedded/releases/tag/v2.6.2
PR: 276144
---
games/moonlight-embedded/Makefile | 16 +-
games/moonlight-embedded/distinfo | 6 +-
.../moonlight-embedded/files/patch-CMakeLists.txt | 53 +---
.../files/patch-docs_CMakeLists.txt | 8 -
.../moonlight-embedded/files/patch-docs_README.pod | 120 --------
.../files/patch-libgamestream_CMakeLists.txt | 2 +-
.../files/patch-libgamestream_client.c | 13 +-
.../files/patch-libgamestream_http.c | 6 +-
.../files/patch-src_audio_audio.h | 6 +-
.../moonlight-embedded/files/patch-src_audio_oss.c | 37 +--
games/moonlight-embedded/files/patch-src_config.c | 28 --
games/moonlight-embedded/files/patch-src_config.h | 10 -
.../files/patch-src_input_evdev.c | 248 +++++------------
.../moonlight-embedded/files/patch-src_input_sdl.c | 309 ---------------------
.../moonlight-embedded/files/patch-src_input_sdl.h | 8 -
.../moonlight-embedded/files/patch-src_input_x11.c | 185 ------------
games/moonlight-embedded/files/patch-src_main.c | 64 ++---
.../moonlight-embedded/files/patch-src_platform.c | 40 +--
games/moonlight-embedded/files/patch-src_sdl.c | 64 -----
games/moonlight-embedded/files/patch-src_sdl.h | 19 --
.../files/patch-src_video_ffmpeg__vaapi.c | 19 --
.../moonlight-embedded/files/patch-src_video_x11.c | 42 ---
...d__party_moonlight-common-c_enet_CMakeLists.txt | 26 --
games/moonlight-embedded/pkg-plist | 4 -
24 files changed, 162 insertions(+), 1171 deletions(-)
diff --git a/games/moonlight-embedded/Makefile b/games/moonlight-embedded/Makefile
index 62846f1b23f9..7fd965f80162 100644
--- a/games/moonlight-embedded/Makefile
+++ b/games/moonlight-embedded/Makefile
@@ -1,5 +1,5 @@
PORTNAME= moonlight-embedded
-DISTVERSION= 2.6.1
+DISTVERSION= 2.6.2
CATEGORIES= games
MASTER_SITES= https://github.com/moonlight-stream/moonlight-embedded/releases/download/v${DISTVERSION}/
@@ -33,10 +33,20 @@ USE_XORG= x11
NO_WRKSUBDIR= yes
CFLAGS+= -DHAS_SOCKLEN_T=1 -I${LOCALBASE}/include/libepoll-shim/
LDFLAGS+= -lepoll-shim
+CMAKE_OFF= ENABLE_CEC ENABLE_PULSE
+CMAKE_ON= ENET_NO_INSTALL
-post-patch:
- @${REINPLACE_CMD} -e 's@/usr/local@${PREFIX}@' \
+PLIST_FILES= bin/moonlight \
+ "@sample etc/moonlight.conf.sample" \
+ share/man/man1/moonlight.1.gz \
+ share/moonlight/gamecontrollerdb.txt
+
+post-extract:
+ @${REINPLACE_CMD} -e 's|/etc/moonlight/|${PREFIX}/etc/moonlight/|g' \
${WRKSRC}/docs/README.pod
+ @${REINPLACE_CMD} -e 's@/usr/local@${PREFIX}@' \
+ -e 's@/etc@${PREFIX}/etc@' \
+ ${WRKSRC}/src/config.c
post-install:
@${MV} ${STAGEDIR}${PREFIX}/etc/moonlight.conf \
diff --git a/games/moonlight-embedded/distinfo b/games/moonlight-embedded/distinfo
index d28e65f19dbf..fbade7d0fe56 100644
--- a/games/moonlight-embedded/distinfo
+++ b/games/moonlight-embedded/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1697067500
-SHA256 (moonlight-embedded-2.6.1.tar.xz) = 1a252e18ac637e0ad7180238fa868e04629a3d8e43232097d5ccaa3b4142fded
-SIZE (moonlight-embedded-2.6.1.tar.xz) = 327632
+TIMESTAMP = 1701007066
+SHA256 (moonlight-embedded-2.6.2.tar.xz) = 8bcc69b403a628efaf8686d40c0d1428b46defe4c65b06ff6ccc3fe32f0b2356
+SIZE (moonlight-embedded-2.6.2.tar.xz) = 328660
diff --git a/games/moonlight-embedded/files/patch-CMakeLists.txt b/games/moonlight-embedded/files/patch-CMakeLists.txt
index c5c6282c5376..fef9d3015b15 100644
--- a/games/moonlight-embedded/files/patch-CMakeLists.txt
+++ b/games/moonlight-embedded/files/patch-CMakeLists.txt
@@ -1,45 +1,14 @@
---- CMakeLists.txt.orig 2023-09-01 23:40:56 UTC
+--- CMakeLists.txt.orig 2023-11-03 06:08:34 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)
+@@ -87,6 +87,11 @@ add_executable(moonlight ${SRC_LIST})
+ target_link_libraries(moonlight m)
+ target_link_libraries(moonlight gamestream)
+
++if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
++ set(ALSA_FOUND FALSE)
++ target_sources(moonlight PRIVATE ./src/audio/oss.c)
++endif()
++
+ 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
deleted file mode 100644
index 5e6b83654eba..000000000000
--- a/games/moonlight-embedded/files/patch-docs_CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
---- 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
deleted file mode 100644
index 4763811ca71f..000000000000
--- a/games/moonlight-embedded/files/patch-docs_README.pod
+++ /dev/null
@@ -1,120 +0,0 @@
---- docs/README.pod.orig 2023-10-11 15:50:11 UTC
-+++ docs/README.pod
-@@ -13,7 +13,10 @@ Usage: I<moonlight> E<lt>actionE<gt> [options] [host]
-
- =item B<pair>
-
--Pair this computer with the host.
-+ Pair this computer with the host.
-+ If [host] is not specified here,moonlight will auto discover host first.
-+ It's need start avahi-daemon first.
-+ NOTE:It's not work under wifibox.
-
- =item B<unpair>
-
-@@ -22,6 +25,7 @@ Unpair this computer with the host.
- =item B<stream>
-
- Stream game from host to this computer.
-+If [host] is not specified here,moonlight will auto discover host first.
-
- =item B<list>
-
-@@ -99,9 +103,9 @@ By default, 1392 is used on LAN and 1024 on WAN.
- =item B<-codec> [I<CODEC>]
-
- 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<yes/no/auto>]
-
-@@ -138,8 +142,10 @@ By default the gamecontrollerdb.txt provided by Moonli
- =item B<-platform> [I<PLATFORM>]
-
- Select platform for audio and video output and input.
--<PLATFORM> can be pi, imx, aml, x11, x11_vdpau, sdl or fake.
-+<PLATFORM> 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,10 +176,11 @@ Enable the I<INPUT> device.
- By default all available input devices are enabled.
- Only evdev devices /dev/input/event* are supported.
-
--=item B<-audio> [I<DEVICE>]
-+=item B<-nosdl>
-
--Use <DEVICE> as audio output device.
--The default value is 'sysdefault' for ALSA and 'hdmi' for OMX on the Raspberry Pi.
-+Use libevdev to drive game controller instead.
-+SDL controller module have better compatibility for gamepad.
-+So it's not recommended.
-
- =item B<-windowed>
-
-@@ -182,22 +189,51 @@ 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
-+ /usr/local/etc/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 KEYBOARD SHORTCUTS
-+
-+ Use Ctrl+Alt+Shift+Q or Play+Back+LeftShoulder+RightShoulder to quit the streaming session.
-+ Use Ctrl+Alt+Shift+Z to Grab/Ungrab keyboard.
-+ It may not grab the keyboard Using sdl platform under wayland.
-+
-+=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
-
--Use Ctrl+Alt+Shift+Q or Play+Back+LeftShoulder+RightShoulder to quit the streaming session.
-+Platform 'sdl' and 'x11' is soft decoding.'x11' is deprecated.
-+Platform 'x11_vaapi' and 'x11_vdpau' is hard accel decoding.
-+If you want to use GPU decoding for intel gpu,you must meet 3 conditions:
-+ 1.Use platform 'x11_vaapi'
-+ 2.Use intel GPU driver in xorg.conf but not modesetting.
-+ 3.Install package:libva-intel-driver/libva-intel-media-driver or libva-vdpau-driver.
-
-+
- =head1 AUTHOR
-
--Iwan Timmer E<lt>irtimmer@gmail.comE<gt>
-+ Thanks Iwan Timmer and every contributor!
-+ Armin Zhu E<lt>lisp_25689@163.comE<gt>.
diff --git a/games/moonlight-embedded/files/patch-libgamestream_CMakeLists.txt b/games/moonlight-embedded/files/patch-libgamestream_CMakeLists.txt
index 4b13c31dafa9..a758f6c03392 100644
--- a/games/moonlight-embedded/files/patch-libgamestream_CMakeLists.txt
+++ b/games/moonlight-embedded/files/patch-libgamestream_CMakeLists.txt
@@ -1,4 +1,4 @@
---- libgamestream/CMakeLists.txt.orig 2023-09-01 23:40:56 UTC
+--- libgamestream/CMakeLists.txt.orig 2023-11-03 06:08:34 UTC
+++ libgamestream/CMakeLists.txt
@@ -3,7 +3,7 @@ set(SO_VERSION 4)
find_package(LibUUID REQUIRED)
diff --git a/games/moonlight-embedded/files/patch-libgamestream_client.c b/games/moonlight-embedded/files/patch-libgamestream_client.c
index 700b97ea461e..1efe5f0f8e14 100644
--- a/games/moonlight-embedded/files/patch-libgamestream_client.c
+++ b/games/moonlight-embedded/files/patch-libgamestream_client.c
@@ -1,13 +1,18 @@
---- libgamestream/client.c.orig 2023-09-01 23:40:56 UTC
+--- libgamestream/client.c.orig 2023-11-03 06:08:34 UTC
+++ libgamestream/client.c
-@@ -537,7 +537,11 @@ int gs_pair(PSERVER_DATA server, char* pin) {
+@@ -537,7 +537,16 @@ 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)
++
++#ifdef __FreeBSD__
++ #if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
X509_get0_signature(&asnSignature, NULL, cert);
-+#else
++ #else
+ asnSignature = cert->signature;
++ #endif
++#else
++ X509_get0_signature(&asnSignature, NULL, cert);
+#endif
char challenge_response[16 + SIGNATURE_LEN + sizeof(client_secret_data)];
diff --git a/games/moonlight-embedded/files/patch-libgamestream_http.c b/games/moonlight-embedded/files/patch-libgamestream_http.c
index 636e06ffd888..112582df9d7c 100644
--- a/games/moonlight-embedded/files/patch-libgamestream_http.c
+++ b/games/moonlight-embedded/files/patch-libgamestream_http.c
@@ -1,12 +1,12 @@
---- libgamestream/http.c.orig 2023-09-01 23:40:56 UTC
+--- libgamestream/http.c.orig 2023-11-03 06:08:34 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);
++#ifdef __FreeBSD__
+ curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1);
++#endif
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
index 58f9452db2da..66625239ed63 100644
--- a/games/moonlight-embedded/files/patch-src_audio_audio.h
+++ b/games/moonlight-embedded/files/patch-src_audio_audio.h
@@ -1,7 +1,9 @@
---- src/audio/audio.h.orig 2023-09-01 23:40:56 UTC
+--- src/audio/audio.h.orig 2023-11-03 06:08:34 UTC
+++ src/audio/audio.h
-@@ -31,3 +31,4 @@ extern AUDIO_RENDERER_CALLBACKS audio_callbacks_sdl;
+@@ -31,3 +31,6 @@ extern AUDIO_RENDERER_CALLBACKS audio_callbacks_sdl;
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_pulse;
bool audio_pulse_init(char* audio_device);
#endif
++#ifdef __FreeBSD__
+extern AUDIO_RENDERER_CALLBACKS audio_callbacks_oss;
++#endif
diff --git a/games/moonlight-embedded/files/patch-src_audio_oss.c b/games/moonlight-embedded/files/patch-src_audio_oss.c
index dfd79dd889d4..ddd61c493d8a 100644
--- a/games/moonlight-embedded/files/patch-src_audio_oss.c
+++ b/games/moonlight-embedded/files/patch-src_audio_oss.c
@@ -1,6 +1,6 @@
---- src/audio/oss.c.orig 2023-09-24 06:52:39 UTC
+--- src/audio/oss.c.orig 2024-01-01 05:31:28 UTC
+++ src/audio/oss.c
-@@ -0,0 +1,102 @@
+@@ -0,0 +1,105 @@
+/*
+ * This file is part of Moonlight Embedded.
+ *
@@ -20,21 +20,24 @@
+ * along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
+ */
+
++#ifdef __FreeBSD__
+#include <sys/soundcard.h>
++#include <sys/ioctl.h>
+#include "audio.h"
+
-+#include <stdio.h>
+#include <opus_multistream.h>
+
-+#include <sys/ioctl.h>
-+#include <unistd.h>
++#include <errno.h>
+#include <fcntl.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
+
+static OpusMSDecoder* decoder;
+static short* pcmBuffer;
+static int samplesPerFrame;
+static int channelCount;
-+static int fd;
++static int fd = -1;
+
+static int oss_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int arFlags) {
+ int rc;
@@ -46,27 +49,26 @@
+ if (pcmBuffer == NULL)
+ return -1;
+
-+ char* oss_name = "/dev/dsp";
++ const 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!!!");
++ printf("Open audio device /dev/dsp failed! error %d\n", errno);
+ return -1;
+ }
++ // buffer size for fragment ,selector 12 is 4096;11 is 2048;10 is 1024; 13is 8192
+ int frag = 12;
+ if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag) == -1)
-+ printf("Set framgment for /dev/dsp faild.");
++ printf("Set fragment for /dev/dsp failed.");
+
+ 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.");
++ printf("Set format for /dev/dsp failed.");
+ if (ioctl(fd, SNDCTL_DSP_CHANNELS, &channels) == -1)
-+ printf("Set channels for /dev/dsp faild.");
++ printf("Set channels for /dev/dsp failed.");
+ if (ioctl(fd, SNDCTL_DSP_SPEED, &rate) == -1)
-+ printf("Set sameple rate for /dev/dsp faild.");
++ printf("Set sample rate for /dev/dsp failed.");
+
+ return 0;
+}
@@ -82,9 +84,9 @@
+ pcmBuffer = NULL;
+ }
+
-+ if (fd != 0) {
++ if (fd != -1) {
+ close(fd);
-+ fd = 0;
++ fd = -1;
+ }
+}
+
@@ -92,7 +94,7 @@
+ int decodeLen = opus_multistream_decode(decoder, data, length, pcmBuffer, samplesPerFrame, 0);
+ if (decodeLen > 0) {
+ write(fd, pcmBuffer, decodeLen * channelCount * sizeof(short));
-+ } else {
++ } else if (decodeLen < 0) {
+ printf("Opus error from decode: %d\n", decodeLen);
+ }
+}
@@ -103,3 +105,4 @@
+ .decodeAndPlaySample = oss_renderer_decode_and_play_sample,
+ .capabilities = CAPABILITY_DIRECT_SUBMIT | CAPABILITY_SUPPORTS_ARBITRARY_AUDIO_DURATION,
+};
++#endif
diff --git a/games/moonlight-embedded/files/patch-src_config.c b/games/moonlight-embedded/files/patch-src_config.c
deleted file mode 100644
index 58b295aad0f0..000000000000
--- a/games/moonlight-embedded/files/patch-src_config.c
+++ /dev/null
@@ -1,28 +0,0 @@
---- src/config.c.orig 2023-10-11 15:50:11 UTC
-+++ src/config.c
-@@ -42,6 +42,7 @@
- #define write_config_bool(fd, key, value) fprintf(fd, "%s = %s\n", key, value ? "true":"false")
-
- bool inputAdded = false;
-+bool isNoSdl = false;
-
- static struct option long_options[] = {
- {"720", no_argument, NULL, 'a'},
-@@ -49,6 +50,7 @@ static struct option long_options[] = {
- {"4k", no_argument, NULL, '0'},
- {"width", required_argument, NULL, 'c'},
- {"height", required_argument, NULL, 'd'},
-+ {"nosdl", no_argument, NULL, 'e'},
- {"bitrate", required_argument, NULL, 'g'},
- {"packetsize", required_argument, NULL, 'h'},
- {"app", required_argument, NULL, 'i'},
-@@ -149,6 +151,9 @@ static void parse_argument(int c, char* value, PCONFIG
- break;
- case 'd':
- config->stream.height = atoi(value);
-+ break;
-+ case 'e':
-+ isNoSdl = true;
- break;
- case 'g':
- config->stream.bitrate = atoi(value);
diff --git a/games/moonlight-embedded/files/patch-src_config.h b/games/moonlight-embedded/files/patch-src_config.h
deleted file mode 100644
index f7b36617a241..000000000000
--- a/games/moonlight-embedded/files/patch-src_config.h
+++ /dev/null
@@ -1,10 +0,0 @@
---- src/config.h.orig 2023-10-11 15:50:11 UTC
-+++ src/config.h
-@@ -51,6 +51,7 @@ typedef struct _CONFIGURATION {
- } CONFIGURATION, *PCONFIGURATION;
-
- extern bool inputAdded;
-+extern bool isNoSdl;
-
- bool config_file_parse(char* filename, PCONFIGURATION config);
- void config_parse(int argc, char* argv[], PCONFIGURATION config);
diff --git a/games/moonlight-embedded/files/patch-src_input_evdev.c b/games/moonlight-embedded/files/patch-src_input_evdev.c
index b93c258415f6..f2812ca25ca6 100644
--- a/games/moonlight-embedded/files/patch-src_input_evdev.c
+++ b/games/moonlight-embedded/files/patch-src_input_evdev.c
@@ -1,211 +1,115 @@
---- src/input/evdev.c.orig 2023-10-11 15:50:11 UTC
+--- src/input/evdev.c.orig 2023-11-03 06:08:34 UTC
+++ src/input/evdev.c
-@@ -38,10 +38,16 @@
+@@ -38,9 +38,15 @@
#include <limits.h>
#include <unistd.h>
#include <pthread.h>
--#include <endian.h>
++#ifdef __linux__
+ #include <endian.h>
++#else
+#include <sys/endian.h>
++#endif
#include <math.h>
--#if __BYTE_ORDER == __LITTLE_ENDIAN
-+extern bool isNoSdl;
-+bool iskeyboardgrab = false;
-+void grab_window(bool grabstat);
-+static bool waitingToSwitchGrabOnModifierUp = false;
-+static bool isgrabkeyrelease = false;
++static bool isUseKbdmux = false;
+
-+#if _BYTE_ORDER == _LITTLE_ENDIAN
+ #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 +72,8 @@ struct input_device {
+@@ -66,8 +72,13 @@ struct input_device {
int hats_state[3][2];
int fd;
char modifiers;
-- __s32 mouseDeltaX, mouseDeltaY, mouseVScroll, mouseHScroll;
-- __s32 touchDownX, touchDownY, touchX, touchY;
++ #ifdef __linux__
+ __s32 mouseDeltaX, mouseDeltaY, mouseVScroll, mouseHScroll;
+ __s32 touchDownX, touchDownY, touchX, touchY;
++ #else
+ int32_t mouseDeltaX, mouseDeltaY, mouseVScroll, mouseHScroll;
+ int32_t touchDownX, touchDownY, touchX, touchY;
++ #endif
struct timeval touchDownTime;
struct timeval btnDownTime;
short controllerId;
-@@ -127,6 +133,7 @@ int evdev_gamepads = 0;
-
- #define ACTION_MODIFIERS (MODIFIER_SHIFT|MODIFIER_ALT|MODIFIER_CTRL)
- #define QUIT_KEY KEY_Q
-+#define GRAB_KEY KEY_Z
- #define QUIT_BUTTONS (PLAY_FLAG|BACK_FLAG|LB_FLAG|RB_FLAG)
-
- static bool (*handler) (struct input_event*, struct input_device*);
-@@ -139,6 +146,22 @@ static int evdev_get_map(int* map, int length, int val
- return -1;
- }
-
-+static short keystatlist[0xFF];
-+static void keyrelease(int keycode) {
-+ keystatlist[keycode] = 0;
-+}
-+static void keypress(int keycode) {
-+ keystatlist[keycode] = 1;
-+}
-+static void freeallkey () {
-+ for (int i=0;i<0xFF;i++) {
-+ if (keystatlist[i] == 1) {
-+ keystatlist[i] = 0;
-+ LiSendKeyboardEvent(0x80 << 8 | keyCodes[i], KEY_ACTION_UP, 0);
-+ }
-+ }
-+}
-+
- static bool evdev_init_parms(struct input_device *dev, struct input_abs_parms *parms, int code) {
- int abs = evdev_get_map(dev->abs_map, ABS_MAX, code);
-
-@@ -343,7 +366,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++) {
-@@ -398,15 +421,41 @@ static bool evdev_handle_event(struct input_event *ev,
- }
-
- // After the quit key combo is pressed, quit once all keys are raised
-- if ((dev->modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS &&
-- ev->code == QUIT_KEY && ev->value != 0) {
-- waitingToExitOnModifiersUp = true;
-- return true;
-- } else if (waitingToExitOnModifiersUp && dev->modifiers == 0)
-+ if ((dev->modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS && ev->value != 0) {
-+ if (ev->code == QUIT_KEY) {
-+ waitingToExitOnModifiersUp = true;
-+ return true;
-+ } else if (ev->code == GRAB_KEY && iskeyboardgrab) {
-+ waitingToSwitchGrabOnModifierUp = true;
-+ return true;
-+ }
-+ }
-+ if (waitingToSwitchGrabOnModifierUp) {
-+ if (ev->code == GRAB_KEY && ev->value == 0) {
-+ isgrabkeyrelease = true;
-+ if (dev->modifiers != 0)
-+ return true;
-+ }
-+ if (dev->modifiers == 0 && isgrabkeyrelease) {
-+ waitingToSwitchGrabOnModifierUp = false;
-+ isgrabkeyrelease = false;
-+ freeallkey();
-+ grab_window(!iskeyboardgrab);
-+ return true;
-+ }
-+ } else if (waitingToExitOnModifiersUp && dev->modifiers == 0) {
-+ freeallkey();
-+ grab_window(false);
- return false;
-+ }
-
-+ if (ev->value)
-+ keypress(ev->code);
-+ else
-+ keyrelease(ev->code);
- short code = 0x80 << 8 | keyCodes[ev->code];
- LiSendKeyboardEvent(code, ev->value?KEY_ACTION_DOWN:KEY_ACTION_UP, dev->modifiers);
-+
- } else {
- int mouseCode = 0;
- int gamepadCode = 0;
-@@ -749,8 +798,10 @@ static int evdev_handle(int fd) {
+@@ -749,7 +760,7 @@ static int evdev_handle(int fd) {
struct input_event ev;
while ((rc = libevdev_next_event(devices[i].dev, LIBEVDEV_READ_FLAG_NORMAL, &ev)) >= 0) {
if (rc == LIBEVDEV_READ_STATUS_SYNC)
- fprintf(stderr, "Error: cannot keep up\n");
+ fprintf(stderr, "Error:%s(%d) cannot keep up\n", libevdev_get_name(devices[i].dev), i);
else if (rc == LIBEVDEV_READ_STATUS_SUCCESS) {
-+ if (!iskeyboardgrab)
-+ break;
if (!handler(&ev, &devices[i]))
return LOOP_RETURN;
- }
-@@ -840,7 +891,28 @@ void evdev_create(const char* device, struct mapping*
+@@ -766,6 +777,39 @@ static int evdev_handle(int fd) {
+ return LOOP_OK;
+ }
+
++void is_use_kbdmux() {
++ const char* tryFirstInput = "/dev/input/event0";
++ const char* trySecondInput = "/dev/input/event1";
++
++ int fdFirst = open(tryFirstInput, O_RDWR|O_NONBLOCK);
++ int fdSecond = open(trySecondInput, O_RDWR|O_NONBLOCK);
++ if (fdFirst <= 0 && fdSecond <= 0) {
++ //Suppose use kbdmux because of default behavior
++ isUseKbdmux = true;
++ return;
++ }
++
++ struct libevdev *evdevFirst = libevdev_new();
++ libevdev_set_fd(evdevFirst, fdFirst);
++ const char* nameFirst = libevdev_get_name(evdevFirst);
++ struct libevdev *evdevSecond = libevdev_new();
++ libevdev_set_fd(evdevSecond, fdSecond);
++ const char* nameSecond = libevdev_get_name(evdevSecond);
++
++ libevdev_free(evdevFirst);
++ libevdev_free(evdevSecond);
++ close(fdFirst);
++ close(fdSecond);
++
++ if (strcmp(nameFirst, "System keyboard multiplexer") == 0 ||
++ strcmp(nameSecond, "System keyboard multiplexer") == 0) {
++ isUseKbdmux = true;
++ return;
++ }
++
++ return;
++}
++
+ void evdev_create(const char* device, struct mapping* mappings, bool verbose, int rotate) {
+ int fd = open(device, O_RDWR|O_NONBLOCK);
+ if (fd <= 0) {
+@@ -840,6 +884,33 @@ void evdev_create(const char* device, struct mapping*
libevdev_has_event_code(evdev, EV_ABS, ABS_WHEEL) ||
libevdev_has_event_code(evdev, EV_ABS, ABS_GAS) ||
libevdev_has_event_code(evdev, EV_ABS, ABS_BRAKE));
-+ bool is_acpibutton =
-+ is_keyboard &&
-+ (strcmp(libevdev_get_name(evdev), "Sleep Button") == 0 ||
-+ strcmp(libevdev_get_name(evdev), "Power Button") == 0);
-+ bool is_likekeyboard =
-+ is_keyboard &&
-+ (libevdev_get_id_version(evdev) > 1000 ||
-+ libevdev_get_id_bustype(evdev) <= 3);
-
++ bool is_acpibutton =
++ strcmp(name, "Sleep Button") == 0 ||
++ strcmp(name, "Power Button") == 0;
++ // Just use System keyboard multiplexer for FreeBSD,see kbdcontrol(1) and kbdmux(4)
++ // Trying to grab kbdmux0 and keyboard it's self at the same time results in
++ // the keyboard becoming unresponsive on FreeBSD.
++ bool is_likekeyboard =
++ is_keyboard && isUseKbdmux && strcmp(name, "System keyboard multiplexer") != 0;
++/*
++ (is_keyboard && guid[0] <= 3) ||
++ strcmp(name, "AT keyboard") == 0;
++*/
++
+ // In some cases,acpibutton can be mistaken for a keyboard and freeze the keyboard when tring grab.
+ if (is_acpibutton) {
+ if (verbose)
-+ printf("Do Not grab acpibutton: %s\n", libevdev_get_name(evdev));
-+ is_keyboard = false;
++ printf("Skip acpibutton: %s\n", name);
++ libevdev_free(evdev);
++ close(fd);
++ return;
+ }
-+ // In some cases,tring grab "Logitech USB Receiver Keyboard" will freeze the keyboard.
++ // In some cases,Do not grab likekeyboard for avoiding keyboard unresponsive
+ if (is_likekeyboard) {
+ if (verbose)
-+ printf("Do Not grab likekeyboard: %s,version: %d,bustype: %d\n", libevdev_get_name(evdev), libevdev_get_id_version(evdev), libevdev_get_id_bustype(evdev));
++ printf("Do NOT grab like-keyboard: %s,version: %d,bustype: %d\n", name, guid[6], guid[0]);
+ is_keyboard = false;
+ }
-+
+
if (is_accelerometer) {
if (verbose)
- printf("Ignoring accelerometer: %s\n", name);
-@@ -850,6 +922,13 @@ void evdev_create(const char* device, struct mapping*
- }
-
- if (is_gamepad) {
-+ if (!isNoSdl) {
-+ if (verbose)
-+ printf("Gamepad %s ignored,use sdl instead.\n", name);
-+ libevdev_free(evdev);
-+ close(fd);
-+ return;
-+ }
- evdev_gamepads++;
-
- if (mappings == NULL) {
-@@ -1054,11 +1133,7 @@ void evdev_start() {
- // code looks for. For this reason, we wait to grab until
- // 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) {
-- fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
-- }
-- }
-+ grab_window(true);
-
- // Any new input devices detected after this point will be grabbed immediately
- grabbingDevices = true;
-@@ -1111,4 +1186,23 @@ void evdev_rumble(unsigned short controller_id, unsign
- event.value = 1;
- write(device->fd, (const void*) &event, sizeof(event));
- device->haptic_effect_id = effect.id;
-+}
-+
-+void grab_window(bool grabstat) {
-+ if (grabstat != iskeyboardgrab) {
-+ int grabnum;
-+ if (iskeyboardgrab) {
-+ grabnum = 0;
-+ iskeyboardgrab = false;
-+ } else {
-+ grabnum = 1;
-+ iskeyboardgrab = true;
-+ }
-+ for (int i = 0; i < numDevices; i++) {
-+ if (devices[i].is_keyboard || devices[i].is_mouse || devices[i].is_touchscreen) {
-+ if (ioctl(devices[i].fd, EVIOCGRAB, grabnum) < 0)
-+ fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
-+ }
-+ }
-+ }
- }
diff --git a/games/moonlight-embedded/files/patch-src_input_sdl.c b/games/moonlight-embedded/files/patch-src_input_sdl.c
deleted file mode 100644
index 6b6278d8109e..000000000000
--- a/games/moonlight-embedded/files/patch-src_input_sdl.c
+++ /dev/null
@@ -1,309 +0,0 @@
---- src/input/sdl.c.orig 2023-10-08 02:12:37 UTC
-+++ src/input/sdl.c
-@@ -19,15 +19,23 @@
-
- #include "sdl.h"
- #include "../sdl.h"
-+#include "../loop.h"
-
-+#include <poll.h>
-+#include <fcntl.h>
-+#include <unistd.h>
- #include <Limelight.h>
-
- #define ACTION_MODIFIERS (MODIFIER_SHIFT|MODIFIER_ALT|MODIFIER_CTRL)
- #define QUIT_KEY SDLK_q
- #define QUIT_BUTTONS (PLAY_FLAG|BACK_FLAG|LB_FLAG|RB_FLAG)
- #define FULLSCREEN_KEY SDLK_f
--#define UNGRAB_KEY SDLK_z
-+#define UNGRAB_MOUSE_KEY SDLK_m
-+#define UNGRAB_WINDOW_KEY SDLK_z
-
-+static bool isx11sdlcall = false;
-+static int x11_sdl_event_handle(int fd);
-+
- static const int SDL_TO_LI_BUTTON_MAP[] = {
- A_FLAG, B_FLAG, X_FLAG, Y_FLAG,
- BACK_FLAG, SPECIAL_FLAG, PLAY_FLAG,
-@@ -51,6 +59,8 @@ typedef struct _GAMEPAD_STATE {
- int haptic_effect_id;
- #endif
- short id;
-+ int fd;
-+ bool fdadded;
- bool initialized;
- } GAMEPAD_STATE, *PGAMEPAD_STATE;
-
-@@ -62,6 +72,22 @@ static GAMEPAD_STATE gamepads[MAX_GAMEPADS];
- static int keyboard_modifiers;
- static int activeGamepadMask = 0;
-
-+static short keystatlist[0xFF];
-+static void keyrelease(int keycode) {
-+ keystatlist[keycode] = 0;
-+}
-+static void keypress(int keycode) {
-+ keystatlist[keycode] = 1;
-+}
-+static void freeallkey () {
-+ for (int i=0;i<0xFF;i++) {
-+ if (keystatlist[i] == 1) {
-+ keystatlist[i] = 0;
-+ LiSendKeyboardEvent(0x80 << 8 | i, KEY_ACTION_UP, 0);
-+ }
-+ }
-+}
-+
- int sdl_gamepads = 0;
-
- static void send_controller_arrival(PGAMEPAD_STATE state) {
-@@ -142,12 +168,22 @@ static PGAMEPAD_STATE get_gamepad(SDL_JoystickID sdl_i
- }
-
- static void add_gamepad(int joystick_index) {
-+ int fd;
- SDL_GameController* controller = SDL_GameControllerOpen(joystick_index);
- if (!controller) {
- fprintf(stderr, "Could not open gamecontroller %i: %s\n", joystick_index, SDL_GetError());
- return;
- }
--
-+ if (isx11sdlcall) {
-+ char* controllerpath = SDL_GameControllerPath(controller);
-+ fd = open(controllerpath, O_RDWR|O_NONBLOCK);
-+ if (fd == -1) {
-+ close(fd);
-+ fprintf(stderr, "Could not open gamecontroller from path: %s\n", controllerpath);
-+ return;
-+ }
-+ }
-+
- SDL_Joystick* joystick = SDL_GameControllerGetJoystick(controller);
- SDL_JoystickID joystick_id = SDL_JoystickInstanceID(joystick);
-
-@@ -166,10 +202,15 @@ static void add_gamepad(int joystick_index) {
- // Create a new gamepad state
- state = get_gamepad(joystick_id, true);
- state->controller = controller;
-+ if (isx11sdlcall) {
-+ state->fd = fd;
-+ loop_add_fd(state->fd, &x11_sdl_event_handle, POLLIN);
-+ state->fdadded = true;
-+ }
-
- #if !SDL_VERSION_ATLEAST(2, 0, 9)
- state->haptic = SDL_HapticOpenFromJoystick(joystick);
-- if (haptic && (SDL_HapticQuery(state->haptic) & SDL_HAPTIC_LEFTRIGHT) == 0) {
-+ if (state->haptic && (SDL_HapticQuery(state->haptic) & SDL_HAPTIC_LEFTRIGHT) == 0) {
- SDL_HapticClose(state->haptic);
- state->haptic = NULL;
- }
-@@ -182,6 +223,11 @@ static void add_gamepad(int joystick_index) {
- sdl_gamepads++;
- }
-
-+static void x11_add_gamepad(int joystick_index) {
-+ isx11sdlcall = true;
-+ add_gamepad(joystick_index);
-+}
-+
- static void remove_gamepad(SDL_JoystickID sdl_id) {
- for (int i = 0;i<MAX_GAMEPADS;i++) {
- if (gamepads[i].initialized && gamepads[i].sdl_id == sdl_id) {
-@@ -208,6 +254,20 @@ static void remove_gamepad(SDL_JoystickID sdl_id) {
- }
- }
-
-+static void x11_remove_gamepad(SDL_JoystickID sdl_id) {
-+ for (int i=0;i<MAX_GAMEPADS;i++) {
-+ if (gamepads[i].initialized && gamepads[i].sdl_id == sdl_id) {
-+ if (gamepads[i].fdadded) {
-+ loop_remove_fd(gamepads[i].fd);
-+ gamepads[i].fdadded = false;
-+ close(gamepads[i].fd);
-+ }
-+ remove_gamepad(gamepads[i].sdl_id);
-+ return;
-+ }
-+ }
-+}
-+
- void sdlinput_init(char* mappings) {
- memset(gamepads, 0, sizeof(gamepads));
-
-@@ -317,15 +377,28 @@ int sdlinput_handle_event(SDL_Window* window, SDL_Even
- keyboard_modifiers &= ~modifier;
- }
-
-- LiSendKeyboardEvent(0x80 << 8 | button, event->type==SDL_KEYDOWN?KEY_ACTION_DOWN:KEY_ACTION_UP, keyboard_modifiers);
--
- // Quit the stream if all the required quit keys are down
-- if ((keyboard_modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS && event->key.keysym.sym == QUIT_KEY && event->type==SDL_KEYUP)
-+ if ((keyboard_modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS && event->key.keysym.sym == QUIT_KEY && event->type==SDL_KEYUP) {
-+ freeallkey();
- return SDL_QUIT_APPLICATION;
-- else if ((keyboard_modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS && event->key.keysym.sym == FULLSCREEN_KEY && event->type==SDL_KEYUP)
-+ } else if ((keyboard_modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS && event->key.keysym.sym == FULLSCREEN_KEY && event->type==SDL_KEYUP) {
-+ freeallkey();
- return SDL_TOGGLE_FULLSCREEN;
-- else if ((keyboard_modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS && event->key.keysym.sym == UNGRAB_KEY && event->type==SDL_KEYUP)
-+ } else if ((keyboard_modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS && event->key.keysym.sym == UNGRAB_MOUSE_KEY && event->type==SDL_KEYUP) {
-+ freeallkey();
- return SDL_GetRelativeMouseMode() ? SDL_MOUSE_UNGRAB : SDL_MOUSE_GRAB;
-+ } else if ((keyboard_modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS && event->key.keysym.sym == UNGRAB_WINDOW_KEY && event->type==SDL_KEYUP) {
-+ freeallkey();
-+ return iskeyboardgrab ? SDL_WINDOW_UNGRAB : SDL_WINDOW_GRAB;
-+ }
-+
-+ if (event->type==SDL_KEYDOWN)
-+ keypress(button);
-+ else
-+ keyrelease(button);
-+
-+
-+ LiSendKeyboardEvent(0x80 << 8 | button, event->type==SDL_KEYDOWN?KEY_ACTION_DOWN:KEY_ACTION_UP, keyboard_modifiers);
- break;
- case SDL_FINGERDOWN:
- case SDL_FINGERMOTION:
-@@ -524,4 +597,139 @@ void sdlinput_set_controller_led(unsigned short contro
- #if SDL_VERSION_ATLEAST(2, 0, 14)
- SDL_GameControllerSetLED(state->controller, r, g, b);
- #endif
*** 712 LINES SKIPPED ***