Skip to content

Commit

Permalink
Ignore axes which return data out of the range [-1; 1] in centered po…
Browse files Browse the repository at this point in the history
…sition

For task: Integrate Bluetooth Joystick to mobile VR set #86
  • Loading branch information
MaxZhaloba committed Mar 27, 2019
1 parent ae036b1 commit c450f9e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions leobot_web_server/web_content/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ $(function(){
if (a >= -1 && a <= 1) {
axis = a;
}
initialGamepadAxes.push(a);
initialGamepadAxes.push(axis);
});

console.log("Initial gamepad axes values:", initialGamepadAxes);
break;

case TABS.check:
Expand Down Expand Up @@ -256,10 +258,12 @@ $(function(){
if (!configEntry) return;

gamepad.axes.forEach(function(a, i) {
var pitch = a - initialGamepadAxes[i];
// Can be null
var axis = initialGamepadAxes[i];
var pitch = a - axis;
var absPitch = Math.abs(pitch);

if (absPitch > pitchThreshold && i!==9) {
if (axis !== null && absPitch > pitchThreshold) {
if (!configEntry.releasedValue) {
configEntry.releasedValue = configEntry.pitchedValue = initialGamepadAxes[i];
}
Expand Down

0 comments on commit c450f9e

Please sign in to comment.