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

Collapse All | Expand All

(-)libgamestream/http.c (-49 / +101 lines)
Line  Link Here
QÈNw›ýÂTC2q¯dakJëêÝ ‰n»ê4a–CNԞPÉo›õˆÌ˜„Ò^.?´Ñ_}ŽúîPÆ5¸~Ï ª`°®#ÿûÙï¸uä«	¡R/¢s}ÖVW'ÙÆwÖO;T»$]îGº#äø€ d„aô´|ýX0ì˜KÔáè—δ>à՘9€©¤i~Ât—Æ>92¡„J¡X‹9:Ãr* ¨½¥*ì-¡º"«”xq¶pM íî¾Øåfé¸m!EôŽ·n‘MYênË5;E#:d­[VÁ™ñ³ð¨öàBRE?›ˆ4H2xéÇÒä<î²9Ý.õ û#ðBMFݟ¡>e°Ñð-3^G]9žÐM%¾à°ïOŸëŒßkL(ÆJ£ÐЫõÌkÇeßÑSÝMì:$ݺ½áv—±œp5V(Â@|NGžÍè£ë
3Rµò‰òxÝâ³î0¤96È؜ÚOæÅé)L¨âxÕ£’›á•VÐ^ÿìHIÛw1Ü	móÖ¹
1
"­“ª¼¡ê§•Ó8¸×ˆÚ¯Jc‚á†júͽ:ý{I—fW]ʆšªH9]M+ãR=‰›¦Ý ÔLé?‘@›„wnáºQV‚‡³œp÷Î5åkþetæÂ±ŽW§÷&itÜ@<–	,T	fóÉdӷՌN/W#°'5ßaˆÕ¬¼nõU*®½40ãt—eÃþWž§bïé‡ÀÒ³¦ÊöÀד«)|Ùß¿¶ñj¶ß©ÊVa Ñ ç¿æUt֞ՁHè^c6ÜôÒwŠÇ”¿Xµcuè»óþ¹Z+;SԖâ_a;Wþm©yëŸå _&ý½Ì8YjuÜÝy=tM¯à¯fp£{ôډ#
ëBJf£ðaÞ§÷¨UPû¾
ûm“xò—laFúp6Ç.ýP nM+ X°ixFîQhuæÞ+
0ő6؁³QêYJÛQT-IïVFFéäðQ‚ŒüÁQ	$LÄ=! ‰‰Ý0¨ÏÉWT͗¤o‰xœÚǯBÙ?åVùxö;㛡ñ?ÉýH"HǍ‹…žtÿW^ï4m"4œµ^ð•_J}›-
2
0ő6؁³QêYJÛQT-IïVFFéäðQ‚ŒüÁQ	$LÄ=! ‰‰Ý0¨ÏÉWT͗¤o‰xœÚǯBÙ?åVùxö;㛡ñ?ÉýH"HǍ‹…žtÿW^ï4m"4œµ^ð•_J}›-
1
³ Få·OV‡ØUέ̽䙗È}7š3HƒÝLìPàNB¶ÑöëÖ¯c+Ö°¥js+۞ÍYº]¸šû6œÛa®C•<±ÿMb>üG5|ä0“l_¢—«–g—X uüR/­™L{õ$86—ُá‡6>Pº0Ò'ÌÖ¦!qÛíÑW–Ðu\±Œ+ÓÏ>¥d©ŒHb&CjÁß~•…åÇÖ°JŏÁ~¶°êão¿™KgሉiüÓ()Ç#ås†¬—MrÅó÷é
²yØêþhi®\æÒÓáñÞÊ=ð#¶æ<j?ˆMì«fòÞ6%p-¯X[›ó·Ã׿åÀÀŸ Âu8ˆÁÒW"Í~è²[ˆ¸¯èÆõʝŽ
ýGMºÏSÞ&‡4é†;72e„|”¢ÑŽ}uÉҜçã
´EÄÜiBÎNÙ¸†¬bM¾0í~ƒ¬‘ôüÄÛùKLŒ¡}ÞQ`iGÀ©6d ,äy7)ðLlàsIæÉ÷ڗq1̎	„wè“&՗
ŸO!äÓ_’B‡Ä;[B\
3
àñ}PÇvð¡Mõ»¨ðjtT'„‰ÑFØnNyQė\
É©ùo»|ŸoÕ©ÒHÛöEÃ#"žYD³ÿÅ.ðôÈ]֋ᄬ՟•ò/³õàý0`bSQè¬Ç”À/8áû·©"ÝÜ.’¼Å¡	Ì+‹2o^RûJð$S•­„†NäKæá)hòù±uHæio¦VØWw›
2
×S?V¡½ÕJj é—ŽÖzèûóæô{Ð]gzº¢!¾4ىe,w(^’a!á­Ê‘G[_(œ	åÂå¨4uìhà,‡„ŵ…”ì$…?bI8í® q@DÎÈAqy›±6Mu{cð]‡xøíhÃi@°sÙC/¡û“Œü}›4Ø(D,„–ՁÉQ—|ìÞX ‹Ÿ˜°¶¹–ÿ$Z(Çh[ÅÓã̙ekŸ5žž÷4Qèåk¼3Ý$¾WÍåUY‡œE䋐–‰üþDÒ¤vjœvïðhŽ”’Z
3
1œ£Ûg¿ÁVT½;Ñ»éòì­Ï;´×ËU!ØTŠ€bµªÐŸ$)ýzàѳ2ŸŽ”Ðyõ ‹Â!›Zz`—pŽ:Ì~iÏly(݇C0v•ÒЭÎnõKRþCµ‡ðDVE$‹)‰.š,šŽé N֑Q[È û¼ƒ07³=aŸ³ÆOQ¤;â‘7ªuÆë™x˛~&É5º±›*ï†ù
ºLlFÞËÏ ˜Ÿ—FF;ÇI[lªLȑSµvþ¾÷í›ÈªžXl)ý~sÂ@ùGÊ®mÎÿðÖþ›øÁ]fÜøݏ¡4éù‘ùBý¨»´XÇä#½Š©è4I
4
1œ£Ûg¿ÁVT½;Ñ»éòì­Ï;´×ËU!ØTŠ€bµªÐŸ$)ýzàѳ2ŸŽ”Ðyõ ‹Â!›Zz`—pŽ:Ì~iÏly(݇C0v•ÒЭÎnõKRþCµ‡ðDVE$‹)‰.š,šŽé N֑Q[È û¼ƒ07³=aŸ³ÆOQ¤;â‘7ªuÆë™x˛~&É5º±›*ï†ù
ºLlFÞËÏ ˜Ÿ—FF;ÇI[lªLȑSµvþ¾÷í›ÈªžXl)ý~sÂ@ùGÊ®mÎÿðÖþ›øÁ]fÜøݏ¡4éù‘ùBý¨»´XÇä#½Š©è4I
4
+e”ˆ@LüÇiœ"AÄ·àTÇGÏü1a/jå<HbìÞiTËݑ„Dø×I !H·14\Ÿr&•O:>åuj‘ýðmS6q”/vãÌ[U~…Ì@mæ!Ÿ+PÜȓäLˆ?õd†æ*CäÐÃӒZV„1Çì7¡E+×ß½ª24üLá£_åt˜Ümóö¶"èÇzôYâJ³´/J9sb9N–ЫiQÞ±¢€UØïu
5
+e”ˆ@LüÇiœ"AÄ·àTÇGÏü1a/jå<HbìÞiTËݑ„Dø×I !H·14\Ÿr&•O:>åuj‘ýðmS6q”/vãÌ[U~…Ì@mæ!Ÿ+PÜȓäLˆ?õd†æ*CäÐÃӒZV„1Çì7¡E+×ß½ª24üLá£_åt˜Ümóö¶"èÇzôYâJ³´/J9sb9N–ЫiQÞ±¢€UØïu
5
#C¶ÚE圻Y;­ËÞÝHù²éa•F-€™g•òÀt¹ËÑt¶ÔÀÁߍV§8¹sONJâi2bMi+µ~`²IØP
6
#C¶ÚE圻Y;­ËÞÝHù²éa•F-€™g•òÀt¹ËÑt¶ÔÀÁߍV§8¹sONJâi2bMi+µ~`²IØP
6
´±¼Ù°Z雝 6CîÓGVò¡Ð14Asg~×LÒ@᳁‰’?õtZtôð¥Ð€e‹ÉY‹0ø7o„eý¢ds¶!EѶƒkñ‚ëÊ&¢Xo‡H‘›JÂÿó&’¦ b…â¡ÐûG­4²·ÜVMàÔ1
7
´±¼Ù°Z雝 6CîÓGVò¡Ð14Asg~×LÒ@᳁‰’?õtZtôð¥Ð€e‹ÉY‹0ø7o„eý¢ds¶!EѶƒkñ‚ëÊ&¢Xo‡H‘›JÂÿó&’¦ b…â¡ÐûG­4²·ÜVMàÔ1
7
²~=Ð
8
²~=Ð
9
eaa©Ega[|5èÔ"oœ.í*ãÿùeø. ˜#ÙU‡ÒW»2ò0÷e>ˆ
10
11
+"%ÃK,’]y@¨> ÙõD]æãS'ð‘,*‹ƒWtlièùà<UÜ@t\<UUÁ–hõµÑôGa³CIŸ‘*³Ñþƒ"Lj!4‹^ØA§ Ì1\^˜õ|îÕøUÿûg3t&ä}FŽzÊY÷'†NZyw2P€7Üû”t8‚YBÏ.•c`xÙÌÙK&ŤvkÖ£Ïс‘ß!}ª8ɟ¤t²±Á°Í_žó=FÇH†ÞX‚pÿœËŠYþ:ˆåx
†<…s^ä„&ôIêGOÉjLC«èh€zšÊiDxo]òY «ÝpQÍWŒØÍ/¤{ºáÀÁ¢fs6ÿävåÓ:iŸS×.ª³‡²•(ʊ
Åùz´¿æ[‚Â"Û¤<_„¨N„„6h:ÏqEúBV
Lines 23-28 Link Here
23
#include "platform.h"
23
#include "platform.h"
24
#include "config.h"
24
#include "config.h"
25
#include "sdl.h"
25
#include "sdl.h"
26
#include "x11_sdl.h"
26
27
27
#include "audio/audio.h"
28
#include "audio/audio.h"
28
#include "video/video.h"
29
#include "video/video.h"
Lines 42-47 Link Here
42
#include <client.h>
43
#include <client.h>
43
#include <discover.h>
44
#include <discover.h>
44
45
46
#include <time.h>
45
#include <stdio.h>
47
#include <stdio.h>
46
#include <stdlib.h>
48
#include <stdlib.h>
47
#include <stdbool.h>
49
#include <stdbool.h>
Lines 52-58 Link Here
52
#include <netinet/in.h>
54
#include <netinet/in.h>
53
#include <netdb.h>
55
#include <netdb.h>
54
#include <arpa/inet.h>
56
#include <arpa/inet.h>
55
#include <openssl/rand.h>
56
57
57
static void applist(PSERVER_DATA server) {
58
static void applist(PSERVER_DATA server) {
58
  PAPP_LIST list = NULL;
59
  PAPP_LIST list = NULL;
Lines 139-146 Link Here
139
    connection_debug = true;
140
    connection_debug = true;
140
  }
141
  }
141
142
142
  if (IS_EMBEDDED(system))
143
  if (IS_EMBEDDED(system)) {
143
    loop_init();
144
    loop_init();
145
    if (!isNoSdl)
146
      x11_sdl_init();
147
  }
144
148
145
  platform_start(system);
149
  platform_start(system);
146
  LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system, config->audio_device), NULL, drFlags, config->audio_device, 0);
150
  LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system, config->audio_device), NULL, drFlags, config->audio_device, 0);
Lines 148-154 Link Here
148
  if (IS_EMBEDDED(system)) {
152
  if (IS_EMBEDDED(system)) {
149
    if (!config->viewonly)
153
    if (!config->viewonly)
150
      evdev_start();
154
      evdev_start();
151
    loop_main();
155
    if (!isNoSdl)
156
      x11_sdl_loop_main(config->stream.width, config->stream.height);
157
    else
158
      loop_main();
152
    if (!config->viewonly)
159
    if (!config->viewonly)
153
      evdev_stop();
160
      evdev_stop();
154
  }
161
  }
Lines 202-208 Link Here
202
  printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
209
  printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
203
  printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");
210
  printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");
204
  printf("\t-codec <codec>\t\tSelect used codec: auto/h264/h265/av1 (default auto)\n");
211
  printf("\t-codec <codec>\t\tSelect used codec: auto/h264/h265/av1 (default auto)\n");
205
  printf("\t-hdr\t\tEnable HDR streaming (experimental, requires host and device support)\n");
206
  printf("\t-remote <yes/no/auto>\t\t\tEnable optimizations for WAN streaming (default auto)\n");
212
  printf("\t-remote <yes/no/auto>\t\t\tEnable optimizations for WAN streaming (default auto)\n");
207
  printf("\t-app <app>\t\tName of app to stream\n");
213
  printf("\t-app <app>\t\tName of app to stream\n");
208
  printf("\t-nosops\t\t\tDon't allow GFE to modify game settings\n");
214
  printf("\t-nosops\t\t\tDon't allow GFE to modify game settings\n");
Lines 251-258 Link Here
251
      exit(-1);
257
      exit(-1);
252
    }
258
    }
253
259
254
    evdev_create(config.inputs[0], NULL, config.debug_level > 0, config.rotate);
260
    if (isNoSdl) {
255
    evdev_map(config.inputs[0]);
261
      evdev_create(config.inputs[0], NULL, config.debug_level > 0, config.rotate);
262
      evdev_map(config.inputs[0]);    
263
    }
256
    exit(0);
264
    exit(0);
257
  }
265
  }
258
266
Lines 300-306 Link Here
300
  if (config.debug_level > 0) {
308
  if (config.debug_level > 0) {
301
    printf("GPU: %s, GFE: %s (%s, %s)\n", server.gpuType, server.serverInfo.serverInfoGfeVersion, server.gsVersion, server.serverInfo.serverInfoAppVersion);
309
    printf("GPU: %s, GFE: %s (%s, %s)\n", server.gpuType, server.serverInfo.serverInfoGfeVersion, server.gsVersion, server.serverInfo.serverInfoAppVersion);
302
    printf("Server codec flags: 0x%x\n", server.serverInfo.serverCodecModeSupport);
310
    printf("Server codec flags: 0x%x\n", server.serverInfo.serverCodecModeSupport);
303
  }
311
  }    
304
312
305
  if (strcmp("list", config.action) == 0) {
313
  if (strcmp("list", config.action) == 0) {
306
    pair_check(&server);
314
    pair_check(&server);
Lines 322-340 Link Here
322
    config.stream.supportedVideoFormats = VIDEO_FORMAT_H264;
330
    config.stream.supportedVideoFormats = VIDEO_FORMAT_H264;
323
    if (config.codec == CODEC_HEVC || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, CODEC_HEVC))) {
331
    if (config.codec == CODEC_HEVC || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, CODEC_HEVC))) {
324
      config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265;
332
      config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265;
325
      if (config.hdr)
333
      //if (config.hdr)
326
        config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10;
334
      //  config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10;
327
    }
335
    }
328
    if (config.codec == CODEC_AV1 || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, CODEC_AV1))) {
336
    if (config.codec == CODEC_AV1 || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, CODEC_AV1))) {
329
      config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN8;
337
      config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN8;
330
      if (config.hdr)
338
      //if (config.hdr)
331
        config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10;
339
      //  config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10;
332
    }
340
    }
333
341
334
    if (config.hdr && !(config.stream.supportedVideoFormats & VIDEO_FORMAT_MASK_10BIT)) {
342
    //if (config.hdr && !(config.stream.supportedVideoFormats & VIDEO_FORMAT_MASK_10BIT)) {
335
      fprintf(stderr, "HDR streaming requires HEVC or AV1 codec\n");
343
    //  fprintf(stderr, "HDR streaming requires HEVC or AV1 codec\n");
336
      exit(-1);
344
    //  exit(-1);
337
    }
345
    //}    
338
346
339
    #ifdef HAVE_SDL
347
    #ifdef HAVE_SDL
340
    if (system == SDL)
348
    if (system == SDL)
Lines 371-377 Link Here
371
379
372
        udev_init(!inputAdded, mappings, config.debug_level > 0, config.rotate);
380
        udev_init(!inputAdded, mappings, config.debug_level > 0, config.rotate);
373
        evdev_init(config.mouse_emulation);
381
        evdev_init(config.mouse_emulation);
374
        rumble_handler = evdev_rumble;
382
        if (isNoSdl)
383
          rumble_handler = evdev_rumble;
384
        else {
385
          sdlinput_init(config.mapping);
386
          rumble_handler = sdlinput_rumble;
387
          rumble_triggers_handler = sdlinput_rumble_triggers;
388
          set_motion_event_state_handler = sdlinput_set_motion_event_state;
389
          set_controller_led_handler = sdlinput_set_controller_led;
390
        }
375
        #ifdef HAVE_LIBCEC
391
        #ifdef HAVE_LIBCEC
376
        cec_init();
392
        cec_init();
377
        #endif /* HAVE_LIBCEC */
393
        #endif /* HAVE_LIBCEC */
Lines 398-404 Link Here
398
    if (config.pin > 0 && config.pin <= 9999) {
414
    if (config.pin > 0 && config.pin <= 9999) {
399
      sprintf(pin, "%04d", config.pin);
415
      sprintf(pin, "%04d", config.pin);
400
    } else {
416
    } else {
401
      sprintf(pin, "%d%d%d%d", (unsigned)random() % 10, (unsigned)random() % 10, (unsigned)random() % 10, (unsigned)random() % 10);
417
      srand((unsigned)time(NULL));
418
      sprintf(pin, "%04d", (unsigned)rand() % 9999 + 1);
402
    }
419
    }
403
    printf("Please enter the following PIN on the target PC: %s\n", pin);
420
    printf("Please enter the following PIN on the target PC: %s\n", pin);
404
    fflush(stdout);
421
    fflush(stdout);
Lines 77-84 Link Here
77
  bool x11 = strcmp(name, "x11") == 0;
77
  bool x11 = strcmp(name, "x11") == 0;
78
  bool vdpau = strcmp(name, "x11_vdpau") == 0;
78
  bool vdpau = strcmp(name, "x11_vdpau") == 0;
79
  bool vaapi = strcmp(name, "x11_vaapi") == 0;
79
  bool vaapi = strcmp(name, "x11_vaapi") == 0;
80
  if (std || x11 || vdpau || vaapi) {
80
  if (x11 || vdpau || vaapi) {
81
    int init = x11_init(std || vdpau, std || vaapi);
81
    int init = x11_init(vdpau, vaapi);
82
    #ifdef HAVE_VAAPI
82
    #ifdef HAVE_VAAPI
83
    if (init == INIT_VAAPI)
83
    if (init == INIT_VAAPI)
84
      return X11_VAAPI;
84
      return X11_VAAPI;
Lines 87-104 Link Here
87
    if (init == INIT_VDPAU)
87
    if (init == INIT_VDPAU)
88
      return X11_VDPAU;
88
      return X11_VDPAU;
89
    #endif
89
    #endif
90
    #ifdef HAVE_SDL
91
    return SDL;
92
    #else
93
    return X11;
90
    return X11;
94
    #endif
95
  }
91
  }
