| <!DOCTYPE html> |
| <body> |
| <script src="../fast/js/resources/js-test-pre.js"></script> |
| <script> |
| if (window.gamepadController) |
| { |
| // start all disconnected |
| gamepadController.disconnect(0); |
| gamepadController.disconnect(1); |
| gamepadController.disconnect(2); |
| gamepadController.disconnect(3); |
| shouldBe("navigator.webkitGetGamepads().length", "4"); |
| shouldBeUndefined("navigator.webkitGetGamepads()[0]"); |
| shouldBeUndefined("navigator.webkitGetGamepads()[1]"); |
| shouldBeUndefined("navigator.webkitGetGamepads()[2]"); |
| shouldBeUndefined("navigator.webkitGetGamepads()[3]"); |
| |
| // connect and disconnect |
| gamepadController.connect(0); |
| shouldBeNonNull("navigator.webkitGetGamepads()[0]"); |
| gamepadController.disconnect(0); |
| shouldBeUndefined("navigator.webkitGetGamepads()[0]"); |
| |
| // connect again, and check standard access |
| gamepadController.connect(0); |
| gamepadController.setId(0, "MockStick 3000"); |
| gamepadController.setButtonCount(0, 2); |
| gamepadController.setAxisCount(0, 2); |
| gamepadController.setButtonData(0, 0, 1); |
| gamepadController.setButtonData(0, 1, 0); |
| gamepadController.setAxisData(0, 0, .5); |
| gamepadController.setAxisData(0, 1, -1.0); |
| shouldBe("navigator.webkitGetGamepads()[0].id", "'MockStick 3000'"); |
| shouldBe("navigator.webkitGetGamepads()[0].buttons.length", "2"); |
| shouldBe("navigator.webkitGetGamepads()[0].axes.length", "2"); |
| shouldBe("navigator.webkitGetGamepads()[0].buttons[0]", "1.0"); |
| shouldBe("navigator.webkitGetGamepads()[0].buttons[1]", "0.0"); |
| shouldBe("navigator.webkitGetGamepads()[0].axes.length", "2"); |
| shouldBe("navigator.webkitGetGamepads()[0].axes[0]", "0.5"); |
| shouldBe("navigator.webkitGetGamepads()[0].axes[1]", "-1.0"); |
| } |
| else |
| { |
| console.log("FAIL: no gamepadController available.") |
| } |
| </script> |
| <script src="../fast/js/resources/js-test-post.js"></script> |
| <p>Typical polling access to gamepads contents.</p> |
| </body> |