Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement JSON/YAML/ENV output #333

Merged
merged 14 commits into from
Apr 1, 2024
Merged
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Language: Cpp
BasedOnStyle: WebKit
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
InsertNewlineAtEOF: true
...
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/1_new_device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,15 @@ body:
```

</details>
- type: checkboxes
id: newdevice
attributes:
label: New Device Implementation Checklist
description: Implementing a new device requires specific steps and tools (like WireShark) to capture and analyze device communications. This process typically can only be done by those who have physical access to the device.
options:
- label: I acknowledge that implementing a new device requires direct access to the device and familiarity with capturing and analyzing its communications. I have access to the device and am willing to contribute by capturing necessary data and/or attempting implementation.
required: true
- label: I have already attempted to capture device communications using WireShark or similar tools and am including my findings (successful or not) with this issue to assist in implementation efforts.
required: false
- label: I am seeking guidance on how to begin this process and am willing to collaborate with the community to add support for this device. I understand where to find resources (refer to the WIKI).
required: false
8 changes: 8 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Changes made

<!--- Describe your changes here --->.

### Checklist

- [ ] I adjusted the README (if needed)
- [ ] For new features in HeadsetControl: I discussed it beforehand in Issues or Discussions and adhered to the [wiki](https://github.com/Sapd/HeadsetControl/wiki/Development#adding-a-new-feature-to-the-headsestcontrol-application-itself)
4 changes: 3 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ jobs:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ jobs:
triplet: x64-osx
INSTALL_DEPS: brew install hidapi
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: lukka/get-cmake@latest

- name: Install Dependencies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.11
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.17
with:
source: '.'
extensions: 'h,c'
clangFormatVersion: 11
clangFormatVersion: 16
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
build/
src/version.h

.idea/
cmake-build-debug/
.codechecker/

.vscode/*
*.code-workspace
Expand Down
53 changes: 52 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,57 @@ ENDIF()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# ------------------------------------------------------------------------------
# Git version
# ------------------------------------------------------------------------------

execute_process(
COMMAND git describe --tags --dirty=-modified
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Configure a header file to pass the version number to the source code
configure_file(
"${PROJECT_SOURCE_DIR}/src/version.h.in"
"${PROJECT_SOURCE_DIR}/src/version.h"
@ONLY
)

# ------------------------------------------------------------------------------
# VA Copy check for asprintf
# ------------------------------------------------------------------------------

# Check for va_copy
include(CheckCSourceCompiles)

check_c_source_compiles("
#include <stdarg.h>
int main() {
va_list x, y;
va_copy(x, y);
return 0;
}
" HAVE_VA_COPY)

if(HAVE_VA_COPY)
add_definitions(-DHAVE_VA_COPY=1)
endif()

# Check for __va_copy
check_c_source_compiles("
#include <stdarg.h>
int main() {
va_list x, y;
__va_copy(x, y);
return 0;
}
" HAVE___VA_COPY)

if(HAVE___VA_COPY)
add_definitions(-DHAVE___VA_COPY=1)
endif()

# ------------------------------------------------------------------------------
# Clang format
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -143,7 +194,7 @@ include (CTest)
## Simple test wether we can run the application (should basic hidapi functions, like enumerate, work)
enable_testing()
add_test(run_test headsetcontrol)
set_tests_properties(run_test PROPERTIES PASS_REGULAR_EXPRESSION "No supported headset found")
set_tests_properties(run_test PROPERTIES PASS_REGULAR_EXPRESSION "No supported device found;Found")
# use make check to compile+test
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
DEPENDS headsetcontrol)
157 changes: 63 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,35 @@ talking. This differs from a simple loopback via PulseAudio as you won't have an

## Supported Headsets

- HyperX Cloud Alpha Wireless
- Battery, Inactive time, Sidetone, Voice Prompts (only tested on Linux)
- HyperX Cloud Flight Wireless
- Battery only (only tested on Linux)
- Corsair **Void** (Most void-versions*)
- Sidetone, Battery (for Wireless), LED on/off, Notification Sound
- Logitech G430
- No support in current version (Last working on macOS in commit 41be99379f)
- Logitech G432
- Sidetone (only tested on Linux)
- Logitech G433
- Sidetone (only tested on Linux)
- Logitech G533
- Sidetone, Battery (for Wireless)
- Logitech G535
- Sidetone, Battery, Inactive time (only tested on Linux)
- Logitech G633 / G635 / G733 / G933 / G935
- Sidetone, Battery (for Wireless), LED on/off
- Logitech G930
- Sidetone, Battery
- SteelSeries Arctis 1, Arctis 1 for XBox
- Sidetone, Battery, Inactive time
- SteelSeries Arctis Nova 3
- Sidetone, Equalizer Presets, Equalizer, Microphone Mute LED Brightness, Microphone Volume
- SteelSeries Arctis (7 and Pro)
- Sidetone, Battery, Inactive time, Chat-Mix level, LED on/off (allows to turn off the blinking LED on the base-station)
- SteelSeries Arctis 7+
- Sidetone, Battery, Chat-Mix level, Inactive time, Equalizer Presets, Equalizer
- SteelSeries Arctis Nova 7
- Sidetone, Battery, Chat-Mix level, Inactive time, Equalizer Presets, Equalizer
- SteelSeries Arctis 9
- Sidetone, Battery, Inactive time, Chat-Mix level
- SteelSeries Arctis Pro Wireless
- Sidetone, Battery, Inactive time
- SteelSeries Arctis Nova Pro Wireless
- Sidetone, Battery, Inactive time
- Logitech G PRO
- Sidetone, Battery, Inactive time
- Logitech G PRO X 2
- Sidetone, Inactive time
- Logitech Zone Wired/Zone 750
- Sidetone, Voice prompts, Rotate to mute
- Roccat Elo 7.1 Air
- LED on/off, Inactive time (Note for Linux: Sidetone is handled by sound driver => use AlsaMixer)
| Device | sidetone | battery | notification sound | lights | inactive time | chatmix | voice prompts | rotate to mute | equalizer preset | equalizer | microphone mute led brightness | microphone volume |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Corsair Headset Device | x | x | x | x | | | | | | | | |
| HyperX Cloud Alpha Wireless | x | x | | | x | | x | | | | | |
| HyperX Cloud Flight Wireless | | x | | | | | | | | | | |
| Logitech G430 | x | | | | | | | | | | | |
| Logitech G432/G433 | x | | | | | | | | | | | |
| Logitech G533 | x | x | | | x | | | | | | | |
| Logitech G535 | x | x | | | x | | | | | | | |
| Logitech G930 | x | x | | | | | | | | | | |
| Logitech G633/G635/G733/G933/G935 | x | x | | x | | | | | | | | |
| Logitech G PRO Series | x | x | | | x | | | | | | | |
| Logitech G PRO X 2 | x | | | | x | | | | | | | |
| Logitech Zone Wired/Zone 750 | x | | | | | | x | x | | | | |
| SteelSeries Arctis (1/7X) Wireless | x | x | | | x | | | | | | | |
| SteelSeries Arctis (7/Pro) | x | x | | x | x | x | | | | | | |
| SteelSeries Arctis 9 | x | x | | | x | x | | | | | | |
| SteelSeries Arctis Pro Wireless | x | x | | | x | | | | | | | |
| ROCCAT Elo 7.1 Air | | | | x | x | | | | | | | |
| ROCCAT Elo 7.1 USB | | | | x | | | | | | | | |
| SteelSeries Arctis Nova 3 | x | | | | | | | | x | x | x | x |
| SteelSeries Arctis Nova 7 | x | x | | | x | x | | | x | x | | |
| SteelSeries Arctis 7+ | x | x | | | x | x | | | x | x | | |
| SteelSeries Arctis Nova Pro Wireless | x | x | | x | x | | | | x | x | | |
| HeadsetControl Test device | x | x | x | x | x | x | x | x | x | x | x | x |

For non-supported headsets on Linux: There is a chance that you can set the sidetone via AlsaMixer

&ast; *If your Corsair headset is not recognized, see [Adding a corsair device](https://github.com/Sapd/HeadsetControl/wiki/Adding-a-Corsair-device).* HS80 and HS70 wired, RGB Elite, and Virtuso is not supported, but you can change its sidetone in Alsamixer.
&ast; *If your Corsair headset is not recognized - or you have a very similar headset to an existing one, see [Adding a corsair device](https://github.com/Sapd/HeadsetControl/wiki/Adding-a-Corsair-device).* HS80 and HS70 wired, RGB Elite, and Virtuso is not supported, but you can change its sidetone in Alsamixer.

For more features or other headsets, the protocol of the respective headset must be analyzed further. This can be done by capturing the USB traffic between the device and the original Windows software and analyzing it with WireShark or USBlyzer. For that, you can also use a virtual machine with USB passthrough. The [wiki](https://github.com/Sapd/HeadsetControl/wiki/Development) provides a tutorial.

Expand All @@ -66,16 +47,17 @@ Some headsets expose sidetone as audio-channel volume and as such can be changed

### Prerequisites

You will need hidapi, c compilers and cmake. All usually installable via package managers.
Before building, ensure you have the necessary dependencies installed, including HIDAPI, C compilers, and CMake. These dependencies can usually be installed via your system's package manager.

#### Debian / Ubuntu

`apt-get install build-essential git cmake libhidapi-dev`

#### CentOS / RHEL (RedHat based)

RHEL and CentOS also require the epel-repository: `yum install epel-release`. Please inform yourself about the consequences of activating the epel-repository.
RHEL and CentOS also require the epel-repository.

`yum install epel-release`
`yum groupinstall "Development tools"`
`yum install git cmake hidapi-devel`

Expand Down Expand Up @@ -104,82 +86,69 @@ RHEL and CentOS also require the epel-repository: `yum install epel-release`. Pl

`emerge -a app-misc/headsetcontrol`

#### Mac OS X

I recommend using [Homebrew](https://brew.sh).

You can automatically compile and install the latest version of the software, by using
`brew install sapd/headsetcontrol/headsetcontrol --HEAD`.

If you wish to compile it manually, you can install the dependencies with `brew install hidapi cmake`.

Also you have to download Xcode via the Mac App Store for the compilers.

#### Windows

Windows support is a bit experimental and might not work in all cases. You can find binaries in the [releases](https://github.com/Sapd/HeadsetControl/releases) page, or compile instructions via MSYS2/MinGW in the [wiki](https://github.com/Sapd/HeadsetControl/wiki/Development#windows).

### Compiling

```
```bash
git clone https://github.com/Sapd/HeadsetControl && cd HeadsetControl
mkdir build && cd build
cmake ..
make
```

