Add gamepad events

This commit is contained in:
gingerBill
2024-09-22 16:24:46 +01:00
parent 94288161e9
commit 66e83ef30d
2 changed files with 47 additions and 4 deletions
+17 -2
View File
@@ -1533,8 +1533,8 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory, ev
wmi.storeU8(off(1), !!e.repeat);
wmi.storeI32(off(W), e.key.length)
wmi.storeI32(off(W), e.code.length)
wmi.storeInt(off(W), e.key.length)
wmi.storeInt(off(W), e.code.length)
wmi.storeString(off(16, 1), e.key);
wmi.storeString(off(16, 1), e.code);
} else if (e.type === 'scroll') {
@@ -1542,6 +1542,21 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory, ev
wmi.storeF64(off(8), window.scrollY);
} else if (e.type === 'visibilitychange') {
wmi.storeU8(off(1), !document.hidden);
} else if (e instanceof GamepadEvent) {
const idPtr = off(W*2, W);
const mappingPtr = off(W*2, W);
wmi.storeI32(off(W), e.gamepad.index);
wmi.storeU8(off(1), !!e.gamepad.connected);
wmi.storeF64(off(8), e.gamepad.timestamp);
wmi.storeInt(off(W), e.gamepad.buttons.length);
wmi.storeInt(off(W), e.gamepad.axes.length);
wmi.storeInt(off(W), e.gamepad.id.length)
wmi.storeInt(off(W), e.gamepad.mapping.length)
wmi.storeString(off(64, 1), e.gamepad.id);
wmi.storeString(off(64, 1), e.gamepad.mapping);
}
},