96
  #endif
92
  #endif
97
  #ifdef HAVE_SDL
93
  #ifdef HAVE_SDL
98
  if (std || strcmp(name, "sdl") == 0)
94
  if (std || strcmp(name, "sdl") == 0)
99
    return SDL;
95
    return SDL;
100
  #endif
96
  #endif
101
102
  if (strcmp(name, "fake") == 0)
97
  if (strcmp(name, "fake") == 0)
103
    return FAKE;
98
    return FAKE;
104
99
Lines 109-122 Link Here
109
  switch (system) {
104
  switch (system) {
110
  #ifdef HAVE_AML
105
  #ifdef HAVE_AML
111
  case AML:
106
  case AML:
112
    write_bool("/sys/class/graphics/fb0/blank", true);
107
    blank_fb("/sys/class/graphics/fb0/blank", true);
113
    write_bool("/sys/class/graphics/fb1/blank", true);
108
    blank_fb("/sys/class/graphics/fb1/blank", true);
114
    write_bool("/sys/class/video/disable_video", false);
109
    blank_fb("/sys/class/video/disable_video", false);
115
    break;
110
    break;
116
  #endif
111
  #endif
117
  #if defined(HAVE_PI) || defined(HAVE_MMAL)
112
  #if defined(HAVE_PI) || defined(HAVE_MMAL)
118
  case PI:
113
  case PI:
119
    write_bool("/sys/class/graphics/fb0/blank", true);
114
    blank_fb("/sys/class/graphics/fb0/blank", true);
120
    break;
115
    break;
121
  #endif
116
  #endif
122
  }
117
  }
Lines 126-138 Link Here
126
  switch (system) {
121
  switch (system) {
127
  #ifdef HAVE_AML
122
  #ifdef HAVE_AML
128
  case AML:
123
  case AML:
129
    write_bool("/sys/class/graphics/fb0/blank", false);
124
    blank_fb("/sys/class/graphics/fb0/blank", false);
130
    write_bool("/sys/class/graphics/fb1/blank", false);
125
    blank_fb("/sys/class/graphics/fb1/blank", false);
131
    break;
126
    break;
132
  #endif
127
  #endif
133
  #if defined(HAVE_PI) || defined(HAVE_MMAL)
128
  #if defined(HAVE_PI) || defined(HAVE_MMAL)
134
  case PI:
129
  case PI:
135
    write_bool("/sys/class/graphics/fb0/blank", false);
130
    blank_fb("/sys/class/graphics/fb0/blank", false);
136
    break;
131
    break;
137
  #endif
132
  #endif
138
  }
133
  }
Lines 195-207 Link Here
195
    // fall-through
190
    // fall-through
196
  #endif
191
  #endif
197
  default:
192
  default:
198
    #ifdef HAVE_PULSE
193
      return &audio_callbacks_oss;
199
    if (audio_pulse_init(audio_device))
200
      return &audio_callbacks_pulse;
201
    #endif
202
    #ifdef HAVE_ALSA
203
    return &audio_callbacks_alsa;
204
    #endif
205
  }
194
  }
206
  return NULL;
195
  return NULL;
207
}
196
}
Lines 38-47 Link Here
38
#include <limits.h>
38
#include <limits.h>
39
#include <unistd.h>
39
#include <unistd.h>
40
#include <pthread.h>
40
#include <pthread.h>
41
#include <endian.h>
41
#include <sys/endian.h>
42
#include <math.h>
42
#include <math.h>
43
43
44
#if __BYTE_ORDER == __LITTLE_ENDIAN
44
extern bool isNoSdl;
45
bool iskeyboardgrab = true;
46
47
#if _BYTE_ORDER == _LITTLE_ENDIAN
45
#define int16_to_le(val) val
48
#define int16_to_le(val) val
46
#else
49
#else
47
#define int16_to_le(val) ((((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00))
50
#define int16_to_le(val) ((((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00))
Lines 66-73 Link Here
66
  int hats_state[3][2];
69
  int hats_state[3][2];
67
  int fd;
70
  int fd;
68
  char modifiers;
71
  char modifiers;
69
  __s32 mouseDeltaX, mouseDeltaY, mouseVScroll, mouseHScroll;
72
  int32_t mouseDeltaX, mouseDeltaY, mouseVScroll, mouseHScroll;
70
  __s32 touchDownX, touchDownY, touchX, touchY;
73
  int32_t touchDownX, touchDownY, touchX, touchY;
71
  struct timeval touchDownTime;
74
  struct timeval touchDownTime;
72
  struct timeval btnDownTime;
75
  struct timeval btnDownTime;
73
  short controllerId;
76
  short controllerId;
Lines 127-132 Link Here
127
130
128
#define ACTION_MODIFIERS (MODIFIER_SHIFT|MODIFIER_ALT|MODIFIER_CTRL)
131
#define ACTION_MODIFIERS (MODIFIER_SHIFT|MODIFIER_ALT|MODIFIER_CTRL)
129
#define QUIT_KEY KEY_Q
132
#define QUIT_KEY KEY_Q
133
#define UNGRAB_KEY KEY_G
130
#define QUIT_BUTTONS (PLAY_FLAG|BACK_FLAG|LB_FLAG|RB_FLAG)
134
#define QUIT_BUTTONS (PLAY_FLAG|BACK_FLAG|LB_FLAG|RB_FLAG)
131
135
132
static bool (*handler) (struct input_event*, struct input_device*);
136
static bool (*handler) (struct input_event*, struct input_device*);
Lines 247-254 Link Here
247
    deltaY = pow((float)rawY / 32767.0f * MOUSE_EMULATION_MOTION_MULTIPLIER, 3);
251
    deltaY = pow((float)rawY / 32767.0f * MOUSE_EMULATION_MOTION_MULTIPLIER, 3);
248
252
249
    // Enforce deadzones
253
    // Enforce deadzones
250
    deltaX = fabs(deltaX) > MOUSE_EMULATION_DEADZONE ? deltaX - MOUSE_EMULATION_DEADZONE : 0;
254
    deltaX = abs(deltaX) > MOUSE_EMULATION_DEADZONE ? deltaX - MOUSE_EMULATION_DEADZONE : 0;
