View | Details | Raw Unified | Return to bug 274026 | Differences between
and this patch

Collapse All | Expand All

(-)b/Makefile (-12 / +4 lines)
Lines 1-12 Link Here
1
PORTNAME=	moonlight-embedded
1
PORTNAME=	moonlight-embedded
2
DISTVERSION=	2.5.3
2
DISTVERSION=	2.6.0
3
PORTREVISION=	2
4
CATEGORIES=	games
3
CATEGORIES=	games
5
MASTER_SITES=	https://github.com/irtimmer/moonlight-embedded/releases/download/v${DISTVERSION}/
4
MASTER_SITES=	https://github.com/moonlight-stream/moonlight-embedded/releases/download/v${DISTVERSION}/
6
5
7
MAINTAINER=	ports@FreeBSD.org
6
MAINTAINER=	lisp_25689@163.com
8
COMMENT=	Gamestream client
7
COMMENT=	Gamestream client
9
WWW=		https://github.com/irtimmer/moonlight-embedded
8
WWW=		https://github.com/moonlight-stream/moonlight-embedded
10
9
11
LICENSE=	GPLv3+
10
LICENSE=	GPLv3+
12
LICENSE_FILE=	${WRKSRC}/LICENSE
11
LICENSE_FILE=	${WRKSRC}/LICENSE
Lines 32-44 CFLAGS+= -DHAS_SOCKLEN_T=1 -I${LOCALBASE}/include/libepoll-shim/ Link Here
32
LDFLAGS+=	-lepoll-shim
31
LDFLAGS+=	-lepoll-shim
33
32
34
post-patch:
33
post-patch:
35
	@${REINPLACE_CMD} -e '/(ALSA)/d' \
36
		-e '/libpulse-simple/d' \
37
		-e '/libcec/d' \
38
		${WRKSRC}/CMakeLists.txt
39
	@${REINPLACE_CMD} -e 's@SHARED@STATIC@' \
40
		-e 's@OpenSSL 1.0.2@OpenSSL@' -e '/^install(/d' \
41
		${WRKSRC}/libgamestream/CMakeLists.txt
42
	@${REINPLACE_CMD} -e 's@/etc/moonlight/moonlight.conf@${PREFIX}/etc/moonlight.conf@' \
34
	@${REINPLACE_CMD} -e 's@/etc/moonlight/moonlight.conf@${PREFIX}/etc/moonlight.conf@' \
43
		-e 's@moonligt@moonlight@g' \
35
		-e 's@moonligt@moonlight@g' \
44
		${WRKSRC}/docs/README.pod
36
		${WRKSRC}/docs/README.pod
(-)b/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1666188557
1
TIMESTAMP = 1695536824
2
SHA256 (moonlight-embedded-2.5.3.tar.xz) = 2fcd00049f58b0af882f0eec7077013c062bc35c8705f3d6bb7949d44e98fac0
2
SHA256 (moonlight-embedded-2.6.0.tar.xz) = 71c883e10c65085c82a75c9affaef5e63f43d9074df74d48039d8c9b83120df7
3
SIZE (moonlight-embedded-2.5.3.tar.xz) = 303180
3
SIZE (moonlight-embedded-2.6.0.tar.xz) = 324572
(-)b/files/patch-CMakeLists.txt (+45 lines)
Added Link Here
1
--- CMakeLists.txt.orig	2023-09-24 06:11:13 UTC
2
+++ CMakeLists.txt
3
@@ -5,14 +5,11 @@ SET(CMAKE_C_STANDARD 99)
4
 include(${CMAKE_ROOT}/Modules/GNUInstallDirs.cmake)
5
 include(${CMAKE_SOURCE_DIR}/cmake/generate_version_header.cmake)
6
 
7
-add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-pointer-sign -Wno-sign-compare -Wno-switch)
8
-
9
 aux_source_directory(./src SRC_LIST)
10
 list(APPEND SRC_LIST ./src/input/evdev.c ./src/input/mapping.c ./src/input/udev.c)
11
 
12
 set(MOONLIGHT_DEFINITIONS)
13
 
14
-find_package(ALSA)
15
 find_package(Opus REQUIRED)
16
 find_package(Broadcom-OMX)
17
 find_package(Freescale)
18
@@ -46,10 +43,8 @@ if (ENABLE_FFMPEG)
19
   endif()
20
 endif()
21
 if (ENABLE_PULSE)
22
-  pkg_check_modules(PULSE libpulse-simple)
23
 endif()
24
 if (ENABLE_CEC)
25
-  pkg_check_modules(CEC libcec>=4)
26
 endif()
27
 
28
 pkg_check_modules(MMAL mmal)
29
@@ -91,7 +86,6 @@ if (CEC_FOUND)
30
   list(APPEND MOONLIGHT_DEFINITIONS HAVE_LIBCEC)
31
   list(APPEND MOONLIGHT_OPTIONS CEC)
32
   target_sources(moonlight PRIVATE ./src/input/cec.c)
33
-  target_include_directories(moonlight PRIVATE ./third_party/libcec ${CEC_INCLUDE_DIRS})
34
   target_link_libraries(moonlight ${CEC_LIBRARIES})
35
 endif()
36
 
37
@@ -158,7 +152,7 @@ if (SOFTWARE_FOUND)
38
   if(X11_FOUND)
39
     list(APPEND MOONLIGHT_DEFINITIONS HAVE_X11)
40
     list(APPEND MOONLIGHT_OPTIONS X11)
41
-    target_sources(moonlight PRIVATE ./src/video/x11.c ./src/video/egl.c ./src/input/x11.c)
42
+    target_sources(moonlight PRIVATE ./src/video/x11.c ./src/video/egl.c ./src/input/x11.c ./src/audio/oss.c)
43
     target_include_directories(moonlight PRIVATE ${XLIB_INCLUDE_DIRS} ${EGL_INCLUDE_DIRS} ${GLES_INCLUDE_DIRS})
44
     target_link_libraries(moonlight ${XLIB_LIBRARIES} ${EGL_LIBRARIES} ${GLES_LIBRARIES})
45
   endif()
(-)b/files/patch-docs_CMakeLists.txt (+8 lines)
Added Link Here
1
--- docs/CMakeLists.txt.orig	2023-09-24 06:11:13 UTC
2
+++ docs/CMakeLists.txt
3
@@ -1,4 +1,4 @@
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)
5
+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)
6
 add_custom_target(docs ALL DEPENDS moonlight.1)
7
 
8
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/moonlight.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
(-)b/files/patch-docs_README.pod (+117 lines)
Added Link Here
1
--- docs/README.pod.orig	2023-09-24 06:11:13 UTC
2
+++ docs/README.pod
3
@@ -27,6 +27,11 @@ Stream game from host to this computer.
4
 
5
 List all available games and application on host.
6
 
7
+=item B<discover>
8
+
9
+Discover moonlight server host.Need start avahi-daemon first.
10
+NOTE:It's not work under wifibox.
11
+
12
 =item B<quit>
13
 
14
 Quit the current running game or application on host.
