====== Compiling the hidapi USB library in an Orx project ====== If you are interested in interfacing custom USB devices (HID) to control games written by Orx (or any other C++ application), this article will show you the easiest way to compile hidapi along with your Windows-based Orx project. This is not a very wide use case for many projects, but one example of this is the [[https://alienabductionunit.com/pinball | Virtual Pinball tables at the Alien Abduction Unit]]. These use a PIC microcontroller-based USB device as the controller for the pinball launch and paddles. The hidapi library can be compiled many ways, but getting it set up can be a minefield using their [[https://github.com/libusb/hidapi/blob/master/BUILD.md | github set up page]]. This following method is the easiest, and this article will be covering version 0.12.0. ==== The easiest method ===== - [[en:tutorials:projects:creating_your_own_project|Create a new blank orx project]]. - Clone the [[https://github.com/libusb/hidapi | hidapi project]] somewhere on your computer. - Copy the ''hidapi/windows/hid.c'' file to your project ''/src'' folder. - In your IDE, edit the project's list of include folders and add some direct paths like the following: * ''C:\Work\Dev\hidapi\hidapi-0.12.0\hidapi'' * ''C:\Work\Dev\hidapi\hidapi-0.12.0\windows'' Of course, the paths above can be relative rather than absolute if you plan to keep hidapi relative to your orx project. Ensure ''hidapi.h'' is included in the ''main.cpp'' file: #include "orx.h" #include "hidapi.h" There are no special linker libraries or paths required. That should be enough to compile and run. Code for testing a USB device within the Orx application is beyond the scope of this article but you can learn how to use it looking at [[https://github.com/libusb/hidapi/tree/master/testgui | their test application]], and you can also get usage tips in the [[https://gitlab.com/sausagejohnson/rlb | Reload Bar Pinball source code]].