Skip to content

Commit

Permalink
Update demo for two controllers.
Browse files Browse the repository at this point in the history
  • Loading branch information
vaneenige committed Jul 24, 2018
1 parent 8c1cf91 commit 275fca7
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions demo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,35 @@ function logButton(control, state) {
ul.innerHTML = `<li>${control} was ${state ? 'pressed' : 'released'}</li> ${ul.innerHTML}`;
}

function LogAxes(position) {
ul.innerHTML = `<li>Axes position ${position}</li> ${ul.innerHTML}`;
function LogAxes(controller, position) {
ul.innerHTML = `<li>${controller} ~ Axes position ${position}</li> ${ul.innerHTML}`;
}

const controller = new Controller({
b: pressed => logButton('B', pressed),
a: pressed => logButton('A', pressed),
y: pressed => logButton('Y', pressed),
x: pressed => logButton('X', pressed),
l: pressed => logButton('L', pressed),
r: pressed => logButton('R', pressed),
axes: position => LogAxes(position),
const controllerLeft = new Controller({
side: 'L',
b: pressed => logButton('1 ~ B', pressed),
a: pressed => logButton('1 ~ A', pressed),
y: pressed => logButton('1 ~ Y', pressed),
x: pressed => logButton('1 ~ X', pressed),
l: pressed => logButton('1 ~ L', pressed),
r: pressed => logButton('1 ~ R', pressed),
axes: position => LogAxes('1', position),
});

const controllerRight = new Controller({
side: 'R',
b: pressed => logButton('2 ~ B', pressed),
a: pressed => logButton('2 ~ A', pressed),
y: pressed => logButton('2 ~ Y', pressed),
x: pressed => logButton('2 ~ X', pressed),
l: pressed => logButton('2 ~ L', pressed),
r: pressed => logButton('2 ~ R', pressed),
axes: position => LogAxes('2', position),
});

function render() {
controller.update();
controllerLeft.update();
controllerRight.update();
requestAnimationFrame(render);
}

Expand Down

0 comments on commit 275fca7

Please sign in to comment.