fix key_up bug in ludus.js
This commit is contained in:
parent
6eb28888ca
commit
2b2875720f
|
@ -85,7 +85,7 @@ function io_poller () {
|
||||||
outbox = []
|
outbox = []
|
||||||
}
|
}
|
||||||
if (ready && running) {
|
if (ready && running) {
|
||||||
if (keys_down.size > 0) bundle_keys()
|
bundle_keys()
|
||||||
worker.postMessage(outbox)
|
worker.postMessage(outbox)
|
||||||
outbox = []
|
outbox = []
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -18,7 +18,7 @@ export function io (out) {
|
||||||
resolve(JSON.stringify(e.data))
|
resolve(JSON.stringify(e.data))
|
||||||
}
|
}
|
||||||
// cancel the response if it takes too long
|
// 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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,14 +86,14 @@ pub async fn do_io (msgs: Vec<MsgOut>) -> Vec<MsgIn> {
|
||||||
let inbox = match inbox {
|
let inbox = match inbox {
|
||||||
Ok(msgs) => msgs,
|
Ok(msgs) => msgs,
|
||||||
Err(errs) => {
|
Err(errs) => {
|
||||||
console_log!("error receiving messages in io; {:?}", errs);
|
// console_log!("error receiving messages in io; {:?}", errs);
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let inbox = inbox.as_string().expect("response should be a string");
|
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");
|
let inbox: Vec<MsgIn> = serde_json::from_str(inbox.as_str()).expect("response from js should be valid");
|
||||||
if !inbox.is_empty() {
|
if !inbox.is_empty() {
|
||||||
console_log!("ludus received messages");
|
// console_log!("ludus received messages");
|
||||||
for msg in inbox.iter() {
|
for msg in inbox.iter() {
|
||||||
console_log!("{}", msg);
|
console_log!("{}", msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -472,6 +472,7 @@ impl World {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_keys(&mut self, keys: Value) {
|
fn register_keys(&mut self, keys: Value) {
|
||||||
|
// console_log!("New keys: {keys}");
|
||||||
let keys_down_rc = self.buffers.keys_down();
|
let keys_down_rc = self.buffers.keys_down();
|
||||||
keys_down_rc.replace(keys);
|
keys_down_rc.replace(keys);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user