Skip to content

Development

Denis Arnst edited this page Jan 9, 2020 · 15 revisions

See the main README for basic compilation instructions.

Contributing

We use the WebKit coding style and clang-format to enforce it. You can usually install clang-format via package managers (clang-format or clang-format-9.0).

Also we use clang-tidy, it can also be installed via package managers (clang-tidy).

If both is installed, you can build the project with cmake .. -DENABLE_CLANG_FORMAT=1 DENABLE_CLANG_TIDY=1 -DCMAKE_BUILD_TYPE=Debug.

Use it like this:

  • make tidy clang-tidy is called indicating problems (ignore system header warnings)
  • make format will automatically format your code to our specification

When you do a Pull Request (PR), the CI will check both, and will also check for unneccessary whitespaces (you can also check it yourself with git diff --check HEAD^)

Adding a new headset

You need a bit experience in programming. Start by looking into the devices/ folder, and see how the structure of a device file is set up (ignore the actual raw package bytes for now).

Also you need the original driver-software installed in a Windows machine. This can als be a Windows installation in a virtual machine with USB passthrough.

Use a capturing software like USBLyzer. You will probably see your device in the list as "Composite device". Select "USB Input Device" (also the HID devices) for capturing and start it.

While capturing, start to slide the slider of the sidetone option in your driver's software up and down and stop if afterwards.

Screenshot (big version)

The data packages consist of packages to your device (the one's without a duration column) and packages to your desktop. You have to search for packages to your device consisting of Set Report or Write. When changing the slider, probably one (or two) bytes of the data changes. In the Screenshot you can see the raw data of the Sidetone packet to the Corsair Void, DF being the actual sidetone value. All bytes are relevant for the implementation.

When it's a Set Report, you need to use hid_send_feature_report, and for a write hid_write. You can call those functions directly with the raw data you see at the capturing software.

For the implementation look into other device files, to see how they are set up. When creating new source code, make sure to add your files to src/devices/CMakeLists.txt and call your init function at src/device_registry.c. After creating new files, you'll have to delete your build folder and rerun cmake.

Make sure that you send the correct amount of bytes (like shown in the capturing software), don't cut ending 0-bytes or the Windows implementation will fail. Also try to set idUsagePage and idUsage for the Windows implementation, it can be easily found using the testgui of hidapi (see the Windows section below). You can also use the testgui for testing it (but only if it uses set report), simply write the bytes you want to send besides the "Set Report"-button and click it.

Windows

Compilation

  1. Download and Install MSYS2
  2. pacman -Syu
  3. Close the msys terminal and start it again
  4. pacman -Syu
  5. pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-hidapi make git
  6. There should be now also a "MSYS2 MinGW 64-bit"-shortcut in your start menu (just use Windows Search), start and use it now
  7. git clone the repository
  8. mkdir build && cd build
  9. cmake -G"MSYS Makefiles" ..
  10. make and if wanted make install

You can also call the application then normally via windows-cmd or bat file etc., but you probably need to copy libhidapi-0.dll to the same directory of the executable (can be found at /mingw64/bin/libhidapi-0.dll)

Problems

Windows needs different endpoints then the UNIX-implementations. They are called Usages and Usage Pages. There could be multiple different endpoints for different packets (like sidetone <-> leds). However the HeadsetControl software only supports one endpoint for each device for now.

You can see the endpoints with the hidapi testgui software (found here in hidapi-0.7.0.zip\hidapi-0.7.0\testgui or directly here from this repo as .exe).

Also Windows expects the correct amount of bytes for every packet sent by the software. Linux/MacOS is more forgiving and allows ending 0's to be omitted.

"Incorrect function"

The endpoint (usageid / usagepage) is wrong.

"Incorrect parameter"

You probably didn't send the correct amount of bytes.

Clone this wiki locally