standard-mapper/gamepad.js
function (gamepadId) {
    var gamepad = gamepadSupport.gamepads[gamepadId];

    // Update all the buttons (and their corresponding labels) on screen.
    window.tester.updateButton(gamepad.buttons[0], gamepadId, 'button-1');
    window.tester.updateButton(gamepad.buttons[1], gamepadId, 'button-2');
    window.tester.updateButton(gamepad.buttons[2], gamepadId, 'button-3');
    window.tester.updateButton(gamepad.buttons[3], gamepadId, 'button-4');

    window.tester.updateButton(gamepad.buttons[4], gamepadId,
        'button-left-shoulder-top');
    window.tester.updateButton(gamepad.buttons[6], gamepadId,
        'button-left-shoulder-bottom');
    window.tester.updateButton(gamepad.buttons[5], gamepadId,
        'button-right-shoulder-top');
    window.tester.updateButton(gamepad.buttons[7], gamepadId,
        'button-right-shoulder-bottom');

    window.tester.updateButton(gamepad.buttons[8], gamepadId, 'button-select');
    window.tester.updateButton(gamepad.buttons[9], gamepadId, 'button-start');

    window.tester.updateButton(gamepad.buttons[10], gamepadId, 'stick-1');
    window.tester.updateButton(gamepad.buttons[11], gamepadId, 'stick-2');

    window.tester.updateButton(gamepad.buttons[12], gamepadId, 'button-dpad-top');
    window.tester.updateButton(gamepad.buttons[13], gamepadId, 'button-dpad-bottom');
    window.tester.updateButton(gamepad.buttons[14], gamepadId, 'button-dpad-left');
    window.tester.updateButton(gamepad.buttons[15], gamepadId, 'button-dpad-right');

    // Update all the analogue sticks.
    window.tester.updateAxis(gamepad.axes[0], gamepadId,
        'stick-1-axis-x', 'stick-1', true);
    window.tester.updateAxis(gamepad.axes[1], gamepadId,
        'stick-1-axis-y', 'stick-1', false);
    window.tester.updateAxis(gamepad.axes[2], gamepadId,
        'stick-2-axis-x', 'stick-2', true);
    window.tester.updateAxis(gamepad.axes[3], gamepadId,
        'stick-2-axis-y', 'stick-2', false);

    // Update extraneous buttons.
    var extraButtonId = gamepadSupport.TYPICAL_BUTTON_COUNT;
    while (typeof gamepad.buttons[extraButtonId] !== 'undefined') {
      window.tester.updateButton(gamepad.buttons[extraButtonId], gamepadId,
          'extra-button-' + extraButtonId);

      extraButtonId++;
    }

    // Update extraneous axes.
    var extraAxisId = gamepadSupport.TYPICAL_AXIS_COUNT;
    while (typeof gamepad.axes[extraAxisId] !== 'undefined') {
      window.tester.updateAxis(gamepad.axes[extraAxisId], gamepadId,
          'extra-axis-' + extraAxisId);

      extraAxisId++;
    }

  }
function (gamepadId) {
    var gamepad = gamepadSupport.gamepads[gamepadId];

    // Update all the buttons (and their corresponding labels) on screen.
    window.tester.updateButton(gamepad.buttons[0], gamepadId, 'button-1');
    window.tester.updateButton(gamepad.buttons[1], gamepadId, 'button-2');
    window.tester.updateButton(gamepad.buttons[2], gamepadId, 'button-3');
    window.tester.updateButton(gamepad.buttons[3], gamepadId, 'button-4');

    window.tester.updateButton(gamepad.buttons[4], gamepadId,
        'button-left-shoulder-top');
    window.tester.updateButton(gamepad.buttons[6], gamepadId,
        'button-left-shoulder-bottom');
    window.tester.updateButton(gamepad.buttons[5], gamepadId,
        'button-right-shoulder-top');
    window.tester.updateButton(gamepad.buttons[7], gamepadId,
        'button-right-shoulder-bottom');

    window.tester.updateButton(gamepad.buttons[8], gamepadId, 'button-select');
    window.tester.updateButton(gamepad.buttons[9], gamepadId, 'button-start');

    window.tester.updateButton(gamepad.buttons[10], gamepadId, 'stick-1');
    window.tester.updateButton(gamepad.buttons[11], gamepadId, 'stick-2');

    window.tester.updateButton(gamepad.buttons[12], gamepadId, 'button-dpad-top');
    window.tester.updateButton(gamepad.buttons[13], gamepadId, 'button-dpad-bottom');
    window.tester.updateButton(gamepad.buttons[14], gamepadId, 'button-dpad-left');
    window.tester.updateButton(gamepad.buttons[15], gamepadId, 'button-dpad-right');

    // Update all the analogue sticks.
    window.tester.updateAxis(gamepad.axes[0], gamepadId,
        'stick-1-axis-x', 'stick-1', true);
    window.tester.updateAxis(gamepad.axes[1], gamepadId,
        'stick-1-axis-y', 'stick-1', false);
    window.tester.updateAxis(gamepad.axes[2], gamepadId,
        'stick-2-axis-x', 'stick-2', true);
    window.tester.updateAxis(gamepad.axes[3], gamepadId,
        'stick-2-axis-y', 'stick-2', false);

    // Update extraneous buttons.
    var extraButtonId = gamepadSupport.TYPICAL_BUTTON_COUNT;
    while (typeof gamepad.buttons[extraButtonId] !== 'undefined') {
      window.tester.updateButton(gamepad.buttons[extraButtonId], gamepadId,
          'extra-button-' + extraButtonId);

      extraButtonId++;
    }

    // Update extraneous axes.
    var extraAxisId = gamepadSupport.TYPICAL_AXIS_COUNT;
    while (typeof gamepad.axes[extraAxisId] !== 'undefined') {
      window.tester.updateAxis(gamepad.axes[extraAxisId], gamepadId,
          'extra-axis-' + extraAxisId);

      extraAxisId++;
    }

  }
