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

SDL_TOUCH_MOUSEID is missing in sdl2-sys #1265

Open
KivApple opened this issue Oct 15, 2022 · 6 comments
Open

SDL_TOUCH_MOUSEID is missing in sdl2-sys #1265

KivApple opened this issue Oct 15, 2022 · 6 comments

Comments

@KivApple
Copy link

SDL_TOUCH_MOUSEID constant is missing in sdl2-sys crate

@Cobrand
Copy link
Member

Cobrand commented Oct 16, 2022

You can have an updated sdl2-sys using the feature use-bindgen. Otherwise, at some point the sdl2-sys bindings will be updated and it will be a part of it then.

@KivApple
Copy link
Author

This constant defined since SDL 2.0.0.

@Cobrand
Copy link
Member

Cobrand commented Oct 18, 2022

I've looked at it, this is a bindgen problem. The constant is defined as #define SDL_TOUCH_MOUSEID ((Uint32)-1), but the preprocessor variables are not expanded in bindgen yet (see rust-lang/rust-bindgen#753 )

@KivApple
Copy link
Author

KivApple commented Oct 18, 2022

Maybe you can add some usable interface for the safe wrappers to check if mouse event came from touch screen? Because now it's only possible to hardcode which == 0xFFFFFFFF condition for Event::MouseDown, Event::MouseUp and Event::MouseMotion, because the constant is unavailable. I think it's better to do that in the library rather than in the user code. You can declare some constant in sdl2 crate (not sys) or methods for sdl2::Event structure as you prefer. Even if we have this contant in sdl2::sys it won't be reexported to safe wrappers by default and I think you can add safe wrappers ahead of time just hardcoding 0xFFFFFFFF (it's unlikely that this value will change on SDL updates). Because in any case it's a bit strange to use sdl2::sys to interpret sdl2::Event safe wrapper data. For example, you did this for sdl2::mouse::Button.

@Cobrand
Copy link
Member

Cobrand commented Oct 18, 2022

You can very well add a is_touchscreen method to Event, and only make it do something if the event can handle touchscreens (click / drag / pointer move / ... I assume), otherwise return false. A PR is always welcome!

EDIT: Also instead of using 0xFFFFFFFF you can use u32::MAX instead, but I think the PR is the better option.

@KivApple
Copy link
Author

I've added is_touch: bool field to all mouse events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants