mirror of
https://github.com/rock88/moonlight-nx
synced 2024-11-10 06:14:15 +00:00
refactoring
This commit is contained in:
parent
fb92e7356a
commit
a3557d06f1
18 changed files with 139 additions and 93 deletions
11
Makefile
11
Makefile
|
@ -45,7 +45,7 @@ APP_VERSION := 1.2.0
|
|||
BUILD := build
|
||||
SOURCES := src src/libgamestream src/switch src/nanogui_resources src/streaming src/streaming/ffmpeg \
|
||||
src/crypto src/streaming/video src/crypto src/streaming/audio src/ui/windows src/ui/buttons src/ui src/utils \
|
||||
src/controls src/controls/switch \
|
||||
src/controls src/controls/switch src/streaming/switch \
|
||||
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
|
||||
|
@ -65,7 +65,7 @@ ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
|
|||
|
||||
M_INCLUDES := \
|
||||
-I$(TOPDIR)/src -I$(TOPDIR)/src/switch -I$(TOPDIR)/src/streaming -I$(TOPDIR)/src/crypto -I$(TOPDIR)/src/crypto/keys \
|
||||
-I$(TOPDIR)/src/streaming/ffmpeg -I$(TOPDIR)/src/streaming/video -I$(TOPDIR)/src/streaming/audio \
|
||||
-I$(TOPDIR)/src/streaming/ffmpeg -I$(TOPDIR)/src/streaming/video -I$(TOPDIR)/src/streaming/audio -I$(TOPDIR)/src/streaming/switch \
|
||||
-I$(TOPDIR)/src/nanogui_resources -I$(TOPDIR)/src/utils -I$(TOPDIR)/src/controls -I$(TOPDIR)/src/controls/switch \
|
||||
-I$(TOPDIR)/src/ui -I$(TOPDIR)/src/ui/buttons -I$(TOPDIR)/src/ui/windows \
|
||||
-I$(TOPDIR)/src/libgamestream \
|
||||
|
@ -131,9 +131,10 @@ MOONLIGHT_LIBRETRO_CXX_SOURCES = \
|
|||
KeyboardController.cpp \
|
||||
GamepadController.cpp \
|
||||
StreamControlsController.cpp \
|
||||
MouseFrontendSwitch.cpp \
|
||||
KeyboardFrontendSwitch.cpp \
|
||||
GamepadFrontendSwitch.cpp
|
||||
SwitchMouseFrontend.cpp \
|
||||
SwitchKeyboardFrontend.cpp \
|
||||
SwitchGamepadFrontend.cpp \
|
||||
SwitchMoonlightSessionDecoderAndRenderProvider.cpp
|
||||
|
||||
MOONLIGHT_COMMON_C_SOURCES = \
|
||||
callbacks.c \
|
||||
|
|
|
@ -21,9 +21,10 @@
|
|||
/* End PBXAggregateTarget section */
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
28896584262C343C00139ABE /* GamepadFrontendSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2889657E262C343C00139ABE /* GamepadFrontendSwitch.cpp */; };
|
||||
28896585262C343C00139ABE /* KeyboardFrontendSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2889657F262C343C00139ABE /* KeyboardFrontendSwitch.cpp */; };
|
||||
28896586262C343C00139ABE /* MouseFrontendSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 28896580262C343C00139ABE /* MouseFrontendSwitch.cpp */; };
|
||||
28858432262CBC5300862DB4 /* SwitchMoonlightSessionDecoderAndRenderProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 28858430262CBC5300862DB4 /* SwitchMoonlightSessionDecoderAndRenderProvider.cpp */; };
|
||||
28896584262C343C00139ABE /* SwitchGamepadFrontend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2889657E262C343C00139ABE /* SwitchGamepadFrontend.cpp */; };
|
||||
28896585262C343C00139ABE /* SwitchKeyboardFrontend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2889657F262C343C00139ABE /* SwitchKeyboardFrontend.cpp */; };
|
||||
28896586262C343C00139ABE /* SwitchMouseFrontend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 28896580262C343C00139ABE /* SwitchMouseFrontend.cpp */; };
|
||||
28896595262C88C000139ABE /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28896594262C88C000139ABE /* AudioToolbox.framework */; };
|
||||
28896597262C88C700139ABE /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28896596262C88C700139ABE /* CoreMedia.framework */; };
|
||||
28896599262C88D000139ABE /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28896598262C88D000139ABE /* CoreVideo.framework */; };
|
||||
|
@ -147,18 +148,21 @@
|
|||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
28858412262CA94800862DB4 /* MouseFrontendDummy.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MouseFrontendDummy.hpp; sourceTree = "<group>"; };
|
||||
28858415262CA98C00862DB4 /* KeyboardFrontendDummy.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = KeyboardFrontendDummy.hpp; sourceTree = "<group>"; };
|
||||
28858416262CA9BD00862DB4 /* GamepadFrontendDummy.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = GamepadFrontendDummy.hpp; sourceTree = "<group>"; };
|
||||
28858412262CA94800862DB4 /* DummyMouseFrontend.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DummyMouseFrontend.hpp; sourceTree = "<group>"; };
|
||||
28858415262CA98C00862DB4 /* DummyKeyboardFrontend.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DummyKeyboardFrontend.hpp; sourceTree = "<group>"; };
|
||||
28858416262CA9BD00862DB4 /* DummyGamepadFrontend.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DummyGamepadFrontend.hpp; sourceTree = "<group>"; };
|
||||
28858430262CBC5300862DB4 /* SwitchMoonlightSessionDecoderAndRenderProvider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SwitchMoonlightSessionDecoderAndRenderProvider.cpp; sourceTree = "<group>"; };
|
||||
28858431262CBC5300862DB4 /* SwitchMoonlightSessionDecoderAndRenderProvider.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SwitchMoonlightSessionDecoderAndRenderProvider.hpp; sourceTree = "<group>"; };
|
||||
28858437262CBC8700862DB4 /* MoonlightSessionDecoderAndRenderProvider.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MoonlightSessionDecoderAndRenderProvider.hpp; sourceTree = "<group>"; };
|
||||
28896563262B628700139ABE /* MouseFrontend.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MouseFrontend.hpp; sourceTree = "<group>"; };
|
||||
2889656B262B6E0100139ABE /* GamepadFrontend.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = GamepadFrontend.hpp; sourceTree = "<group>"; };
|
||||
28896573262C20C000139ABE /* KeyboardFrontend.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = KeyboardFrontend.hpp; sourceTree = "<group>"; };
|
||||
2889657E262C343C00139ABE /* GamepadFrontendSwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GamepadFrontendSwitch.cpp; sourceTree = "<group>"; };
|
||||
2889657F262C343C00139ABE /* KeyboardFrontendSwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyboardFrontendSwitch.cpp; sourceTree = "<group>"; };
|
||||
28896580262C343C00139ABE /* MouseFrontendSwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseFrontendSwitch.cpp; sourceTree = "<group>"; };
|
||||
28896581262C343C00139ABE /* GamepadFrontendSwitch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GamepadFrontendSwitch.hpp; sourceTree = "<group>"; };
|
||||
28896582262C343C00139ABE /* KeyboardFrontendSwitch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KeyboardFrontendSwitch.hpp; sourceTree = "<group>"; };
|
||||
28896583262C343C00139ABE /* MouseFrontendSwitch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MouseFrontendSwitch.hpp; sourceTree = "<group>"; };
|
||||
2889657E262C343C00139ABE /* SwitchGamepadFrontend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SwitchGamepadFrontend.cpp; sourceTree = "<group>"; };
|
||||
2889657F262C343C00139ABE /* SwitchKeyboardFrontend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SwitchKeyboardFrontend.cpp; sourceTree = "<group>"; };
|
||||
28896580262C343C00139ABE /* SwitchMouseFrontend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SwitchMouseFrontend.cpp; sourceTree = "<group>"; };
|
||||
28896581262C343C00139ABE /* SwitchGamepadFrontend.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SwitchGamepadFrontend.hpp; sourceTree = "<group>"; };
|
||||
28896582262C343C00139ABE /* SwitchKeyboardFrontend.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SwitchKeyboardFrontend.hpp; sourceTree = "<group>"; };
|
||||
28896583262C343C00139ABE /* SwitchMouseFrontend.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SwitchMouseFrontend.hpp; sourceTree = "<group>"; };
|
||||
28896594262C88C000139ABE /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
|
||||
28896596262C88C700139ABE /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
|
||||
28896598262C88D000139ABE /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; };
|
||||
|
@ -416,22 +420,31 @@
|
|||
28858411262CA93300862DB4 /* dummy */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
28858412262CA94800862DB4 /* MouseFrontendDummy.hpp */,
|
||||
28858415262CA98C00862DB4 /* KeyboardFrontendDummy.hpp */,
|
||||
28858416262CA9BD00862DB4 /* GamepadFrontendDummy.hpp */,
|
||||
28858412262CA94800862DB4 /* DummyMouseFrontend.hpp */,
|
||||
28858415262CA98C00862DB4 /* DummyKeyboardFrontend.hpp */,
|
||||
28858416262CA9BD00862DB4 /* DummyGamepadFrontend.hpp */,
|
||||
);
|
||||
path = dummy;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
2885842F262CBC3B00862DB4 /* switch */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
28858430262CBC5300862DB4 /* SwitchMoonlightSessionDecoderAndRenderProvider.cpp */,
|
||||
28858431262CBC5300862DB4 /* SwitchMoonlightSessionDecoderAndRenderProvider.hpp */,
|
||||
);
|
||||
path = switch;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
2889657D262C343C00139ABE /* switch */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
28896580262C343C00139ABE /* MouseFrontendSwitch.cpp */,
|
||||
28896583262C343C00139ABE /* MouseFrontendSwitch.hpp */,
|
||||
2889657F262C343C00139ABE /* KeyboardFrontendSwitch.cpp */,
|
||||
28896582262C343C00139ABE /* KeyboardFrontendSwitch.hpp */,
|
||||
2889657E262C343C00139ABE /* GamepadFrontendSwitch.cpp */,
|
||||
28896581262C343C00139ABE /* GamepadFrontendSwitch.hpp */,
|
||||
28896580262C343C00139ABE /* SwitchMouseFrontend.cpp */,
|
||||
28896583262C343C00139ABE /* SwitchMouseFrontend.hpp */,
|
||||
2889657F262C343C00139ABE /* SwitchKeyboardFrontend.cpp */,
|
||||
28896582262C343C00139ABE /* SwitchKeyboardFrontend.hpp */,
|
||||
2889657E262C343C00139ABE /* SwitchGamepadFrontend.cpp */,
|
||||
28896581262C343C00139ABE /* SwitchGamepadFrontend.hpp */,
|
||||
);
|
||||
path = switch;
|
||||
sourceTree = "<group>";
|
||||
|
@ -812,11 +825,13 @@
|
|||
36D3F8462469C8DD00CDEF9B /* streaming */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2885842F262CBC3B00862DB4 /* switch */,
|
||||
36D3F8482469CC0400CDEF9B /* audio */,
|
||||
3661D2FB2469DEDB0060EE24 /* video */,
|
||||
36D3F8472469CB8800CDEF9B /* ffmpeg */,
|
||||
36D3F8422469B5C400CDEF9B /* MoonlightSession.cpp */,
|
||||
36D3F8432469B5C400CDEF9B /* MoonlightSession.hpp */,
|
||||
28858437262CBC8700862DB4 /* MoonlightSessionDecoderAndRenderProvider.hpp */,
|
||||
36BFCCF52479724900245D40 /* GameStreamClient.cpp */,
|
||||
36BFCCF42479724900245D40 /* GameStreamClient.hpp */,
|
||||
36EB491124993A4C0059EDB7 /* WakeOnLanManager.cpp */,
|
||||
|
@ -1090,7 +1105,7 @@
|
|||
3652F067245C292B001FABF3 /* packet.c in Sources */,
|
||||
3661D2F92469D1940060EE24 /* FFmpegVideoDecoder.cpp in Sources */,
|
||||
363898342471B7C500F99920 /* MbedTLSCryptoManager.cpp in Sources */,
|
||||
28896586262C343C00139ABE /* MouseFrontendSwitch.cpp in Sources */,
|
||||
28896586262C343C00139ABE /* SwitchMouseFrontend.cpp in Sources */,
|
||||
3652F072245C292B001FABF3 /* RtspConnection.c in Sources */,
|
||||
36BFCCF22479723E00245D40 /* client.cpp in Sources */,
|
||||
3678EF732476D9DA0097345D /* DebugFileRecorderAudioRenderer.cpp in Sources */,
|
||||
|
@ -1107,7 +1122,7 @@
|
|||
367D2D7424829A0800A946F4 /* LogsWindow.cpp in Sources */,
|
||||
36A0C03A2461E4C00083289C /* SettingsWindow.cpp in Sources */,
|
||||
3652EFD4245B3B00001FABF3 /* shader_gl.cpp in Sources */,
|
||||
28896585262C343C00139ABE /* KeyboardFrontendSwitch.cpp in Sources */,
|
||||
28896585262C343C00139ABE /* SwitchKeyboardFrontend.cpp in Sources */,
|
||||
3602C3BD245DBA9100368900 /* AppButton.cpp in Sources */,
|
||||
36BFCCF32479723E00245D40 /* http.cpp in Sources */,
|
||||
36D3F8442469B5C400CDEF9B /* MoonlightSession.cpp in Sources */,
|
||||
|
@ -1126,6 +1141,7 @@
|
|||
3652F06F245C292B001FABF3 /* ControlStream.c in Sources */,
|
||||
3652EFD6245B3B00001FABF3 /* window.cpp in Sources */,
|
||||
3652F071245C292B001FABF3 /* InputStream.c in Sources */,
|
||||
28858432262CBC5300862DB4 /* SwitchMoonlightSessionDecoderAndRenderProvider.cpp in Sources */,
|
||||
3652EFDD245B3B00001FABF3 /* texture_gl.cpp in Sources */,
|
||||
3652F069245C292B001FABF3 /* peer.c in Sources */,
|
||||
3602C3B7245D903000368900 /* HostButton.cpp in Sources */,
|
||||
|
@ -1152,7 +1168,7 @@
|
|||
3652F078245C292B001FABF3 /* FakeCallbacks.c in Sources */,
|
||||
3652F06B245C292B001FABF3 /* host.c in Sources */,
|
||||
3602C3BA245DB3C800368900 /* AppListWindow.cpp in Sources */,
|
||||
28896584262C343C00139ABE /* GamepadFrontendSwitch.cpp in Sources */,
|
||||
28896584262C343C00139ABE /* SwitchGamepadFrontend.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "GamepadFrontend.hpp"
|
||||
#pragma once
|
||||
|
||||
class GamepadFrontendDummy: public GamepadFrontend {
|
||||
class DummyGamepadFrontend: public GamepadFrontend {
|
||||
public:
|
||||
GamepadFrontendDummy() {}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#include "KeyboardFrontend.hpp"
|
||||
#pragma once
|
||||
|
||||
class KeyboardFrontendDummy: public KeyboardFrontend {
|
||||
class DummyKeyboardFrontend: public KeyboardFrontend {
|
||||
public:
|
||||
KeyboardFrontendDummy() {}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#include "MouseFrontend.hpp"
|
||||
#pragma once
|
||||
|
||||
class MouseFrontendDummy: public MouseFrontend {
|
||||
class DummyMouseFrontend: public MouseFrontend {
|
||||
public:
|
||||
MouseFrontendDummy() {}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "GamepadFrontendSwitch.hpp"
|
||||
#include "SwitchGamepadFrontend.hpp"
|
||||
#include "Limelight.h"
|
||||
#include <nanogui/opengl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
@ -117,7 +117,7 @@ static inline void padUpdateOverKeyboard(PadState* pad) {
|
|||
}
|
||||
}
|
||||
|
||||
GamepadFrontendSwitch::GamepadFrontendSwitch() {
|
||||
SwitchGamepadFrontend::SwitchGamepadFrontend() {
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&m_pad_state);
|
||||
|
||||
|
@ -125,7 +125,7 @@ GamepadFrontendSwitch::GamepadFrontendSwitch() {
|
|||
hidInitializeVibrationDevices(m_vibration_device_handles[1], 2, HidNpadIdType_No1, HidNpadStyleTag_NpadJoyDual);
|
||||
}
|
||||
|
||||
void GamepadFrontendSwitch::handle_gamepad() {
|
||||
void SwitchGamepadFrontend::handle_gamepad() {
|
||||
PadState state = m_pad_state;
|
||||
|
||||
#ifdef __SWITCH__
|
||||
|
@ -156,7 +156,7 @@ void GamepadFrontendSwitch::handle_gamepad() {
|
|||
}
|
||||
}
|
||||
|
||||
void GamepadFrontendSwitch::handle_rumple(unsigned short controller, unsigned short low_freq_motor, unsigned short high_freq_motor) {
|
||||
void SwitchGamepadFrontend::handle_rumple(unsigned short controller, unsigned short low_freq_motor, unsigned short high_freq_motor) {
|
||||
if (controller == 0) {
|
||||
float low = (float)low_freq_motor / 0xFFFF;
|
||||
float high = (float)high_freq_motor / 0xFFFF;
|
||||
|
@ -178,7 +178,7 @@ void GamepadFrontendSwitch::handle_rumple(unsigned short controller, unsigned sh
|
|||
}
|
||||
}
|
||||
|
||||
void GamepadFrontendSwitch::stop_rumple() {
|
||||
void SwitchGamepadFrontend::stop_rumple() {
|
||||
HidVibrationValue stop;
|
||||
memset(&stop, 0, sizeof(HidVibrationValue));
|
||||
|
||||
|
@ -193,7 +193,7 @@ void GamepadFrontendSwitch::stop_rumple() {
|
|||
hidSendVibrationValues(m_vibration_device_handles[1 - target_device], m_vibration_values, 2);
|
||||
}
|
||||
|
||||
bool GamepadFrontendSwitch::set_new_pad_state(PadState& state) {
|
||||
bool SwitchGamepadFrontend::set_new_pad_state(PadState& state) {
|
||||
if (!pad_is_equal(m_pad_state, state)) {
|
||||
m_pad_state = state;
|
||||
return true;
|
|
@ -2,9 +2,9 @@
|
|||
#include <switch.h>
|
||||
#pragma once
|
||||
|
||||
class GamepadFrontendSwitch: public GamepadFrontend {
|
||||
class SwitchGamepadFrontend: public GamepadFrontend {
|
||||
public:
|
||||
GamepadFrontendSwitch();
|
||||
SwitchGamepadFrontend();
|
||||
|
||||
void handle_gamepad();
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
#include "KeyboardFrontendSwitch.hpp"
|
||||
#include "SwitchKeyboardFrontend.hpp"
|
||||
#include "Logger.hpp"
|
||||
#include "Limelight.h"
|
||||
#include <switch.h>
|
||||
#include <nanogui/opengl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
static KeyboardFrontendSwitch* m_frontend = NULL;
|
||||
static SwitchKeyboardFrontend* m_frontend = NULL;
|
||||
|
||||
static inline int find_glfw_key_index(int key, KeyboardState& state) {
|
||||
for (int i = 0; i < state.keys.size(); i++) {
|
||||
|
@ -60,7 +60,7 @@ static inline int find_switch_key_index(int key, KeyboardState& state) {
|
|||
}
|
||||
}
|
||||
|
||||
KeyboardFrontendSwitch::KeyboardFrontendSwitch(GLFWwindow* window) {
|
||||
SwitchKeyboardFrontend::SwitchKeyboardFrontend(GLFWwindow* window) {
|
||||
m_frontend = this;
|
||||
|
||||
hidInitializeKeyboard();
|
||||
|
@ -80,7 +80,7 @@ KeyboardFrontendSwitch::KeyboardFrontendSwitch(GLFWwindow* window) {
|
|||
m_hid_keyboard_state.assign(256, false);
|
||||
}
|
||||
|
||||
void KeyboardFrontendSwitch::handle_keyboard() {
|
||||
void SwitchKeyboardFrontend::handle_keyboard() {
|
||||
HidKeyboardState state;
|
||||
|
||||
if (hidGetKeyboardStates(&state, 1)) {
|
||||
|
@ -124,7 +124,7 @@ void KeyboardFrontendSwitch::handle_keyboard() {
|
|||
}
|
||||
}
|
||||
|
||||
void KeyboardFrontendSwitch::handle_key(int key, int scancode, int action, int mods) {
|
||||
void SwitchKeyboardFrontend::handle_key(int key, int scancode, int action, int mods) {
|
||||
int index = find_glfw_key_index(key, m_keyboard_state);
|
||||
|
||||
if (index >= 0) {
|
||||
|
@ -156,6 +156,6 @@ void KeyboardFrontendSwitch::handle_key(int key, int scancode, int action, int m
|
|||
m_keyboard_state.moonlight_modifiers = moonlight_modifiers;
|
||||
}
|
||||
|
||||
void KeyboardFrontendSwitch::handle_char(unsigned int input) {
|
||||
void SwitchKeyboardFrontend::handle_char(unsigned int input) {
|
||||
// TODO: no needs anymore?
|
||||
}
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
struct GLFWwindow;
|
||||
|
||||
class KeyboardFrontendSwitch: public KeyboardFrontend {
|
||||
class SwitchKeyboardFrontend: public KeyboardFrontend {
|
||||
public:
|
||||
KeyboardFrontendSwitch(GLFWwindow* window);
|
||||
SwitchKeyboardFrontend(GLFWwindow* window);
|
||||
|
||||
void handle_keyboard();
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
#include "MouseFrontendSwitch.hpp"
|
||||
#include "SwitchMouseFrontend.hpp"
|
||||
#include <nanogui/opengl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
static MouseFrontendSwitch* m_frontend = NULL;
|
||||
static SwitchMouseFrontend* m_frontend = NULL;
|
||||
|
||||
MouseFrontendSwitch::MouseFrontendSwitch(GLFWwindow* window) {
|
||||
SwitchMouseFrontend::SwitchMouseFrontend(GLFWwindow* window) {
|
||||
m_frontend = this;
|
||||
|
||||
hidInitializeMouse();
|
||||
|
@ -23,7 +23,7 @@ MouseFrontendSwitch::MouseFrontendSwitch(GLFWwindow* window) {
|
|||
});
|
||||
}
|
||||
|
||||
void MouseFrontendSwitch::handle_mouse() {
|
||||
void SwitchMouseFrontend::handle_mouse() {
|
||||
HidMouseState hid_mouse_state;
|
||||
|
||||
if (hidGetMouseStates(&hid_mouse_state, 1) && (hid_mouse_state.attributes & HidMouseAttribute_IsConnected)) {
|
||||
|
@ -57,14 +57,14 @@ void MouseFrontendSwitch::handle_mouse() {
|
|||
}
|
||||
}
|
||||
|
||||
void MouseFrontendSwitch::handle_mouse_move(double x, double y) {
|
||||
void SwitchMouseFrontend::handle_mouse_move(double x, double y) {
|
||||
m_hid_mouse_is_used = false;
|
||||
|
||||
m_mouse_state.x = (int)x;
|
||||
m_mouse_state.y = (int)y;
|
||||
}
|
||||
|
||||
void MouseFrontendSwitch::handle_mouse_buttons(int button, int action, int modifiers) {
|
||||
void SwitchMouseFrontend::handle_mouse_buttons(int button, int action, int modifiers) {
|
||||
m_hid_mouse_is_used = false;
|
||||
|
||||
if (button == NANOGUI_MOUSE_BUTTON_1) {
|
||||
|
@ -74,7 +74,7 @@ void MouseFrontendSwitch::handle_mouse_buttons(int button, int action, int modif
|
|||
}
|
||||
}
|
||||
|
||||
void MouseFrontendSwitch::handle_mouse_scroll(int x, int y) {
|
||||
void SwitchMouseFrontend::handle_mouse_scroll(int x, int y) {
|
||||
m_hid_mouse_is_used = false;
|
||||
|
||||
m_mouse_state.scroll_y = y;
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
struct GLFWwindow;
|
||||
|
||||
class MouseFrontendSwitch: public MouseFrontend {
|
||||
class SwitchMouseFrontend: public MouseFrontend {
|
||||
public:
|
||||
MouseFrontendSwitch(GLFWwindow* window);
|
||||
SwitchMouseFrontend(GLFWwindow* window);
|
||||
|
||||
void handle_mouse();
|
||||
|
15
src/main.cpp
15
src/main.cpp
|
@ -6,11 +6,13 @@
|
|||
#include "GameStreamClient.hpp"
|
||||
#include "Logger.hpp"
|
||||
#include "MouseController.hpp"
|
||||
#include "MouseFrontendSwitch.hpp"
|
||||
#include "SwitchMouseFrontend.hpp"
|
||||
#include "KeyboardController.hpp"
|
||||
#include "KeyboardFrontendSwitch.hpp"
|
||||
#include "SwitchKeyboardFrontend.hpp"
|
||||
#include "GamepadController.hpp"
|
||||
#include "GamepadFrontendSwitch.hpp"
|
||||
#include "SwitchGamepadFrontend.hpp"
|
||||
#include "MoonlightSession.hpp"
|
||||
#include "SwitchMoonlightSessionDecoderAndRenderProvider.hpp"
|
||||
#include <glad/glad.h>
|
||||
#include <switch.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
@ -66,9 +68,10 @@ int main(int argc, const char * argv[]) {
|
|||
|
||||
GameStreamClient::instance().start();
|
||||
|
||||
MouseController::instance().init(new MouseFrontendSwitch(window));
|
||||
KeyboardController::instance().init(new KeyboardFrontendSwitch(window));
|
||||
GamepadController::instance().init(new GamepadFrontendSwitch());
|
||||
MoonlightSession::set_provider(new SwitchMoonlightSessionDecoderAndRenderProvider());
|
||||
MouseController::instance().init(new SwitchMouseFrontend(window));
|
||||
KeyboardController::instance().init(new SwitchKeyboardFrontend(window));
|
||||
GamepadController::instance().init(new SwitchGamepadFrontend());
|
||||
|
||||
nanogui::init();
|
||||
nanogui::ref<Application> app = new Application(Size(m_width, m_height), Size(m_fb_width, m_fb_height));
|
||||
|
|
|
@ -7,12 +7,21 @@
|
|||
#include <nanogui/nanogui.h>
|
||||
|
||||
static MoonlightSession* m_active_session = nullptr;
|
||||
static MoonlightSessionDecoderAndRenderProvider* m_provider = nullptr;
|
||||
|
||||
void MoonlightSession::set_provider(MoonlightSessionDecoderAndRenderProvider* provider) {
|
||||
m_provider = provider;
|
||||
}
|
||||
|
||||
MoonlightSession::MoonlightSession(const std::string &address, int app_id) {
|
||||
m_address = address;
|
||||
m_app_id = app_id;
|
||||
|
||||
m_active_session = this;
|
||||
|
||||
m_video_decoder = m_provider->video_decoder();
|
||||
m_video_renderer = m_provider->video_renderer();
|
||||
m_audio_renderer = m_provider->audio_renderer();
|
||||
}
|
||||
|
||||
MoonlightSession::~MoonlightSession() {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "GameStreamClient.hpp"
|
||||
#include "IAudioRenderer.hpp"
|
||||
#include "IVideoRenderer.hpp"
|
||||
#include "IFFmpegVideoDecoder.hpp"
|
||||
#include "MoonlightSessionDecoderAndRenderProvider.hpp"
|
||||
#pragma once
|
||||
|
||||
struct SessionStats {
|
||||
|
@ -11,20 +9,10 @@ struct SessionStats {
|
|||
|
||||
class MoonlightSession {
|
||||
public:
|
||||
static void set_provider(MoonlightSessionDecoderAndRenderProvider* provider);
|
||||
|
||||
MoonlightSession(const std::string &address, int app_id);
|
||||
~MoonlightSession();
|
||||
|
||||
void set_video_decoder(IFFmpegVideoDecoder* video_decoder) {
|
||||
m_video_decoder = video_decoder;
|
||||
}
|
||||
|
||||
void set_video_renderer(IVideoRenderer* video_renderer) {
|
||||
m_video_renderer = video_renderer;
|
||||
}
|
||||
|
||||
void set_audio_renderer(IAudioRenderer* audio_renderer) {
|
||||
m_audio_renderer = audio_renderer;
|
||||
}
|
||||
|
||||
void start(ServerCallback<bool> callback);
|
||||
void stop(int terminate_app);
|
||||
|
|
11
src/streaming/MoonlightSessionDecoderAndRenderProvider.hpp
Normal file
11
src/streaming/MoonlightSessionDecoderAndRenderProvider.hpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "IAudioRenderer.hpp"
|
||||
#include "IVideoRenderer.hpp"
|
||||
#include "IFFmpegVideoDecoder.hpp"
|
||||
#pragma once
|
||||
|
||||
class MoonlightSessionDecoderAndRenderProvider {
|
||||
public:
|
||||
virtual IFFmpegVideoDecoder* video_decoder() = 0;
|
||||
virtual IVideoRenderer* video_renderer() = 0;
|
||||
virtual IAudioRenderer* audio_renderer() = 0;
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
#include "SwitchMoonlightSessionDecoderAndRenderProvider.hpp"
|
||||
#include "FFmpegVideoDecoder.hpp"
|
||||
#include "GLVideoRenderer.hpp"
|
||||
#ifdef __SWITCH__
|
||||
#include "AudrenAudioRenderer.hpp"
|
||||
#endif
|
||||
#include "DebugFileRecorderAudioRenderer.hpp"
|
||||
|
||||
IFFmpegVideoDecoder* SwitchMoonlightSessionDecoderAndRenderProvider::video_decoder() {
|
||||
return new FFmpegVideoDecoder();
|
||||
}
|
||||
|
||||
IVideoRenderer* SwitchMoonlightSessionDecoderAndRenderProvider::video_renderer() {
|
||||
return new GLVideoRenderer();
|
||||
}
|
||||
|
||||
IAudioRenderer* SwitchMoonlightSessionDecoderAndRenderProvider::audio_renderer() {
|
||||
#ifdef __SWITCH__
|
||||
return new AudrenAudioRenderer();
|
||||
#else
|
||||
return new DebugFileRecorderAudioRenderer(false);
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#include "MoonlightSession.hpp"
|
||||
|
||||
class SwitchMoonlightSessionDecoderAndRenderProvider: public MoonlightSessionDecoderAndRenderProvider {
|
||||
public:
|
||||
SwitchMoonlightSessionDecoderAndRenderProvider() {}
|
||||
|
||||
IFFmpegVideoDecoder* video_decoder();
|
||||
IVideoRenderer* video_renderer();
|
||||
IAudioRenderer* audio_renderer();
|
||||
};
|
|
@ -3,12 +3,6 @@
|
|||
#include "Alert.hpp"
|
||||
#include "StreamControlsController.hpp"
|
||||
#include "MouseController.hpp"
|
||||
#include "FFmpegVideoDecoder.hpp"
|
||||
#include "GLVideoRenderer.hpp"
|
||||
#ifdef __SWITCH__
|
||||
#include "AudrenAudioRenderer.hpp"
|
||||
#endif
|
||||
#include "DebugFileRecorderAudioRenderer.hpp"
|
||||
#include "nanovg.h"
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
@ -21,15 +15,6 @@ StreamWindow::StreamWindow(Widget *parent, const std::string &address, int app_i
|
|||
m_size = parent->size();
|
||||
m_session = new MoonlightSession(address, app_id);
|
||||
|
||||
m_session->set_video_decoder(new FFmpegVideoDecoder());
|
||||
m_session->set_video_renderer(new GLVideoRenderer());
|
||||
|
||||
#ifdef __SWITCH__
|
||||
m_session->set_audio_renderer(new AudrenAudioRenderer());
|
||||
#else
|
||||
m_session->set_audio_renderer(new DebugFileRecorderAudioRenderer(false));
|
||||
#endif
|
||||
|
||||
m_loader = add<LoadingOverlay>("Starting...");
|
||||
|
||||
inc_ref();
|
||||
|
|
Loading…
Reference in a new issue