1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Moved gamepad to input and serverNotofications cleanup

This commit is contained in:
ferferga 2020-02-05 14:13:28 +01:00
parent c60dbbb3ae
commit ab0a9ef065
4 changed files with 120 additions and 107 deletions

View file

@ -191,36 +191,14 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
events.trigger(serverNotifications, msg.MessageType, [apiClient, msg.Data]);
}
}
function bindEvents(apiClient) {
events.off(apiClient, "message", onMessageReceived);
events.on(apiClient, "message", onMessageReceived);
}
function attachgamepad(e) {
if (navigator.getGamepads.length > 0) {
require(["components/serverNotifications/gamepadtokey"]);
console.log("Gamepad connected! Attaching gamepadtokey.js script");
}
}
function dettachgamepad(e) {
delete require.cache[require(["components/serverNotifications/gamepadtokey"])];
console.log("Gamepad disconnected! Dettaching gamepadtokey.js");
}
connectionManager.getApiClients().forEach(bindEvents);
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {
bindEvents(newApiClient);
});
if (navigator.getGamepads()[0] != null) {
require(["components/serverNotifications/gamepadtokey"]);
console.log("Gamepad connected! Attaching gamepadtokey.js script");
window.addEventListener("gamepaddisconnected", dettachgamepad);
} else {
window.addEventListener("gamepadconnected", attachgamepad);
console.log("No gamepad connected to this device");
}
// require(["components/serverNotifications/mouseManager"]);
return serverNotifications;
});