Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/device_registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
#include "devices/logitech_gpro.h"
#include "devices/logitech_zone_wired.h"
#include "devices/roccat_elo_7_1_air.h"
#include "devices/roccat_elo_7_1_usb.h"
#include "devices/steelseries_arctis_1.h"
#include "devices/steelseries_arctis_7.h"
#include "devices/steelseries_arctis_9.h"
#include "devices/steelseries_arctis_pro_wireless.h"

#include <string.h>

#define NUMDEVICES 13
#define NUMDEVICES 14

// array of pointers to device
static struct device*(devicelist[NUMDEVICES]);
Expand All @@ -36,6 +37,7 @@ void init_devices()
zone_wired_init(&devicelist[10]);
elo71Air_init(&devicelist[11]);
g432_init(&devicelist[12]);
elo71USB_init(&devicelist[13]);
}

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 @@ -19,6 +19,8 @@ set(SOURCE_FILES ${SOURCE_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/steelseries_arctis_pro_wireless.h
${CMAKE_CURRENT_SOURCE_DIR}/roccat_elo_7_1_air.h
${CMAKE_CURRENT_SOURCE_DIR}/roccat_elo_7_1_air.c
${CMAKE_CURRENT_SOURCE_DIR}/roccat_elo_7_1_usb.h
${CMAKE_CURRENT_SOURCE_DIR}/roccat_elo_7_1_usb.c
${CMAKE_CURRENT_SOURCE_DIR}/logitech_g633_g933_935.c
${CMAKE_CURRENT_SOURCE_DIR}/logitech_g633_g933_935.h
${CMAKE_CURRENT_SOURCE_DIR}/logitech_gpro.c
Expand Down
92 changes: 92 additions & 0 deletions src/devices/roccat_elo_7_1_usb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include "../device.h"

#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

static struct device device_elo71USB;

static const uint16_t PRODUCT_ID = 0x3a34;

static int elo71USB_switch_lights(hid_device* hid_device, uint8_t on);

void elo71USB_init(struct device** device)
{
device_elo71USB.idVendor = VENDOR_ROCCAT;
device_elo71USB.idProductsSupported = &PRODUCT_ID;
device_elo71USB.numIdProducts = 1;
device_elo71USB.idInterface = 0;

strncpy(device_elo71USB.device_name, "ROCCAT Elo 7.1 USB", sizeof(device_elo71USB.device_name));

device_elo71USB.capabilities = CAP_LIGHTS;
device_elo71USB.switch_lights = &elo71USB_switch_lights;

*device = &device_elo71USB;
}

/*
* Sends size bytes from data to the headset.
* If out_buffer points to 64 byte of preallocated memory, send_receive will
* receive 64 byte into id over the HID stream.
*
* The Roccat Elo 71 Air hates, if it gets 64 bytes blocks to quickly. The
* windows software seems just to wait a bit, so send_receive does as well. :-/
*
* This function returns the code from hid_read or hid_write, if either no read
* was requested or hid_write already failed.
*/
static int send_receive(hid_device* hid_device, const uint8_t* data,
int size, uint8_t* out_buffer)
{
struct timespec ts;
int r;

r = hid_write(hid_device, data, size);

if ((out_buffer != NULL) && (r >= 0)) {
r = hid_read(hid_device, out_buffer, 16);
}

ts.tv_sec = 0;
ts.tv_nsec = 40 * 1000000;
nanosleep(&ts, NULL);

return r;
}

static int elo71USB_switch_lights(hid_device* hid_device, uint8_t on)
{
uint8_t cmd92[16] = { 0xff, 0x02 };
uint8_t cmd93[16] = { 0xff, 0x03, 0x00, 0x01 };
uint8_t cmd94[16] = { 0xff, 0x04, 0x00, 0x00, 0xf4 };
uint8_t cmd95[16] = { 0xff, 0x01 };
uint8_t cmd97[16] = { 0xff, 0x04 };

int r;

r = send_receive(hid_device, cmd92, sizeof(cmd92), NULL);
if (r <= 0)
return r;

r = send_receive(hid_device, cmd93, sizeof(cmd93), NULL);
if (r <= 0)
return r;

if (on == 1) {
r = send_receive(hid_device, cmd94, sizeof(cmd94), NULL);
if (r <= 0)
return r;
} else {
r = send_receive(hid_device, cmd97, sizeof(cmd97), NULL);
if (r <= 0)
return r;
}

r = send_receive(hid_device, cmd95, sizeof(cmd95), NULL);
if (r <= 0)
return r;

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

void elo71USB_init(struct device** device);