icculus / ControllerImage

A library for producing images of SDL controllers.
zlib License
107 stars 2 forks source link

Feature Request: Draw Button/Axis "Variants" #30

Open ShockSlayer opened 2 months ago

ShockSlayer commented 2 months ago

Presently, each button/axis is only represented by a single image. I think it would be reasonable to pass an extra value to allow drawing variant states. For buttons, this would probably just amount to drawing a "pressed" variant, while for an axis this would be along the lines of drawing an up/down/left/right/none version.

Basically, I think having a way to use a few more of these already-drawn variants would greatly elevate the utility of the library: preview-xbox-series

ShockSlayer commented 2 months ago

I've got this working locally, by making the arrays in ControllerImage_Device 2D, and by adding/splitting text off of the svg filenames using an underscore as a delimiter; ie rightshoulder.svg becomes rightshoulder_0.svg and so on. If a variant is requested and not found, the default variant of 0 is used instead.

If this design philosophy makes sense for the project, I wouldn't mind creating a pull request, although I am a little less than confident about the implementation given that C-style string manipulation is not my forte. I'd also like to get a full example theme set up first, which will take a little bit of time to complete.