mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Handle gamepads more gracefully based in window focus
This commit is contained in:
parent
440675fbee
commit
9c84b8268f
1 changed files with 4 additions and 2 deletions
|
@ -373,14 +373,14 @@ require(['apphost'], function (appHost) {
|
|||
}
|
||||
|
||||
function attachGamepad(e) {
|
||||
if (isGamepadConnected()) {
|
||||
if (isGamepadConnected() && document.hasFocus()) {
|
||||
console.log("Gamepad connected! Starting input loop");
|
||||
startInputLoop();
|
||||
}
|
||||
}
|
||||
|
||||
function dettachGamepad(e) {
|
||||
if (!isGamepadConnected()) {
|
||||
if (!isGamepadConnected() || !document.hasFocus()) {
|
||||
console.log("Gamepad disconnected! No other gamepads are connected, stopping input loop");
|
||||
stopInputLoop();
|
||||
} else {
|
||||
|
@ -391,6 +391,8 @@ require(['apphost'], function (appHost) {
|
|||
// Event Listeners for any change in gamepads' state.
|
||||
window.addEventListener("gamepaddisconnected", dettachGamepad);
|
||||
window.addEventListener("gamepadconnected", attachGamepad);
|
||||
window.addEventListener("blur", dettachGamepad);
|
||||
window.addEventListener("focus", attachGamepad);
|
||||
|
||||
// The gamepadInputEmulation is a string property that exists in JavaScript UWAs and in WebViews in UWAs.
|
||||
// It won't exist in Win8.1 style apps or browsers.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue