Skip to content

Commit 1c43c54

Browse files
committed
A bit of documentation details on callback API
1 parent 12a30f1 commit 1c43c54

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

hidapi/hidapi.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ extern "C" {
303303
This callback may be called by an internal event thread and as such it is
304304
recommended the callback do minimal processing before returning.
305305
306+
It is NOT safe to call hid_open/hid_open_path or any other global/non-device
307+
functions from within this callback. If you need to open
308+
or close a device in response to a hotplug event, queue the
309+
device path and handle it on your own application thread.
310+
306311
hidapi will call this function later, when a matching event had happened on
307312
a matching device.
308313
@@ -315,6 +320,8 @@ extern "C" {
315320
316321
@param callback_handle The hid_hotplug_callback_handle callback handle.
317322
@param device The hid_device_info of device this event occurred on event that occurred.
323+
The device pointer is only valid for the duration of the callback.
324+
If you need the information later, copy the relevant fields before returning.
318325
@param event Event that occurred.
319326
@param user_data User data provided when this callback was registered.
320327
(Optionally NULL).
@@ -358,6 +365,9 @@ extern "C" {
358365
359366
This function is safe to call from within a hotplug callback.
360367
368+
It is safe to call this function on an already deregistered
369+
callback handle - the call will be a no-op returning 0.
370+
361371
@ingroup API
362372
363373
@param callback_handle The handle of the callback to deregister.

0 commit comments

Comments
 (0)