forked from EmulatorJS/EmulatorJS
-
Notifications
You must be signed in to change notification settings - Fork 5
/
plugin.html
114 lines (95 loc) · 2.87 KB
/
plugin.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<html>
<head>
<script>
window.addEventListener('message', (event) => {
if (typeof event.data !== "object") return;
const game = event.data;
if (!game?.data) return;
if (game.data instanceof ArrayBuffer) {
game.data = new Blob([game.data]);
}
if (game.bios instanceof ArrayBuffer) {
game.bios = URL.createObjectURL(new Blob([game.bios]));
}
if (['segaMS', 'segaGG'].includes(game.core)) {
game.core = 'picodrive';
}
if (['gb'].includes(game.core)) {
game.core = 'mgba';
}
window.EJS_player = "#game";
window.EJS_biosUrl = game.bios || undefined;
window.EJS_gameName = game.name;
window.EJS_gameUrl = game.data;
window.EJS_core = game.core;
window.EJS_pathtodata = "data/";
window.EJS_startOnLoaded = true;
window.EJS_backgroundBlur = true;
window.EJS_volume = 1;
window.EJS_defaultOptions = {
'save-state-location': 'browser',
};
// window.EJS_DEBUG_XX = true;
const script = document.createElement("script");
script.src = "data/loader.js";
document.body.appendChild(script);
});
</script>
<style>
body,
html {
height: 100%;
}
body {
font-family: monospace;
font-weight: bold;
font-size: 20px;
margin: 0;
overflow: hidden;
background-color: #333;
}
body {
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
#display {
width: 100%;
height: 100%;
}
#game {
cursor: none;
}
</style>
</head>
<body>
<div id="game">
<div id="display">
</div>
</div>
<script>
// Prevent bubbling of arrow key events
document.onkeydown = function (evt) {
evt = evt || window.event;
const keyCode = evt.keyCode;
if (keyCode >= 37 && keyCode <= 40) {
return false;
}
};
let timer;
document.addEventListener('mousemove', function () {
// clear the existing timer
if (timer) {
clearTimeout(timer);
}
// show the cursor if it was hidden
document.getElementById('game').style.cursor = 'auto';
// start a new timer
timer = setTimeout(function () {
document.getElementById('game').style.cursor = 'none';
}, 2000); // timeout after 2 seconds
});
</script>
</body>
</html>