SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Detect device form factor

Open Semphriss opened this issue 8 months ago • 2 comments

Description

This adds a new function SDL_GetDeviceFormFactor(), which guesses what kind of device the current device may be.

It can report the following devices:

  • Desktop
  • Laptop
  • Phone
  • Tablet
  • Console
  • Handheld console
  • Smartwatch
  • TV
  • VR
  • Car

I've added support to the best of my abilities, but I couldn't cover 100% of cases either because I'm not familiar enough with the platform (QNX can be in phones, cars, and other embedded systems) or because the system itself doesn't provide that information (generic Unix).

I'm also aware that private platforms may want to provide their own value, but I couldn't find a compiler macro that detects if SDL is currently being compiled for a private platform. I would need help to find out how that can be done.

Existing Issue(s)

None

Semphriss avatar Mar 19 '25 13:03 Semphriss

SDL_GetDeviceFormFactorName giving a human readable name would be nice to have

TheMode avatar Mar 31 '25 16:03 TheMode

@TheMode I'm not sure how translation would be supported, but I can give it a try. I'll see if there's another similar function in SDL to use as a template.

Edit: I've given it a quick look, and it seems that most functions promising a "human readable" string either returns a string generated by something outside SDL (like a camera device name) or the literal stringification of an enum (like SDL_GetPixelFormatName). I'm not sure what the use case is for the latter, other than error/debug messages, but I suppose I can make something similar to that.

Semphriss avatar May 21 '25 02:05 Semphriss