Skip to content

Commit

Permalink
update readme with examples of button names and gamepad icon update
Browse files Browse the repository at this point in the history
  • Loading branch information
lunarcloud committed Oct 15, 2023
1 parent c000efd commit 73dfbf2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Game-Input (JavaScript) Library
=============
![](demo/img/generic.png)

A client-side JavaScript module one can import to add good gamepad support to web-powered games or other gamepad-powered web applications.

Expand All @@ -10,6 +11,13 @@ const gameInput = new GameInput()
// Events style
.onReinitialize(() => {
console.debug("Players updated")
const firstPlayer = this.gameInput.getPlayer(0)
if (!firstPlayer?.model) {
noPlayers()
return
}
displayButtons(firstPlayer?.type.buttonNames)
document.querySelector('img.gamepad').src = `img/${firstPlayer?.model?.iconName || 'generic'}.png`
})
.onButtonDown((index, button) => {
const player = this.gameInput.getPlayer(index)
Expand Down

0 comments on commit 73dfbf2

Please sign in to comment.