If you want to be able to call HeadsetControl from every folder type:
To make `headsetcontrol` accessible globally, run:

```bash
make install
```

This will copy the binary to a folder globally accessible via path.

### Access without root
sudo make install

Also in Linux, you need udev rules if you don't want to start the application with root. Those rules are generated via `headsetcontrol -u`. Typing `make install` on Linux generates and writes them automatically to /etc/udev/rules.d/.

You can reload udev configuration without reboot via `sudo udevadm control --reload-rules && sudo udevadm trigger`

## Usage
# On LINUX, to access without root reboot your computer or run
sudo udevadm control --reload-rules && sudo udevadm trigger
```

Type `headsetcontrol -h` to get all available options.\
(Don't forget to prefix it with `./` when the application resides in the current folder)
This command installs the binary in a location that is globally accessible via your system's PATH. On Linux it also runs `headsetcontrol -u` for generating udev files and stores them in `/etc/udev/rules.d/` (used to allow non-root access)

Type `headsetcontrol -?` to get a list of supported capabilities for the currently detected headset.
### OS X

`headsetcontrol -s 128` sets the sidetone to 128 (REAL loud). You can silence it with `0`. I recommend a loudness of 16.
Recommendation: Use [Homebrew](https://brew.sh).

The following options don't work on all devices yet:
* To automatically compile and install the latest version:

`headsetcontrol -b` check battery level. Returns a value from 0 to 100 or loading.
```bash
brew install sapd/headsetcontrol/headsetcontrol --HEAD
```

`headsetcontrol -n 0|1` sends a notification sound, made by the headset. 0 or 1 are currently supported as values.
* To manually compile, first install the dependencies:
`brew install hidapi cmake`

`headsetcontrol -l 0|1` switches LED off/on (off almost doubles battery lifetime!).
Note: Xcode must be downloaded via the Mac App Store for the compilers.

`headsetcontrol --short-output` cut unnecessary output, for reading by other scripts or applications.
### Windows

`headsetcontrol -i 0-90` sets inactive time in minutes, time must be between 0 and 90, 0 disables the feature.
* Binaries are available on the [releases](https://github.com/Sapd/HeadsetControl/releases) page.
* For compilation instructions using MSYS2/MinGW refer to the [wiki](https://github.com/Sapd/HeadsetControl/wiki/Development#windows).

`headsetcontrol -m` retrieves the current chat-mix-dial level setting between 0 and 128. Below 64 is the game side and above is the chat side.
## Usage

`headsetcontrol -v 0|1` turn voice prompts on or off.
To view available options for your device, use:

`headsetcontrol -r 0|1` turn rotate to mute feature on or off.
```bash
headsetcontrol -h
```

`headsetcontrol -u` Generates and outputs udev-rules for Linux.
For a complete list of all options, run:

`headsetcontrol --dev` Advanced menu for developers, to send and/or receive custom data
```bash
headsetcontrol --help-all
```

`headsetcontrol -p 0-3` sets equalizer preset, must be between 0 and 3, 0 is the default preset.
To use headsetcontrol in scripts or other applications, explore:

`headsetcontrol -e string` sets equalizer to specified curve, string must contain band values specific to the device (hex or decimal) delimited by spaces, or commas, or new-lines e.g "0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18".
```bash
headsetcontrol --output
```

##### Modifiers
(and the wiki article about [API development](https://github.com/Sapd/HeadsetControl/wiki/API-%E2%80%90-Building-Applications-on-top-of-HeadsetControl))

`--timeout 5000` Specifies a timeout for read-operations in milliseconds. Default is 5 seconds, 0 disables timeout.
Note: When running the application from the current directory, prefix commands with `./`

### Third Party

Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ set(SOURCE_FILES ${SOURCE_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/device_registry.h
${CMAKE_CURRENT_SOURCE_DIR}/hid_utility.c
${CMAKE_CURRENT_SOURCE_DIR}/hid_utility.h
${CMAKE_CURRENT_SOURCE_DIR}/output.c
${CMAKE_CURRENT_SOURCE_DIR}/output.h
${CMAKE_CURRENT_SOURCE_DIR}/utility.c
${CMAKE_CURRENT_SOURCE_DIR}/utility.h
PARENT_SCOPE)
Loading
Loading