Re: FFI Wrapping Help
- Posted by Icy_Viking 3 months ago
- 232 views
ChrisB said...
Icy_Viking said...
Hello all,
I am wondering how you would wrap this with the FFI library.
typedef struct SDL_GameControllerButtonBind { SDL_GameControllerBindType bindType; union { int button; int axis; struct { int hat; int hat_mask; } hat; } value; } SDL_GameControllerButtonBind;
I know with unions you can't exactly wrap them as you would with a normal struct.
My idea is
export constant SDL_GAMECONTROLLERBUTTONID = define_c_type({ C_INT --button C_INT --axis C_POINTER --for struct C_INT --hat C_INT --hat_mask })
And yes, that looks exactly right - you can flatten out the 'single layer' structures within unions, as th memory is accessible n the same way - they are read into (in our cases) sequences or variables before use any way.
Cheers
Chris
Thanks Chris. Yeah that Joystick code is still good. I'll have to wait and see what and if there are any major changes when SDL 3 is released.