diff --git a/README.md b/README.md index 4e7b2d04..0be31f69 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ talking. This differs from a simple loopback via PulseAudio as you won't have an - Sidetone (only tested on Linux) - Logitech G533 - Sidetone, Battery (for Wireless) +- Logitech G535 + - Sidetone (only tested on Linux) - Logitech G633 / G635 / G733 / G933 / G935 - Sidetone, Battery (for Wireless), LED on/off - Logitech G930 diff --git a/src/device_registry.c b/src/device_registry.c index f1e3934e..09d2ee61 100644 --- a/src/device_registry.c +++ b/src/device_registry.c @@ -5,6 +5,7 @@ #include "devices/logitech_g430.h" #include "devices/logitech_g432.h" #include "devices/logitech_g533.h" +#include "devices/logitech_g535.h" #include "devices/logitech_g633_g933_935.h" #include "devices/logitech_g930.h" #include "devices/logitech_gpro.h" @@ -19,7 +20,7 @@ #include -#define NUMDEVICES 16 +#define NUMDEVICES 17 // array of pointers to device static struct device*(devicelist[NUMDEVICES]); @@ -42,6 +43,7 @@ void init_devices() elo71USB_init(&devicelist[13]); arctis_7_plus_init(&devicelist[14]); cflight_init(&devicelist[15]); + g535_init(&devicelist[16]); } int get_device(struct device* device_found, uint16_t idVendor, uint16_t idProduct) diff --git a/src/devices/CMakeLists.txt b/src/devices/CMakeLists.txt index 0b6222a4..410172da 100644 --- a/src/devices/CMakeLists.txt +++ b/src/devices/CMakeLists.txt @@ -11,6 +11,8 @@ set(SOURCE_FILES ${SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/logitech_g432.h ${CMAKE_CURRENT_SOURCE_DIR}/logitech_g533.c ${CMAKE_CURRENT_SOURCE_DIR}/logitech_g533.h + ${CMAKE_CURRENT_SOURCE_DIR}/logitech_g535.c + ${CMAKE_CURRENT_SOURCE_DIR}/logitech_g535.h ${CMAKE_CURRENT_SOURCE_DIR}/steelseries_arctis_1.c ${CMAKE_CURRENT_SOURCE_DIR}/steelseries_arctis_1.h ${CMAKE_CURRENT_SOURCE_DIR}/steelseries_arctis_7.c diff --git a/src/devices/logitech_g535.c b/src/devices/logitech_g535.c new file mode 100644 index 00000000..79999366 --- /dev/null +++ b/src/devices/logitech_g535.c @@ -0,0 +1,41 @@ +#include "../device.h" +#include "../utility.h" +#include "logitech.h" + +#include +#include + +#define MSG_SIZE 20 + +static struct device device_g535; + +static const uint16_t PRODUCT_ID = 0x0ac4; + +static int g535_send_sidetone(hid_device* device_handle, uint8_t num); + +void g535_init(struct device** device) +{ + device_g535.idVendor = VENDOR_LOGITECH; + device_g535.idProductsSupported = &PRODUCT_ID; + device_g535.numIdProducts = 1; + + strncpy(device_g535.device_name, "Logitech G535", sizeof(device_g535.device_name)); + + device_g535.capabilities = B(CAP_SIDETONE); + device_g535.capability_details[CAP_SIDETONE] = (struct capability_detail) { .usagepage = 0xc, .usageid = 0x1, .interface = 3 }; + device_g535.send_sidetone = &g535_send_sidetone; + + *device = &device_g535; +} + +static int g535_send_sidetone(hid_device* device_handle, uint8_t num) +{ + num = map(num, 0, 128, 0, 100); + + uint8_t set_sidetone_level[MSG_SIZE] = { 0x11, 0xff, 0x04, 0x1e, num }; + + for (int i = 16; i < MSG_SIZE; i++) + set_sidetone_level[i] = 0; + + return hid_send_feature_report(device_handle, set_sidetone_level, MSG_SIZE); +} diff --git a/src/devices/logitech_g535.h b/src/devices/logitech_g535.h new file mode 100644 index 00000000..c9c98dfe --- /dev/null +++ b/src/devices/logitech_g535.h @@ -0,0 +1,3 @@ +#pragma once + +void g535_init(struct device** device);