SDL_hid_get_input_report(3)

πŸ’– SDL_hid_get_input_report ✨

okay bestie, so this one is a page from the SDL3 FUNCTIONS section of the manual, and it's all about the HID device life. SDL_hid_get_input_report β€” say it with me β€” it grabs an input report off a HID device. that's the whole vibe. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_hidapi.h>

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

🌸 DESCRIPTION 🌸

ok so listen, this is the part where you have to be a little careful, no cap. πŸ‘‘

Set the first byte of data to the Report ID of the report you wanna read. that's on you, bestie, the function will not do it for you. πŸ™ˆ

And make sure you leave space for that extra byte in data β€” it's giving "surprise, there's an extra byte" but it's not a surprise, i told you. πŸ’…

Upon return, the first byte will still contain the Report ID, and the actual report data will start in data[1]. so like, the report ID is main character energy and it's not moving out of slot zero. 🌟


πŸ’œ FUNCTION PARAMETERS πŸ’œ

  • dev β€” a device handle returned from SDL_hid_open(). you know, the little ticket that says "yes, this is my device." 🎟️
  • data β€” a buffer to put the read data into, including the Report ID. Set the first byte of data to the Report ID of the report to be read, or set it to zero if your device does not use numbered reports. 🫢
  • length β€” the number of bytes to read, including an extra byte for the report ID. and the tea is: the buffer can be longer than the actual report. so don't stress if you over-allocated, it's fine, she's flexible. ✨

πŸ”₯ RETURN VALUE πŸ”₯

Returns the number of bytes read plus one for the report ID (which is still chilling in the first byte). πŸ₯°

Or... -1 on on failure. 😭 and if that happens, call SDL_GetError() for more info, because she will tell you what went wrong. (and yes, the original says "on on failure" β€” we do not gatekeep, we do not edit, periodt.) πŸ’€


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. so if you're on something older, bestie, you're simply not invited to this party. 🌈


and that's the whole page, you ate it up, no crumbs. πŸ“ this lil beauty comes to you from Simple Directmedia Layer, version SDL 3.4.18, and it's filed under SDL_hid_get_input_report(3). mwah, go read the report. πŸ’…πŸŽ€βœ¨

πŸ“¦ where this page comes from