Skip to content

Commit

Permalink
Fix how button helds are handled. Changed dead zone sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
likethemammal committed Jul 22, 2016
1 parent 4b106d9 commit 7c53d99
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 94 deletions.
10 changes: 1 addition & 9 deletions README.md
Expand Up @@ -19,15 +19,7 @@ There you'll find:
+ [How-to](http://daisywheeljs.org/#how-it-works)
+ [Setup](http://daisywheeljs.org/#docs)
+ [Documentation](http://daisywheeljs.org/#docs)
+ [Troubleshooting](http://daisywheeljs.org/#troubleshooting)

### Patreon

#### [https://patreon.com/daisywheeljs](https://www.patreon.com/daisywheeljs) ####

![Support on Patreon!](https://s3.amazonaws.com/patreon_public_assets/toolbox/patreon_logo.png)

This project is funded through [Patreon](https://www.patreon.com), an ongoing crowd-funding site. [Check it out](https://www.patreon.com/daisywheeljs), and consider supporting Daisywheel's development. There you can find out more about the current status of the project through developer posts and community discussion. Pledging allows you to vote on **controller support** and **feature requests**, and gives access to **small-group chat** and **beta testing**.
+ [Troubleshooting](https://github.com/likethemammal/daisywheeljs/wiki)

### Contributing

Expand Down
101 changes: 62 additions & 39 deletions dist/daisywheel.js

Large diffs are not rendered by default.

50 changes: 39 additions & 11 deletions dist/daisywheel.min.js

Large diffs are not rendered by default.

29 changes: 13 additions & 16 deletions src/js/stores/gamepad.js
Expand Up @@ -30,7 +30,7 @@ module.exports = Fluxxor.createStore({
resetState: function() {
this.gamepadConnected = false;
this.stickDirection = false;
this.lastButton = false;
this.otherButtons = {};
this.dPadDirection = false;
this.actionButton = false;
},
Expand All @@ -40,7 +40,7 @@ module.exports = Fluxxor.createStore({
gamepadConnected: this.gamepadConnected,
gamepadSupported: this.gamepadSupported,
stickDirection: this.stickDirection,
lastButton: this.lastButton,
otherButtons: this.otherButtons,
dPadDirection: this.dPadDirection,
actionButton: this.actionButton,
actionButtonMapping: this.actionButtonMapping
Expand Down Expand Up @@ -86,7 +86,8 @@ module.exports = Fluxxor.createStore({

getDirectionFromAxes: function(xAxis, yAxis, ratio) {
var direction = false;
var isNoise = BetweenNums(yAxis, 0, 0.1) && BetweenNums(xAxis, 0, 0.1);
var assumedNoise = 0.24;
var isNoise = BetweenNums(yAxis, 0, assumedNoise) && BetweenNums(xAxis, 0, assumedNoise);
var isStill = xAxis === 0 && yAxis === 0;

if (isNoise || isStill) {
Expand Down Expand Up @@ -129,43 +130,39 @@ module.exports = Fluxxor.createStore({
setButtons: function(buttons) {
this.actionButton = false;
this.dPadDirection = false;
this.lastButton = false;
this.otherButtons = {};
_.map(buttons, function(state, button) {
if (!state) {
return;
}

this.lastButton = {
name: button,
released: state.released,
held: state.held
};

switch (button) {
case 'actionSouth':
case 'actionNorth':
case 'actionEast':
case 'actionWest':
this.setActionButton(button);
this.actionButton = button || false;
return;
break;
case 'dPadUp':
case 'dPadRight':
case 'dPadDown':
case 'dPadLeft':
this.setDPadDirection(button);
return;
break;
}

this.otherButtons[button] = {
released: state.released,
held: state.held
};
}.bind(this));
this.emit('change');
},

setDPadDirection: function(button) {
this.dPadDirection = button || false;
this.emit('change');
},

setActionButton: function(button) {
this.actionButton = button || false;
this.emit('change');
}
});
8 changes: 4 additions & 4 deletions src/js/stores/input.js
Expand Up @@ -111,7 +111,7 @@ module.exports = Fluxxor.createStore({
var selectedSymbol = symbolsState.selectedSymbol;
var defaultSymbolSelection = symbolsState.defaultSymbolSelection;
var dPadDirection = gamepadState.dPadDirection;
var lastButton = gamepadState.lastButton;
var otherButtons = gamepadState.otherButtons;

switch (dPadDirection) {
case 'dPadUp':
Expand All @@ -128,16 +128,16 @@ module.exports = Fluxxor.createStore({
break;
}

if (lastButton) {
switch (lastButton.name) {
_.map(otherButtons, _.bind(function(button, name) {
switch (name) {
case 'leftBumper':
this.onBackspace();
break;
case 'rightBumper':
this.onSpace();
break;
}
}
}, this));


if (selectedSymbol) {
Expand Down
21 changes: 11 additions & 10 deletions src/js/stores/symbols.js
Expand Up @@ -94,42 +94,43 @@ module.exports = Fluxxor.createStore({
this.waitFor(['GamepadStore', 'WheelStore'], _.bind(function(GamepadStore, WheelStore) {
var gamepadState = GamepadStore.getState();
var selectedPetal = WheelStore.getState().selectedPetal;
var lastButton = gamepadState.lastButton;
var otherButtons = gamepadState.otherButtons;
var actionButton = gamepadState.actionButton;
var shouldToggle = this.symbolSets.length < 4;
var actionButtonMapped = gamepadState.actionButtonMapping[actionButton];
var currentSymbolSet = this.symbolSets[this.selectedSetIndex];

if (lastButton) {
switch (lastButton.name) {
_.map(otherButtons, _.bind(function(button, name) {
switch (name) {
case 'leftTrigger':
if (shouldToggle) {
if (lastButton.held) {
if (button.held) {
this.selectedSetIndex = 2;
} else if (lastButton.released) {
} else if (button.released) {
this.selectedSetIndex = 0;
}
} else {
if (lastButton.released) {
if (button.released) {
this.resetSymbols();
}
}
break;
case 'rightTrigger':
if (shouldToggle) {
if (lastButton.held) {
if (button.held) {
this.selectedSetIndex = 1;
} else if (lastButton.released) {
} else if (button.released) {
this.selectedSetIndex = 0;
}
} else {
if (lastButton.released) {
if (button.released) {
this.cycleSymbols();
}
}
break;
}
}
}, this));


if (actionButton && selectedPetal !== 'none') {
var selectedPetalGroupIndex = selectedPetal * 4 - 4;
Expand Down
7 changes: 2 additions & 5 deletions src/js/stores/wheel.js
Expand Up @@ -110,9 +110,10 @@ module.exports = Fluxxor.createStore({
}
}, this));
} else {
this.deselectPetal();
this.selectedPetal = 'none';
}

this.emit('change');
}, this));
},

Expand All @@ -128,8 +129,4 @@ module.exports = Fluxxor.createStore({
this.emit('change');
}, 10),

deselectPetal: function() {
this.selectedPetal = 'none';
this.emit('change');
}
});

0 comments on commit 7c53d99

Please sign in to comment.