Skip to content

Commit de27090

Browse files
committed
Merge pull request phaserjs#958 from renatodarrigo/patch-2
Fix rawpad button array to support win and linux
2 parents a425470 + 1490160 commit de27090

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/input/SinglePad.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,26 @@ Phaser.SinglePad.prototype = {
190190

191191
for (var i = 0; i < this._buttonsLen; i++)
192192
{
193-
if (this._rawPad.buttons[i].value !== this._buttons[i].value)
193+
var rawButtonVal = isNaN(this._rawPad.buttons[i]) ? this._rawPad.buttons[i].value : this._rawPad.buttons[i];
194+
195+
if (rawButtonVal !== this._buttons[i].value)
194196
{
195-
if (this._rawPad.buttons[i].value === 1)
197+
if (rawButtonVal === 1)
196198
{
197-
this.processButtonDown(i, this._rawPad.buttons[i].value);
199+
this.processButtonDown(i, rawButtonVal);
198200
}
199-
else if (this._rawPad.buttons[i].value === 0)
201+
else if (rawButtonVal === 0)
200202
{
201-
this.processButtonUp(i, this._rawPad.buttons[i].value);
203+
this.processButtonUp(i, rawButtonVal);
202204
}
203205
else
204206
{
205-
this.processButtonFloat(i, this._rawPad.buttons[i].value);
207+
this.processButtonFloat(i, rawButtonVal);
206208
}
207209
}
208210
}
209211

210-
/*
212+
211213
for (var j = 0; j < this._axesLen; j++)
212214
{
213215
var axis = this._rawPad.axes[j];
@@ -221,7 +223,6 @@ Phaser.SinglePad.prototype = {
221223
this.processAxisChange( { axis: j, value: 0 } );
222224
}
223225
}
224-
*/
225226

226227
this._prevTimestamp = this._rawPad.timestamp;
227228

0 commit comments

Comments
 (0)