Rust-SDL2 / rust-sdl2

SDL2 bindings for Rust
MIT License
2.74k stars 468 forks source link

SDL_TOUCH_MOUSEID ? #1171

Open gregbuchholz opened 2 years ago

gregbuchholz commented 2 years ago

I'm not seeing "SDL_TOUCH_MOUSEID" in the Rust bindings. Am I overlooking something? The #define comes from C source at "./include/SDL_touch.h", and is used to differentiate between simulated mouse events and touch events on touch enabled devices.

/* Used as the device ID for mouse events simulated with touch input */
#define SDL_TOUCH_MOUSEID ((Uint32)-1)

/* Used as the SDL_TouchID for touch events simulated with mouse input */
#define SDL_MOUSE_TOUCHID ((Sint64)-1) 

See also: https://wiki.libsdl.org/SDL_MouseMotionEvent for more context. I'm not quite following how "sdl2-sys/sdl_bindings.rs" is generated (from "sdl2-sys/build.rs"?), or why it would be missing.

Cobrand commented 2 years ago

It's not defined in sdl_bindings.rs because it's generated via bindgen, which doesn't seem to support it yet: https://github.com/rust-lang/rust-bindgen/issues/316

A solution can be to manually define pub const which those hardcoded values in rust-sdl2 itself (and not using bindgen for this one).

gregbuchholz commented 2 years ago

Ah, good find. The exact same issue in this comment on that thread. Seems like a minor enough issue that it wouldn't be worth breaking the automated build. Easy enough to define in my program. For future searchers on this topic:

const SDL_TOUCH_MOUSEID:u32 = u32::MAX;