diff --git a/libgamestream/CMakeLists.txt b/libgamestream/CMakeLists.txt index 7ee2011..ffbd9b0 100644 --- a/libgamestream/CMakeLists.txt +++ b/libgamestream/CMakeLists.txt @@ -1,4 +1,4 @@ -set(SO_VERSION 3) +set(SO_VERSION 4) find_package(LibUUID REQUIRED) find_package(Threads REQUIRED) diff --git a/libgamestream/client.c b/libgamestream/client.c index 6fe0c0b..2f5d383 100644 --- a/libgamestream/client.c +++ b/libgamestream/client.c @@ -650,7 +650,7 @@ int gs_applist(PSERVER_DATA server, PAPP_LIST *list) { return ret; } -int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, bool sops, bool localaudio) { +int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, bool sops, bool localaudio, int gamepad_mask) { int ret = GS_OK; uuid_t uuid; char* result = NULL; @@ -689,7 +689,7 @@ int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, b if (server->currentGame == 0) { int channelCounnt = config->audioConfiguration == AUDIO_CONFIGURATION_STEREO ? CHANNEL_COUNT_STEREO : CHANNEL_COUNT_51_SURROUND; int mask = config->audioConfiguration == AUDIO_CONFIGURATION_STEREO ? CHANNEL_MASK_STEREO : CHANNEL_MASK_51_SURROUND; - snprintf(url, sizeof(url), "https://%s:47984/launch?uniqueid=%s&uuid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d&surroundAudioInfo=%d", server->serverInfo.address, unique_id, uuid_str, appId, config->width, config->height, config->fps, sops, rikey_hex, rikeyid, localaudio, (mask << 16) + channelCounnt); + snprintf(url, sizeof(url), "https://%s:47984/launch?uniqueid=%s&uuid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d&surroundAudioInfo=%d&remoteControllersBitmap=%d&gcmap=%d", server->serverInfo.address, unique_id, uuid_str, appId, config->width, config->height, config->fps, sops, rikey_hex, rikeyid, localaudio, (mask << 16) + channelCounnt, gamepad_mask, gamepad_mask); } else snprintf(url, sizeof(url), "https://%s:47984/resume?uniqueid=%s&uuid=%s&rikey=%s&rikeyid=%d", server->serverInfo.address, unique_id, uuid_str, rikey_hex, rikeyid); diff --git a/libgamestream/client.h b/libgamestream/client.h index d9f956c..f4d6c25 100644 --- a/libgamestream/client.h +++ b/libgamestream/client.h @@ -42,7 +42,7 @@ typedef struct _SERVER_DATA { } SERVER_DATA, *PSERVER_DATA; int gs_init(PSERVER_DATA server, char* address, const char *keyDirectory, int logLevel, bool unsupported); -int gs_start_app(PSERVER_DATA server, PSTREAM_CONFIGURATION config, int appId, bool sops, bool localaudio); +int gs_start_app(PSERVER_DATA server, PSTREAM_CONFIGURATION config, int appId, bool sops, bool localaudio, int gamepad_mask); int gs_applist(PSERVER_DATA server, PAPP_LIST *app_list); int gs_unpair(PSERVER_DATA server); int gs_pair(PSERVER_DATA server, char* pin); diff --git a/src/input/evdev.c b/src/input/evdev.c index 25710cc..39508db 100644 --- a/src/input/evdev.c +++ b/src/input/evdev.c @@ -91,6 +91,8 @@ static bool* currentReverse; static bool grabbingDevices; +int evdev_gamepads = 0; + #define QUIT_MODIFIERS (MODIFIER_SHIFT|MODIFIER_ALT|MODIFIER_CTRL) #define QUIT_KEY KEY_Q #define QUIT_BUTTONS (PLAY_FLAG|BACK_FLAG|LB_FLAG|RB_FLAG) @@ -495,6 +497,9 @@ void evdev_create(const char* device, struct mapping* mappings, bool verbose) { mappings = default_mapping; } + if (!is_keyboard && !is_mouse) + evdev_gamepads++; + int dev = numDevices; numDevices++; diff --git a/src/input/evdev.h b/src/input/evdev.h index 430dff8..8583a27 100644 --- a/src/input/evdev.h +++ b/src/input/evdev.h @@ -19,6 +19,8 @@ #include "mapping.h" +extern int evdev_gamepads; + void evdev_create(const char* device, struct mapping* mappings, bool verbose); void evdev_loop(); diff --git a/src/input/sdl.c b/src/input/sdl.c index b0ae29c..f2787f9 100644 --- a/src/input/sdl.c +++ b/src/input/sdl.c @@ -42,6 +42,8 @@ static GAMEPAD_STATE gamepads[4]; static int keyboard_modifiers; static int activeGamepadMask = 0; +int sdl_gamepads = 0; + void sdlinput_init(char* mappings) { memset(gamepads, 0, sizeof(gamepads)); @@ -50,6 +52,7 @@ void sdlinput_init(char* mappings) { for (int i = 0; i < SDL_NumJoysticks(); ++i) { if (SDL_IsGameController(i)) { + sdl_gamepads++; if (!SDL_GameControllerOpen(i)) { fprintf(stderr, "Could not open gamecontroller %i: %s\n", i, SDL_GetError()); } diff --git a/src/input/sdl.h b/src/input/sdl.h index 9157680..419e97b 100644 --- a/src/input/sdl.h +++ b/src/input/sdl.h @@ -20,6 +20,8 @@ #include #include +extern int sdl_gamepads; + static const short keyCodes1[] = { 0, //SDLK_EXCLAIM 0, //SDLK_QUOTEDBL diff --git a/src/main.c b/src/main.c index b588da1..b90f35e 100644 --- a/src/main.c +++ b/src/main.c @@ -90,7 +90,16 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys exit(-1); } - int ret = gs_start_app(server, &config->stream, appId, config->sops, config->localaudio); + int gamepads = 0; + gamepads += evdev_gamepads; + #ifdef HAVE_SDL + gamepads += sdl_gamepads; + #endif + int gamepad_mask; + for (int i = 0; i < gamepads && i < 4; i++) + gamepad_mask = (gamepad_mask << 1) + 1; + + int ret = gs_start_app(server, &config->stream, appId, config->sops, config->localaudio, gamepad_mask); if (ret < 0) { if (ret == GS_NOT_SUPPORTED_4K) fprintf(stderr, "Server doesn't support 4K\n");