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

Remove gamepad support since it broke in Chrome 55 #19

Merged
merged 1 commit into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions demo/game/character.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { Component, PropTypes } from 'react';
import { observer } from 'mobx-react';
import Gamepad from 'html5-gamepad';
import Matter from 'matter-js';

import {
Expand All @@ -9,8 +8,6 @@ import {
Sprite,
} from '../../src';

const gamepad = new Gamepad();

@observer
export default class Character extends Component {

Expand Down Expand Up @@ -88,26 +85,26 @@ export default class Character extends Component {

let characterState = 2;

if (keys.isDown(65) || gamepad.button(0, 'b')) {
if (keys.isDown(65)) {
return this.punch();
}

if (keys.isDown(keys.SPACE) || gamepad.button(0, 'a')) {
if (keys.isDown(keys.SPACE)) {
this.jump(body);
}

if (keys.isDown(keys.UP) || gamepad.button(0, 'button 12')) {
if (keys.isDown(keys.UP)) {
return this.enterBuilding(body);
}

if (keys.isDown(keys.LEFT) || gamepad.button(0, 'button 14')) {
if (keys.isDown(keys.LEFT)) {
if (shouldMoveStageLeft) {
store.setStageX(store.stageX + 5);
}

this.move(body, -5);
characterState = 1;
} else if (keys.isDown(keys.RIGHT) || gamepad.button(0, 'button 15')) {
} else if (keys.isDown(keys.RIGHT)) {
if (shouldMoveStageRight) {
store.setStageX(store.stageX - 5);
}
Expand Down Expand Up @@ -139,8 +136,6 @@ export default class Character extends Component {
}

if (!this.isJumping && !this.isPunching && !this.isLeaving) {
gamepad.update();

this.checkKeys(shouldMoveStageLeft, shouldMoveStageRight);

store.setCharacterPosition(body.position);
Expand Down
10 changes: 0 additions & 10 deletions demo/intro.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import React, { Component, PropTypes } from 'react';
import Gamepad from 'html5-gamepad';

import { AudioPlayer } from '../src';

const gamepad = new Gamepad();

export default class Intro extends Component {
static propTypes = {
onStart: PropTypes.func,
};

startUpdate = () => {
gamepad.update();
if (gamepad.button(0, 'left stick')) {
this.startNoise.play();
this.props.onStart();
return;
}
this.animationFrame = requestAnimationFrame(this.startUpdate);
}

Expand Down
19 changes: 0 additions & 19 deletions demo/slides/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Component, PropTypes } from 'react';
import Gamepad from 'html5-gamepad';

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

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

const gamepad = new Gamepad();

export default class Slides extends Component {

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

startUpdate = () => {
gamepad.update();
if (gamepad.button(0, 'y')) {
this.props.onDone();
return;
}

if (gamepad.button(0, 'button 14')) {
this.handlePrev(true);
return;
}

if (gamepad.button(0, 'button 15')) {
this.handleNext(true);
return;
}

this.animationFrame = requestAnimationFrame(this.startUpdate);
};

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"eslint-plugin-import": "^1.14.0",
"eslint-plugin-jsx-a11y": "^2.1.0",
"eslint-plugin-react": "^6.1.2",
"html5-gamepad": "^0.1.4",
"json-loader": "^0.5.4",
"mobx": "^2.5.0",
"mobx-react": "^3.5.5",
Expand Down