SDL_hid_send_feature_report(3)

✨ SDL_hid_send_feature_report ✨

okay bestie, welcome to the SDL_hid_send_feature_report(3) page, straight out of the SDL3 FUNCTIONS lineup πŸ’– this is where you yeet a Feature report at your device, and honestly? it's giving main character energy.


🌸 NAME 🌸

SDL_hid_send_feature_report β€” send a Feature report to the device πŸ’Œ


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_hidapi.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea πŸ“ Feature reports go out over the Control endpoint as a Set_Report transfer. that's just how it is, periodt.

the first byte of data must hold the Report ID β€” no skipping, no negotiating. for devices that only support a single report, that byte has to be set to 0x0. everything after that first byte is the actual report data.

and here's the part that trips people up: because the Report ID is mandatory, every single call to SDL_hid_send_feature_report() will contain one more byte than the report itself contains. one. extra. byte. always. πŸ™ˆ

example time, because numbers make it click: if a hid report is 16 bytes long, you have to pass 17 bytes to SDL_hid_send_feature_report() β€” that's the Report ID (or 0x0, for devices which do not use numbered reports) followed by the report data (the 16 bytes). so in that example, the length you pass in would be 17. slay πŸ’…


πŸ’œ FUNCTION PARAMETERS πŸ’œ

  • dev β€” a device handle returned from SDL_hid_open(). your ticket to the device, basically 🎟️
  • data β€” the data to send, including the report number as the first byte. don't forget that first byte, bestie, I'm begging 😭
  • length β€” the length in bytes of the data to send, including the report number. yes, counting that extra byte. yes, it's on purpose 🌈

⭐ RETURN VALUE ⭐

it returns the actual number of bytes written 🫢 and -1 on failure β€” in which case you should call SDL_GetError() for more info. go get that lore, you deserve to know what went wrong πŸ’€


πŸ‘‘ AVAILABILITY πŸ‘‘

this function is available since SDL 3.2.0 ✨ iconic behaviour, no cap.


Simple Directmedia Layer wrote this one, and this page is living in SDL 3.4.18 β€” mwah, thanks for reading, drink some water, and go send that feature report πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from