Skip to content

Truly independent web browser

980 B
Raw Blame
<!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;

        const trigger = gamepad.triggers[0];

        for (const axisValue of [-1.0, -0.98, -0.96, -0.94, -0.92, -0.9, -0.8033]) {
            const axisValueAsInt = Math.floor(axisValue * shortMax);
            println(`Before moving trigger axis ${trigger} to ${axisValue} (${axisValueAsInt}): ${getStringifiedGamepads()}`);
            gamepad.setAxis(trigger, axisValueAsInt);
            await pumpGamepadEvents();
            println(`After moving trigger axis ${trigger} to ${axisValue} (${axisValueAsInt}): ${getStringifiedGamepads()}`);
        }

        listenForGamepadDisconnected();
        gamepad.disconnect();
        await pumpGamepadEvents();
    });
</script>