From a18683eded16fa4590c418068b68f195b5de7124 Mon Sep 17 00:00:00 2001 From: Ningyuan Li Date: Mon, 15 Jan 2024 00:22:51 +0900 Subject: [PATCH] adding SDL_HINT_WEBOS_CLOUDGAME_ACTIVE --- include/SDL_hints.h | 8 ++++++++ src/video/wayland/SDL_waylandwebos.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/include/SDL_hints.h b/include/SDL_hints.h index e66f155b568c0..a44c698f12f23 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -2473,6 +2473,14 @@ extern "C" { * \brief A variable that decides whether to disable cursor calibration. */ #define SDL_HINT_WEBOS_CURSOR_CALIBRATION_DISABLE "SDL_HINT_WEBOS_CURSOR_CALIBRATION_DISABLE" +/** + * \brief A variable that decides whether to let SDL handle input from game controllers. + * + * Since webOS 8.3.0, input from game controllers is mapped to navigation / volume control keys by default. + * This change is useful, but can cause doubled input. SDL disables this behavior by default to let developers + * handle game controller input by themselves. But the behavior can be disabled by setting this hint to "false". + */ +#define SDL_HINT_WEBOS_CLOUDGAME_ACTIVE "SDL_HINT_WEBOS_CLOUDGAME_ACTIVE" /** * \brief An enumeration of hint priorities diff --git a/src/video/wayland/SDL_waylandwebos.c b/src/video/wayland/SDL_waylandwebos.c index 8b32f9ffc5fa0..146a90fc51cbd 100644 --- a/src/video/wayland/SDL_waylandwebos.c +++ b/src/video/wayland/SDL_waylandwebos.c @@ -123,6 +123,9 @@ int WaylandWebOS_SetupSurface(_THIS, SDL_WindowData *data) if(SDL_GetHintBoolean(SDL_HINT_WEBOS_CURSOR_CALIBRATION_DISABLE, SDL_FALSE)) { wl_webos_shell_surface_set_property(data->shell_surface.webos.webos, "restore_cursor_position", "true"); } + if(SDL_GetHintBoolean(SDL_HINT_WEBOS_CLOUDGAME_ACTIVE, SDL_TRUE)) { + wl_webos_shell_surface_set_property(data->shell_surface.webos.webos, "cloudgame_active", "true"); + } if ((hintValue = SDL_GetHint(SDL_HINT_WEBOS_CURSOR_FREQUENCY)) != NULL) { if (SDL_strtol(hintValue, NULL, 10) > 0) { wl_webos_shell_surface_set_property(data->shell_surface.webos.webos, "cursor_fps", hintValue); @@ -203,6 +206,9 @@ static void WindowHintsCallback(void *userdata, const char *name, const char *ol } else if (SDL_strcmp(name, SDL_HINT_WEBOS_CURSOR_CALIBRATION_DISABLE) == 0) { wl_webos_shell_surface_set_property(win_data->shell_surface.webos.webos, "restore_cursor_position", SDL_GetStringBoolean(newValue, SDL_FALSE) ? "true" : "false"); + } else if (SDL_strcmp(name, SDL_HINT_WEBOS_CLOUDGAME_ACTIVE) == 0) { + wl_webos_shell_surface_set_property(win_data->shell_surface.webos.webos, "cloudgame_active", + SDL_GetStringBoolean(newValue, SDL_TRUE) ? "true" : "false"); } else if (SDL_strcmp(name, SDL_HINT_WEBOS_CURSOR_FREQUENCY) == 0) { if (SDL_strtol(newValue, NULL, 10) > 0) { wl_webos_shell_surface_set_property(win_data->shell_surface.webos.webos, "cursor_fps", newValue);