Enable joystick events in background
Capture the gamepads even when the window is not focused. Note: In theory, with this flag set, we could capture gamepad events even without a window (--no-window). In practice, scrcpy still requires a window, because --no-window implies --no-control, and the input manager is owned by the sc_screen instance, which does not exist if there is no window. Supporting this use case would require a lot of refactors. Refs <https://github.com/Genymobile/scrcpy/pull/5270#issuecomment-2339360460> PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270> Suggested-by: Luiz Henrique Laurini <luizhenriquelaurini@gmail.com>
This commit is contained in:
parent
0ba430a462
commit
f01a622ead
@ -136,6 +136,10 @@ sdl_set_hints(const char *render_driver) {
|
|||||||
if (!SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0")) {
|
if (!SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0")) {
|
||||||
LOGW("Could not disable minimize on focus loss");
|
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
|
static void
|
||||||
|
@ -58,6 +58,10 @@ scrcpy_otg(struct scrcpy_options *options) {
|
|||||||
LOGW("Could not enable linear filtering");
|
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
|
// Minimal SDL initialization
|
||||||
if (SDL_Init(SDL_INIT_EVENTS)) {
|
if (SDL_Init(SDL_INIT_EVENTS)) {
|
||||||
LOGE("Could not initialize SDL: %s", SDL_GetError());
|
LOGE("Could not initialize SDL: %s", SDL_GetError());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user