Ingvar Stepanyan 066a77fc0b webusb: Wasm+WebUSB backend fixes and improvements
- Added long-awaited support for multithreading. Since WebUSB still
 doesn't support accessing same device from multiple threads, this works
 by proxying I/O operations to the main thread as discussed on the
 original issue. For applications that run on the main thread nothing
 changes and they will continue to access WebUSB via Asyncify like
 before, while other threads will use blocking mechanism until an
 asynchronous response is available from the main thread.

 - Rewrote notification mechanism to use atomic waiting via sync Wasm
 instructions or `Atomics.waitAsync` depending on the thread. This
 results in simpler and faster notifications than the previous
 `postMessage`-based approach (which was used because
 `Atomics.waitAsync` wasn't yet available), as well as allows to send
 notifications across threads for multithreading scenario described
 above.

 - Fixed notification access to only wait/notify on the event we're
 interested instead of using a global lock.

 - Rewrote descriptor reading to query device for raw device &
 configuration descriptors instead of re-serializing them from
 JavaScript object representation. This incurs slight extra cost for the
 initial device opening, but fixes number of issues with information
 that is not yet exposed via WebUSB and allows to read supplementary
 descriptors such as string and BOS which were previously not supported.

 - Fixed listing only one alternate instead of all the available ones.

 - Fixed device closing & re-opening which could previously error out
 with "device busy" error.

 - Added mandatory Emscripten-specific linking flags to the generated
 pkgconfig.

 - Added device speed inference. This is not yet exposed via WebUSB, but
 we can at least make a best effort guess based on USB version and
 packet size, like some other backends already do.

 - Simplified & fixed device session ID generation which is now
 guaranteed to be truly unique, whereas previously it could clash with
 other devices of the same type.

 - Prepare code to support building for the Web without mandatory
 multithreading (which is costly on the Web) in the future. For now
 those `#ifdef`s are defunct as libusb is always compiled with
 `-pthread`, but some upcoming changes on the Emscripten side will allow
 to leverage those codepaths for smaller Wasm binaries.

 - Require explicit `--host=wasm32-unknown-emscripten` as we might want
 to add non-Emscripten WebAssembly backends in the future.

 - Various smaller fixes and improvements.

Note that this requires Emscripten 3.1.48 or newer to build for some of
the features used here, namely `co_await` support for JavaScript values
(without it code would be both more complex and slower) and some
proxying APIs. It shouldn't be a big deal in practice as most users
retrieve Emscripten via the official emsdk installer or Docker images.

Closes #1339
2023-12-08 22:17:40 +01:00
2023-11-30 11:52:26 +01:00
2020-12-19 13:29:38 -08:00
2022-06-26 17:09:14 +02:00
2022-04-10 10:57:16 +02:00
2022-04-10 10:57:16 +02:00
2007-12-02 22:54:59 +00:00
2022-06-26 17:09:14 +02:00
2016-07-24 20:00:00 -06:00
2020-03-25 00:09:26 -07:00
2020-08-23 17:32:06 +02:00
2016-07-24 20:02:31 -06:00

libusb

Build Status Build Status Coverity Scan Build Status

libusb is a library for USB device access from Linux, macOS, Windows, OpenBSD/NetBSD, Haiku, Solaris userspace, and WebAssembly via WebUSB. It is written in C (Haiku backend in C++) and licensed under the GNU Lesser General Public License version 2.1 or, at your option, any later version (see COPYING).

libusb is abstracted internally in such a way that it can hopefully be ported to other operating systems. Please see the PORTING file for more information.

libusb homepage: http://libusb.info/

Developers will wish to consult the API documentation: http://api.libusb.info

Use the mailing list for questions, comments, etc: http://mailing-list.libusb.info

(Please use the mailing list rather than mailing developers directly)

Description
⚠️ ARCHIVED: Original GitHub repository no longer exists. Preserved as backup on 2026-01-31T05:30:30.373Z
Readme 4.9 MiB
Languages
C 91.5%
C++ 4.8%
M4 1.3%
Makefile 1.1%
CMake 0.6%
Other 0.6%