-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e32ac1a
commit 864f154
Showing
5 changed files
with
180 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
"vite": "^5.3.1" | ||
}, | ||
"dependencies": { | ||
"nipplejs": "^0.10.2", | ||
"sanitize.css": "^13.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
import nipplejs from "nipplejs"; | ||
import "sanitize.css"; | ||
import "./style.css"; | ||
|
||
document.querySelector("#app").innerHTML = ` | ||
<div> | ||
<h1>Virtual Gamepad</h1> | ||
</div> | ||
`; | ||
let host = "http://localhost"; | ||
let interval = 200; | ||
let showButtons = true; | ||
|
||
document.querySelector("#settings-host").oninput = (event) => { | ||
console.log(`Modify host ${host} -> ${event.target.value}`); | ||
host = event.target.value; | ||
}; | ||
|
||
document.querySelector("#settings-interval").oninput = (event) => { | ||
console.log(`Modify interval ${interval} -> ${event.target.value}`); | ||
interval = event.target.value; | ||
}; | ||
|
||
document.querySelector("#settings-buttons").oninput = (event) => { | ||
console.log(`Modify showButtons ${showButtons} -> ${event.target.checked}`); | ||
showButtons = event.target.checked; | ||
if (showButtons) | ||
document.querySelector("#buttons-zone").classList.remove("erase"); | ||
else document.querySelector("#buttons-zone").classList.add("erase"); | ||
}; | ||
|
||
const joystickManager = nipplejs.create({ | ||
zone: document.querySelector("#joystick-zone"), | ||
color: "#55CCFF", | ||
size: 160, | ||
mode: "dynamic", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
:root { | ||
width: 0; | ||
color: #ffffffcc; | ||
} | ||
|
||
.erase { | ||
position: absolute; | ||
display: none; | ||
width: 0; | ||
height: 0; | ||
margin: 0; | ||
padding: 0; | ||
visibility: hidden; | ||
opacity: 0; | ||
} | ||
|
||
main { | ||
position: absolute; | ||
display: flex; | ||
top: 0; | ||
left: 0; | ||
height: 100dvh; | ||
width: 100dvw; | ||
z-index: -1; | ||
background-color: navy; | ||
} | ||
|
||
#joystick-zone { | ||
flex: 8; | ||
height: 100%; | ||
background-color: #ffaaaa33; | ||
} | ||
|
||
#buttons-zone { | ||
display: flex; | ||
flex: 5; | ||
height: 100%; | ||
flex-direction: column; | ||
} | ||
|
||
#buttons-zone > button { | ||
display: block; | ||
flex: 1; | ||
width: 100%; | ||
font-size: 25dvmin; | ||
opacity: 0.5; | ||
} | ||
|
||
#buttons-zone > button:hover { | ||
opacity: 0.75; | ||
} | ||
|
||
article { | ||
margin: 0.5em; | ||
padding: 0.5em; | ||
max-height: 50dvh; | ||
width: 50dvw; | ||
overflow: scroll; | ||
font-size: max(0.75rem, 2dvmin); | ||
background-color: #55555555; | ||
} | ||
|
||
article * { | ||
margin: 0; | ||
} | ||
|
||
article h1 { | ||
margin: 0.2em 0.1em; | ||
} | ||
|
||
article h2 { | ||
margin: 0.1em 0; | ||
} | ||
|
||
article input[type="checkbox"] { | ||
height: 1.5em; | ||
width: 1.5em; | ||
} | ||
|
||
article code { | ||
padding: 0.25em; | ||
background: #333355; | ||
} |