-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream.html
33 lines (31 loc) · 997 Bytes
/
stream.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html>
<head>
<title>Example streaming gamepad</title>
<script src="gamepad_stream.js"></script>
</head>
<body>
<p>This is an example of a simple HTML page streaming the gamepad.</p>
<div id="code">
</div>
</body>
<script>
function getContent(){
if (gamepad_stream == undefined)
return "GamepadStream not initialized.";
return gamepad_stream.getStatus();
}
var gamepad_stream;
window.addEventListener('gamepadconnected', function (e) {
console.log(e);
gamepad_stream = new GamepadStream('ws://localhost:58000/ws', e.gamepad.index);
gamepad_stream.start();
})
function init(){
setInterval(function() {
document.getElementById("code").innerHTML = "GamepadStream status: " + getContent()
}, 500);
}
window.onload = init;
</script>
</html>