fix key_up bug in ludus.js

This commit is contained in:
Scott Richmond 2025-07-06 18:43:35 -04:00
parent fc81f1149d
commit dc16420545
5 changed files with 6 additions and 5 deletions

View File

@ -85,7 +85,7 @@ function io_poller () {
outbox = []
}
if (ready && running) {
if (keys_down.size > 0) bundle_keys()
bundle_keys()
worker.postMessage(outbox)
outbox = []
}

BIN
pkg/rudus_bg.wasm (Stored with Git LFS)

Binary file not shown.

View File

@ -18,7 +18,7 @@ export function io (out) {
resolve(JSON.stringify(e.data))
}
// cancel the response if it takes too long
setTimeout(() => reject("io took too long"), 1000)
setTimeout(() => reject(`io took too long to respond to ${out}`), 1000)
})
}

View File

@ -86,14 +86,14 @@ pub async fn do_io (msgs: Vec<MsgOut>) -> Vec<MsgIn> {
let inbox = match inbox {
Ok(msgs) => msgs,
Err(errs) => {
console_log!("error receiving messages in io; {:?}", errs);
// console_log!("error receiving messages in io; {:?}", errs);
return vec![];
}
};
let inbox = inbox.as_string().expect("response should be a string");
let inbox: Vec<MsgIn> = serde_json::from_str(inbox.as_str()).expect("response from js should be valid");
if !inbox.is_empty() {
console_log!("ludus received messages");
// console_log!("ludus received messages");
for msg in inbox.iter() {
console_log!("{}", msg);
}

View File

@ -472,6 +472,7 @@ impl World {
}
fn register_keys(&mut self, keys: Value) {
// console_log!("New keys: {keys}");
let keys_down_rc = self.buffers.keys_down();
keys_down_rc.replace(keys);
}