mirror of
https://github.com/shadps4-emu/ext-libusb.git
synced 2026-01-31 00:55:21 +01:00
066a77fc0b5eaa5c23e0820081769637764e1ab0
- 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
libusb
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
- Hans de Goede hdegoede@redhat.com
- Xiaofan Chen xiaofanc@gmail.com
- Ludovic Rousseau ludovic.rousseau@gmail.com
- Nathan Hjelm hjelmn@cs.unm.edu
- Chris Dickens christopher.a.dickens@gmail.com
(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
Languages
C
91.5%
C++
4.8%
M4
1.3%
Makefile
1.1%
CMake
0.6%
Other
0.6%