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

Add sidetone support for Logitech Zone Wired headset #140

Merged
merged 1 commit into from
Mar 10, 2021
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 @@ -6,14 +6,15 @@
#include "devices/logitech_g633_g933_935.h"
#include "devices/logitech_g930.h"
#include "devices/logitech_gpro.h"
#include "devices/logitech_zone_wired.h"
#include "devices/steelseries_arctis_1.h"
#include "devices/steelseries_arctis_1_xbox.h"
#include "devices/steelseries_arctis_7.h"
#include "devices/steelseries_arctis_9.h"

#include <string.h>

#define NUMDEVICES 10
#define NUMDEVICES 11

// array of pointers to device
static struct device*(devicelist[NUMDEVICES]);
Expand All @@ -30,6 +31,7 @@ void init_devices()
arctis_9_init(&devicelist[7]);
gpro_init(&devicelist[8]);
arctis_1_xbox_init(&devicelist[9]);
zone_wired_init(&devicelist[10]);
}

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,4 +19,6 @@ set(SOURCE_FILES ${SOURCE_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/logitech_g633_g933_935.h
${CMAKE_CURRENT_SOURCE_DIR}/logitech_gpro.c
${CMAKE_CURRENT_SOURCE_DIR}/logitech_gpro.h
${CMAKE_CURRENT_SOURCE_DIR}/logitech_zone_wired.c
${CMAKE_CURRENT_SOURCE_DIR}/logitech_zone_wired.h
PARENT_SCOPE)
42 changes: 42 additions & 0 deletions src/devices/logitech_zone_wired.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "../device.h"
#include "../utility.h"
#include "logitech.h"

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

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

#define MSG_SIZE 20

static struct device device_zone_wired;

static const uint16_t PRODUCT_ID = 0x0aad;

static int zone_wired_send_sidetone(hid_device* device_handle, uint8_t num);

void zone_wired_init(struct device** device)
{
device_zone_wired.idVendor = VENDOR_LOGITECH;
device_zone_wired.idProductsSupported = &PRODUCT_ID;
device_zone_wired.numIdProducts = 1;
device_zone_wired.idUsage = 0x0;

strncpy(device_zone_wired.device_name, "Logitech Zone Wired", sizeof(device_zone_wired.device_name));

device_zone_wired.capabilities = CAP_SIDETONE;
device_zone_wired.send_sidetone = &zone_wired_send_sidetone;

*device = &device_zone_wired;
}

static int zone_wired_send_sidetone(hid_device* device_handle, uint8_t num)
{
// The sidetone volume of the Zone Wired is configured in steps of 10%, with 0x00 = 0% and 0x0A = 100%
uint8_t raw_volume = map(num, 0, 128, 0, 10);
uint8_t data[MSG_SIZE] = { 0x22, 0xF1, 0x04, 0x00, 0x04, 0x3d, raw_volume, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

return hid_send_feature_report(device_handle, data, MSG_SIZE);
}
3 changes: 3 additions & 0 deletions src/devices/logitech_zone_wired.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void zone_wired_init(struct device** device);
3 changes: 3 additions & 0 deletions udev/70-headsets.rules
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="046d", ATTRS{idProduct
# logitech G PRO
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="0aa7", TAG+="uaccess"

# logitech Zone Wired
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="0aad", TAG+="uaccess"

# SteelSeries ARCTIS 1
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1038", ATTRS{idProduct}=="12b3", TAG+="uaccess"

Expand Down