Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<script src="gamepad-helper.js"></script>
<script>
promiseTest(async () => {
const gamepad = internals.connectVirtualGamepad();
await pumpGamepadEvents();
listenForGamepadConnected();
const shortMax = 32628;
for (const axis of gamepad.axes.concat(gamepad.triggers)) {
for (const axisValue of [1.0, 0.8, 0.4, -0.4, 0.8, 1.0]) {
const axisValueAsInt = axisValue * shortMax;
const axisValueRounded = axisValue > 0 ? Math.floor(axisValueAsInt) : Math.ceil(axisValueAsInt);
println(`Before moving axis ${axis} to ${axisValue} (${axisValueRounded}): ${getStringifiedGamepads()}`);
gamepad.setAxis(axis, axisValueRounded);
await pumpGamepadEvents();
println(`After moving axis ${axis} to ${axisValue} (${axisValueRounded}): ${getStringifiedGamepads()}`);
}
}
listenForGamepadDisconnected();
gamepad.disconnect();
await pumpGamepadEvents();
});
</script>