User Tools

Site Tools


en:tutorials:input:compiling_hidapi_library

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 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 github set up page.

This following method is the easiest, and this article will be covering version 0.12.0.

The easiest method

  1. Clone the hidapi project somewhere on your computer.
  2. Copy the hidapi/windows/hid.c file to your project /src folder.
  3. 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 their test application, and you can also get usage tips in the Reload Bar Pinball source code.

en/tutorials/input/compiling_hidapi_library.txt · Last modified: 2022/05/31 05:24 (4 weeks ago) by sausage