DC_USBHID_ITERATOR_NEW(3)
π 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.
onDC_STATUS_SUCCESS, the returned iterator needs to be freed when you're done usingdc_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:
dc_context_new(3)dc_bluetooth_iterator_new(3)dc_serial_iterator_new(3)dc_irda_iterator_new(3)dc_usbhid_device_get_pid(3)dc_usbhid_device_get_vid(3)
π§ 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
- nixos 26.05: libdivecomputer 0.9.0
- nixpkgs unstable: libdivecomputer 0.9.0
- Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms