From 2f943db6eb7a4622fb6b189a13a2af8794928f20 Mon Sep 17 00:00:00 2001 From: Adam Rizkalla Date: Fri, 10 May 2019 16:03:59 -0700 Subject: [PATCH] allow only libusb auto detach --- device.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/device.go b/device.go index 2882899..b18bce2 100644 --- a/device.go +++ b/device.go @@ -287,3 +287,17 @@ func (d *Device) SetAutoDetach(autodetach bool) error { } return d.ctx.libusb.setAutoDetach(d.handle, autodetachInt) } + +// SetAutoDetachLibOnly is similar to SetAutoDetach, except it will not +// flag the Device instance to detach all interfaces when changing Configs. +// This will only call the libusb implementation of auto detach. +func (d *Device) SetAutoDetachLibOnly(autodetach bool) error { + if d.handle == nil { + return fmt.Errorf("SetAutoDetachLibOnly(%v) called on %s after Close", autodetach, d) + } + var autodetachInt int + if autodetach { + autodetachInt = 1 + } + return d.ctx.libusb.setAutoDetach(d.handle, autodetachInt) +}