Skip to content

Commit

Permalink
SteelSeries Arctis 7 Battery Support + 2019 Model Support (#40)
Browse files Browse the repository at this point in the history
* Add battery support for SteelSeries Arctis 7 (Pre-2019)

* Adding support for 2019 Arctis 7 variant.

* Correcting error in udev rules.

* Updating README.md to include updates for SteelSeries Arctis 7.

* Fix 50-steelseries-arctis-7.rules UDev rule, According to Udev versions
used in Ubuntu 19.04. Previous version did not work.
  • Loading branch information
jamesj999 authored and Sapd committed Aug 8, 2019
1 parent 94cf16c commit 1dbc9ef
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ talking. This differs from a simple loopback via PulseAudio as you won't have an
- Logitech G533
- Logitech G430 (Last working on macOS in commit 41be99379f)
- SteelSeries Arctis 7
- SteelSeries Arctis 7 (2019 Revision)
- SteelSeries Arctis Pro 2019 Edition

### Other Features


Corsair Void (Pro) also supports checking of the battery and switching LED off/on
SteelSeries Arctis 7 (including 2019 revision) support checking of the battery.


For more features (like getting battery percentage of other devices, or settings LEDs etc. of specific devices), the protocol of the respective headset must be analyzed further. This can be done by capturing the USB traffic and analyzing it with WireShark or USBlyzer.

Expand Down
6 changes: 4 additions & 2 deletions src/device_registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
#include "devices/logitech_g633.h"
#include "devices/logitech_g930.h"
#include "devices/steelseries_arctis7.h"
#include "devices/steelseries_arctis7_2019.h"
#include "devices/steelseries_arctispro_2019.h"

#include <string.h>


#define NUMDEVICES 9
#define NUMDEVICES 10
// array of pointers to device
static struct device *(devicelist[NUMDEVICES]);

Expand All @@ -27,7 +28,8 @@ void init_devices()
g633_init(&devicelist[5]);
g930_init(&devicelist[6]);
arctis7_init(&devicelist[7]);
arctispro_2019_init(&devicelist[8]);
arctis7_2019_init(&devicelist[8]);
arctispro_2019_init(&devicelist[9]);
}

int get_device(struct device* device_found, uint16_t idVendor, uint16_t idProduct)
Expand Down
2 changes: 2 additions & 0 deletions src/devices/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ set(SOURCE_FILES ${SOURCE_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/logitech_g633.h
${CMAKE_CURRENT_SOURCE_DIR}/steelseries_arctis7.c
${CMAKE_CURRENT_SOURCE_DIR}/steelseries_arctis7.h
${CMAKE_CURRENT_SOURCE_DIR}/steelseries_arctis7_2019.c
${CMAKE_CURRENT_SOURCE_DIR}/steelseries_arctis7_2019.h
${CMAKE_CURRENT_SOURCE_DIR}/steelseries_arctispro_2019.c
${CMAKE_CURRENT_SOURCE_DIR}/steelseries_arctispro_2019.h
PARENT_SCOPE)
30 changes: 29 additions & 1 deletion src/devices/steelseries_arctis7.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
static struct device device_arctis7;

static int arctis7_send_sidetone(hid_device *device_handle, uint8_t num);
static int arctis7_request_battery(hid_device *device_handle);

void arctis7_init(struct device** device)
{
Expand All @@ -17,8 +18,9 @@ void arctis7_init(struct device** device)

strcpy(device_arctis7.device_name, "SteelSeries Arctis 7");

device_arctis7.capabilities = CAP_SIDETONE;
device_arctis7.capabilities = CAP_SIDETONE | CAP_BATTERY_STATUS;
device_arctis7.send_sidetone = &arctis7_send_sidetone;
device_arctis7.request_battery = &arctis7_request_battery;

*device = &device_arctis7;
}
Expand Down Expand Up @@ -55,3 +57,29 @@ static int arctis7_send_sidetone(hid_device *device_handle, uint8_t num)

return ret;
}

static int arctis7_request_battery(hid_device *device_handle)
{

int r = 0;

// request battery status
unsigned char data_request[2] = {0x06, 0x18};

r = hid_write(device_handle, data_request, 2);

if (r < 0) return r;

// read battery status
unsigned char data_read[8];

r = hid_read(device_handle, data_read, 8);

if (r < 0) return r;

int bat = data_read[2];

if (bat > 100) return 100;

return bat;
}
85 changes: 85 additions & 0 deletions src/devices/steelseries_arctis7_2019.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include "../device.h"
#include "../utility.h"

#include <hidapi.h>
#include <string.h>
#include <stdlib.h>

static struct device device_arctis7_2019;

static int arctis7_2019_send_sidetone(hid_device *device_handle, uint8_t num);
static int arctis7_2019_request_battery(hid_device *device_handle);

void arctis7_2019_init(struct device** device)
{
device_arctis7_2019.idVendor = VENDOR_STEELSERIES;
device_arctis7_2019.idProduct = 0x12ad;
device_arctis7_2019.idInterface = 0x05;

strcpy(device_arctis7_2019.device_name, "SteelSeries Arctis 7");

device_arctis7_2019.capabilities = CAP_SIDETONE | CAP_BATTERY_STATUS;
device_arctis7_2019.send_sidetone = &arctis7_2019_send_sidetone;
device_arctis7_2019.request_battery = &arctis7_2019_request_battery;

*device = &device_arctis7_2019;
}

static int arctis7_2019_send_sidetone(hid_device *device_handle, uint8_t num)
{
int ret = -1;

// the range of the Arctis 7 seems to be from 0 to 0x12 (18)
num = map(num, 0, 128, 0x00, 0x12);

unsigned char *buf = calloc(31, 1);

if (!buf)
{
return ret;
}

const unsigned char data_on[5] = {0x06, 0x35, 0x01, 0x00, num};
const unsigned char data_off[2] = {0x06, 0x35};

if (num)
{
memmove(buf, data_on, sizeof(data_on));
}
else
{
memmove(buf, data_off, sizeof(data_off));
}

ret = hid_write(device_handle, buf, 31);

SAFE_FREE(buf);

return ret;
}

static int arctis7_2019_request_battery(hid_device *device_handle)
{

int r = 0;

// request battery status
unsigned char data_request[2] = {0x06, 0x18};

r = hid_write(device_handle, data_request, 2);

if (r < 0) return r;

// read battery status
unsigned char data_read[8];

r = hid_read(device_handle, data_read, 8);

if (r < 0) return r;

int bat = data_read[2];

if (bat > 100) return 100;

return bat;
}
3 changes: 3 additions & 0 deletions src/devices/steelseries_arctis7_2019.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void arctis7_2019_init(struct device** device);
1 change: 1 addition & 0 deletions udev/50-steelseries-arctis-7-2019.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1038", ATTRS{idProduct}=="12ad", MODE="0666"
2 changes: 1 addition & 1 deletion udev/50-steelseries-arctis-7.rules
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SUBSYSTEM=="hidraw", SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1260", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1038", ATTRS{idProduct}=="1260", MODE="0666"

0 comments on commit 1dbc9ef

Please sign in to comment.