Render one of a controller's button images to an SDL_Surface.
Defined in <controllerimage.h>
SDL_Surface * ControllerImage_CreateSurfaceForButton(ControllerImage_Device *device, SDL_GamepadButton button, int size);| ControllerImage_Device * | device | the device object for which to generate an image. |
| SDL_GamepadButton | button | the button on the device for which to generate an image. |
| int | size | the size, in pixels, that the generated SDL_Surface should be, This size is used for both the width and height. |
(SDL_Surface *) Returns a new surface on success, or NULL on error; call SDL_GetError() for details.
This creates a new surface with the art for a single button. The artwork is stored as scalable vector graphics, so it can be generated at any desired size and look sharp.
All artwork is generated as a square, so the requested size represents both the width and height in pixels.
Since this has to allocate and rasterize an image, it's not a fast call, and should probably be done once, not every frame.
This returns NULL on error, but also if there is no artwork available. For a controller missing a button, this is not necessarily an error. If the distinction is important, consider calling ControllerImage_DeviceHasArtworkForButton().
The returned SDL_Surface is owned by the caller, who should call SDL_DestroySurface() to dispose of it when done with it.
This function is not thread safe.
This function is available since ControllerImage 1.0.0.