sgraham / gamepad.js

Gamepad access in browsers via Gamepad API
http://www.gamepadjs.com/
255 stars 52 forks source link

error in console/log endlessly repeated #5

Open splace opened 12 years ago

splace commented 12 years ago

Unrecognized pad type, not being mapped! gamepad.js:7Mega World USB Game Controllers (Vendor: 07b5 Product: 0312) /gamepad.js/example/:96Uncaught TypeError: Cannot read property 'leftStick' of undefined update/gamepad.js/example/:96 gamepad.js:7

chrome 18 (dev build) on linux 64 (ubuntu 11.04 based distro.)

splace commented 12 years ago

FWIW

i added;

var ChromeGenericController = function(raw, into, index) {
    into.leftStickX = raw.axes[0];
    into.leftStickY = raw.axes[1];
    into.rightStickX = raw.axes[3];
    into.rightStickY = raw.axes[2];
    into.faceButton0 = raw.buttons[0];
    into.faceButton1 = raw.buttons[1];
    into.faceButton2 = raw.buttons[2];
    into.faceButton3 = raw.buttons[3];
    into.leftShoulder0 = raw.buttons[5];
    into.rightShoulder0 = raw.buttons[7];
    into.leftShoulder1 = raw.buttons[4];
    into.rightShoulder1 = raw.buttons[6];
    into.select = raw.buttons[8];
    into.start = raw.buttons[9];
    into.leftStickButton = raw.buttons[10];
    into.rightStickButton = raw.buttons[11];
    into.dpadUp = raw.axes[5] < -0.5 ? 1 : 0;
    into.dpadDown = raw.axes[5] > 0.5 ? 1 : 0;
    into.dpadLeft = raw.axes[4] < -0.5 ? 1 : 0;
    into.dpadRight = raw.axes[4] > 0.5 ? 1 : 0;
   // From http://msdn.microsoft.com/en-us/library/windows/desktop/ee417001(v=vs.85).aspx
    into.deadZoneLeftStick = 7849.0/32767.0;
    into.deadZoneRightStick = 8689/32767.0;
    into.deadZoneShoulder0 = 0.5;
    into.deadZoneShoulder1 = 30.0/255.0;
};

and } else if (isChrome) { active.push([ '07b5', '0312', ChromeGenericController, "Generic Controller(PS2 like)", Gamepad_ImageDataUrls_Xbox360 ]); }

and it now works.