Skip to content

Commit

Permalink
fixed speed button bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ardean committed Feb 7, 2017
1 parent 7909117 commit 52986df
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
8 changes: 5 additions & 3 deletions demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fullscreen.on("change", () => {

gamepad.on("buttonPressed", function ({ buttonIndex, button, gamepad }) {
const action = currentControllerProfile.getAction(buttonIndex);
gameboyHandlePressAction(action);
gameboyHandlePressAction(action, button);
});

gamepad.on("buttonChanged", function ({ buttonIndex, button, gamepad }) {
Expand Down Expand Up @@ -176,13 +176,15 @@ function getSpeedValue(button) {
return (button.value * 2) + 1;
}

function gameboyHandlePressAction(action) {
function gameboyHandlePressAction(action, button) {
if (action === "save") {
saveAndNotifyState();
} else if (action === "load") {
openAndNotifyState();
} else if (action === "speed") {
gameboy.setSpeed(getSpeedValue(button));
if (button) {
gameboy.setSpeed(getSpeedValue(button));
}
} else if (action === "fullscreen") {
toggleFullscreen();
} else {
Expand Down
8 changes: 5 additions & 3 deletions docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12410,13 +12410,15 @@ $__System.register('a', ['10', '11', 'b'], function (_export, _context) {
return button.value * 2 + 1;
}

function gameboyHandlePressAction(action) {
function gameboyHandlePressAction(action, button) {
if (action === "save") {
saveAndNotifyState();
} else if (action === "load") {
openAndNotifyState();
} else if (action === "speed") {
gameboy.setSpeed(getSpeedValue(button));
if (button) {
gameboy.setSpeed(getSpeedValue(button));
}
} else if (action === "fullscreen") {
toggleFullscreen();
} else {
Expand Down Expand Up @@ -22719,7 +22721,7 @@ $__System.register('a', ['10', '11', 'b'], function (_export, _context) {
gamepad$$1 = _ref.gamepad;

var action = currentControllerProfile.getAction(buttonIndex);
gameboyHandlePressAction(action);
gameboyHandlePressAction(action, button);
});

gamepad.on("buttonChanged", function (_ref2) {
Expand Down
2 changes: 1 addition & 1 deletion docs/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsgbc",
"version": "0.2.4",
"version": "0.2.5",
"description": "A GameBoy Color Emulator written in JavaScript",
"main": "./dist/jsgbc.min.js",
"repository": "https://github.com/ardean/jsGBC",
Expand Down

0 comments on commit 52986df

Please sign in to comment.