summaryrefslogtreecommitdiffstats
path: root/platform/javascript/os_javascript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/javascript/os_javascript.cpp')
-rw-r--r--platform/javascript/os_javascript.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 8ba2b39c85..037f78c7af 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -250,7 +250,8 @@ static Ref<InputEventKey> setup_key_event(const EmscriptenKeyboardEvent *emscrip
ev.instance();
ev->set_echo(emscripten_event->repeat);
dom2godot_mod(emscripten_event, ev);
- ev->set_scancode(dom2godot_scancode(emscripten_event->keyCode));
+ ev->set_keycode(dom2godot_keycode(emscripten_event->keyCode));
+ ev->set_physical_keycode(dom2godot_keycode(emscripten_event->keyCode));
String unicode = String::utf8(emscripten_event->key);
// Check if empty or multi-character (e.g. `CapsLock`).
@@ -270,7 +271,7 @@ EM_BOOL OS_JavaScript::keydown_callback(int p_event_type, const EmscriptenKeyboa
OS_JavaScript *os = get_singleton();
Ref<InputEventKey> ev = setup_key_event(p_event);
ev->set_pressed(true);
- if (ev->get_unicode() == 0 && keycode_has_unicode(ev->get_scancode())) {
+ if (ev->get_unicode() == 0 && keycode_has_unicode(ev->get_keycode())) {
// Defer to keypress event for legacy unicode retrieval.
os->deferred_key_event = ev;
// Do not suppress keypress event.
@@ -295,7 +296,7 @@ EM_BOOL OS_JavaScript::keyup_callback(int p_event_type, const EmscriptenKeyboard
Ref<InputEventKey> ev = setup_key_event(p_event);
ev->set_pressed(false);
get_singleton()->input->parse_input_event(ev);
- return ev->get_scancode() != KEY_UNKNOWN && ev->get_scancode() != 0;
+ return ev->get_keycode() != KEY_UNKNOWN && ev->get_keycode() != 0;
}
// Mouse
@@ -536,17 +537,17 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s
png_meta.height = texture_size.height;
png_meta.format = PNG_FORMAT_RGBA;
- PoolByteArray png;
+ PackedByteArray png;
size_t len;
- PoolByteArray::Read r = image->get_data().read();
+ const uint8_t *r = image->get_data().ptr();
ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, r.ptr(), 0, NULL));
png.resize(len);
- PoolByteArray::Write w = png.write();
+ uint8_t *w = png.ptrw();
ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, w.ptr(), &len, 0, r.ptr(), 0, NULL));
- w = PoolByteArray::Write();
+ w = uint8_t * ();
- r = png.read();
+ r = png.ptr();
char *object_url;
/* clang-format off */
@@ -563,7 +564,7 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s
stringToUTF8(url, string_on_wasm_heap, length_bytes);
}, r.ptr(), len, &object_url);
/* clang-format on */
- r = PoolByteArray::Read();
+ r = const uint8_t * ();
String url = String::utf8(object_url) + "?" + itos(p_hotspot.x) + " " + itos(p_hotspot.y);
@@ -981,10 +982,10 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver,
SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, mousedown, mouse_button_callback)
SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, mouseup, mouse_button_callback)
SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, wheel, wheel_callback)
- SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, touchstart, touch_press_callback)
- SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, touchmove, touchmove_callback)
- SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, touchend, touch_press_callback)
- SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, touchcancel, touch_press_callback)
+ SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchstart, touch_press_callback)
+ SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchmove, touchmove_callback)
+ SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchend, touch_press_callback)
+ SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchcancel, touch_press_callback)
SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, keydown, keydown_callback)
SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, keypress, keypress_callback)
SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, keyup, keyup_callback)
@@ -1178,17 +1179,17 @@ void OS_JavaScript::set_icon(const Ref<Image> &p_icon) {
png_meta.height = icon->get_height();
png_meta.format = PNG_FORMAT_RGBA;
- PoolByteArray png;
+ PackedByteArray png;
size_t len;
- PoolByteArray::Read r = icon->get_data().read();
+ const uint8_t *r = icon->get_data().ptr();
ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, r.ptr(), 0, NULL));
png.resize(len);
- PoolByteArray::Write w = png.write();
+ uint8_t *w = png.ptrw();
ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, w.ptr(), &len, 0, r.ptr(), 0, NULL));
- w = PoolByteArray::Write();
+ w = uint8_t * ();
- r = png.read();
+ r = png.ptr();
/* clang-format off */
EM_ASM_ARGS({
var PNG_PTR = $0;