Skip to content

Display and control your Android device

Enable joystick events in background

Romain Vimontf01a622eadeb
diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c
index 687a9f34..854657fb 100644
--- a/app/src/scrcpy.c
+++ b/app/src/scrcpy.c
@@ -136,6 +136,10 @@ sdl_set_hints(const char *render_driver) {
if (!SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0")) {
LOGW("Could not disable minimize on focus loss");
}
+
+ if (!SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1")) {
+ LOGW("Could not allow joystick background events");
+ }
}
static void
diff --git a/app/src/usb/scrcpy_otg.c b/app/src/usb/scrcpy_otg.c
index 47afd9d0..9595face 100644
--- a/app/src/usb/scrcpy_otg.c
+++ b/app/src/usb/scrcpy_otg.c
@@ -58,6 +58,10 @@ scrcpy_otg(struct scrcpy_options *options) {
LOGW("Could not enable linear filtering");
}
+ if (!SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1")) {
+ LOGW("Could not allow joystick background events");
+ }
+
// Minimal SDL initialization
if (SDL_Init(SDL_INIT_EVENTS)) {
LOGE("Could not initialize SDL: %s", SDL_GetError());