251
    deltaY = fabs(deltaY) > MOUSE_EMULATION_DEADZONE ? deltaY - MOUSE_EMULATION_DEADZONE : 0;
255
    deltaY = abs(deltaY) > MOUSE_EMULATION_DEADZONE ? deltaY - MOUSE_EMULATION_DEADZONE : 0;
252
256
253
    if (deltaX != 0 || deltaY != 0)
257
    if (deltaX != 0 || deltaY != 0)
254
      LiSendMouseMoveEvent(deltaX, -deltaY);
258
      LiSendMouseMoveEvent(deltaX, -deltaY);
Lines 343-349 Link Here
343
    if (dev->mouseHScroll != 0) {
347
    if (dev->mouseHScroll != 0) {
344
      LiSendHScrollEvent(dev->mouseHScroll);
348
      LiSendHScrollEvent(dev->mouseHScroll);
345
      dev->mouseHScroll = 0;
349
      dev->mouseHScroll = 0;
346
    }
350
    } 
347
    if (dev->gamepadModified) {
351
    if (dev->gamepadModified) {
348
      if (dev->controllerId < 0) {
352
      if (dev->controllerId < 0) {
349
        for (int i = 0; i < MAX_GAMEPADS; i++) {
353
        for (int i = 0; i < MAX_GAMEPADS; i++) {
Lines 404-409 Link Here
404
        return true;
408
        return true;
405
      } else if (waitingToExitOnModifiersUp && dev->modifiers == 0)
409
      } else if (waitingToExitOnModifiersUp && dev->modifiers == 0)
406
        return false;
410
        return false;
411
      if ((dev->modifiers & ACTION_MODIFIERS) == ACTION_MODIFIERS &&
412
          ev->code == UNGRAB_KEY && ev->value != 0) {
413
        grab_keyboard();
414
      }
407
415
408
      short code = 0x80 << 8 | keyCodes[ev->code];
416
      short code = 0x80 << 8 | keyCodes[ev->code];
409
      LiSendKeyboardEvent(code, ev->value?KEY_ACTION_DOWN:KEY_ACTION_UP, dev->modifiers);
417
      LiSendKeyboardEvent(code, ev->value?KEY_ACTION_DOWN:KEY_ACTION_UP, dev->modifiers);
Lines 813-819 Link Here
813
  if (mappings == NULL && strstr(name, "Xbox 360 Wireless Receiver") != NULL)
821
  if (mappings == NULL && strstr(name, "Xbox 360 Wireless Receiver") != NULL)
814
    mappings = xwc_mapping;
822
    mappings = xwc_mapping;
815
823
816
  bool is_keyboard = libevdev_has_event_code(evdev, EV_KEY, KEY_Q);
824
  bool is_keyboard = libevdev_has_event_code(evdev, EV_KEY, KEY_Q) && libevdev_get_id_version(evdev) < 500;
817
  bool is_mouse = libevdev_has_event_type(evdev, EV_REL) || libevdev_has_event_code(evdev, EV_KEY, BTN_LEFT);
825
  bool is_mouse = libevdev_has_event_type(evdev, EV_REL) || libevdev_has_event_code(evdev, EV_KEY, BTN_LEFT);
818
  bool is_touchscreen = libevdev_has_event_code(evdev, EV_KEY, BTN_TOUCH);
826
  bool is_touchscreen = libevdev_has_event_code(evdev, EV_KEY, BTN_TOUCH);
819
827
Lines 850-855 Link Here
850
  }
858
  }
851
859
852
  if (is_gamepad) {
860
  if (is_gamepad) {
861
    // stop to using SDL,test if break is better
862
    if (!isNoSdl) {
863
      libevdev_free(evdev);
864
      close(fd);
865
      return;
866
    }
853
    evdev_gamepads++;
867
    evdev_gamepads++;
854
868
855
    if (mappings == NULL) {
869
    if (mappings == NULL) {
Lines 1055-1063 Link Here
1055
  // we're ready to take input events. Ctrl+C works up until
1069
  // we're ready to take input events. Ctrl+C works up until
1056
  // this point.
1070
  // this point.
1057
  for (int i = 0; i < numDevices; i++) {
1071
  for (int i = 0; i < numDevices; i++) {
1058
    if ((devices[i].is_keyboard || devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
1072
    if ((devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
1059
      fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
1073
      fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
1060
    }
1074
    }
1075
    if (devices[i].is_keyboard && libevdev_get_id_bustype(devices[i].dev) > 3) {
1076
      if (ioctl(devices[i].fd, EVIOCGRAB, 1) < 0)
1077
        fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
1078
    }
1061
  }
1079
  }
1062
1080
1063
  // Any new input devices detected after this point will be grabbed immediately
1081
  // Any new input devices detected after this point will be grabbed immediately
Lines 1111-1114 Link Here
1111
  event.value = 1;
1129
  event.value = 1;
1112
  write(device->fd, (const void*) &event, sizeof(event));
1130
  write(device->fd, (const void*) &event, sizeof(event));
1113
  device->haptic_effect_id = effect.id;
1131
  device->haptic_effect_id = effect.id;
1132
}
1133
1134
void grab_keyboard() {
1135
  int grabnum;
1136
  if (iskeyboardgrab) {
1137
    grabnum = 0;
1138
    iskeyboardgrab = false;
1139
  } else {
1140
    grabnum = 1;
1141
    iskeyboardgrab = true;
1142
  }
1143
  for (int i = 0; i < numDevices; i++) {
1144
    if (devices[i].is_keyboard && libevdev_get_id_bustype(devices[i].dev) > 3) {
1145
      if (ioctl(devices[i].fd, EVIOCGRAB, grabnum) < 0)
1146
        fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
1147
    }
1148
  }
1114
}
1149
}
Lines 537-543 Link Here
537
  RAND_bytes(client_secret_data, sizeof(client_secret_data));
537
  RAND_bytes(client_secret_data, sizeof(client_secret_data));
538
538
539
  const ASN1_BIT_STRING *asnSignature;
539
  const ASN1_BIT_STRING *asnSignature;
540
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
540
  X509_get0_signature(&asnSignature, NULL, cert);
541
  X509_get0_signature(&asnSignature, NULL, cert);
542
#else
543
  asnSignature = cert->signature;
544
#endif
541
545
542
  char challenge_response[16 + SIGNATURE_LEN + sizeof(client_secret_data)];
546
  char challenge_response[16 + SIGNATURE_LEN + sizeof(client_secret_data)];
543
  char challenge_response_hash[32];
547
  char challenge_response_hash[32];
Lines 73-78 Link Here
73
int http_request(char* url, PHTTP_DATA data) {
73
int http_request(char* url, PHTTP_DATA data) {
74
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
74
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
75
  curl_easy_setopt(curl, CURLOPT_URL, url);
75
  curl_easy_setopt(curl, CURLOPT_URL, url);
76
  curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L);
77
  curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1);
78
  curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1);
76
79
77
  if (debug)
80
  if (debug)
78
    printf("Request %s\n", url);
81
    printf("Request %s\n", url);
(-)b/moonlight-embedded/Makefile (-5 / +8 lines)
Lines 1-50 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
13
12
14
BUILD_DEPENDS=	${LOCALBASE}/include/linux/input.h:devel/evdev-proto
13
BUILD_DEPENDS=	${LOCALBASE}/include/linux/input.h:devel/evdev-proto
15
LIB_DEPENDS=	libavahi-client.so:net/avahi-app \
14
LIB_DEPENDS=	libavahi-client.so:net/avahi-app \
16
		libavcodec.so:multimedia/ffmpeg \
15
		libavcodec.so:multimedia/ffmpeg \
17
		libcurl.so:ftp/curl \
16
		libcurl.so:ftp/curl \
18
		libenet.so:net/enet \
17
		libenet.so:net/enet \
19
		libexpat.so:textproc/expat2 \
18
		libexpat.so:textproc/expat2 \
20
		libevdev.so:devel/libevdev \
19
		libevdev.so:devel/libevdev \
21
		libopus.so:audio/opus \
20
		libopus.so:audio/opus \
22
		libudev.so:devel/libudev-devd \
21
		libudev.so:devel/libudev-devd \
23
		libuuid.so:misc/e2fsprogs-libuuid
22
		libuuid.so:misc/e2fsprogs-libuuid
24
23
25
USES=		cmake localbase:ldflags perl5 pkgconfig sdl ssl tar:xz
24
USES=		cmake localbase:ldflags perl5 pkgconfig sdl ssl tar:xz
26
USE_LDCONFIG=	yes
25
USE_LDCONFIG=	yes
27
USE_PERL5=	build
26
USE_PERL5=	build
28
USE_SDL=	sdl2
27
USE_SDL=	sdl2
29
28
30
NO_WRKSUBDIR=	yes
29
NO_WRKSUBDIR=	yes
31
CFLAGS+=	-DHAS_SOCKLEN_T=1 -I${LOCALBASE}/include/libepoll-shim/
30
CFLAGS+=	-DHAS_SOCKLEN_T=1 -I${LOCALBASE}/include/libepoll-shim/
32
LDFLAGS+=	-lepoll-shim
31
LDFLAGS+=	-lepoll-shim
33
32
34
post-patch:
33
post-patch:
35
	@${REINPLACE_CMD} -e '/(ALSA)/d' \
34
	@${REINPLACE_CMD} -e '/(ALSA)/d' \
36
		-e '/libpulse-simple/d' \
35
		-e '/libpulse-simple/d' \
37
		-e '/libcec/d' \
36
		-e '/libcec/d' \
37
		-e '/add_compile_o/d' \
38
		-e 's|\(.*input/x11.c.*\))|\1 ./src/audio/oss.c)|' \
38
		${WRKSRC}/CMakeLists.txt
39
		${WRKSRC}/CMakeLists.txt
39
	@${REINPLACE_CMD} -e 's@SHARED@STATIC@' \
40
	@${REINPLACE_CMD} -e 's@SHARED@STATIC@' \
40
		-e 's@OpenSSL 1.0.2@OpenSSL@' -e '/^install(/d' \
41
		-e 's@OpenSSL 1.0.2@OpenSSL@' -e '/^install(/d' \
41
		${WRKSRC}/libgamestream/CMakeLists.txt
42
		${WRKSRC}/libgamestream/CMakeLists.txt
42
	@${REINPLACE_CMD} -e 's@/etc/moonlight/moonlight.conf@${PREFIX}/etc/moonlight.conf@' \
43
	@${REINPLACE_CMD} -e 's@/etc/moonlight/moonlight.conf@${PREFIX}/etc/moonlight.conf@' \
43
		-e 's@moonligt@moonlight@g' \
44
		-e 's@moonligt@moonlight@g' \
44
		${WRKSRC}/docs/README.pod
45
		${WRKSRC}/docs/README.pod
46
	@${REINPLACE_CMD} -e '/^install(/,999d' \
47
		${WRKSRC}/third_party/moonlight-common-c/enet/CMakeLists.txt 
45
48
46
post-install:
49
post-install:
47
	@${MV} ${STAGEDIR}${PREFIX}/etc/moonlight.conf \
50
	@${MV} ${STAGEDIR}${PREFIX}/etc/moonlight.conf \
48
		${STAGEDIR}${PREFIX}/etc/moonlight.conf.sample
51
		${STAGEDIR}${PREFIX}/etc/moonlight.conf.sample
49
52
50
.include <bsd.port.mk>
53
.include <bsd.port.mk>
(-)b/moonlight-embedded/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1666188557
1
TIMESTAMP = 1695360586
2
SHA256 (moonlight-embedded-2.5.3.tar.xz) = 2fcd00049f58b0af882f0eec7077013c062bc35c8705f3d6bb7949d44e98fac0
2
SHA256 (moonlight-embedded-2.6.0.tar.xz) = 94af6202a7b88e12836f818481b5e68220b353ff4fa0ac65411da16f846f1b19
3
SIZE (moonlight-embedded-2.5.3.tar.xz) = 303180
3
SIZE (moonlight-embedded-2.6.0.tar.xz) = 324996
(-)b/moonlight-embedded/files/patch-libgamestream_client.c (-5 / +5 lines)
Lines 1-14 Link Here
1
--- libgamestream/client.c.orig	2018-08-11 15:43:13 UTC
1
--- libgamestream/client.c.orig	2023-09-21 13:24:56.778585000 +0800
2
+++ libgamestream/client.c
2
+++ libgamestream/client.c	2023-09-21 13:17:44.126595000 +0800
3
@@ -505,7 +505,11 @@ int gs_pair(PSERVER_DATA server, char* pin) {
3
@@ -537,7 +537,11 @@
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)
8
   X509_get0_signature(&asnSignature, NULL, cert);
8
   X509_get0_signature(&asnSignature, NULL, cert);
9
+#else
9
+#else
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/moonlight-embedded/files/patch-libgamestream_http.c (+12 lines)
Added Link Here
1
--- libgamestream/http.c.orig	2023-09-21 13:24:50.907143000 +0800
2
+++ libgamestream/http.c	2023-09-21 13:17:44.126971000 +0800
3
@@ -73,6 +73,9 @@
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/moonlight-embedded/files/patch-src_input_evdev.c (-6 / +107 lines)
Lines 1-26 Link Here
1
--- src/input/evdev.c.orig	2021-12-20 00:24:48 UTC
1
--- src/input/evdev.c.orig	2023-09-22 13:23:15.263067000 +0800
2
+++ src/input/evdev.c
2
+++ src/input/evdev.c	2023-09-22 13:23:26.674639000 +0800
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>
7
-#include <endian.h>
7
-#include <endian.h>
8
+#include <sys/endian.h>
8
+#include <sys/endian.h>
9
 #include <math.h>
9
 #include <math.h>
10
 
10
 
11
-#if __BYTE_ORDER == __LITTLE_ENDIAN
11
-#if __BYTE_ORDER == __LITTLE_ENDIAN
12
+extern bool isNoSdl;
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
@@ -850,6 +858,12 @@
79
   }
80
 
81
   if (is_gamepad) {
82
+    // stop to using SDL,test if break is better
83
+    if (!isNoSdl) {
84
+      libevdev_free(evdev);
85
+      close(fd);
86
+      return;
87
+    }
88
     evdev_gamepads++;
89
 
90
     if (mappings == NULL) {
91
@@ -1055,9 +1069,13 @@
92
   // we're ready to take input events. Ctrl+C works up until
93
   // this point.
94
   for (int i = 0; i < numDevices; i++) {
95
-    if ((devices[i].is_keyboard || devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
96
+    if ((devices[i].is_mouse || devices[i].is_touchscreen) && ioctl(devices[i].fd, EVIOCGRAB, 1) < 0) {
97
       fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
98
     }
99
+    if (devices[i].is_keyboard && libevdev_get_id_bustype(devices[i].dev) > 3) {
100
+      if (ioctl(devices[i].fd, EVIOCGRAB, 1) < 0)
101
+        fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
102
+    }
103
   }
104
 
105
   // Any new input devices detected after this point will be grabbed immediately
106
@@ -1111,4 +1129,21 @@
107
   event.value = 1;
108
   write(device->fd, (const void*) &event, sizeof(event));
109
   device->haptic_effect_id = effect.id;
110
+}
111
+
112
+void grab_keyboard() {
113
+  int grabnum;
114
+  if (iskeyboardgrab) {
115
+    grabnum = 0;
116
+    iskeyboardgrab = false;
117
+  } else {
118
+    grabnum = 1;
119
+    iskeyboardgrab = true;
120
+  }
121
+  for (int i = 0; i < numDevices; i++) {
122
+    if (devices[i].is_keyboard && libevdev_get_id_bustype(devices[i].dev) > 3) {
123
+      if (ioctl(devices[i].fd, EVIOCGRAB, grabnum) < 0)
124
+        fprintf(stderr, "EVIOCGRAB failed with error %d\n", errno);
125
+    }
126
+  }
127
 }
(-)b/moonlight-embedded/files/patch-src_main.c (+136 lines)
Added Link Here
1
--- src/main.c.orig	2023-09-21 13:25:05.298839000 +0800
2
+++ src/main.c	2023-09-21 13:17:44.207870000 +0800
3
@@ -23,6 +23,7 @@
4
 #include "platform.h"
5
 #include "config.h"
6
 #include "sdl.h"
7
+#include "x11_sdl.h"
8
 
9
 #include "audio/audio.h"
10
 #include "video/video.h"
11
@@ -42,6 +43,7 @@
12
 #include <client.h>
13
 #include <discover.h>
14
 
15
+#include <time.h>
16
 #include <stdio.h>
17
 #include <stdlib.h>
18
 #include <stdbool.h>
19
@@ -52,7 +54,6 @@
20
 #include <netinet/in.h>
21
 #include <netdb.h>
22
 #include <arpa/inet.h>
23
-#include <openssl/rand.h>
24
 
25
 static void applist(PSERVER_DATA server) {
26
   PAPP_LIST list = NULL;
27
@@ -139,8 +140,11 @@
28
     connection_debug = true;
29
   }
30
 
31
-  if (IS_EMBEDDED(system))
32
+  if (IS_EMBEDDED(system)) {
33
     loop_init();
34
+    if (!isNoSdl)
35
+      x11_sdl_init();
36
+  }
37
 
38
   platform_start(system);
39
   LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system, config->audio_device), NULL, drFlags, config->audio_device, 0);
40
@@ -148,7 +152,10 @@
41
   if (IS_EMBEDDED(system)) {
42
     if (!config->viewonly)
43
       evdev_start();
44
-    loop_main();
45
+    if (!isNoSdl)
46
+      x11_sdl_loop_main(config->stream.width, config->stream.height);
47
+    else
48
+      loop_main();
49
     if (!config->viewonly)
50
       evdev_stop();
51
   }
52
@@ -202,7 +209,6 @@
53
   printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
54
   printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");
55
   printf("\t-codec <codec>\t\tSelect used codec: auto/h264/h265/av1 (default auto)\n");
56
-  printf("\t-hdr\t\tEnable HDR streaming (experimental, requires host and device support)\n");
57
   printf("\t-remote <yes/no/auto>\t\t\tEnable optimizations for WAN streaming (default auto)\n");
58
   printf("\t-app <app>\t\tName of app to stream\n");
59
   printf("\t-nosops\t\t\tDon't allow GFE to modify game settings\n");
60
@@ -251,8 +257,10 @@
61
       exit(-1);
62
     }
63
 
64
-    evdev_create(config.inputs[0], NULL, config.debug_level > 0, config.rotate);
65
-    evdev_map(config.inputs[0]);
66
+    if (isNoSdl) {
67
+      evdev_create(config.inputs[0], NULL, config.debug_level > 0, config.rotate);
68
+      evdev_map(config.inputs[0]);    
69
+    }
70
     exit(0);
71
   }
72
 
73
@@ -300,7 +308,7 @@
74
   if (config.debug_level > 0) {
75
     printf("GPU: %s, GFE: %s (%s, %s)\n", server.gpuType, server.serverInfo.serverInfoGfeVersion, server.gsVersion, server.serverInfo.serverInfoAppVersion);
76
     printf("Server codec flags: 0x%x\n", server.serverInfo.serverCodecModeSupport);
77
-  }
78
+  }    
79
 
80
   if (strcmp("list", config.action) == 0) {
81
     pair_check(&server);
82
@@ -322,19 +330,19 @@
83
     config.stream.supportedVideoFormats = VIDEO_FORMAT_H264;
84
     if (config.codec == CODEC_HEVC || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, CODEC_HEVC))) {
85
       config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265;
86
-      if (config.hdr)
87
-        config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10;
88
+      //if (config.hdr)
89
+      //  config.stream.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10;
90
     }
91
     if (config.codec == CODEC_AV1 || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, CODEC_AV1))) {
92
       config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN8;
93
-      if (config.hdr)
94
-        config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10;
95
+      //if (config.hdr)
96
+      //  config.stream.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10;
97
     }