15
@@ -99,9 +104,9 @@ By default, 1392 is used on LAN and 1024 on WAN.
16
 =item B<-codec> [I<CODEC>]
17
 
18
 Select codec to use.
19
-Can be 'auto', 'h264', 'h265', 'hevc', or 'av1'.
20
-Not all video decoders support H.265/HEVC or AV1.
21
-Will still use H.264 if server doesn't support HEVC or AV1.
22
+Can be 'auto', 'h264', 'h265', 'hevc' or 'av1'.
23
+Not all video decoders do support H.265/HEVC.
24
+Will still use H.264 if server doesn't support HEVC.
25
 
26
 =item B<-remote> [I<yes/no/auto>]
27
 
28
@@ -138,8 +143,10 @@ By default the gamecontrollerdb.txt provided by Moonli
29
 =item B<-platform> [I<PLATFORM>]
30
 
31
 Select platform for audio and video output and input.
32
-<PLATFORM> can be pi, imx, aml, x11, x11_vdpau, sdl or fake.
33
+<PLATFORM> can be x11, x11_vaapi, x11_vdpau, sdl or fake.
34
 
35
+NOTE:x11_vaapi need libva library be installed.For intel,install libva-intel-driver/libva-intel-media-driver
36
+
37
 =item B<-nounsupported>
38
 
39
 Don't stream if resolution is not officially supported by the server
40
@@ -156,6 +163,10 @@ Disable all input processing (view-only mode)
41
 
42
 Disable gamepad mouse emulation (activated by long pressing Start button)
43
 
44
+=item B<-nosdl>
45
+
46
+Not Recommented.Use evdev instead of SDL to drive gamepad.
47
+
48
 =item B<-verbose>
49
 
50
 Enable verbose output
51
@@ -170,11 +181,6 @@ Enable the I<INPUT> device.
52
 By default all available input devices are enabled.
53
 Only evdev devices /dev/input/event* are supported.
54
 
55
-=item B<-audio> [I<DEVICE>]
56
-
57
-Use <DEVICE> as audio output device.
58
-The default value is 'sysdefault' for ALSA and 'hdmi' for OMX on the Raspberry Pi.
59
-
60
 =item B<-windowed>
61
 
62
 Display the stream in a window instead of fullscreen.
63
@@ -182,22 +188,49 @@ Only available when X11 or SDL platform is used.
64
 
65
 =back
66
 
67
+=head1 EXAMPLE
68
+
69
+Pair:
70
+  # moonlight pair 192.168.0.1
71
+
72
+Connect:
73
+ The following cmd means to connect 192.168.0.1 with a resolution 2560x1600.
74
+  # moonlight stream -app Desktop -width 2560 -height 1600 192.168.0.1
75
+ The following cmd means to connect 192.168.0.1 with a resolution 1080p and the fps 120.And try to decoding with GPU.
76
+  # moonlight stream -app Steam -width 1920 -height 1080 -fps 120 -platform 'x11_vaapi' 192.168.0.1
77
+
78
 =head1 CONFIG FILE
79
 
80
 Moonlight Embedded will load a confiuration file from:
81
 
82
-  $XDG_CONFIG_HOME/moonligt/moonlight.conf (fallback to ~/.config/moonligt/moonlight.conf)
83
+  $XDG_CONFIG_HOME/moonlight/moonlight.conf (fallback to ~/.config/moonlight/moonlight.conf)
84
 
85
 If no user specified configuration file is available the configuration will be loaded from:
86
 
87
-  /etc/moonlight/moonlight.conf
88
+  /usr/local/etc/moonlight.conf
89
 
90
-A documented example configuration file can be found at /etc/moonlight/moonlight.conf.
91
+A documented example configuration file can be found at /usr/local/etc/moonlight.conf.
92
 
93
-=head1 COMMENTS
94
+=head1 KEYBOARD SHORTCUTS
95
 
96
 Use Ctrl+Alt+Shift+Q or Play+Back+LeftShoulder+RightShoulder to quit the streaming session.
97
+Use Ctrl+Alt+Shift+G to grab or ungrab keyboard.(only x11* platform)
98
 
99
+=head1 GAMEPAD
100
+
101
+FreeBSD supports fewer controllers.Please see hgame(4) xb360gp(4) ps4dshock(4) and FreeBSD forums...
102
+There is a problem with the evdev drive gamepad,so -nosdl is not recommended.But you can try it yourself.
103
+
104
+=head1 COMMENTS
105
+
106
+Platform 'sdl' and 'x11' is soft decoding.
107
+Platform 'x11_vaapi' and 'x11_vdpau' is hard decoding.
108
+If you want to use GPU decoding,you must meet 3 conditions:
109
+  1.Use platform 'x11_vaapi' or 'x11_vdpau'.
110
+  2.Use Intel or AMD(not test) GPU driver in xorg.conf
111
+  3.Install package:libva-intel-driver/libva-intel-media-driver or libva-vdpau-driver.
112
+
113
 =head1 AUTHOR
114
 
115
-Iwan Timmer E<lt>irtimmer@gmail.comE<gt>
116
+Thanks Iwan Timmer and every contributor!
117
+Armin Zhu E<lt>lisp_25689@163.comE<gt>
(-)b/files/patch-libgamestream_CMakeLists.txt (+29 lines)
Added Link Here
1
--- libgamestream/CMakeLists.txt.orig	2023-09-24 06:11:13 UTC
2
+++ libgamestream/CMakeLists.txt
3
@@ -3,7 +3,7 @@ set(SO_VERSION 4)
4
 find_package(LibUUID REQUIRED)
5
 find_package(Threads REQUIRED)
6
 find_package(CURL REQUIRED)
7
-find_package(OpenSSL 1.0.2 REQUIRED)
8
+find_package(OpenSSL REQUIRED)
9
 find_package(EXPAT REQUIRED)
10
 
11
 pkg_check_modules(AVAHI REQUIRED avahi-client)
