Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SDL2 version from 2.24.2 to 2.26.0 #21337

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/browser/test_sdl2_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ int main(int argc, char **argv) {

SDL_StartTextInput();

emscripten_run_script("keydown(38);keyup(38)"); // up
emscripten_run_script("keydown(40);keyup(40);"); // down
emscripten_run_script("keydown(37);keyup(37);"); // left
emscripten_run_script("keydown(39);keyup(39);"); // right
emscripten_run_script("keydown(65);keyup(65);"); // a
emscripten_run_script("keydown(66);keyup(66);"); // b
emscripten_run_script("keydown(100);keyup(100);"); // trigger the end
emscripten_run_script("keydown(38, 'ArrowUp'); keyup(38, 'ArrowUp')"); // up
emscripten_run_script("keydown(40, 'ArrowDown'); keyup(40, 'ArrowDown')"); // down
emscripten_run_script("keydown(37, 'ArrowLeft'); keyup(37, 'ArrowLeft');"); // left
emscripten_run_script("keydown(39, 'ArrowRight');keyup(39, 'ArrowRight');"); // right
emscripten_run_script("keydown(65, 'KeyA'); keyup(65, 'KeyA');"); // a
emscripten_run_script("keydown(66, 'KeyB'); keyup(66, 'KeyB');"); // b
emscripten_run_script("keydown(100, 'Numpad4'); keyup(100, 'Numpad4');"); // trigger the end

emscripten_set_main_loop(pump_events, 3, 0);
return 99;
Expand Down
6 changes: 4 additions & 2 deletions test/browser/test_sdl2_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ void one() {
printf("motion : %d,%d %d,%d\n", m->x, m->y, m->xrel, m->yrel);

if (mouse_motions == 0) {
// Starting with SDL 2.26.0 initial xrel and yrel values are zero
// See: https://github.com/libsdl-org/SDL/commit/0e61c106
#ifdef TEST_SDL_MOUSE_OFFSETS
assert(eq(m->x, 5) && eq(m->y, 15) && eq(m->xrel, 5) && eq(m->yrel, 15));
assert(eq(m->x, 5) && eq(m->y, 15) && eq(m->xrel, 0) && eq(m->yrel, 0));
#else
assert(eq(m->x, 10) && eq(m->y, 20) && eq(m->xrel, 10) && eq(m->yrel, 20));
assert(eq(m->x, 10) && eq(m->y, 20) && eq(m->xrel, 0) && eq(m->yrel, 0));
#endif
} else if (mouse_motions == 1) {
#ifdef TEST_SDL_MOUSE_OFFSETS
Expand Down
6 changes: 3 additions & 3 deletions test/browser/test_sdl2_pumpevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ int main(int argc, char *argv[])
SDL_Window *window;
SDL_CreateWindow("window", 0, 0, 600, 450, 0);

emscripten_run_script("keydown(37);"); // left
emscripten_run_script("keydown(37, 'ArrowLeft');"); // left
loop1();
emscripten_run_script("keydown(39);"); // right
emscripten_run_script("keydown(39, 'ArrowRight');"); // right
loop2();
emscripten_run_script("keydown(65);"); // A
emscripten_run_script("keydown(65, 'KeyA');"); // A
alphakey();
return 0;
}
14 changes: 7 additions & 7 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3054,19 +3054,19 @@ def test_sdl2_image_formats(self):
@no_wasm64('SDL2 + wasm64')
def test_sdl2_key(self):
create_file('pre.js', '''
function keydown(c) {
var event = new KeyboardEvent("keydown", { 'keyCode': c, 'charCode': c, 'view': window, 'bubbles': true, 'cancelable': true });
function keydown(keyCode, code) {
var event = new KeyboardEvent("keydown", { keyCode, code, charCode: keyCode, 'view': window, 'bubbles': true, 'cancelable': true });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does closure treat keyCode as a string identifier it will not minify even after this change?

It's no longer in quotes which is what worries me. Specifically I worry that minifying the parameters seems like it would lead to changing the string names:

function a(b, c) {
  var d = new KeyboardEvent("keydown", { b, c, ..

Minifying keyCode to b leads to the object having "b": b which no longer works.

But perhaps closure is aware of this and will not minify the parameter names here? Or perhaps it switches from { b, c, .. notation to { 'keyCode': b, 'code': c, .. - ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we run this test with closure so its not important in this case.

Copy link
Collaborator Author

@sbc100 sbc100 Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I confirmed the closure seems to be aware of the various keys in the object.

$ cat test.js 
let foo = (code, keyCode) => {
  var e = new KeyboardEvent('keydown', { keyCode, code, charCode: keyCode, view: window, bubbles: true, cancelable: true, xxx: 1 });
  return e;
}
foo(1, 2);
$ ./emcc ~/test/hello.c --pre-js=test.js  --closure=1 --minify=0
$ grep "new Key" a.out.js 
new KeyboardEvent("keydown", {keyCode:2, code:1, charCode:2, view:window, bubbles:!0, cancelable:!0, h:1});                                                                                                       

Note that it minified my xxx key but not the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create a followup PR to remove the unneeded key quotes.

var prevented = !document.dispatchEvent(event);

//send keypress if not prevented
if (!prevented) {
var event = new KeyboardEvent("keypress", { 'keyCode': c, 'charCode': c, 'view': window, 'bubbles': true, 'cancelable': true });
var event = new KeyboardEvent("keypress", { keyCode, code, charCode: keyCode, 'view': window, 'bubbles': true, 'cancelable': true });
document.dispatchEvent(event);
}
}

function keyup(c) {
var event = new KeyboardEvent("keyup", { 'keyCode': c, 'charCode': c, 'view': window, 'bubbles': true, 'cancelable': true });
function keyup(keyCode, code) {
var event = new KeyboardEvent("keyup", { keyCode, code, charCode: keyCode, 'view': window, 'bubbles': true, 'cancelable': true });
document.dispatchEvent(event);
}
''')
Expand Down Expand Up @@ -3281,8 +3281,8 @@ def test_sdl2_canvas_proxy(self):
def test_sdl2_pumpevents(self):
# key events should be detected using SDL_PumpEvents
create_file('pre.js', '''
function keydown(c) {
var event = new KeyboardEvent("keydown", { 'keyCode': c, 'charCode': c, 'view': window, 'bubbles': true, 'cancelable': true });
function keydown(keyCode, code) {
var event = new KeyboardEvent("keydown", { keyCode, code, charCode: keyCode, 'view': window, 'bubbles': true, 'cancelable': true });
document.dispatchEvent(event);
}
''')
Expand Down
4 changes: 2 additions & 2 deletions tools/ports/sdl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import os

TAG = 'release-2.24.2'
HASH = 'b178bdc8f7c40271e09a72f639649d1d61953dda4dc12b77437259667b63b961fd3b2c67b0de6fdc5f9f9c80c49bfafd164e4c13715bc1056e550acc8bad5a3c'
TAG = 'release-2.26.0'
HASH = '2e53af5aa3d3ca7e2b8653f999379bf424b2190aad32a7997350fc058624818cca3a780907af74c8f72305ca18a83a2aa15839e1dbc94107128125a7df9cd7fd'
SUBDIR = 'SDL-' + TAG

variants = {'sdl2-mt': {'PTHREADS': 1}}
Expand Down
Loading