DC_USBHID_ITERATOR_NEW(3)

πŸ“¦ version 0.9.0, in nixos 26.05, nixpkgs unstable

πŸ’… DC_USBHID_ITERATOR_NEW(3) πŸ’…

okay bestie, so this is a page from the Library Functions Manual for libdivecomputer β€” yes, the libdivecomputer library, she's the main character here. let's get into it ✨


🌸 NAME 🌸

dc_usbhid_iterator_new β€” literally creates an iterator so you can enumerate all the USB HID devices. that's the whole vibe. πŸ¦‹


πŸŽ€ LIBRARY πŸŽ€

the library is libdivecomputer, no cap. she's iconic, she's the blueprint. πŸ‘‘


✨ SYNOPSIS ✨

okay so here's the exact shape of it, don't come for me, just copy it:

#include <libdivecomputer/usbhid.h>

dc_status_t
dc_usbhid_iterator_new(dc_iterator_t **iterator, dc_context_t *context,
    dc_descriptor_t *descriptor);

πŸ’– DESCRIPTION πŸ’–

so what this does is iterate through all the available USB HID devices that match the descriptor you hand it. it takes a context that you opened with dc_context_new(3), plus a descriptor β€” and you usually score that descriptor by searching through dc_descriptor_iterator_new(3). iykyk 🫢

the moment it returns DC_STATUS_SUCCESS, the iterator gets set to a dc_iterator_t, and that's your ticket to walk through the available USB HID devices using dc_iterator_next(3). slay.

the value type of the iterator is dc_usbhid_device_t. and the way that's useful?? you can pass that value into functions that pull info about that specific USB HID device, namely:

and when you're done with the USB HID device, it needs to be freed with dc_usbhid_device_free(3). no leaving her hanging, okay? 😭

and after you're done iterating, the iterator itself needs to be freed using dc_iterator_free(3). both of them. every time. periodt.


πŸ”₯ RETURN VALUES πŸ”₯

returns DC_STATUS_SUCCESS on success, or another dc_status_t code on failure. simple as that, ngl.

on DC_STATUS_SUCCESS, the returned iterator needs to be freed when you're done using dc_iterator_free(3). this is not optional bestie, this is the whole assignment. πŸ’€

🌈 SEE ALSO 🌈

go check out these icons too, they're all linked up:


🧚 AUTHORS 🧚

the library libdivecomputer was written by Jef Driesen, jef@libdivecomputer.org. absolute legend behaviour. πŸ’œ

this manpage was written by Vincent Hagen, vinnie@script4web.nl. give her her flowers. 🌷


⭐ and that's a wrap!! this page is from the Debian edition, dated June 5, 2020, and it's page DC_USBHID_ITERATOR_NEW(3). mwah, go free those iterators responsibly πŸ’…πŸŽ€

πŸ“¦ where this page comes from