Browse Source

Merge f7fe8b88cb into eb7f8912f8

pull/4956/merge
Moros Smith 19 hours ago
committed by GitHub
parent
commit
5c1ab27a9d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 3 deletions
  1. +14
    -3
      src/platforms/rcore_web.c

+ 14
- 3
src/platforms/rcore_web.c View File

@ -137,6 +137,7 @@ static EM_BOOL EmscriptenFocusCallback(int eventType, const EmscriptenFocusEvent
static EM_BOOL EmscriptenVisibilityChangeCallback(int eventType, const EmscriptenVisibilityChangeEvent *visibilityChangeEvent, void *userData);
// Emscripten input callback events
static EM_BOOL EmscriptenKeyboardCallback(int eventType, const EmscriptenKeyboardEvent *keyboardEvent, void *userData);
static EM_BOOL EmscriptenMouseMoveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);
static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);
static EM_BOOL EmscriptenPointerlockCallback(int eventType, const EmscriptenPointerlockChangeEvent *pointerlockChangeEvent, void *userData);
@ -1362,9 +1363,11 @@ int InitPlatform(void)
// Trigger this once to get initial window sizing
EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL);
// Support keyboard events -> Not used, GLFW.JS takes care of that
// emscripten_set_keypress_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback);
// emscripten_set_keydown_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback);
// Support keyboard events
// NOTE: used only to consume keyboard events. GLFW.JS takes care of
// the actual input.
emscripten_set_keypress_callback(GetCanvasId(), NULL, 1, EmscriptenKeyboardCallback);
emscripten_set_keydown_callback(GetCanvasId(), NULL, 1, EmscriptenKeyboardCallback);
// Support mouse events
emscripten_set_click_callback(GetCanvasId(), NULL, 1, EmscriptenMouseCallback);
@ -1620,6 +1623,14 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y)
#endif
}
static EM_BOOL EmscriptenKeyboardCallback(int eventType, const EmscriptenKeyboardEvent *keyboardEvent, void *userData)
{
// NOTE: handled by GLFW, this is only to consume the keyboard events so we
// make use of F-keys and other shortcuts without triggering browser
// functions.
return 1; // The event was consumed by the callback handler
}
static EM_BOOL EmscriptenMouseMoveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
{
// To emulate the GLFW_RAW_MOUSE_MOTION property.

Loading…
Cancel
Save