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

Touch input is off on Y axis on WASM export #10694

Closed
jaminhaber opened this issue Nov 22, 2023 · 8 comments
Closed

Touch input is off on Y axis on WASM export #10694

jaminhaber opened this issue Nov 22, 2023 · 8 comments
Labels
A-Input Player input via keyboard, mouse, gamepad, and more A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior

Comments

@jaminhaber
Copy link

jaminhaber commented Nov 22, 2023

Bevy version

[dependencies]
bevy = "0.12.0"
bevy_embedded_assets = "0.9.1"
rand = "0.8.5"
wasm-bindgen = "0.2.88"

Relevant system information

  • the Rust version you're using (you can get this by running cargo --version)
    • cargo 1.73.0 (9c4383fb5 2023-08-26)
  • the operating system or browser used, including its version
    • MacOS Sonoma 14.1.1 (23B81)
  • Browser: Chrome

What you did

I get the position of a touch like this:

 let just_pressed = touches.iter().find(|t| touches.just_pressed(t.id()));
 let touch_pos =  just_pressed.unwrap().position();
 println!("touch at ({},{})", touch_pos.x, touch_pos.y);

then build using this script

APP_NAME="sokoban"
cargo build --release --target wasm32-unknown-unknown
wasm-bindgen --out-dir 'out/webgl' --target web "target/wasm32-unknown-unknown/release/${APP_NAME}.wasm"
open "out/webgl"

What went wrong

touching the top right of the screen (640x480) produces the coordinates (19,218)

You can experience this by trying to press the buttons on the live version of the game on my website while using the mobile emulator for chrome.... You will have to tap about half way up the screen in order to press the buttons on the menus.

Additional information

image

The coordinates are off by about half the screen height, maybe it has to do with the grid originating from the middle of the screen rather than the top?

Screenshot 2023-11-22 at 12 45 22 PM
@jaminhaber jaminhaber added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 22, 2023
@daxpedda
Copy link
Contributor

This was probably fixed way back in rust-windowing/winit#2704.
Cc #8745.

@nicopap nicopap added A-Input Player input via keyboard, mouse, gamepad, and more A-Windowing Platform-agnostic interface layer to run your app in and removed S-Needs-Triage This issue needs to be labelled labels Nov 22, 2023
@jaminhaber
Copy link
Author

@daxpedda Is that fix included in the packages listed in the report? if not, how can i update to get that?

@daxpedda
Copy link
Contributor

daxpedda commented Nov 22, 2023

It's part of Winit v0.29.
If you are using Bevy you can try #10702.

@jaminhaber
Copy link
Author

@daxpedda will this be merged into bevy main? I can wait until then

@daxpedda
Copy link
Contributor

I was just commenting because I help maintain Winit. I'm not a contributor/maintainer/member of Bevy!

@Vrixyz
Copy link
Member

Vrixyz commented Nov 23, 2023

@daxpedda will this be merged into bevy main? I can wait until then

Hey, I hope so! I believe #10702 is nearing completion.

I've got 1 item on my todo, which should not impact API usage, I'm very interested in having more fresh-eyes reviews :)

@alice-i-cecile
Copy link
Member

This looks like a duplicate of #9071; is it?

@daxpedda
Copy link
Contributor

Indeed, it does look like that to me.

@alice-i-cecile alice-i-cecile closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

5 participants