summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--games/moonlight-embedded/Makefile16
-rw-r--r--games/moonlight-embedded/distinfo6
-rw-r--r--games/moonlight-embedded/files/patch-CMakeLists.txt53
-rw-r--r--games/moonlight-embedded/files/patch-docs_CMakeLists.txt8
-rw-r--r--games/moonlight-embedded/files/patch-docs_README.pod120
-rw-r--r--games/moonlight-embedded/files/patch-libgamestream_CMakeLists.txt2
-rw-r--r--games/moonlight-embedded/files/patch-libgamestream_client.c13
-rw-r--r--games/moonlight-embedded/files/patch-libgamestream_http.c6
-rw-r--r--games/moonlight-embedded/files/patch-src_audio_audio.h6
-rw-r--r--games/moonlight-embedded/files/patch-src_audio_oss.c37
-rw-r--r--games/moonlight-embedded/files/patch-src_config.c28
-rw-r--r--games/moonlight-embedded/files/patch-src_config.h10
-rw-r--r--games/moonlight-embedded/files/patch-src_input_evdev.c248
-rw-r--r--games/moonlight-embedded/files/patch-src_input_sdl.c309
-rw-r--r--games/moonlight-embedded/files/patch-src_input_sdl.h8
-rw-r--r--games/moonlight-embedded/files/patch-src_input_x11.c185
-rw-r--r--games/moonlight-embedded/files/patch-src_main.c64
-rw-r--r--games/moonlight-embedded/files/patch-src_platform.c40
-rw-r--r--games/moonlight-embedded/files/patch-src_sdl.c64
-rw-r--r--games/moonlight-embedded/files/patch-src_sdl.h19
-rw-r--r--games/moonlight-embedded/files/patch-src_video_ffmpeg__vaapi.c19
-rw-r--r--games/moonlight-embedded/files/patch-src_video_x11.c42
-rw-r--r--games/moonlight-embedded/files/patch-third__party_moonlight-common-c_enet_CMakeLists.txt26
-rw-r--r--games/moonlight-embedded/pkg-plist4
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
--}
-\ No newline at end of file
-+}
-+
-+static int x11_sdlinput_handle_event(SDL_Event* event) {
-+ int button = 0;
-+ unsigned char touchEventType;
-+ PGAMEPAD_STATE gamepad;
-+ switch (event->type) {
-+ case SDL_CONTROLLERAXISMOTION:
-+ gamepad = get_gamepad(event->caxis.which, false);
-+ if (!gamepad)
-+ return SDL_NOTHING;
-+ switch (event->caxis.axis) {
-+ case SDL_CONTROLLER_AXIS_LEFTX:
-+ gamepad->leftStickX = event->caxis.value;
-+ break;
-+ case SDL_CONTROLLER_AXIS_LEFTY:
-+ gamepad->leftStickY = -SDL_max(event->caxis.value, (short)-32767);
-+ break;
-+ case SDL_CONTROLLER_AXIS_RIGHTX:
-+ gamepad->rightStickX = event->caxis.value;
-+ break;
-+ case SDL_CONTROLLER_AXIS_RIGHTY:
-+ gamepad->rightStickY = -SDL_max(event->caxis.value, (short)-32767);
-+ break;
-+ case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
-+ gamepad->leftTrigger = (unsigned char)(event->caxis.value * 255UL / 32767);
-+ break;
-+ case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
-+ gamepad->rightTrigger = (unsigned char)(event->caxis.value * 255UL / 32767);
-+ break;
-+ default:
-+ return SDL_NOTHING;
-+ }
-+ LiSendMultiControllerEvent(gamepad->id, activeGamepadMask, gamepad->buttons, gamepad->leftTrigger, gamepad->rightTrigger, gamepad->leftStickX, gamepad->leftStickY, gamepad->rightStickX, gamepad->rightStickY);
-+ break;
-+ case SDL_CONTROLLERBUTTONDOWN:
-+ case SDL_CONTROLLERBUTTONUP:
-+ gamepad = get_gamepad(event->cbutton.which, false);
-+ if (!gamepad)
-+ return SDL_NOTHING;
-+ if (event->cbutton.button >= SDL_arraysize(SDL_TO_LI_BUTTON_MAP))
-+ return SDL_NOTHING;
-+
-+ if (event->type == SDL_CONTROLLERBUTTONDOWN)
-+ gamepad->buttons |= SDL_TO_LI_BUTTON_MAP[event->cbutton.button];
-+ else
-+ gamepad->buttons &= ~SDL_TO_LI_BUTTON_MAP[event->cbutton.button];
-+
-+ if ((gamepad->buttons & QUIT_BUTTONS) == QUIT_BUTTONS)
-+ return SDL_QUIT_APPLICATION;
-+
-+ LiSendMultiControllerEvent(gamepad->id, activeGamepadMask, gamepad->buttons, gamepad->leftTrigger, gamepad->rightTrigger, gamepad->leftStickX, gamepad->leftStickY, gamepad->rightStickX, gamepad->rightStickY);
-+ break;
-+ case SDL_CONTROLLERDEVICEADDED:
-+ x11_add_gamepad(event->cdevice.which);
-+ break;
-+ case SDL_CONTROLLERDEVICEREMOVED:
-+ x11_remove_gamepad(event->cdevice.which);
-+ break;
-+#if SDL_VERSION_ATLEAST(2, 0, 14)
-+ case SDL_CONTROLLERSENSORUPDATE:
-+ gamepad = get_gamepad(event->csensor.which, false);
-+ if (!gamepad)
-+ return SDL_NOTHING;
-+ switch (event->csensor.sensor) {
-+ case SDL_SENSOR_ACCEL:
-+ LiSendControllerMotionEvent(gamepad->id, LI_MOTION_TYPE_ACCEL, event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]);
-+ break;
-+ case SDL_SENSOR_GYRO:
-+ // Convert rad/s to deg/s
-+ LiSendControllerMotionEvent(gamepad->id, LI_MOTION_TYPE_GYRO,
-+ event->csensor.data[0] * 57.2957795f,
-+ event->csensor.data[1] * 57.2957795f,
-+ event->csensor.data[2] * 57.2957795f);
-+ break;
-+ }
-+ break;
-+ case SDL_CONTROLLERTOUCHPADDOWN:
-+ case SDL_CONTROLLERTOUCHPADUP:
-+ case SDL_CONTROLLERTOUCHPADMOTION:
-+ gamepad = get_gamepad(event->ctouchpad.which, false);
-+ if (!gamepad)
-+ return SDL_NOTHING;
-+ switch (event->type) {
-+ case SDL_CONTROLLERTOUCHPADDOWN:
-+ touchEventType = LI_TOUCH_EVENT_DOWN;
-+ break;
-+ case SDL_CONTROLLERTOUCHPADUP:
-+ touchEventType = LI_TOUCH_EVENT_UP;
-+ break;
-+ case SDL_CONTROLLERTOUCHPADMOTION:
-+ touchEventType = LI_TOUCH_EVENT_MOVE;
-+ break;
-+ default:
-+ return SDL_NOTHING;
-+ }
-+ LiSendControllerTouchEvent(gamepad->id, touchEventType, event->ctouchpad.finger,
-+ event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure);
-+ break;
-+#endif
-+ }
-+
-+ return SDL_NOTHING;
-+}
-+
-+static int x11_sdl_event_handle(int fd) {
-+ SDL_Event event;
-+ for (int i=0;i<MAX_GAMEPADS;i++) {
-+ if (gamepads[i].fd == fd) {
-+ int rc;
-+ while (SDL_PollEvent(&event)) {
-+ rc = x11_sdlinput_handle_event(&event);
-+ if (rc == SDL_QUIT_APPLICATION)
-+ return LOOP_RETURN;
-+ }
-+ }
-+ }
-+ return LOOP_OK;
-+}
-+
-+void x11_sdl_init(char* mappings) {
-+ isx11sdlcall = true;
-+ sdlinput_init(mappings);
-+}
-+
-+void x11_sdl_stop() {
-+ for (int i=0;i<MAX_GAMEPADS;i++) {
-+ if (gamepads[i].initialized && gamepads[i].fdadded) {
-+ loop_remove_fd(gamepads[i].fd);
-+ gamepads[i].fdadded = false;
-+ close(gamepads[i].fd);
-+ remove_gamepad(gamepads[i].sdl_id);
-+ }
-+ }
-+ SDL_Quit();
-+}
diff --git a/games/moonlight-embedded/files/patch-src_input_sdl.h b/games/moonlight-embedded/files/patch-src_input_sdl.h
deleted file mode 100644
index 5ccc7cf8b321..000000000000
--- a/games/moonlight-embedded/files/patch-src_input_sdl.h
+++ /dev/null
@@ -1,8 +0,0 @@
---- src/input/sdl.h.orig 2023-10-11 15:50:11 UTC
-+++ src/input/sdl.h
-@@ -105,3 +105,5 @@ void sdlinput_rumble(unsigned short controller_id, uns
- void sdlinput_rumble_triggers(unsigned short controller_id, unsigned short left_trigger, unsigned short right_trigger);
- void sdlinput_set_motion_event_state(unsigned short controller_id, unsigned char motion_type, unsigned short report_rate_hz);
- void sdlinput_set_controller_led(unsigned short controller_id, unsigned char r, unsigned char g, unsigned char b);
-+void x11_sdl_init(char* mappings);
-+void x11_sdl_stop();
diff --git a/games/moonlight-embedded/files/patch-src_input_x11.c b/games/moonlight-embedded/files/patch-src_input_x11.c
deleted file mode 100644
index 582b15b405cd..000000000000
--- a/games/moonlight-embedded/files/patch-src_input_x11.c
+++ /dev/null
@@ -1,185 +0,0 @@
---- src/input/x11.c.orig 2023-10-08 02:12:37 UTC
-+++ src/input/x11.c
-@@ -33,6 +33,8 @@
-
- #define ACTION_MODIFIERS (MODIFIER_SHIFT|MODIFIER_ALT|MODIFIER_CTRL)
- #define QUIT_KEY 0x18 /* KEY_Q */
-+#define GRAB_KEY 0x34 /* KEY_Z */
-+#define TAB_KEY 0x17 /* KEY_Tab */
-
- static Display *display;
- static Window window;
-@@ -46,6 +48,35 @@ static const char data[1] = {0};
- static Cursor cursor;
- static bool grabbed = True;
-
-+static bool isgrabkeyrelease = false;
-+static bool waitingToSwitchGrabOnModifierUp = false;
-+static bool waitingToExitOnModifiersUp = false;
-+extern bool iskeyboardgrab;
-+extern void grab_window(bool grabstat);
-+
-+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 - 8], KEY_ACTION_UP, 0);
-+ }
-+ }
-+}
-+static void clearallkey () {
-+ for (int i=0;i<0xFF;i++) {
-+ if (keystatlist[i] == 1) {
-+ keystatlist[i] = 0;
-+ }
-+ }
-+}
-+
- static int x11_handler(int fd) {
- XEvent event;
- int button = 0;
-@@ -54,18 +85,24 @@ static int x11_handler(int fd) {
- while (XPending(display)) {
- XNextEvent(display, &event);
- switch (event.type) {
-+ case FocusIn:
-+ case FocusOut:
-+ if (event.type == FocusIn) {
-+ clearallkey();
-+ keyboard_modifiers = 0;
-+ grabbed = true;
-+ } else {
-+ if (iskeyboardgrab)
-+ break;
-+ freeallkey();
-+ keyboard_modifiers = 0;
-+ grabbed = false;
-+ }
-+ XDefineCursor(display, window, grabbed ? cursor : 0);
-+ break;
- case KeyPress:
- case KeyRelease:
- if (event.xkey.keycode >= 8 && event.xkey.keycode < (sizeof(keyCodes)/sizeof(keyCodes[0]) + 8)) {
-- if ((keyboard_modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS && event.type == KeyRelease) {
-- if (event.xkey.keycode == QUIT_KEY)
-- return LOOP_RETURN;
-- else {
-- grabbed = !grabbed;
-- XDefineCursor(display, window, grabbed ? cursor : 0);
-- }
-- }
--
- int modifier = 0;
- switch (event.xkey.keycode) {
- case 0x32:
-@@ -89,8 +126,58 @@ static int x11_handler(int fd) {
- keyboard_modifiers &= ~modifier;
- }
-
-+ if ((keyboard_modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS && event.type == KeyPress) {
-+ if (event.xkey.keycode == QUIT_KEY) {
-+ waitingToExitOnModifiersUp = true;
-+ break;
-+ } else if (event.xkey.keycode == GRAB_KEY) {
-+ if (event.type == KeyPress) {
-+ waitingToSwitchGrabOnModifierUp = true;
-+ break;
-+ }
-+ }
-+ }
-+ if (waitingToSwitchGrabOnModifierUp) {
-+ if (event.xkey.keycode == GRAB_KEY && event.type == KeyRelease) {
-+ isgrabkeyrelease = true;
-+ if (keyboard_modifiers != 0)
-+ break;
-+ }
-+ if (keyboard_modifiers == 0 && isgrabkeyrelease) {
-+ waitingToSwitchGrabOnModifierUp = false;
-+ isgrabkeyrelease = false;
-+ XDefineCursor(display, window, cursor);
-+ freeallkey();
-+ grab_window(true);
-+ break;
-+ }
-+ } else if (waitingToExitOnModifiersUp) {
-+ if (event.xkey.keycode == QUIT_KEY) {
-+ if (keyboard_modifiers != 0)
-+ break;
-+ }
-+ if (keyboard_modifiers == 0) {
-+ freeallkey();
-+ waitingToExitOnModifiersUp = false;
-+ return LOOP_RETURN;
-+ }
-+ }
-+ if (event.xkey.keycode == TAB_KEY && keyboard_modifiers == MODIFIER_ALT) {
-+ freeallkey();
-+ keyboard_modifiers = 0;
-+ break;
-+ }
-+ if (event.xkey.keycode == 0x40 || event.xkey.keycode == 0x6c)
-+ break;
-+
-+ if (event.type == KeyPress)
-+ keypress(event.xkey.keycode);
-+ else
-+ keyrelease(event.xkey.keycode);
-+
- short code = 0x80 << 8 | keyCodes[event.xkey.keycode - 8];
-- LiSendKeyboardEvent(code, event.type == KeyPress ? KEY_ACTION_DOWN : KEY_ACTION_UP, keyboard_modifiers);
-+ if (!iskeyboardgrab)
-+ LiSendKeyboardEvent(code, event.type == KeyPress ? KEY_ACTION_DOWN : KEY_ACTION_UP, keyboard_modifiers);
- }
- break;
- case ButtonPress:
-@@ -106,16 +193,20 @@ static int x11_handler(int fd) {
- button = BUTTON_RIGHT;
- break;
- case Button4:
-- LiSendScrollEvent(1);
-+ if (!iskeyboardgrab)
-+ LiSendScrollEvent(1);
- break;
- case Button5:
-- LiSendScrollEvent(-1);
-+ if (!iskeyboardgrab)
-+ LiSendScrollEvent(-1);
- break;
- case 6:
-- LiSendHScrollEvent(-1);
-+ if (!iskeyboardgrab)
-+ LiSendHScrollEvent(-1);
- break;
- case 7:
-- LiSendHScrollEvent(1);
-+ if (!iskeyboardgrab)
-+ LiSendHScrollEvent(1);
- break;
- case 8:
- button = BUTTON_X1;
-@@ -125,14 +216,16 @@ static int x11_handler(int fd) {
- break;
- }
-
-- if (button != 0)
-+ if (button != 0 && !iskeyboardgrab)
- LiSendMouseButtonEvent(event.type==ButtonPress ? BUTTON_ACTION_PRESS : BUTTON_ACTION_RELEASE, button);
- break;
- case MotionNotify:
-+ if (!grabbed)
-+ break;
- motion_x = event.xmotion.x - last_x;
- motion_y = event.xmotion.y - last_y;
- if (abs(motion_x) > 0 || abs(motion_y) > 0) {
-- if (last_x >= 0 && last_y >= 0)
-+ if (last_x >= 0 && last_y >= 0 && !iskeyboardgrab)
- LiSendMouseMoveEvent(motion_x, motion_y);
-
- if (grabbed)
diff --git a/games/moonlight-embedded/files/patch-src_main.c b/games/moonlight-embedded/files/patch-src_main.c
index 32131dc18e63..827f3a3ade46 100644
--- a/games/moonlight-embedded/files/patch-src_main.c
+++ b/games/moonlight-embedded/files/patch-src_main.c
@@ -1,4 +1,4 @@
---- src/main.c.orig 2023-10-11 15:50:11 UTC
+--- src/main.c.orig 2023-11-03 06:08:34 UTC
+++ src/main.c
@@ -42,6 +42,7 @@
#include <client.h>
@@ -8,26 +8,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
-@@ -52,7 +53,6 @@
+@@ -52,7 +53,8 @@
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
-#include <openssl/rand.h>
++
++extern void is_use_kbdmux();
static void applist(PSERVER_DATA server) {
PAPP_LIST list = NULL;
-@@ -149,6 +149,10 @@ static void stream(PSERVER_DATA server, PCONFIGURATION
- if (!config->viewonly)
- evdev_start();
- loop_main();
-+ #ifdef HAVE_SDL
-+ if (!isNoSdl)
-+ x11_sdl_stop();
-+ #endif
- if (!config->viewonly)
- evdev_stop();
- }
-@@ -202,7 +206,6 @@ static void help() {
+@@ -202,7 +204,6 @@ static void help() {
printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");
printf("\t-codec <codec>\t\tSelect used codec: auto/h264/h265/av1 (default auto)\n");
@@ -35,19 +26,7 @@
printf("\t-remote <yes/no/auto>\t\t\tEnable optimizations for WAN streaming (default auto)\n");
printf("\t-app <app>\t\tName of app to stream\n");
printf("\t-nosops\t\t\tDon't allow GFE to modify game settings\n");
-@@ -238,7 +241,10 @@ static void pair_check(PSERVER_DATA server) {
- int main(int argc, char* argv[]) {
- CONFIGURATION config;
- config_parse(argc, argv, &config);
--
-+ #ifndef HAVE_SDL
-+ isNoSdl = true;
-+ #endif
-+
- if (config.action == NULL || strcmp("help", config.action) == 0)
- help();
-
-@@ -322,19 +328,19 @@ int main(int argc, char* argv[]) {
+@@ -322,19 +323,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;
@@ -75,27 +54,16 @@
#ifdef HAVE_SDL
if (system == SDL)
-@@ -371,7 +377,19 @@ int main(int argc, char* argv[]) {
+@@ -362,6 +363,8 @@ int main(int argc, char* argv[]) {
+ mappings = map;
+ }
- udev_init(!inputAdded, mappings, config.debug_level > 0, config.rotate);
- evdev_init(config.mouse_emulation);
-+ #ifdef HAVE_SDL
-+ if (isNoSdl)
-+ rumble_handler = evdev_rumble;
-+ else {
-+ x11_sdl_init(config.mapping);
-+ rumble_handler = sdlinput_rumble;
-+ rumble_triggers_handler = sdlinput_rumble_triggers;
-+ set_motion_event_state_handler = sdlinput_set_motion_event_state;
-+ set_controller_led_handler = sdlinput_set_controller_led;
-+ }
-+ #else
- rumble_handler = evdev_rumble;
-+ #endif
- #ifdef HAVE_LIBCEC
- cec_init();
- #endif /* HAVE_LIBCEC */
-@@ -398,7 +416,8 @@ int main(int argc, char* argv[]) {
++ // test is use kbdmux driver
++ is_use_kbdmux();
+ for (int i=0;i<config.inputsCount;i++) {
+ if (config.debug_level > 0)
+ printf("Adding input device %s...\n", config.inputs[i]);
+@@ -398,7 +401,8 @@ int main(int argc, char* argv[]) {
if (config.pin > 0 && config.pin <= 9999) {
sprintf(pin, "%04d", config.pin);
} else {
@@ -105,7 +73,7 @@
}
printf("Please enter the following PIN on the target PC: %s\n", pin);
fflush(stdout);
-@@ -406,6 +425,7 @@ int main(int argc, char* argv[]) {
+@@ -406,6 +410,7 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "Failed to pair to server: %s\n", gs_error);
} else {
printf("Succesfully paired\n");
diff --git a/games/moonlight-embedded/files/patch-src_platform.c b/games/moonlight-embedded/files/patch-src_platform.c
index 278ea160ccac..4fe2435269b2 100644
--- a/games/moonlight-embedded/files/patch-src_platform.c
+++ b/games/moonlight-embedded/files/patch-src_platform.c
@@ -1,40 +1,12 @@
---- src/platform.c.orig 2023-09-01 23:40:56 UTC
+--- src/platform.c.orig 2023-11-03 06:08:34 UTC
+++ src/platform.c
-@@ -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;
+@@ -202,6 +202,9 @@ AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum plat
+ #ifdef HAVE_ALSA
+ return &audio_callbacks_alsa;
#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:
-- #ifdef HAVE_PULSE
-- if (audio_pulse_init(audio_device))
-- return &audio_callbacks_pulse;
-- #endif
-- #ifdef HAVE_ALSA
-- return &audio_callbacks_alsa;
-- #endif
++ #ifdef __FreeBSD__
+ return &audio_callbacks_oss;
++ #endif
}
return NULL;
}
diff --git a/games/moonlight-embedded/files/patch-src_sdl.c b/games/moonlight-embedded/files/patch-src_sdl.c
deleted file mode 100644
index 849b82b2e379..000000000000
--- a/games/moonlight-embedded/files/patch-src_sdl.c
+++ /dev/null
@@ -1,64 +0,0 @@
---- src/sdl.c.orig 2023-10-11 15:50:11 UTC
-+++ src/sdl.c
-@@ -42,6 +42,10 @@ void sdl_init(int width, int height, bool fullscreen)
- fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
- exit(1);
- }
-+ if(!SDL_SetHint(SDL_HINT_GRAB_KEYBOARD,"1"))
-+ printf("Override SDL_HINT_GRAB_KEYBOARD to 1 failed.\n");
-+ if(!SDL_SetHint(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED,"0"))
-+ printf("Override SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED to 0 failed.\n");
-
- fullscreen_flags = fullscreen?SDL_WINDOW_FULLSCREEN:0;
- window = SDL_CreateWindow("Moonlight", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL | fullscreen_flags);
-@@ -72,8 +76,19 @@ void sdl_init(int width, int height, bool fullscreen)
- void sdl_loop() {
- SDL_Event event;
-
-+ iskeyboardgrab = true;
- SDL_SetRelativeMouseMode(SDL_TRUE);
-+#if SDL_VERSION_ATLEAST(2, 0, 15)
-+ // On SDL 2.0.15+, we can get keyboard-only grab on Win32, X11, and Wayland.
-+ // SDL 2.0.18 adds keyboard grab on macOS (if built with non-AppStore APIs).
-+ SDL_SetWindowKeyboardGrab(window, SDL_TRUE);
-+ if(!SDL_GetWindowKeyboardGrab(window))
-+ printf("Try to grab window failed.\n");
-+#else
-+ SDL_SetWindowGrab(window, SDL_TRUE);
-+#endif
-
-+
- while(!done && SDL_WaitEvent(&event)) {
- switch (sdlinput_handle_event(window, &event)) {
- case SDL_QUIT_APPLICATION:
-@@ -90,6 +105,30 @@ void sdl_loop() {
- case SDL_MOUSE_UNGRAB:
- SDL_SetRelativeMouseMode(SDL_FALSE);
- SDL_ShowCursor(SDL_DISABLE);
-+ break;
-+ case SDL_WINDOW_GRAB:
-+ if(!SDL_SetHintWithPriority(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED,"0",SDL_HINT_OVERRIDE))
-+ printf("Override SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED to 0 failed.\n");
-+ SDL_ShowCursor(SDL_ENABLE);
-+ SDL_SetRelativeMouseMode(SDL_TRUE);
-+ iskeyboardgrab = true;
-+#if SDL_VERSION_ATLEAST(2, 0, 15)
-+ SDL_SetWindowKeyboardGrab(window, SDL_TRUE);
-+#else
-+ SDL_SetWindowGrab(window, SDL_TRUE);
-+#endif
-+ break;
-+ case SDL_WINDOW_UNGRAB:
-+ if(!SDL_SetHintWithPriority(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED,"1",SDL_HINT_OVERRIDE))
-+ printf("Override SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED to 1 failed.\n");
-+ SDL_SetRelativeMouseMode(SDL_FALSE);
-+ SDL_ShowCursor(SDL_DISABLE);
-+ iskeyboardgrab = false;
-+#if SDL_VERSION_ATLEAST(2, 0, 15)
-+ SDL_SetWindowKeyboardGrab(window, SDL_FALSE);
-+#else
-+ SDL_SetWindowGrab(window, SDL_FALSE);
-+#endif
- break;
- default:
- if (event.type == SDL_QUIT)
diff --git a/games/moonlight-embedded/files/patch-src_sdl.h b/games/moonlight-embedded/files/patch-src_sdl.h
deleted file mode 100644
index f2410ccc5a54..000000000000
--- a/games/moonlight-embedded/files/patch-src_sdl.h
+++ /dev/null
@@ -1,19 +0,0 @@
---- src/sdl.h.orig 2023-10-11 15:50:11 UTC
-+++ src/sdl.h
-@@ -28,6 +28,8 @@
- #define SDL_MOUSE_GRAB 2
- #define SDL_MOUSE_UNGRAB 3
- #define SDL_TOGGLE_FULLSCREEN 4
-+#define SDL_WINDOW_GRAB 5
-+#define SDL_WINDOW_UNGRAB 6
-
- #define SDL_CODE_FRAME 0
-
-@@ -36,6 +38,7 @@
- void sdl_init(int width, int height, bool fullscreen);
- void sdl_loop();
-
-+extern bool iskeyboardgrab;
- extern SDL_mutex *mutex;
- extern int sdlCurrentFrame, sdlNextFrame;
-
diff --git a/games/moonlight-embedded/files/patch-src_video_ffmpeg__vaapi.c b/games/moonlight-embedded/files/patch-src_video_ffmpeg__vaapi.c
deleted file mode 100644
index e91d34a4276e..000000000000
--- a/games/moonlight-embedded/files/patch-src_video_ffmpeg__vaapi.c
+++ /dev/null
@@ -1,19 +0,0 @@
---- src/video/ffmpeg_vaapi.c.orig 2023-09-01 23:40:56 UTC
-+++ src/video/ffmpeg_vaapi.c
-@@ -23,6 +23,7 @@
- #include <libavutil/hwcontext.h>
- #include <libavutil/hwcontext_vaapi.h>
- #include <X11/Xlib.h>
-+#include <stdlib.h>
-
- #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-src_video_x11.c b/games/moonlight-embedded/files/patch-src_video_x11.c
deleted file mode 100644
index 8c9079fc91fe..000000000000
--- a/games/moonlight-embedded/files/patch-src_video_x11.c
+++ /dev/null
@@ -1,42 +0,0 @@
---- src/video/x11.c.orig 2023-10-08 02:12:37 UTC
-+++ src/video/x11.c
-@@ -53,6 +53,16 @@ static int pipefd[2];
- static int display_width;
- static int display_height;
-
-+static void resetcursor() {
-+ XColor dummy;
-+ Cursor cursor;
-+ const char data[1] = {0};
-+ Pixmap blank = XCreateBitmapFromData(display, window, data, 1, 1);
-+ cursor = XCreatePixmapCursor(display, blank, blank, &dummy, &dummy, 0, 0);
-+ XFreePixmap(display, blank);
-+ XDefineCursor(display, window, cursor);
-+}
-+
- static int frame_handle(int pipefd) {
- AVFrame* frame = NULL;
- while (read(pipefd, &frame, sizeof(void*)) > 0);
-@@ -75,7 +85,7 @@ int x11_init(bool vdpau, bool vaapi) {
- return 0;
-
- #ifdef HAVE_VAAPI
-- if (vaapi && vaapi_init_lib(display) == 0)
-+ if (vaapi && vaapi_init_lib() == 0)
- return INIT_VAAPI;
- #endif
-
-@@ -100,10 +110,12 @@ int x11_setup(int videoFormat, int width, int height,
- }
-
- Window root = DefaultRootWindow(display);
-- XSetWindowAttributes winattr = { .event_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask };
-+ XSetWindowAttributes winattr = { .event_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | FocusChangeMask };
- window = XCreateWindow(display, root, 0, 0, display_width, display_height, 0, CopyFromParent, InputOutput, CopyFromParent, CWEventMask, &winattr);
- XMapWindow(display, window);
- XStoreName(display, window, "Moonlight");
-+ // Fix the bug that the default cursor keep in screen when streaming.
-+ resetcursor();
-
- if (drFlags & DISPLAY_FULLSCREEN) {
- Atom wm_state = XInternAtom(display, "_NET_WM_STATE", False);
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
deleted file mode 100644
index f2550dd2c585..000000000000
--- a/games/moonlight-embedded/files/patch-third__party_moonlight-common-c_enet_CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
---- third_party/moonlight-common-c/enet/CMakeLists.txt.orig 2023-09-21 01:51:32 UTC
-+++ third_party/moonlight-common-c/enet/CMakeLists.txt
-@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 2.8.12...3.20)
-
- project(enet)
-
--option(ENET_NO_INSTALL "Disable installation of headers and libraries" OFF)
--
- # The "configure" step.
- include(CheckFunctionExists)
- include(CheckStructHasMember)
-@@ -108,14 +106,4 @@ target_include_directories(enet SYSTEM PUBLIC include)
-
- if (MINGW)
- target_link_libraries(enet winmm ws2_32)
--endif()
--
--if(NOT ENET_NO_INSTALL)
-- install(TARGETS enet
-- RUNTIME DESTINATION bin
-- ARCHIVE DESTINATION lib/static
-- LIBRARY DESTINATION lib)
--
-- install(DIRECTORY include/
-- DESTINATION include)
- endif()
diff --git a/games/moonlight-embedded/pkg-plist b/games/moonlight-embedded/pkg-plist
deleted file mode 100644
index 451acc8f0c12..000000000000
--- a/games/moonlight-embedded/pkg-plist
+++ /dev/null
@@ -1,4 +0,0 @@
-bin/moonlight
-@sample etc/moonlight.conf.sample
-share/man/man1/moonlight.1.gz
-share/moonlight/gamecontrollerdb.txt