mirror of
https://github.com/jiojciojsioe3/a3cjroijsiojiorj.git
synced 2024-11-15 07:21:50 +08:00
Merge pull request #93 from LoveEevee/gamepad-disable-with-keyboard-input
Gamepad: Disable with keyboard input
This commit is contained in:
commit
790f77bd6d
@ -32,6 +32,9 @@ class Gamepad{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
play(callback){
|
play(callback){
|
||||||
|
if(pageEvents.lastKeyEvent + 5000 > Date.now()){
|
||||||
|
return
|
||||||
|
}
|
||||||
if("getGamepads" in navigator){
|
if("getGamepads" in navigator){
|
||||||
var gamepads = navigator.getGamepads()
|
var gamepads = navigator.getGamepads()
|
||||||
}else{
|
}else{
|
||||||
|
@ -3,6 +3,7 @@ class PageEvents{
|
|||||||
this.allEvents = new Map()
|
this.allEvents = new Map()
|
||||||
this.keyListeners = new Map()
|
this.keyListeners = new Map()
|
||||||
this.mouseListeners = new Map()
|
this.mouseListeners = new Map()
|
||||||
|
this.lastKeyEvent = -Infinity
|
||||||
this.add(window, "keydown", this.keyEvent.bind(this))
|
this.add(window, "keydown", this.keyEvent.bind(this))
|
||||||
this.add(window, "keyup", this.keyEvent.bind(this))
|
this.add(window, "keyup", this.keyEvent.bind(this))
|
||||||
this.add(window, "mousemove", this.mouseEvent.bind(this))
|
this.add(window, "mousemove", this.mouseEvent.bind(this))
|
||||||
@ -80,6 +81,7 @@ class PageEvents{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
keyEvent(event){
|
keyEvent(event){
|
||||||
|
this.lastKeyEvent = Date.now()
|
||||||
this.keyListeners.forEach(addedKeyCode => {
|
this.keyListeners.forEach(addedKeyCode => {
|
||||||
this.checkListener(addedKeyCode.get("all"), event)
|
this.checkListener(addedKeyCode.get("all"), event)
|
||||||
this.checkListener(addedKeyCode.get(event.keyCode), event)
|
this.checkListener(addedKeyCode.get(event.keyCode), event)
|
||||||
|
@ -714,6 +714,9 @@ class Scoresheet{
|
|||||||
this.redrawRunning = false
|
this.redrawRunning = false
|
||||||
pageEvents.keyRemove(this, "all")
|
pageEvents.keyRemove(this, "all")
|
||||||
pageEvents.remove(this.canvas, ["mousedown", "touchstart"])
|
pageEvents.remove(this.canvas, ["mousedown", "touchstart"])
|
||||||
|
if(p2.session){
|
||||||
|
pageEvents.remove(p2, "message")
|
||||||
|
}
|
||||||
delete this.ctx
|
delete this.ctx
|
||||||
delete this.canvas
|
delete this.canvas
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ class Session{
|
|||||||
this.gamepad.clean()
|
this.gamepad.clean()
|
||||||
pageEvents.remove(window, ["mousedown", "touchstart"])
|
pageEvents.remove(window, ["mousedown", "touchstart"])
|
||||||
pageEvents.keyRemove(this, 27)
|
pageEvents.keyRemove(this, 27)
|
||||||
|
pageEvents.remove(p2, "message")
|
||||||
delete this.endButton
|
delete this.endButton
|
||||||
delete this.sessionInvite
|
delete this.sessionInvite
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user