mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-19 14:50:58 +00:00
Make SDL more reliable
This commit is contained in:
@@ -43,8 +43,7 @@ static int keyboard_modifiers;
|
|||||||
void sdlinput_init() {
|
void sdlinput_init() {
|
||||||
memset(gamepads, 0, sizeof(gamepads));
|
memset(gamepads, 0, sizeof(gamepads));
|
||||||
|
|
||||||
//SDL_SetRelativeMouseMode(SDL_TRUE);
|
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||||
SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
|
|
||||||
SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt");
|
SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt");
|
||||||
|
|
||||||
for (int i = 0; i < SDL_NumJoysticks(); ++i) {
|
for (int i = 0; i < SDL_NumJoysticks(); ++i) {
|
||||||
|
|||||||
10
src/main.c
10
src/main.c
@@ -84,7 +84,13 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys
|
|||||||
|
|
||||||
gs_start_app(server, &config->stream, appId, config->sops, config->localaudio);
|
gs_start_app(server, &config->stream, appId, config->sops, config->localaudio);
|
||||||
|
|
||||||
LiStartConnection(server->address, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system), NULL, 0, server->serverMajorVersion);
|
void *context = NULL;
|
||||||
|
#ifdef HAVE_SDL
|
||||||
|
if (system == SDL)
|
||||||
|
context = sdl_window;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LiStartConnection(server->address, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system), context, 0, server->serverMajorVersion);
|
||||||
|
|
||||||
if (IS_EMBEDDED(system))
|
if (IS_EMBEDDED(system))
|
||||||
loop_main();
|
loop_main();
|
||||||
@@ -207,7 +213,7 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
#ifdef HAVE_SDL
|
#ifdef HAVE_SDL
|
||||||
else if (system == SDL)
|
else if (system == SDL)
|
||||||
sdlinput_init();
|
sdl_init(config.stream.width, config.stream.height);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
stream(&server, &config, system);
|
stream(&server, &config, system);
|
||||||
|
|||||||
21
src/sdl.c
21
src/sdl.c
@@ -25,16 +25,29 @@
|
|||||||
#include "limelight-common/Limelight.h"
|
#include "limelight-common/Limelight.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
static bool done;
|
static bool done;
|
||||||
|
|
||||||
void sdl_loop() {
|
SDL_Window *sdl_window;
|
||||||
SDL_InitSubSystem(SDL_INIT_EVENTS);
|
|
||||||
|
void sdl_init(int width, int height) {
|
||||||
|
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS)) {
|
||||||
|
fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sdl_window = SDL_CreateWindow("Moonlight", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, 0);
|
||||||
|
if(!sdl_window) {
|
||||||
|
fprintf(stderr, "SDL: could not create window - exiting\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
//SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
|
sdlinput_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void sdl_loop() {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
while(!done && SDL_WaitEvent(&event)) {
|
while(!done && SDL_WaitEvent(&event)) {
|
||||||
if (!sdlinput_handle_event(&event))
|
if (!sdlinput_handle_event(&event))
|
||||||
done = true;
|
done = true;
|
||||||
|
|||||||
@@ -19,6 +19,11 @@
|
|||||||
|
|
||||||
#ifdef HAVE_SDL
|
#ifdef HAVE_SDL
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
SDL_Window *sdl_window;
|
||||||
|
|
||||||
|
void sdl_init(int width, int height);
|
||||||
void sdl_loop();
|
void sdl_loop();
|
||||||
|
|
||||||
#endif /* HAVE_SDL */
|
#endif /* HAVE_SDL */
|
||||||
|
|||||||
@@ -44,9 +44,19 @@ static void sdl_setup(int width, int height, int redrawRate, void* context, int
|
|||||||
fprintf(stderr, "Not enough memory\n");
|
fprintf(stderr, "Not enough memory\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_width = width;
|
SDL_Window *window = (SDL_Window*) context;
|
||||||
screen_height = height;
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||||
|
if (!renderer) {
|
||||||
|
fprintf(stderr, "SDL: could not create renderer - exiting\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bmp = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_TARGET, width, height);
|
||||||
|
if (!bmp) {
|
||||||
|
fprintf(stderr, "SDL: could not create texture - exiting\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdl_cleanup() {
|
static void sdl_cleanup() {
|
||||||
@@ -54,31 +64,6 @@ static void sdl_cleanup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int sdl_submit_decode_unit(PDECODE_UNIT decodeUnit) {
|
static int sdl_submit_decode_unit(PDECODE_UNIT decodeUnit) {
|
||||||
if (window == NULL) {
|
|
||||||
if(SDL_Init(SDL_INIT_VIDEO)) {
|
|
||||||
fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
window = SDL_CreateWindow("Moonlight", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_width, screen_height, 0);
|
|
||||||
if(!window) {
|
|
||||||
fprintf(stderr, "SDL: could not create window - exiting\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_TARGETTEXTURE);
|
|
||||||
if (!renderer) {
|
|
||||||
fprintf(stderr, "SDL: could not create renderer - exiting\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
bmp = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_TARGET, screen_width, screen_height);
|
|
||||||
if (!bmp) {
|
|
||||||
fprintf(stderr, "SDL: could not create texture - exiting\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (decodeUnit->fullLength < DECODER_BUFFER_SIZE) {
|
if (decodeUnit->fullLength < DECODER_BUFFER_SIZE) {
|
||||||
PLENTRY entry = decodeUnit->bufferList;
|
PLENTRY entry = decodeUnit->bufferList;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user