98
 
99
-    if (config.hdr && !(config.stream.supportedVideoFormats & VIDEO_FORMAT_MASK_10BIT)) {
100
-      fprintf(stderr, "HDR streaming requires HEVC or AV1 codec\n");
101
-      exit(-1);
102
-    }
103
+    //if (config.hdr && !(config.stream.supportedVideoFormats & VIDEO_FORMAT_MASK_10BIT)) {
104
+    //  fprintf(stderr, "HDR streaming requires HEVC or AV1 codec\n");
105
+    //  exit(-1);
106
+    //}    
107
 
108
     #ifdef HAVE_SDL
109
     if (system == SDL)
110
@@ -371,7 +379,15 @@
111
 
112
         udev_init(!inputAdded, mappings, config.debug_level > 0, config.rotate);
113
         evdev_init(config.mouse_emulation);
114
-        rumble_handler = evdev_rumble;
115
+        if (isNoSdl)
116
+          rumble_handler = evdev_rumble;
117
+        else {
118
+          sdlinput_init(config.mapping);
119
+          rumble_handler = sdlinput_rumble;
120
+          rumble_triggers_handler = sdlinput_rumble_triggers;
121
+          set_motion_event_state_handler = sdlinput_set_motion_event_state;
122
+          set_controller_led_handler = sdlinput_set_controller_led;
123
+        }
124
         #ifdef HAVE_LIBCEC
