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

How to convert *mut sdl2_sys::SDL_Event into sdl2::event::Event ? #1023

Closed
TonalidadeHidrica opened this issue Aug 30, 2020 · 4 comments · Fixed by #1070
Closed

How to convert *mut sdl2_sys::SDL_Event into sdl2::event::Event ? #1023

TonalidadeHidrica opened this issue Aug 30, 2020 · 4 comments · Fixed by #1070
Labels

Comments

@TonalidadeHidrica
Copy link
Contributor

I want to receive event callbacks via SDL_AddEventWatch. The callback is provided with *mut sdl2_sys::SDL_Event. I want to convert it to sdl2::event::Event, but unfortunately Event::from_ll is a private function. Is there any other way to convert the raw pointer into Rust enum?

@Cobrand
Copy link
Member

Cobrand commented Sep 5, 2020

I don't think there is a way yet -- sdl2 is supposed to work with itself first, compatibility with sdl2-sys is a second tier citizen. I think making "from_ll" public in that case can be a good option, there are already other places in the code where it's public because of that.

@TonalidadeHidrica
Copy link
Contributor Author

#1070 introduced a safe wrapper for SDL_AddEventWatch, so I don't need this to be public anymore. If somebody want this in other reason, feel free to reopen it.

@jpteb
Copy link
Contributor

jpteb commented Feb 17, 2022

I have a use case where I get a raw *mut sdl2_sys::SDL_Event by hooking SDL_PollEvent of an existing program. I would like to convert it to a sdl2::event::Event.

Does anything speak against making the function sdl2::event::Event::from_ll public? It is already done in quite a few other places like sdl2::video::Window::from_ll.

@Cobrand
Copy link
Member

Cobrand commented Feb 17, 2022

@Gosuo create a new issue for that. There is nothing against putting Event::from_ll public if someone has a use-case for it.

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

Successfully merging a pull request may close this issue.

3 participants