-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
Please include the following in your bug report:
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.62 (34c1aa36052b1882058f22aa1916437ba0872690)
clang version 19.0.0git (https:/github.com/llvm/llvm-project c00ada070207979f092be9046a02fcfff8b9f9ce)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /usr/local/emsdk/upstream/bin
Here is the full source code that reproduces the issue:
#include <stdio.h>
#include <emscripten.h>
#include <emscripten/html5.h>
static bool kShouldClose = false;
void loop()
{
if(kShouldClose)
{
emscripten_cancel_main_loop();
}
}
EM_BOOL callback(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
{
printf("callback: %d : %s\n", keyEvent->keyCode, keyEvent->repeat ? "true" : "false");
return false;
}
int main() {
emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, false, callback);
emscripten_set_main_loop(loop, 0, false);
return 0;
}
Here is how I compile it
> emcc issue.c -o build/index.html
When you run this code, it always display false
when you hold a key. I am attaching the full build (zip file) with a tweaked index.js which adds the following line of code to registerKeyEventCallback
:
console.log(`e.repeat=${e.repeat}`);
The output is the following:
e.repeat=false
(index):144 callback: 65 : false
index.js:2165 e.repeat=true
(index):144 callback: 65 : false
index.js:2165 e.repeat=true
(index):144 callback: 65 : false
index.js:2165 e.repeat=true
...
This shows that the javascript event is correct but the C event is not...
Metadata
Metadata
Assignees
Labels
No labels