From 91646cbafee3ff67baff52499529ac9077675239 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Tue, 7 Jan 2025 00:16:22 +0100 Subject: Fix clipboard; TODO keys --- index.htm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'index.htm') diff --git a/index.htm b/index.htm index 7f82840..33d6c2d 100644 --- a/index.htm +++ b/index.htm @@ -34,9 +34,12 @@ }, env : { p_clipboard_write : (size, text) => { + let text_buffer = new ArrayBuffer(size); + new Uint8Array(text_buffer).set(new Uint8Array(this.memory_buffer, text, size)); + this.port.postMessage({ - id : "clipboard", - text : new TextDecoder("utf8").decode(new Uint8Array(this.memory_buffer, text, size)), // FIXME + id : "clipboard", + text_buffer : text_buffer, }); }, p_time_impl : Date.now, @@ -370,7 +373,7 @@ }, clipboard : (ev) => { - navigator.clipboard.writeText(ev.text); + navigator.clipboard.writeText(new TextDecoder("utf8").decode(new Uint8Array(ev.text_buffer))); }, frame : (ev) => { @@ -424,7 +427,7 @@ }); }); - canvas.addEventListener("keydown", (ev) => { + window.addEventListener("keydown", (ev) => { ev.preventDefault(); if (!sound_ready) return; @@ -435,6 +438,8 @@ if (key == 0) return; + console.log(ev); + sound_node.port.postMessage({ id : "keydown", mod : mod, @@ -442,7 +447,7 @@ }); }); - canvas.addEventListener("keyup", (ev) => { + window.addEventListener("keyup", (ev) => { ev.preventDefault(); if (!sound_ready) return; -- cgit v1.2.3