12
@@ -15,9 +15,9 @@ aux_source_directory(../third_party/moonlight-common-c
13
 aux_source_directory(../third_party/moonlight-common-c/src MOONLIGHT_COMMON_SRC_LIST)
14
 aux_source_directory(../third_party/moonlight-common-c/reedsolomon MOONLIGHT_COMMON_SRC_LIST)
15
 
16
-add_library(moonlight-common SHARED ${MOONLIGHT_COMMON_SRC_LIST})
17
+add_library(moonlight-common STATIC ${MOONLIGHT_COMMON_SRC_LIST})
18
 
19
-add_library(gamestream SHARED ${GAMESTREAM_SRC_LIST})
20
+add_library(gamestream STATIC ${GAMESTREAM_SRC_LIST})
21
 target_link_libraries(gamestream moonlight-common)
22
 
23
 set_target_properties(gamestream PROPERTIES SOVERSION ${SO_VERSION} VERSION ${PROJECT_VERSION})
24
@@ -28,5 +28,3 @@ target_include_directories(moonlight-common PRIVATE ..
25
 target_link_libraries(gamestream ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ${EXPAT_LIBRARIES} ${AVAHI_LIBRARIES} ${LIBUUID_LIBRARIES})
26
 
27
 target_link_libraries(gamestream ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
28
-
29
-install(TARGETS gamestream moonlight-common DESTINATION ${CMAKE_INSTALL_LIBDIR})
(-)b/files/patch-libgamestream_client.c (-4 / +4 lines)
Lines 1-7 Link Here
1
--- libgamestream/client.c.orig	2018-08-11 15:43:13 UTC
1
--- libgamestream/client.c.orig	2023-09-24 06:11:13 UTC
2
+++ libgamestream/client.c
2
+++ libgamestream/client.c
3
@@ -505,7 +505,11 @@ int gs_pair(PSERVER_DATA server, char* pin) {
3
@@ -537,7 +537,11 @@ int gs_pair(PSERVER_DATA server, char* pin) {
4
   RAND_bytes(client_secret_data, 16);
4
   RAND_bytes(client_secret_data, sizeof(client_secret_data));
5
 
5
 
6
   const ASN1_BIT_STRING *asnSignature;
6
   const ASN1_BIT_STRING *asnSignature;
7
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
7
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
Lines 10-14 Link Here
10
+  asnSignature = cert->signature;
10
+  asnSignature = cert->signature;
11
+#endif
11
+#endif
12
 
12
 
13
   char challenge_response[16 + 256 + 16];
13
   char challenge_response[16 + SIGNATURE_LEN + sizeof(client_secret_data)];
14
   char challenge_response_hash[32];
14
   char challenge_response_hash[32];
(-)b/files/patch-libgamestream_http.c (+12 lines)
Added Link Here
1
--- libgamestream/http.c.orig	2023-09-24 06:11:13 UTC
2
+++ libgamestream/http.c
3
@@ -73,6 +73,9 @@ int http_init(const char* keyDirectory, int logLevel) 
4
 int http_request(char* url, PHTTP_DATA data) {
5
   curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
6
   curl_easy_setopt(curl, CURLOPT_URL, url);
7
+  curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L);
8
+  curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1);
9
+  curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1);
10
 
11
   if (debug)
12
     printf("Request %s\n", url);
(-)b/files/patch-src_audio_audio.h (+7 lines)
Added Link Here
1
--- src/audio/audio.h.orig	2023-09-24 06:11:13 UTC
2
+++ src/audio/audio.h
3
@@ -31,3 +31,4 @@ extern AUDIO_RENDERER_CALLBACKS audio_callbacks_sdl;
4
 extern AUDIO_RENDERER_CALLBACKS audio_callbacks_pulse;
5
 bool audio_pulse_init(char* audio_device);
6
 #endif
7
+extern AUDIO_RENDERER_CALLBACKS audio_callbacks_oss;
(-)b/files/patch-src_audio_oss.c (+105 lines)
Added Link Here
1
--- src/audio/oss.c.orig	2023-09-24 06:11:13 UTC
2
+++ src/audio/oss.c
3
@@ -0,0 +1,102 @@
4
+/*
5
+ * This file is part of Moonlight Embedded.
6
+ *
7
+ * Copyright (C) 2015-2017 Iwan Timmer
8
+ *
9
+ * Moonlight is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation; either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * Moonlight is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+
23
+#include <sys/soundcard.h>
24
+#include "audio.h"
25
+
26
+#include <stdio.h>
27
+#include <opus_multistream.h>
28
+
29
+#include <sys/ioctl.h>
30
+#include <unistd.h>
31
+#include <fcntl.h>
32
+
33
+static OpusMSDecoder* decoder;
34
+static short* pcmBuffer;
35
+static int samplesPerFrame;
36
+static int channelCount;
37
+static int fd;
38
+
39
+static int oss_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int arFlags) {
40
+  int rc;
41
+  decoder = opus_multistream_decoder_create(opusConfig->sampleRate, opusConfig->channelCount, opusConfig->streams, opusConfig->coupledStreams, opusConfig->mapping, &rc);
42
+
43
+  channelCount = opusConfig->channelCount;
44
+  samplesPerFrame = opusConfig->samplesPerFrame;
45
+  pcmBuffer = malloc(sizeof(short) * channelCount * samplesPerFrame);
46
+  if (pcmBuffer == NULL)
47
+    return -1;
48
+
49
+  char* oss_name = "/dev/dsp";
50
+  fd = open(oss_name, O_WRONLY);
51
+  // buffer size for fragment ,selector 12 is 4096;11 is 2048;10 is 1024; 13is 8192
52
+  if (fd == -1) {
53
+    close(fd);
54
+    printf("Open audio device /dev/dsp faild!!!");
55
+    return -1;
56
+  }
57
+  int frag = 12;
58
+  if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag) == -1)
59
+    printf("Set framgment for /dev/dsp faild.");
60
+
61
+  int format = AFMT_S16_LE;
62
+  int channels = opusConfig->channelCount;
63
+  int rate = opusConfig->sampleRate;
64
+  if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) == -1)
65
+    printf("Set framgment for /dev/dsp faild.");
66
+  if (ioctl(fd, SNDCTL_DSP_CHANNELS, &channels) == -1)
67
+    printf("Set channels for /dev/dsp faild.");
68
+  if (ioctl(fd, SNDCTL_DSP_SPEED, &rate) == -1)
69
+    printf("Set sameple rate for /dev/dsp faild.");
70
+
71
+  return 0;
72
+}
73
+
74
+static void oss_renderer_cleanup() {
75
+  if (decoder != NULL) {
76
+    opus_multistream_decoder_destroy(decoder);
77
+    decoder = NULL;
78
+  }
79
+
80
+  if (pcmBuffer != NULL) {
81
+    free(pcmBuffer);
82
+    pcmBuffer = NULL;
83
+  }
84
+
85
+  if (fd != 0) {
86
+    close(fd);
87
+    fd = 0;
88
+  }
89
+}
90
+
91
+static void oss_renderer_decode_and_play_sample(char* data, int length) {
92
+  int decodeLen = opus_multistream_decode(decoder, data, length, pcmBuffer, samplesPerFrame, 0);
93
+  if (decodeLen > 0) {
94
+    write(fd, pcmBuffer, decodeLen * channelCount * sizeof(short));
95
+  } else {
96
+    printf("Opus error from decode: %d\n", decodeLen);
97
+  }
98
+}
99
+
100
+AUDIO_RENDERER_CALLBACKS audio_callbacks_oss = {
101
+  .init = oss_renderer_init,
102
+  .cleanup = oss_renderer_cleanup,
103
+  .decodeAndPlaySample = oss_renderer_decode_and_play_sample,
104
+  .capabilities = CAPABILITY_DIRECT_SUBMIT | CAPABILITY_SUPPORTS_ARBITRARY_AUDIO_DURATION,
105
+};
(-)b/files/patch-src_input_evdev.c (-5 / +93 lines)
Lines 1-6 Link Here
1
--- src/input/evdev.c.orig	2021-12-20 00:24:48 UTC
1
--- src/input/evdev.c.orig	2023-09-24 06:11:13 UTC
2
+++ src/input/evdev.c
2
+++ src/input/evdev.c
3
@@ -38,10 +38,10 @@
3
@@ -38,10 +38,13 @@
4
 #include <limits.h>
4
 #include <limits.h>
5
 #include <unistd.h>
5
 #include <unistd.h>
6
 #include <pthread.h>
6
 #include <pthread.h>
Lines 9-26 Link Here
9
 #include <math.h>
9
 #include <math.h>
10
 
10
 
11
-#if __BYTE_ORDER == __LITTLE_ENDIAN
11
-#if __BYTE_ORDER == __LITTLE_ENDIAN
12
+void grab_keyboard();
13
+bool iskeyboardgrab = true;
14
+
12
+#if _BYTE_ORDER == _LITTLE_ENDIAN
15
+#if _BYTE_ORDER == _LITTLE_ENDIAN
13
 #define int16_to_le(val) val
16
 #define int16_to_le(val) val
14
 #else
17
 #else
15
 #define int16_to_le(val) ((((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00))
18
 #define int16_to_le(val) ((((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00))
16
@@ -66,8 +66,8 @@ struct input_device {
19
@@ -66,8 +69,8 @@ struct input_device {
17
   int hats_state[3][2];
20
   int hats_state[3][2];
18
   int fd;
21
   int fd;
19
   char modifiers;
22
   char modifiers;
20
-  __s32 mouseDeltaX, mouseDeltaY, mouseScroll;
23
-  __s32 mouseDeltaX, mouseDeltaY, mouseVScroll, mouseHScroll;
21
-  __s32 touchDownX, touchDownY, touchX, touchY;
24
-  __s32 touchDownX, touchDownY, touchX, touchY;
22
+  int32_t mouseDeltaX, mouseDeltaY, mouseScroll;
25
+  int32_t mouseDeltaX, mouseDeltaY, mouseVScroll, mouseHScroll;
23
+  int32_t touchDownX, touchDownY, touchX, touchY;
26
+  int32_t touchDownX, touchDownY, touchX, touchY;
24
   struct timeval touchDownTime;
27
   struct timeval touchDownTime;
25
   struct timeval btnDownTime;
28
   struct timeval btnDownTime;
26
   short controllerId;
29
   short controllerId;
30
@@ -127,6 +130,7 @@ int evdev_gamepads = 0;
31
 
32
 #define ACTION_MODIFIERS (MODIFIER_SHIFT|MODIFIER_ALT|MODIFIER_CTRL)
33
 #define QUIT_KEY KEY_Q
34
+#define UNGRAB_KEY KEY_G
35
 #define QUIT_BUTTONS (PLAY_FLAG|BACK_FLAG|LB_FLAG|RB_FLAG)
36
 
37
 static bool (*handler) (struct input_event*, struct input_device*);
38
@@ -247,8 +251,8 @@ void *HandleMouseEmulation(void* param)
39
     deltaY = pow((float)rawY / 32767.0f * MOUSE_EMULATION_MOTION_MULTIPLIER, 3);
40
 
41
     // Enforce deadzones
42
-    deltaX = fabs(deltaX) > MOUSE_EMULATION_DEADZONE ? deltaX - MOUSE_EMULATION_DEADZONE : 0;
43
-    deltaY = fabs(deltaY) > MOUSE_EMULATION_DEADZONE ? deltaY - MOUSE_EMULATION_DEADZONE : 0;
44
+    deltaX = abs(deltaX) > MOUSE_EMULATION_DEADZONE ? deltaX - MOUSE_EMULATION_DEADZONE : 0;
45
+    deltaY = abs(deltaY) > MOUSE_EMULATION_DEADZONE ? deltaY - MOUSE_EMULATION_DEADZONE : 0;
46
 
47
     if (deltaX != 0 || deltaY != 0)
48
       LiSendMouseMoveEvent(deltaX, -deltaY);
49
@@ -343,7 +347,7 @@ static bool evdev_handle_event(struct input_event *ev,
50
     if (dev->mouseHScroll != 0) {
51
       LiSendHScrollEvent(dev->mouseHScroll);
52
       dev->mouseHScroll = 0;
53
-    }
54
+    } 
55
     if (dev->gamepadModified) {
56
       if (dev->controllerId < 0) {
57
         for (int i = 0; i < MAX_GAMEPADS; i++) {
58
@@ -404,6 +408,10 @@ static bool evdev_handle_event(struct input_event *ev,
59
         return true;
60
       } else if (waitingToExitOnModifiersUp && dev->modifiers == 0)
61
         return false;
62
+      if ((dev->modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS &&
63
+          ev->code == UNGRAB_KEY && ev->value != 0) {
64
+        grab_keyboard();
65
+      }
66
 
67
       short code = 0x80 << 8 | keyCodes[ev->code];
68
       LiSendKeyboardEvent(code, ev->value?KEY_ACTION_DOWN:KEY_ACTION_UP, dev->modifiers);
69
@@ -813,7 +821,7 @@ void evdev_create(const char* device, struct mapping* 
70
   if (mappings == NULL && strstr(name, "Xbox 360 Wireless Receiver") != NULL)
71
     mappings = xwc_mapping;
72
 
73
-  bool is_keyboard = libevdev_has_event_code(evdev, EV_KEY, KEY_Q);
74
+  bool is_keyboard = libevdev_has_event_code(evdev, EV_KEY, KEY_Q) && libevdev_get_id_version(evdev) < 500;
75
   bool is_mouse = libevdev_has_event_type(evdev, EV_REL) || libevdev_has_event_code(evdev, EV_KEY, BTN_LEFT);
76
   bool is_touchscreen = libevdev_has_event_code(evdev, EV_KEY, BTN_TOUCH);
77
 
78
@@ -1055,9 +1063,13 @@ void evdev_start() {
79
   // we're ready to take input events. Ctrl+C works up until
80
   // this point.
81
   for (int i = 0; i < numDevices; i++) {
82
-    if ((devices[i].is_keyboard || devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
83
+    if ((devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
84
       fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
85
     }
86
+    if (devices[i].is_keyboard && libevdev_get_id_bustype(devices[i].dev) > 3) {
87
+      if (ioctl(devices[i].fd, EVIOCGRAB, 1) < 0)
88
+        fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
89
+    }
90
   }
91
 
92
   // Any new input devices detected after this point will be grabbed immediately
93
@@ -1111,4 +1123,21 @@ void evdev_rumble(unsigned short controller_id, unsign
94
   event.value = 1;
95
   write(device->fd, (const void*) &event, sizeof(event));
96
   device->haptic_effect_id = effect.id;
97
+}
98
+
99
+void grab_keyboard() {
100
+  int grabnum;
101
+  if (iskeyboardgrab) {
102
+    grabnum = 0;
103
+    iskeyboardgrab = false;
104
+  } else {
105
+    grabnum = 1;
106
+    iskeyboardgrab = true;
107
+  }
108
+  for (int i = 0; i < numDevices; i++) {
109
+    if (devices[i].is_keyboard && libevdev_get_id_bustype(devices[i].dev) > 3) {
110
+      if (ioctl(devices[i].fd, EVIOCGRAB, grabnum) < 0)
111
+        fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
112
+    }
113
+  }
114
 }
(-)b/files/patch-src_main.c (+64 lines)
Added Link Here
1
--- src/main.c.orig	2023-09-24 06:11:13 UTC
2
+++ src/main.c
3
@@ -42,6 +42,7 @@
4
 #include <client.h>
5
 #include <discover.h>
6
 
7
+#include <time.h>
8
 #include <stdio.h>
9
 #include <stdlib.h>
10
 #include <stdbool.h>
11
@@ -52,7 +53,6 @@
12
 #include <netinet/in.h>
13
 #include <netdb.h>
14
 #include <arpa/inet.h>
15
-#include <openssl/rand.h>
16
 
17
 static void applist(PSERVER_DATA server) {
18
   PAPP_LIST list = NULL;
19
@@ -202,7 +202,6 @@ static void help() {
20
   printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
21
   printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");
22
   printf("\t-codec <codec>\t\tSelect used codec: auto/h264/h265/av1 (default auto)\n");
23
-  printf("\t-hdr\t\tEnable HDR streaming (experimental, requires host and device support)\n");
24
   printf("\t-remote <yes/no/auto>\t\t\tEnable optimizations for WAN streaming (default auto)\n");
25
   printf("\t-app <app>\t\tName of app to stream\n");
26
   printf("\t-nosops\t\t\tDon't allow GFE to modify game settings\n");
27
@@ -322,19 +321,19 @@ int main(int argc, char* argv[]) {
28
     config.stream.supportedVideoFormats = VIDEO_FORMAT_H264;
29
     if (config.codec == CODEC_HEVC || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, CODEC_HEVC))) {
30
       config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265;
31
-      if (config.hdr)
32
-        config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10;
33
+      //if (config.hdr)
34
+      //  config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10;
35
     }
36
     if (config.codec == CODEC_AV1 || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, CODEC_AV1))) {
37
       config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN8;
38
-      if (config.hdr)
39
-        config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10;
40
+      //if (config.hdr)
41
+      //  config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10;
42
     }
43
 
44
-    if (config.hdr && !(config.stream.supportedVideoFormats & VIDEO_FORMAT_MASK_10BIT)) {
45
-      fprintf(stderr, "HDR streaming requires HEVC or AV1 codec\n");
46
-      exit(-1);
47
-    }
48
+    //if (config.hdr && !(config.stream.supportedVideoFormats & VIDEO_FORMAT_MASK_10BIT)) {
49
+    //  fprintf(stderr, "HDR streaming requires HEVC or AV1 codec\n");
50
+    //  exit(-1);
51
+    //}    
52
 
53
     #ifdef HAVE_SDL
54
     if (system == SDL)
55
@@ -398,7 +397,8 @@ int main(int argc, char* argv[]) {
56
     if (config.pin > 0 && config.pin <= 9999) {
57
       sprintf(pin, "%04d", config.pin);
58
     } else {
59
-      sprintf(pin, "%d%d%d%d", (unsigned)random() % 10, (unsigned)random() % 10, (unsigned)random() % 10, (unsigned)random() % 10);
60
+      srand((unsigned)time(NULL));
61
+      sprintf(pin, "%04d", (unsigned)rand() % 9999 + 1);
62
     }
63
     printf("Please enter the following PIN on the target PC: %s\n", pin);
64
     fflush(stdout);
(-)b/files/patch-src_platform.c (-4 / +27 lines)
Lines 1-10 Link Here
1
--- src/platform.c.orig	2021-12-20 00:24:48 UTC
1
--- src/platform.c.orig	2023-09-24 06:11:13 UTC
2
+++ src/platform.c
2
+++ src/platform.c
3
@@ -188,14 +188,6 @@ AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum plat
3
@@ -77,8 +77,8 @@ enum platform platform_check(char* name) {
4
       return (PAUDIO_RENDERER_CALLBACKS) dlsym(RTLD_DEFAULT, "audio_callbacks_omx");
4
   bool x11 = strcmp(name, "x11") == 0;
5
   bool vdpau = strcmp(name, "x11_vdpau") == 0;
6
   bool vaapi = strcmp(name, "x11_vaapi") == 0;
7
-  if (std || x11 || vdpau || vaapi) {
8
-    int init = x11_init(std || vdpau, std || vaapi);
9
+  if (x11 || vdpau || vaapi) {
10
+    int init = x11_init(vdpau, vaapi);
11
     #ifdef HAVE_VAAPI
12
     if (init == INIT_VAAPI)
13
       return X11_VAAPI;
14
@@ -87,11 +87,7 @@ enum platform platform_check(char* name) {
15
     if (init == INIT_VDPAU)
16
       return X11_VDPAU;
17
     #endif
18
-    #ifdef HAVE_SDL
19
-    return SDL;
20
-    #else
21
     return X11;
22
-    #endif
23
   }
24
   #endif
25
   #ifdef HAVE_SDL
26
@@ -195,13 +191,7 @@ AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum plat
5
     // fall-through
27
     // fall-through
6
   #endif
28
   #endif
7
-  default:
29
   default:
8
-    #ifdef HAVE_PULSE
30
-    #ifdef HAVE_PULSE
9
-    if (audio_pulse_init(audio_device))
31
-    if (audio_pulse_init(audio_device))
10
-      return &audio_callbacks_pulse;
32
-      return &audio_callbacks_pulse;
Lines 12-17 Link Here
12
-    #ifdef HAVE_ALSA
34
-    #ifdef HAVE_ALSA
13
-    return &audio_callbacks_alsa;
35
-    return &audio_callbacks_alsa;
14
-    #endif
36
-    #endif
37
+    return &audio_callbacks_oss;
15
   }
38
   }
16
   return NULL;
39
   return NULL;
17
 }
40
 }
(-)b/files/patch-src_video_ffmpeg__vaapi.c (+19 lines)
Added Link Here
1
--- src/video/ffmpeg_vaapi.c.orig	2023-09-24 06:11:13 UTC
2
+++ src/video/ffmpeg_vaapi.c
3
@@ -23,6 +23,7 @@
4
 #include <libavutil/hwcontext.h>
5
 #include <libavutil/hwcontext_vaapi.h>
6
 #include <X11/Xlib.h>
7
+#include <stdlib.h>
8
 
9
 #define MAX_SURFACES 16
10
 
11
@@ -59,7 +60,7 @@ static int va_get_buffer(AVCodecContext* context, AVFr
12
 }
13
 
14
 int vaapi_init_lib() {
15
-  return av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_VAAPI, ":0", NULL, 0);
16
+  return av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_VAAPI, getenv("DISPLAY") == NULL ? ":0" : getenv("DISPLAY"), NULL, 0);
17
 }
18
 
19
 int vaapi_init(AVCodecContext* decoder_ctx) {
(-)b/files/patch-third__party_moonlight-common-c_enet_CMakeLists.txt (+14 lines)
Added Link Here
1
--- third_party/moonlight-common-c/enet/CMakeLists.txt.orig	2023-09-24 06:11:13 UTC
2
+++ third_party/moonlight-common-c/enet/CMakeLists.txt
3
@@ -107,11 +107,3 @@ target_include_directories(enet SYSTEM PUBLIC include)
4
 if (MINGW)
5
     target_link_libraries(enet winmm ws2_32)
6
 endif()
7
-
8
-install(TARGETS enet
9
-    RUNTIME DESTINATION bin
10
-    ARCHIVE DESTINATION lib/static
11
-    LIBRARY DESTINATION lib)
12
-
13
-install(DIRECTORY include/
14
-        DESTINATION include)
(-)b/pkg-descr (-2 / +5 lines)
Lines 3-5 GameStream, as used by the NVIDIA Shield. Link Here
3
3
4
Moonlight Embedded allows you to stream your full collection of games
4
Moonlight Embedded allows you to stream your full collection of games
5
from your powerful Windows desktop to your FreeBSD system.
5
from your powerful Windows desktop to your FreeBSD system.
6
- 
6
7
--
7
First, pair: # moonlight pair 192.168.0.1
8
Then, connect: # moonlight stream -app Desktop -1080 192.168.0.1
9
10
ENJOY!
8
files/patch-CMakeLists.txt                    |  2 +-
11
files/patch-CMakeLists.txt                    |  2 +-
9
files/patch-docs_CMakeLists.txt               |  2 +-
12
files/patch-docs_CMakeLists.txt               |  2 +-
10
files/patch-docs_README.pod                   | 20 ++----
13
files/patch-docs_README.pod                   | 20 ++----
11
files/patch-libgamestream_CMakeLists.txt      |  2 +-
14
files/patch-libgamestream_CMakeLists.txt      |  2 +-
12
files/patch-libgamestream_client.c            |  2 +-
15
files/patch-libgamestream_client.c            |  2 +-
13
files/patch-libgamestream_http.c              |  2 +-
16
files/patch-libgamestream_http.c              |  2 +-
14
files/patch-src_audio_audio.h                 |  2 +-
17
files/patch-src_audio_audio.h                 |  2 +-
15
files/patch-src_audio_oss.c                   |  2 +-
18
files/patch-src_audio_oss.c                   |  2 +-
16
files/patch-src_input_evdev.c                 | 70 +++----------------
19
files/patch-src_input_evdev.c                 | 70 +++----------------
17
files/patch-src_main.c                        |  2 +-
20
files/patch-src_main.c                        |  2 +-
18
files/patch-src_platform.c                    |  2 +-
21
files/patch-src_platform.c                    |  2 +-
19
files/patch-src_video_ffmpeg__vaapi.c         |  2 +-
22
files/patch-src_video_ffmpeg__vaapi.c         |  2 +-
20
...rty_moonlight-common-c_enet_CMakeLists.txt |  2 +-
23
...rty_moonlight-common-c_enet_CMakeLists.txt |  2 +-
21
13 files changed, 23 insertions(+), 89 deletions(-)
24
13 files changed, 23 insertions(+), 89 deletions(-)
(-)b/files/patch-CMakeLists.txt (-1 / +1 lines)
Lines 1-4 Link Here
1
--- CMakeLists.txt.orig	2023-09-24 06:11:13 UTC
1
--- CMakeLists.txt.orig	2023-09-01 23:40:56 UTC
2
+++ CMakeLists.txt
2
+++ CMakeLists.txt
3
@@ -5,14 +5,11 @@ SET(CMAKE_C_STANDARD 99)
3
@@ -5,14 +5,11 @@ SET(CMAKE_C_STANDARD 99)
4
 include(${CMAKE_ROOT}/Modules/GNUInstallDirs.cmake)
4
 include(${CMAKE_ROOT}/Modules/GNUInstallDirs.cmake)
(-)b/files/patch-docs_CMakeLists.txt (-1 / +1 lines)
Lines 1-4 Link Here
1
--- docs/CMakeLists.txt.orig	2023-09-24 06:11:13 UTC
1
--- docs/CMakeLists.txt.orig	2023-09-01 23:40:56 UTC
2
+++ docs/CMakeLists.txt
2
+++ docs/CMakeLists.txt
3
@@ -1,4 +1,4 @@
3
@@ -1,4 +1,4 @@
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)
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)
(-)b/files/patch-docs_README.pod (-16 / +4 lines)
Lines 1-4 Link Here
1
--- docs/README.pod.orig	2023-09-24 06:11:13 UTC
1
--- docs/README.pod.orig	2023-09-01 23:40:56 UTC
2
+++ docs/README.pod
2
+++ docs/README.pod
3
@@ -27,6 +27,11 @@ Stream game from host to this computer.
3
@@ -27,6 +27,11 @@ Stream game from host to this computer.
4
 
4
 
Lines 37-54 Link Here
37
 =item B<-nounsupported>
37
 =item B<-nounsupported>
38
 
38
 
39
 Don't stream if resolution is not officially supported by the server
39
 Don't stream if resolution is not officially supported by the server
40
@@ -156,6 +163,10 @@ Disable all input processing (view-only mode)
40
@@ -170,11 +177,6 @@ Enable the I<INPUT> device.
41
 
42
 Disable gamepad mouse emulation (activated by long pressing Start button)
43
 
44
+=item B<-nosdl>
45
+
46
+Not Recommented.Use evdev instead of SDL to drive gamepad.
47
+
48
 =item B<-verbose>
49
 
50
 Enable verbose output
51
@@ -170,11 +181,6 @@ Enable the I<INPUT> device.
52
 By default all available input devices are enabled.
41
 By default all available input devices are enabled.
53
 Only evdev devices /dev/input/event* are supported.
42
 Only evdev devices /dev/input/event* are supported.
54
 
43
 
Lines 60-66 Link Here
60
 =item B<-windowed>
49
 =item B<-windowed>
61
 
50
 
62
 Display the stream in a window instead of fullscreen.
51
 Display the stream in a window instead of fullscreen.
63
@@ -182,22 +188,49 @@ Only available when X11 or SDL platform is used.
52
@@ -182,22 +184,48 @@ Only available when X11 or SDL platform is used.
64
 
53
 
65
 =back
54
 =back
66
 
55
 
Lines 94-105 Link Here
94
+=head1 KEYBOARD SHORTCUTS
83
+=head1 KEYBOARD SHORTCUTS
95
 
84
 
96
 Use Ctrl+Alt+Shift+Q or Play+Back+LeftShoulder+RightShoulder to quit the streaming session.
85
 Use Ctrl+Alt+Shift+Q or Play+Back+LeftShoulder+RightShoulder to quit the streaming session.
97
+Use Ctrl+Alt+Shift+G to grab or ungrab keyboard.(only x11* platform)
98
 
86
 
99
+=head1 GAMEPAD
87
+=head1 GAMEPAD
100
+
88
+
101
+FreeBSD supports fewer controllers.Please see hgame(4) xb360gp(4) ps4dshock(4) and FreeBSD forums...
89
+FreeBSD supports fewer controllers.Please see hgame(4) xb360gp(4) ps4dshock(4) and FreeBSD forums...
102
+There is a problem with the evdev drive gamepad,so -nosdl is not recommended.But you can try it yourself.
90
+SDL platforms have better compatibility for gamepad.
103
+
91
+
104
+=head1 COMMENTS
92
+=head1 COMMENTS
105
+
93
+
(-)b/files/patch-libgamestream_CMakeLists.txt (-1 / +1 lines)
Lines 1-4 Link Here
1
--- libgamestream/CMakeLists.txt.orig	2023-09-24 06:11:13 UTC
1
--- libgamestream/CMakeLists.txt.orig	2023-09-01 23:40:56 UTC
2
+++ libgamestream/CMakeLists.txt
2
+++ libgamestream/CMakeLists.txt
3
@@ -3,7 +3,7 @@ set(SO_VERSION 4)
3
@@ -3,7 +3,7 @@ set(SO_VERSION 4)
4
 find_package(LibUUID REQUIRED)
4
 find_package(LibUUID REQUIRED)
(-)b/files/patch-libgamestream_client.c (-1 / +1 lines)
Lines 1-4 Link Here
1
--- libgamestream/client.c.orig	2023-09-24 06:11:13 UTC
1
--- libgamestream/client.c.orig	2023-09-01 23:40:56 UTC
2
+++ libgamestream/client.c
2
+++ libgamestream/client.c
3
@@ -537,7 +537,11 @@ int gs_pair(PSERVER_DATA server, char* pin) {
3
@@ -537,7 +537,11 @@ int gs_pair(PSERVER_DATA server, char* pin) {
4
   RAND_bytes(client_secret_data, sizeof(client_secret_data));
4
   RAND_bytes(client_secret_data, sizeof(client_secret_data));
(-)b/files/patch-libgamestream_http.c (-1 / +1 lines)
Lines 1-4 Link Here
1
--- libgamestream/http.c.orig	2023-09-24 06:11:13 UTC
1
--- libgamestream/http.c.orig	2023-09-01 23:40:56 UTC
2
+++ libgamestream/http.c
2
+++ libgamestream/http.c
3
@@ -73,6 +73,9 @@ int http_init(const char* keyDirectory, int logLevel) 
3
@@ -73,6 +73,9 @@ int http_init(const char* keyDirectory, int logLevel) 
4
 int http_request(char* url, PHTTP_DATA data) {
4
 int http_request(char* url, PHTTP_DATA data) {
(-)b/files/patch-src_audio_audio.h (-1 / +1 lines)
Lines 1-4 Link Here
1
--- src/audio/audio.h.orig	2023-09-24 06:11:13 UTC
1
--- src/audio/audio.h.orig	2023-09-01 23:40:56 UTC
2
+++ src/audio/audio.h
2
+++ src/audio/audio.h
3
@@ -31,3 +31,4 @@ extern AUDIO_RENDERER_CALLBACKS audio_callbacks_sdl;
3
@@ -31,3 +31,4 @@ extern AUDIO_RENDERER_CALLBACKS audio_callbacks_sdl;
4
 extern AUDIO_RENDERER_CALLBACKS audio_callbacks_pulse;
4
 extern AUDIO_RENDERER_CALLBACKS audio_callbacks_pulse;
(-)b/files/patch-src_audio_oss.c (-1 / +1 lines)
Lines 1-4 Link Here
1
--- src/audio/oss.c.orig	2023-09-24 06:11:13 UTC
1
--- src/audio/oss.c.orig	2023-09-24 06:52:39 UTC
2
+++ src/audio/oss.c
2
+++ src/audio/oss.c
3
@@ -0,0 +1,102 @@
3
@@ -0,0 +1,102 @@
4
+/*
4
+/*
(-)b/files/patch-src_input_evdev.c (-62 / +8 lines)
Lines 1-6 Link Here
1
--- src/input/evdev.c.orig	2023-09-24 06:11:13 UTC
1
--- src/input/evdev.c.orig	2023-09-01 23:40:56 UTC
2
+++ src/input/evdev.c
2
+++ src/input/evdev.c
3
@@ -38,10 +38,13 @@
3
@@ -38,10 +38,12 @@
4
 #include <limits.h>
4
 #include <limits.h>
5
 #include <unistd.h>
5
 #include <unistd.h>
6
 #include <pthread.h>
6
 #include <pthread.h>
Lines 9-22 Link Here
9
 #include <math.h>
9
 #include <math.h>
10
 
10
 
11
-#if __BYTE_ORDER == __LITTLE_ENDIAN
11
-#if __BYTE_ORDER == __LITTLE_ENDIAN
12
+void grab_keyboard();
13
+bool iskeyboardgrab = true;
12
+bool iskeyboardgrab = true;
14
+
13
+
15
+#if _BYTE_ORDER == _LITTLE_ENDIAN
14
+#if _BYTE_ORDER == _LITTLE_ENDIAN
16
 #define int16_to_le(val) val
15
 #define int16_to_le(val) val
17
 #else
16
 #else
18
 #define int16_to_le(val) ((((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00))
17
 #define int16_to_le(val) ((((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00))
19
@@ -66,8 +69,8 @@ struct input_device {
18
@@ -66,8 +68,8 @@ struct input_device {
20
   int hats_state[3][2];
19
   int hats_state[3][2];
21
   int fd;
20
   int fd;
22
   char modifiers;
21
   char modifiers;
Lines 27-52 Link Here
27
   struct timeval touchDownTime;
26
   struct timeval touchDownTime;
28
   struct timeval btnDownTime;
27
   struct timeval btnDownTime;
29
   short controllerId;
28
   short controllerId;
30
@@ -127,6 +130,7 @@ int evdev_gamepads = 0;
29
@@ -343,7 +345,7 @@ static bool evdev_handle_event(struct input_event *ev,
31
 
32
 #define ACTION_MODIFIERS (MODIFIER_SHIFT|MODIFIER_ALT|MODIFIER_CTRL)
33
 #define QUIT_KEY KEY_Q
34
+#define UNGRAB_KEY KEY_G
35
 #define QUIT_BUTTONS (PLAY_FLAG|BACK_FLAG|LB_FLAG|RB_FLAG)
36
 
37
 static bool (*handler) (struct input_event*, struct input_device*);
38
@@ -247,8 +251,8 @@ void *HandleMouseEmulation(void* param)
39
     deltaY = pow((float)rawY / 32767.0f * MOUSE_EMULATION_MOTION_MULTIPLIER, 3);
40
 
41
     // Enforce deadzones
42
-    deltaX = fabs(deltaX) > MOUSE_EMULATION_DEADZONE ? deltaX - MOUSE_EMULATION_DEADZONE : 0;
43
-    deltaY = fabs(deltaY) > MOUSE_EMULATION_DEADZONE ? deltaY - MOUSE_EMULATION_DEADZONE : 0;
44
+    deltaX = abs(deltaX) > MOUSE_EMULATION_DEADZONE ? deltaX - MOUSE_EMULATION_DEADZONE : 0;
45
+    deltaY = abs(deltaY) > MOUSE_EMULATION_DEADZONE ? deltaY - MOUSE_EMULATION_DEADZONE : 0;
46
 
47
     if (deltaX != 0 || deltaY != 0)
48
       LiSendMouseMoveEvent(deltaX, -deltaY);
49
@@ -343,7 +347,7 @@ static bool evdev_handle_event(struct input_event *ev,
50
     if (dev->mouseHScroll != 0) {
30
     if (dev->mouseHScroll != 0) {
51
       LiSendHScrollEvent(dev->mouseHScroll);
31
       LiSendHScrollEvent(dev->mouseHScroll);
52
       dev->mouseHScroll = 0;
32
       dev->mouseHScroll = 0;
Lines 55-72 Link Here
55
     if (dev->gamepadModified) {
35
     if (dev->gamepadModified) {
56
       if (dev->controllerId < 0) {
36
       if (dev->controllerId < 0) {
57
         for (int i = 0; i < MAX_GAMEPADS; i++) {
37
         for (int i = 0; i < MAX_GAMEPADS; i++) {
58
@@ -404,6 +408,10 @@ static bool evdev_handle_event(struct input_event *ev,
38
@@ -813,7 +815,7 @@ void evdev_create(const char* device, struct mapping* 
59
         return true;
60
       } else if (waitingToExitOnModifiersUp && dev->modifiers == 0)
61
         return false;
62
+      if ((dev->modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS &&
63
+          ev->code == UNGRAB_KEY && ev->value != 0) {
64
+        grab_keyboard();
65
+      }
66
 
67
       short code = 0x80 << 8 | keyCodes[ev->code];
68
       LiSendKeyboardEvent(code, ev->value?KEY_ACTION_DOWN:KEY_ACTION_UP, dev->modifiers);
69
@@ -813,7 +821,7 @@ void evdev_create(const char* device, struct mapping* 
70
   if (mappings == NULL && strstr(name, "Xbox 360 Wireless Receiver") != NULL)
39
   if (mappings == NULL && strstr(name, "Xbox 360 Wireless Receiver") != NULL)
71
     mappings = xwc_mapping;
40
     mappings = xwc_mapping;
72
 
41
 
Lines 75-114 Link Here
75
   bool is_mouse = libevdev_has_event_type(evdev, EV_REL) || libevdev_has_event_code(evdev, EV_KEY, BTN_LEFT);
44
   bool is_mouse = libevdev_has_event_type(evdev, EV_REL) || libevdev_has_event_code(evdev, EV_KEY, BTN_LEFT);
76
   bool is_touchscreen = libevdev_has_event_code(evdev, EV_KEY, BTN_TOUCH);
45
   bool is_touchscreen = libevdev_has_event_code(evdev, EV_KEY, BTN_TOUCH);
77
 
46
 
78
@@ -1055,9 +1063,13 @@ void evdev_start() {
47
@@ -1055,8 +1057,12 @@ void evdev_start() {
79
   // we're ready to take input events. Ctrl+C works up until
48
   // we're ready to take input events. Ctrl+C works up until
80
   // this point.
49
   // this point.
81
   for (int i = 0; i < numDevices; i++) {
50
   for (int i = 0; i < numDevices; i++) {
82
-    if ((devices[i].is_keyboard || devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
51
-    if ((devices[i].is_keyboard || devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
83
+    if ((devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
52
+    if ((devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
84
       fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
53
       fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
85
     }
54
+    }
86
+    if (devices[i].is_keyboard && libevdev_get_id_bustype(devices[i].dev) > 3) {
55
+    if (devices[i].is_keyboard && libevdev_get_id_bustype(devices[i].dev) > 3) {
87
+      if (ioctl(devices[i].fd, EVIOCGRAB, 1) < 0)
56
+      if (ioctl(devices[i].fd, EVIOCGRAB, 1) < 0)
88
+        fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
57
+        fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
89
+    }
58
     }
90
   }
59
   }
91
 
60
 
92
   // Any new input devices detected after this point will be grabbed immediately
93
@@ -1111,4 +1123,21 @@ void evdev_rumble(unsigned short controller_id, unsign
94
   event.value = 1;
95
   write(device->fd, (const void*) &event, sizeof(event));
96
   device->haptic_effect_id = effect.id;
97
+}
98
+
99
+void grab_keyboard() {
100
+  int grabnum;
101
+  if (iskeyboardgrab) {
102
+    grabnum = 0;
103
+    iskeyboardgrab = false;
104
+  } else {
105
+    grabnum = 1;
106
+    iskeyboardgrab = true;
107
+  }
108
+  for (int i = 0; i < numDevices; i++) {
109
+    if (devices[i].is_keyboard && libevdev_get_id_bustype(devices[i].dev) > 3) {
110
+      if (ioctl(devices[i].fd, EVIOCGRAB, grabnum) < 0)
111
+        fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
112
+    }
113
+  }
114
 }
(-)b/files/patch-src_main.c (-1 / +1 lines)
Lines 1-4 Link Here
1
--- src/main.c.orig	2023-09-24 06:11:13 UTC
1
--- src/main.c.orig	2023-09-01 23:40:56 UTC
2
+++ src/main.c
2
+++ src/main.c
3
@@ -42,6 +42,7 @@
3
@@ -42,6 +42,7 @@
4
 #include <client.h>
4
 #include <client.h>
(-)b/files/patch-src_platform.c (-1 / +1 lines)
Lines 1-4 Link Here
1
--- src/platform.c.orig	2023-09-24 06:11:13 UTC
1
--- src/platform.c.orig	2023-09-01 23:40:56 UTC
2
+++ src/platform.c
2
+++ src/platform.c
3
@@ -77,8 +77,8 @@ enum platform platform_check(char* name) {
3
@@ -77,8 +77,8 @@ enum platform platform_check(char* name) {
4
   bool x11 = strcmp(name, "x11") == 0;
4
   bool x11 = strcmp(name, "x11") == 0;
(-)b/files/patch-src_video_ffmpeg__vaapi.c (-1 / +1 lines)
Lines 1-4 Link Here
1
--- src/video/ffmpeg_vaapi.c.orig	2023-09-24 06:11:13 UTC
1
--- src/video/ffmpeg_vaapi.c.orig	2023-09-01 23:40:56 UTC
2
+++ src/video/ffmpeg_vaapi.c
2
+++ src/video/ffmpeg_vaapi.c
3
@@ -23,6 +23,7 @@
3
@@ -23,6 +23,7 @@
4
 #include <libavutil/hwcontext.h>
4
 #include <libavutil/hwcontext.h>
(-)b/files/patch-third__party_moonlight-common-c_enet_CMakeLists.txt (-2 / +1 lines)
Lines 1-4 Link Here
1
--- third_party/moonlight-common-c/enet/CMakeLists.txt.orig	2023-09-24 06:11:13 UTC
1
--- third_party/moonlight-common-c/enet/CMakeLists.txt.orig	2023-07-30 18:58:58 UTC
2
+++ third_party/moonlight-common-c/enet/CMakeLists.txt
2
+++ third_party/moonlight-common-c/enet/CMakeLists.txt
3
@@ -107,11 +107,3 @@ target_include_directories(enet SYSTEM PUBLIC include)
3
@@ -107,11 +107,3 @@ target_include_directories(enet SYSTEM PUBLIC include)
4
 if (MINGW)
4
 if (MINGW)
5
- 

Return to bug 274026