Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 25cf0b7

Browse files
authored
Merge pull request #19 from eschaefer/feature/no-gamepad
Remove gamepad support since it broke in Chrome 55
2 parents 18b57bf + fc97aa0 commit 25cf0b7

File tree

4 files changed

+5
-40
lines changed

4 files changed

+5
-40
lines changed

demo/game/character.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { Component, PropTypes } from 'react';
22
import { observer } from 'mobx-react';
3-
import Gamepad from 'html5-gamepad';
43
import Matter from 'matter-js';
54

65
import {
@@ -9,8 +8,6 @@ import {
98
Sprite,
109
} from '../../src';
1110

12-
const gamepad = new Gamepad();
13-
1411
@observer
1512
export default class Character extends Component {
1613

@@ -88,26 +85,26 @@ export default class Character extends Component {
8885

8986
let characterState = 2;
9087

91-
if (keys.isDown(65) || gamepad.button(0, 'b')) {
88+
if (keys.isDown(65)) {
9289
return this.punch();
9390
}
9491

95-
if (keys.isDown(keys.SPACE) || gamepad.button(0, 'a')) {
92+
if (keys.isDown(keys.SPACE)) {
9693
this.jump(body);
9794
}
9895

99-
if (keys.isDown(keys.UP) || gamepad.button(0, 'button 12')) {
96+
if (keys.isDown(keys.UP)) {
10097
return this.enterBuilding(body);
10198
}
10299

103-
if (keys.isDown(keys.LEFT) || gamepad.button(0, 'button 14')) {
100+
if (keys.isDown(keys.LEFT)) {
104101
if (shouldMoveStageLeft) {
105102
store.setStageX(store.stageX + 5);
106103
}
107104

108105
this.move(body, -5);
109106
characterState = 1;
110-
} else if (keys.isDown(keys.RIGHT) || gamepad.button(0, 'button 15')) {
107+
} else if (keys.isDown(keys.RIGHT)) {
111108
if (shouldMoveStageRight) {
112109
store.setStageX(store.stageX - 5);
113110
}
@@ -139,8 +136,6 @@ export default class Character extends Component {
139136
}
140137

141138
if (!this.isJumping && !this.isPunching && !this.isLeaving) {
142-
gamepad.update();
143-
144139
this.checkKeys(shouldMoveStageLeft, shouldMoveStageRight);
145140

146141
store.setCharacterPosition(body.position);

demo/intro.js

-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
import React, { Component, PropTypes } from 'react';
2-
import Gamepad from 'html5-gamepad';
3-
42
import { AudioPlayer } from '../src';
53

6-
const gamepad = new Gamepad();
7-
84
export default class Intro extends Component {
95
static propTypes = {
106
onStart: PropTypes.func,
117
};
128

139
startUpdate = () => {
14-
gamepad.update();
15-
if (gamepad.button(0, 'left stick')) {
16-
this.startNoise.play();
17-
this.props.onStart();
18-
return;
19-
}
2010
this.animationFrame = requestAnimationFrame(this.startUpdate);
2111
}
2212

demo/slides/index.js

-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { Component, PropTypes } from 'react';
2-
import Gamepad from 'html5-gamepad';
32

43
import Basics from './basics';
54
import Loop from './loop';
@@ -10,8 +9,6 @@ import Physics from './physics';
109

1110
const slides = [Basics, Loop, Scaling, Sprites, TileMaps, Physics];
1211

13-
const gamepad = new Gamepad();
14-
1512
export default class Slides extends Component {
1613

1714
static propTypes = {
@@ -32,22 +29,6 @@ export default class Slides extends Component {
3229
};
3330

3431
startUpdate = () => {
35-
gamepad.update();
36-
if (gamepad.button(0, 'y')) {
37-
this.props.onDone();
38-
return;
39-
}
40-
41-
if (gamepad.button(0, 'button 14')) {
42-
this.handlePrev(true);
43-
return;
44-
}
45-
46-
if (gamepad.button(0, 'button 15')) {
47-
this.handleNext(true);
48-
return;
49-
}
50-
5132
this.animationFrame = requestAnimationFrame(this.startUpdate);
5233
};
5334

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"eslint-plugin-import": "^1.14.0",
4343
"eslint-plugin-jsx-a11y": "^2.1.0",
4444
"eslint-plugin-react": "^6.1.2",
45-
"html5-gamepad": "^0.1.4",
4645
"json-loader": "^0.5.4",
4746
"mobx": "^2.5.0",
4847
"mobx-react": "^3.5.5",

0 commit comments

Comments
 (0)