Fix gamepads with only one button
This commit is contained in:
parent
f1560bd036
commit
aa76d73583
@ -9,23 +9,23 @@ class Gamepad{
|
|||||||
this.menuBtn = {}
|
this.menuBtn = {}
|
||||||
this.menuBtn[kbd["pause"]] = ["start"]
|
this.menuBtn[kbd["pause"]] = ["start"]
|
||||||
this.b = {
|
this.b = {
|
||||||
"a": "0",
|
"a": 0,
|
||||||
"b": "1",
|
"b": 1,
|
||||||
"x": "2",
|
"x": 2,
|
||||||
"y": "3",
|
"y": 3,
|
||||||
"lb": "4",
|
"lb": 4,
|
||||||
"rb": "5",
|
"rb": 5,
|
||||||
"lt": "6",
|
"lt": 6,
|
||||||
"rt": "7",
|
"rt": 7,
|
||||||
"back": "8",
|
"back": 8,
|
||||||
"start": "9",
|
"start": 9,
|
||||||
"ls": "10",
|
"ls": 10,
|
||||||
"rs": "11",
|
"rs": 11,
|
||||||
"u": "12",
|
"u": 12,
|
||||||
"d": "13",
|
"d": 13,
|
||||||
"l": "14",
|
"l": 14,
|
||||||
"r": "15",
|
"r": 15,
|
||||||
"guide": "16"
|
"guide": 16
|
||||||
}
|
}
|
||||||
this.btn = {}
|
this.btn = {}
|
||||||
this.keyboard = keyboard
|
this.keyboard = keyboard
|
||||||
@ -43,7 +43,7 @@ class Gamepad{
|
|||||||
for(var bind in bindings){
|
for(var bind in bindings){
|
||||||
this.toRelease[bind] = bindings[bind].length
|
this.toRelease[bind] = bindings[bind].length
|
||||||
}
|
}
|
||||||
for(var btnName in gamepads[i].buttons){
|
for(var btnName = 0; btnName <= 16; btnName++){
|
||||||
buttonSearch: {
|
buttonSearch: {
|
||||||
for(var bind in bindings){
|
for(var bind in bindings){
|
||||||
for(var name in bindings[bind]){
|
for(var name in bindings[bind]){
|
||||||
@ -63,9 +63,12 @@ class Gamepad{
|
|||||||
var button = false
|
var button = false
|
||||||
for(var i = 0; i < gamepads.length; i++){
|
for(var i = 0; i < gamepads.length; i++){
|
||||||
if(gamepads[i]){
|
if(gamepads[i]){
|
||||||
var btnPressed = gamepads[i].buttons[btnName].pressed
|
var btn = gamepads[i].buttons[btnName]
|
||||||
if(btnPressed){
|
if(btn){
|
||||||
button = btnPressed
|
var btnPressed = btn.pressed || btn.value >= 0.5
|
||||||
|
if(btnPressed){
|
||||||
|
button = btnPressed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user