mirror of
https://github.com/rock88/moonlight-nx
synced 2024-11-10 06:14:15 +00:00
Try to run this on a Horizon OS :C
This commit is contained in:
parent
183405f575
commit
555cf228db
9 changed files with 549 additions and 5 deletions
2
Makefile
2
Makefile
|
@ -203,7 +203,7 @@ DEFINES += -DNANOGUI_USE_OPENGL -DNVG_STB_IMAGE_IMPLEMENTATION -DNANOGUI_NO_GLFW
|
|||
-DHAS_SOCKLEN_T -DHAS_POLL -DHAS_FCNTL -D_GNU_SOURCE -D__LIBRETRO__
|
||||
|
||||
CFLAGS += -Wall -pedantic $(fpic) -std=gnu11 $(DEFINES)
|
||||
CXXFLAGS += -std=gnu++17 -fno-permissive $(DEFINES)
|
||||
CXXFLAGS += -std=gnu++17 $(DEFINES)
|
||||
|
||||
LIBS += -lcrypto -lssl -lcurl -lz -lexpat -lopus \
|
||||
-lavcodec -lavformat -lavutil -lavdevice -lstdc++
|
||||
|
|
343
Makefile.libnx
Normal file
343
Makefile.libnx
Normal file
|
@ -0,0 +1,343 @@
|
|||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITPRO)/libnx/switch_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
|
||||
#
|
||||
# NO_ICON: if set to anything, do not use icon.
|
||||
# NO_NACP: if set to anything, no .nacp file is generated.
|
||||
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
|
||||
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
|
||||
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
|
||||
# ICON is the filename of the icon (.jpg), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.jpg
|
||||
# - icon.jpg
|
||||
# - <libnx folder>/default_icon.jpg
|
||||
#
|
||||
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.json
|
||||
# - config.json
|
||||
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
|
||||
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
|
||||
# NACP building is skipped as well.
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := moonlight
|
||||
BUILD := build
|
||||
SOURCES := libgamestream src/nanogui_resources src src/decoders src/ui/windows src/ui/buttons src/ui \
|
||||
third_party/moonlight-common-c/enet third_party/moonlight-common-c/reedsolomon third_party/moonlight-common-c/src \
|
||||
third_party/nanogui/ext/nanovg/src third_party/nanogui/src
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
#ROMFS := romfs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
|
||||
|
||||
M_INCLUDES := \
|
||||
-I$(TOPDIR)/src -I$(TOPDIR)/src/decoders \
|
||||
-I$(TOPDIR)/src/nanogui_resources \
|
||||
-I$(TOPDIR)/src/ui -I$(TOPDIR)/src/ui/buttons -I$(TOPDIR)/src/ui/windows \
|
||||
-I$(TOPDIR)/libgamestream \
|
||||
-I$(TOPDIR)/third_party/moonlight-common-c/reedsolomon \
|
||||
-I$(TOPDIR)/third_party/moonlight-common-c/src \
|
||||
-I$(TOPDIR)/third_party/moonlight-common-c/enet/include \
|
||||
-I$(TOPDIR)/third_party/nanogui/include \
|
||||
-I$(TOPDIR)/third_party/nanogui/ext/nanovg/src \
|
||||
-I$(TOPDIR)/third_party/json/single_include/nlohmann \
|
||||
-I/Users/rock88/Documents/Projects/Switch/moonlight-switch-new/deps/include \
|
||||
-I/Users/rock88/Documents/Projects/Switch/moonlight-switch-new/third_party
|
||||
|
||||
DEFINES := -DNANOGUI_USE_OPENGL -DNVG_STB_IMAGE_IMPLEMENTATION -DNANOGUI_NO_GLFW \
|
||||
-DHAS_SOCKLEN_T -DHAS_POLL -DHAS_FCNTL -D_GNU_SOURCE -D__LIBRETRO__
|
||||
|
||||
CFLAGS := -g -Wall -O0 -ffunction-sections \
|
||||
$(ARCH) $(DEFINES)
|
||||
|
||||
CFLAGS += $(INCLUDE) $(M_INCLUDES) -D__SWITCH__
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -std=gnu++17
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto \
|
||||
-lavcodec -lavutil -lopus -lssl -lcrypto -lbz2 -lz -lexpat -lm \
|
||||
-lglad -lEGL -lglapi -ldrm_nouveau -lglfw3 \
|
||||
-lnx -lwebp -lswresample -lavformat -lvpx \
|
||||
-L/Users/rock88/Documents/Projects/Switch/moonlight-switch-new/deps/lib
|
||||
|
||||
LIBGAMESTREAM_SOURCES = \
|
||||
client.c \
|
||||
http.c \
|
||||
mkcert.c \
|
||||
xml.c
|
||||
|
||||
MOONLIGHT_LIBRETRO_C_SOURCES = \
|
||||
nanogui_resources.c \
|
||||
moonlight_libnx.c \
|
||||
moonlight_glfw.c \
|
||||
ffmpeg.c \
|
||||
gl_render.c \
|
||||
video_decoder.c \
|
||||
audio_decoder.c
|
||||
|
||||
MOONLIGHT_LIBRETRO_CXX_SOURCES = \
|
||||
AddHostWindow.cpp \
|
||||
ContentWindow.cpp \
|
||||
MainWindow.cpp \
|
||||
StreamWindow.cpp \
|
||||
AppListWindow.cpp \
|
||||
SettingsWindow.cpp \
|
||||
AddHostButton.cpp \
|
||||
AppButton.cpp \
|
||||
HostButton.cpp \
|
||||
Application.cpp \
|
||||
LoadingOverlay.cpp \
|
||||
GameStreamClient.cpp \
|
||||
Settings.cpp \
|
||||
InputController.cpp
|
||||
|
||||
MOONLIGHT_COMMON_C_SOURCES = \
|
||||
callbacks.c \
|
||||
compress.c \
|
||||
host.c \
|
||||
list.c \
|
||||
packet.c \
|
||||
peer.c \
|
||||
protocol.c \
|
||||
unix.c \
|
||||
win32.c \
|
||||
rs.c \
|
||||
AudioStream.c \
|
||||
ByteBuffer.c \
|
||||
Connection.c \
|
||||
ControlStream.c \
|
||||
FakeCallbacks.c \
|
||||
InputStream.c \
|
||||
LinkedBlockingQueue.c \
|
||||
Misc.c \
|
||||
Platform.c \
|
||||
PlatformSockets.c \
|
||||
RtpFecQueue.c \
|
||||
RtpReorderQueue.c \
|
||||
RtspConnection.c \
|
||||
RtspParser.c \
|
||||
SdpGenerator.c \
|
||||
SimpleStun.c \
|
||||
VideoDepacketizer.c \
|
||||
VideoStream.c
|
||||
|
||||
NANOGUI_C_SOURCES = \
|
||||
nanovg.c
|
||||
|
||||
NANOGUI_CXX_SOURCES = \
|
||||
widget.cpp \
|
||||
button.cpp \
|
||||
common.cpp \
|
||||
screen.cpp \
|
||||
checkbox.cpp \
|
||||
vscrollpanel.cpp \
|
||||
colorpicker.cpp \
|
||||
textarea.cpp \
|
||||
shader_gl.cpp \
|
||||
canvas.cpp \
|
||||
window.cpp \
|
||||
graph.cpp \
|
||||
popup.cpp \
|
||||
layout.cpp \
|
||||
texture.cpp \
|
||||
texture_gl.cpp \
|
||||
tabwidget.cpp \
|
||||
shader.cpp \
|
||||
imageview.cpp \
|
||||
progressbar.cpp \
|
||||
combobox.cpp \
|
||||
theme.cpp \
|
||||
traits.cpp \
|
||||
label.cpp \
|
||||
opengl.cpp \
|
||||
renderpass_gl.cpp \
|
||||
imagepanel.cpp \
|
||||
colorwheel.cpp \
|
||||
messagedialog.cpp \
|
||||
textbox.cpp \
|
||||
slider.cpp \
|
||||
popupbutton.cpp
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(LIBGAMESTREAM_SOURCES) $(MOONLIGHT_LIBRETRO_C_SOURCES) $(MOONLIGHT_COMMON_C_SOURCES) $(NANOGUI_C_SOURCES)
|
||||
CPPFILES := $(MOONLIGHT_LIBRETRO_CXX_SOURCES) $(NANOGUI_CXX_SOURCES)
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
||||
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(CONFIG_JSON)),)
|
||||
jsons := $(wildcard *.json)
|
||||
ifneq (,$(findstring $(TARGET).json,$(jsons)))
|
||||
export APP_JSON := $(TOPDIR)/$(TARGET).json
|
||||
else
|
||||
ifneq (,$(findstring config.json,$(jsons)))
|
||||
export APP_JSON := $(TOPDIR)/config.json
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.jpg)
|
||||
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
|
||||
else
|
||||
ifneq (,$(findstring icon.jpg,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.jpg
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(NO_ICON)),)
|
||||
export NROFLAGS += --icon=$(APP_ICON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(NO_NACP)),)
|
||||
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
|
||||
endif
|
||||
|
||||
ifneq ($(APP_TITLEID),)
|
||||
export NACPFLAGS += --titleid=$(APP_TITLEID)
|
||||
endif
|
||||
|
||||
ifneq ($(ROMFS),)
|
||||
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.libnx
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
ifeq ($(strip $(APP_JSON)),)
|
||||
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
|
||||
else
|
||||
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
|
||||
endif
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
.PHONY: all
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(APP_JSON)),)
|
||||
|
||||
all : $(OUTPUT).nro
|
||||
|
||||
ifeq ($(strip $(NO_NACP)),)
|
||||
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
|
||||
else
|
||||
$(OUTPUT).nro : $(OUTPUT).elf
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
all : $(OUTPUT).nsp
|
||||
|
||||
$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm
|
||||
|
||||
$(OUTPUT).nso : $(OUTPUT).elf
|
||||
|
||||
endif
|
||||
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
$(OFILES_SRC) : $(HFILES_BIN)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o %_bin.h : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
3
dbg.sh
Executable file
3
dbg.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
/opt/devkitpro/devkitA64/bin/aarch64-none-elf-addr2line -e moonlight.elf -f -p -C -a $1
|
|
@ -30,7 +30,6 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/rand.h>
|
||||
|
@ -58,6 +57,138 @@ static EVP_PKEY *privateKey;
|
|||
|
||||
const char* gs_error;
|
||||
|
||||
typedef unsigned char uuid_t[16];
|
||||
|
||||
struct uuid {
|
||||
uint32_t time_low;
|
||||
uint16_t time_mid;
|
||||
uint16_t time_hi_and_version;
|
||||
uint16_t clock_seq;
|
||||
uint8_t node[6];
|
||||
};
|
||||
|
||||
uid_t getuid() {
|
||||
return 123;
|
||||
}
|
||||
|
||||
void __random_get_bytes(void *buf, size_t nbytes) {
|
||||
size_t i, n = nbytes;
|
||||
int fd = 1;
|
||||
int lose_counter = 0;
|
||||
unsigned char *cp = (unsigned char *) buf;
|
||||
|
||||
if (fd >= 0) {
|
||||
while (n > 0) {
|
||||
ssize_t x = rand();
|
||||
if (x <= 0) {
|
||||
if (lose_counter++ > 16)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
n -= x;
|
||||
cp += x;
|
||||
lose_counter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (cp = buf, i = 0; i < nbytes; i++)
|
||||
*cp++ ^= (rand() >> 7) & 0xFF;
|
||||
}
|
||||
|
||||
void __uuid_pack(const struct uuid *uu, uuid_t ptr) {
|
||||
uint32_t tmp;
|
||||
unsigned char *out = ptr;
|
||||
|
||||
tmp = uu->time_low;
|
||||
out[3] = (unsigned char) tmp;
|
||||
tmp >>= 8;
|
||||
out[2] = (unsigned char) tmp;
|
||||
tmp >>= 8;
|
||||
out[1] = (unsigned char) tmp;
|
||||
tmp >>= 8;
|
||||
out[0] = (unsigned char) tmp;
|
||||
|
||||
tmp = uu->time_mid;
|
||||
out[5] = (unsigned char) tmp;
|
||||
tmp >>= 8;
|
||||
out[4] = (unsigned char) tmp;
|
||||
|
||||
tmp = uu->time_hi_and_version;
|
||||
out[7] = (unsigned char) tmp;
|
||||
tmp >>= 8;
|
||||
out[6] = (unsigned char) tmp;
|
||||
|
||||
tmp = uu->clock_seq;
|
||||
out[9] = (unsigned char) tmp;
|
||||
tmp >>= 8;
|
||||
out[8] = (unsigned char) tmp;
|
||||
|
||||
memcpy(out+10, uu->node, 6);
|
||||
}
|
||||
|
||||
void __uuid_unpack(const uuid_t in, struct uuid *uu) {
|
||||
const uint8_t *ptr = in;
|
||||
uint32_t tmp;
|
||||
|
||||
tmp = *ptr++;
|
||||
tmp = (tmp << 8) | *ptr++;
|
||||
tmp = (tmp << 8) | *ptr++;
|
||||
tmp = (tmp << 8) | *ptr++;
|
||||
uu->time_low = tmp;
|
||||
|
||||
tmp = *ptr++;
|
||||
tmp = (tmp << 8) | *ptr++;
|
||||
uu->time_mid = tmp;
|
||||
|
||||
tmp = *ptr++;
|
||||
tmp = (tmp << 8) | *ptr++;
|
||||
uu->time_hi_and_version = tmp;
|
||||
|
||||
tmp = *ptr++;
|
||||
tmp = (tmp << 8) | *ptr++;
|
||||
uu->clock_seq = tmp;
|
||||
|
||||
memcpy(uu->node, ptr, 6);
|
||||
}
|
||||
|
||||
void __uuid_generate_random(uuid_t out) {
|
||||
int nm = 1;
|
||||
int *num = &nm;
|
||||
uuid_t buf;
|
||||
struct uuid uu;
|
||||
int i, n;
|
||||
|
||||
if (!num || !*num)
|
||||
n = 1;
|
||||
else
|
||||
n = *num;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
__random_get_bytes(buf, sizeof(buf));
|
||||
__uuid_unpack(buf, &uu);
|
||||
|
||||
uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000;
|
||||
uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF)
|
||||
| 0x4000;
|
||||
__uuid_pack(&uu, out);
|
||||
out += sizeof(uuid_t);
|
||||
}
|
||||
}
|
||||
|
||||
void __uuid_unparse(const uuid_t uu, char *out) {
|
||||
struct uuid uuid;
|
||||
|
||||
__uuid_unpack(uu, &uuid);
|
||||
sprintf(out, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||
uuid.time_low, uuid.time_mid, uuid.time_hi_and_version,
|
||||
uuid.clock_seq >> 8, uuid.clock_seq & 0xFF,
|
||||
uuid.node[0], uuid.node[1], uuid.node[2],
|
||||
uuid.node[3], uuid.node[4], uuid.node[5]);
|
||||
}
|
||||
|
||||
#define uuid_generate_random __uuid_generate_random
|
||||
#define uuid_unparse __uuid_unparse
|
||||
|
||||
int mkdirtree(const char* directory) {
|
||||
char buffer[PATH_MAX];
|
||||
char* p = buffer;
|
||||
|
|
|
@ -276,6 +276,8 @@
|
|||
3652F089245C8569001FABF3 /* ContentWindow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ContentWindow.cpp; sourceTree = "<group>"; };
|
||||
367CD958245DE25F00A95738 /* StreamWindow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StreamWindow.cpp; sourceTree = "<group>"; };
|
||||
367CD959245DE25F00A95738 /* StreamWindow.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StreamWindow.hpp; sourceTree = "<group>"; };
|
||||
369445A82466CE2700786D0A /* Makefile.libnx */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; path = Makefile.libnx; sourceTree = "<group>"; };
|
||||
369445A92466E2B000786D0A /* moonlight_libnx.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = moonlight_libnx.c; sourceTree = "<group>"; };
|
||||
36A0C0352461DBA30083289C /* AddHostButton.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AddHostButton.cpp; sourceTree = "<group>"; };
|
||||
36A0C0362461DBA30083289C /* AddHostButton.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AddHostButton.hpp; sourceTree = "<group>"; };
|
||||
36A0C0382461E4C00083289C /* SettingsWindow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SettingsWindow.cpp; sourceTree = "<group>"; };
|
||||
|
@ -639,6 +641,7 @@
|
|||
3652F084245C6CFC001FABF3 /* libretro.h */,
|
||||
3652F085245C6CFC001FABF3 /* moonlight_libretro.cpp */,
|
||||
36B406962459F460005BD903 /* moonlight_glfw.cpp */,
|
||||
369445A92466E2B000786D0A /* moonlight_libnx.c */,
|
||||
);
|
||||
path = src;
|
||||
sourceTree = "<group>";
|
||||
|
@ -647,6 +650,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
3602C3C0245DC7E300368900 /* Makefile */,
|
||||
369445A82466CE2700786D0A /* Makefile.libnx */,
|
||||
36A0C03E2461FFF10083289C /* build_opus_lakka_switch.sh */,
|
||||
3652F006245C2918001FABF3 /* libgamestream */,
|
||||
36B406932459F41E005BD903 /* src */,
|
||||
|
|
3
run.sh
Executable file
3
run.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
/opt/devkitpro/tools/bin/nxlink -s moonlight.nro
|
|
@ -1,6 +1,11 @@
|
|||
#include "gl_render.h"
|
||||
#include "libretro.h"
|
||||
|
||||
#ifdef __SWITCH__
|
||||
#include <glad/glad.h>
|
||||
#else
|
||||
#include "glsym.h"
|
||||
#endif
|
||||
|
||||
static const char *vertex_shader_string = "\
|
||||
#version 140\n\
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "glsym/glsym.h"
|
||||
#include "Application.hpp"
|
||||
#include "Settings.hpp"
|
||||
#include "Limelight.h"
|
||||
|
@ -9,6 +7,14 @@
|
|||
#include "libretro.h"
|
||||
#include "InputController.hpp"
|
||||
|
||||
#ifdef __SWITCH__
|
||||
#include <glad/glad.h>
|
||||
#else
|
||||
#include "glsym/glsym.h"
|
||||
#endif
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
extern retro_input_state_t input_state_cb;
|
||||
|
||||
static int mouse_x = 0, mouse_y = 0;
|
||||
|
@ -63,9 +69,14 @@ int main(int argc, const char * argv[]) {
|
|||
|
||||
GLFWwindow* window = glfwCreateWindow(1280, 720, "Test", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
rglgen_resolve_symbols(glfwGetProcAddress);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
#ifdef __SWITCH__
|
||||
gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
|
||||
#else
|
||||
rglgen_resolve_symbols(glfwGetProcAddress);
|
||||
#endif
|
||||
|
||||
gl_render_init();
|
||||
|
||||
glfwSetCursorPosCallback(window, [](GLFWwindow *w, double x, double y) {
|
||||
|
@ -93,7 +104,11 @@ int main(int argc, const char * argv[]) {
|
|||
glfwGetWindowSize(window, &width, &height);
|
||||
glfwGetFramebufferSize(window, &fb_width, &fb_height);
|
||||
|
||||
#ifdef __SWITCH__
|
||||
Settings::settings()->set_working_dir("sdmc:/switch/moonlight");
|
||||
#else
|
||||
Settings::settings()->set_working_dir("/Users/rock88/Documents/RetroArch/system/moonlight");
|
||||
#endif
|
||||
|
||||
nanogui::init();
|
||||
nanogui::ref<Application> app = new Application(Size(width, height), Size(fb_width, fb_height));
|
||||
|
|
40
src/moonlight_libnx.c
Normal file
40
src/moonlight_libnx.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <netinet/in.h>
|
||||
#include <stdint.h>
|
||||
#include <switch.h>
|
||||
#include "libretro.h"
|
||||
|
||||
retro_audio_sample_batch_t audio_batch_cb = NULL;
|
||||
retro_input_state_t input_state_cb = NULL;
|
||||
|
||||
uint32_t htonl(uint32_t hostlong) {
|
||||
return __builtin_bswap32(hostlong);
|
||||
}
|
||||
|
||||
uint16_t htons(uint16_t hostshort) {
|
||||
return __builtin_bswap16(hostshort);
|
||||
}
|
||||
|
||||
uint32_t ntohl(uint32_t netlong) {
|
||||
return __builtin_bswap32(netlong);
|
||||
}
|
||||
|
||||
uint16_t ntohs(uint16_t netshort) {
|
||||
return __builtin_bswap16(netshort);
|
||||
}
|
||||
|
||||
int sigaction(int a, const struct sigaction* b, struct sigaction* c) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nxlink_sock = -1;
|
||||
|
||||
void userAppInit() {
|
||||
socketInitializeDefault();
|
||||
nxlink_sock = nxlinkStdio();
|
||||
}
|
||||
|
||||
void userAppExit() {
|
||||
if (nxlink_sock != -1)
|
||||
close(nxlink_sock);
|
||||
socketExit();
|
||||
}
|
Loading…
Reference in a new issue