function ( gamepadId ) { var gamepad = gamepadSupport . gamepads [ gamepadId ] ; // Update all the buttons (and their corresponding labels) on screen. window . tester . updateButton ( gamepad . buttons [ 0 ] , gamepadId , 'button-1' ) ; window . tester . updateButton ( gamepad . buttons [ 1 ] , gamepadId , 'button-2' ) ; window . tester . updateButton ( gamepad . buttons [ 2 ] , gamepadId , 'button-3' ) ; window . tester . updateButton ( gamepad . buttons [ 3 ] , gamepadId , 'button-4' ) ; window . tester . updateButton ( gamepad . buttons [ 4 ] , gamepadId , 'button-left-shoulder-top' ) ; window . tester . updateButton ( gamepad . buttons [ 6 ] , gamepadId , 'button-left-shoulder-bottom' ) ; window . tester . updateButton ( gamepad . buttons [ 5 ] , gamepadId , 'button-right-shoulder-top' ) ; window . tester . updateButton ( gamepad . buttons [ 7 ] , gamepadId , 'button-right-shoulder-bottom' ) ; window . tester . updateButton ( gamepad . buttons [ 8 ] , gamepadId , 'button-select' ) ; window . tester . updateButton ( gamepad . buttons [ 9 ] , gamepadId , 'button-start' ) ; window . tester . updateButton ( gamepad . buttons [ 10 ] , gamepadId , 'stick-1' ) ; window . tester . updateButton ( gamepad . buttons [ 11 ] , gamepadId , 'stick-2' ) ; window . tester . updateButton ( gamepad . buttons [ 12 ] , gamepadId , 'button-dpad-top' ) ; window . tester . updateButton ( gamepad . buttons [ 13 ] , gamepadId , 'button-dpad-bottom' ) ; window . tester . updateButton ( gamepad . buttons [ 14 ] , gamepadId , 'button-dpad-left' ) ; window . tester . updateButton ( gamepad . buttons [ 15 ] , gamepadId , 'button-dpad-right' ) ; // Update all the analogue sticks. window . tester . updateAxis ( gamepad . axes [ 0 ] , gamepadId , 'stick-1-axis-x' , 'stick-1' , true ) ; window . tester . updateAxis ( gamepad . axes [ 1 ] , gamepadId , 'stick-1-axis-y' , 'stick-1' , false ) ; window . tester . updateAxis ( gamepad . axes [ 2 ] , gamepadId , 'stick-2-axis-x' , 'stick-2' , true ) ; window . tester . updateAxis ( gamepad . axes [ 3 ] , gamepadId , 'stick-2-axis-y' , 'stick-2' , false ) ; // Update extraneous buttons. var extraButtonId = gamepadSupport . TYPICAL_BUTTON_COUNT ; while ( typeof gamepad . buttons [ extraButtonId ] !== 'undefined' ) { window . tester . updateButton ( gamepad . buttons [ extraButtonId ] , gamepadId , 'extra-button-' + extraButtonId ) ; extraButtonId ++ ; } // Update extraneous axes. var extraAxisId = gamepadSupport . TYPICAL_AXIS_COUNT ; while ( typeof gamepad . axes [ extraAxisId ] !== 'undefined' ) { window . tester . updateAxis ( gamepad . axes [ extraAxisId ] , gamepadId , 'extra-axis-' + extraAxisId ) ; extraAxisId ++ ; } }
Call the tester with new state and ask it to update the visual representation of a given gamepad.
Call the tester with new state and ask it to update the visual representation of a given gamepad .