Files
ladybird/Tests/LibWeb/Text/input/GamepadAPI/gamepad-exposed-after-pressing-triggers.html

28 lines
1007 B
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script src="gamepad-helper.js"></script>
<script>
asyncTest(async (done) => {
const gamepad = internals.connectVirtualGamepad();
await handleSDLInputEvents();
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 handleSDLInputEvents();
println(`After moving trigger axis ${trigger} to ${axisValue} (${axisValueAsInt}): ${getStringifiedGamepads()}`);
}
listenForGamepadDisconnected();
gamepad.disconnect();
await handleSDLInputEvents();
done();
});
</script>