SDL_hid_get_feature_report(3)

πŸ’– SDL_hid_get_feature_report πŸ’–

okay bestie, welcome to the SDL_hid_get_feature_report(3) page, straight out of the SDL3 FUNCTIONS section of the manual, no cap. this one's all about pulling a feature report out of a HID device. let's get into it πŸ¦‹


✨ NAME ✨

SDL_hid_get_feature_report β€” grab a feature report from a HID device, periodt.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_hidapi.h>

int SDL_hid_get_feature_report(SDL_hid_device *dev, unsigned char *data, size_t length);

πŸ’… DESCRIPTION πŸ’…

okay so here's the tea πŸ“ β€” you set the first byte of data to the Report ID of the report you wanna read. and listen, make sure you actually leave space for that extra byte in data, because it's coming along for the ride.

when the call comes back, that first byte is still holding the Report ID (she's not going anywhere πŸ’β™€οΈ), and the actual report data starts over at data[1]. iconic behavior honestly.


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • dev β€” a device handle that came from SDL_hid_open(). your little key to the device, basically πŸ”‘
  • data β€” the buffer where the read data goes, Report ID included. set the first byte of data to the Report ID of the report you're reading, or set it to zero if your device doesn't do numbered reports. either way, she's in there.
  • length β€” how many bytes to read, counting that extra byte for the report ID. lowkey the buffer can be bigger than the actual report, so no stress about it being exactly sized 🫢

⭐ RETURN VALUE ⭐

returns the number of bytes read plus one for the report ID (which is still chillin' in the first byte), or -1 on failure 😭. if it fails, hit up SDL_GetError() for more info.


🌈 AVAILABILITY 🌈

this function has been available since SDL 3.2.0. she's new-ish but she's thriving πŸ‘‘


and that's the whole page, bestie β€” go read some reports πŸ’œ

shoutout to the Simple Directmedia Layer for making this happen, version SDL 3.4.18, SDL_hid_get_feature_report(3). mwah, bye πŸ§šπŸ’–

πŸ“¦ where this page comes from