125
         cec_init();
126
         #endif /* HAVE_LIBCEC */
127
@@ -398,7 +414,8 @@
128
     if (config.pin > 0 && config.pin <= 9999) {
129
       sprintf(pin, "%04d", config.pin);
130
     } else {
131
-      sprintf(pin, "%d%d%d%d", (unsigned)random() % 10, (unsigned)random() % 10, (unsigned)random() % 10, (unsigned)random() % 10);
132
+      srand((unsigned)time(NULL));
133
+      sprintf(pin, "%04d", (unsigned)rand() % 9999 + 1);
134
     }
135
     printf("Please enter the following PIN on the target PC: %s\n", pin);
136
     fflush(stdout);
(-)b/moonlight-embedded/files/patch-src_platform.c (-5 / +71 lines)
Lines 1-17 Link Here
1
--- src/platform.c.orig	2021-12-20 00:24:48 UTC
1
--- src/platform.c.orig	2023-09-21 13:30:28.000000000 +0800
2
+++ src/platform.c
2
+++ src/platform.c	2023-09-21 21:30:20.507461000 +0800
3
@@ -188,14 +188,6 @@ AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum plat
3
@@ -77,8 +77,8 @@
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,18 +87,13 @@
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
   if (std || strcmp(name, "sdl") == 0)
27
     return SDL;
28
   #endif
29
-
30
   if (strcmp(name, "fake") == 0)
31
     return FAKE;
32
 
33
@@ -109,14 +104,14 @@
34
   switch (system) {
35
   #ifdef HAVE_AML
36
   case AML:
37
-    write_bool("/sys/class/graphics/fb0/blank", true);
38
-    write_bool("/sys/class/graphics/fb1/blank", true);
39
-    write_bool("/sys/class/video/disable_video", false);
40
+    blank_fb("/sys/class/graphics/fb0/blank", true);
41
+    blank_fb("/sys/class/graphics/fb1/blank", true);
42
+    blank_fb("/sys/class/video/disable_video", false);
43
     break;
44
   #endif
45
   #if defined(HAVE_PI) || defined(HAVE_MMAL)
46
   case PI:
47
-    write_bool("/sys/class/graphics/fb0/blank", true);
48
+    blank_fb("/sys/class/graphics/fb0/blank", true);
49
     break;
50
   #endif
51
   }
52
@@ -126,13 +121,13 @@
53
   switch (system) {
54
   #ifdef HAVE_AML
55
   case AML:
56
-    write_bool("/sys/class/graphics/fb0/blank", false);
57
-    write_bool("/sys/class/graphics/fb1/blank", false);
58
+    blank_fb("/sys/class/graphics/fb0/blank", false);
59
+    blank_fb("/sys/class/graphics/fb1/blank", false);
60
     break;
61
   #endif
62
   #if defined(HAVE_PI) || defined(HAVE_MMAL)
63
   case PI:
64
-    write_bool("/sys/class/graphics/fb0/blank", false);
65
+    blank_fb("/sys/class/graphics/fb0/blank", false);
66
     break;
67
   #endif
68
   }
69
@@ -195,13 +190,7 @@
5
     // fall-through
70
     // fall-through
6
   #endif
71
   #endif
7
-  default:
72
   default:
8
-    #ifdef HAVE_PULSE
73
-    #ifdef HAVE_PULSE
9
-    if (audio_pulse_init(audio_device))
74
-    if (audio_pulse_init(audio_device))
10
-      return &audio_callbacks_pulse;
75
-      return &audio_callbacks_pulse;
11
-    #endif
76
-    #endif
12
-    #ifdef HAVE_ALSA
77
-    #ifdef HAVE_ALSA
13
-    return &audio_callbacks_alsa;
78
-    return &audio_callbacks_alsa;
14
-    #endif
79
-    #endif
80
+      return &audio_callbacks_oss;
15
   }
81
   }
16
   return NULL;
82
   return NULL;
17
 }
83
 }
(-)b/moonlight-embedded/pkg-descr (+5 lines)
Lines 1-5 Link Here
1
Moonlight Embedded is an open source implementation of NVIDIA's
1
Moonlight Embedded is an open source implementation of NVIDIA's
2
GameStream, as used by the NVIDIA Shield.
2
GameStream, as used by the NVIDIA Shield.
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
7
First, pair: # moonlight pair 192.168.0.1
8
Then, connect: # moonlight stream -app Desktop -1080 192.168.0.1
9
10
ENJOY!

Return to bug 274026