1
0
forked from drath/libratbag

sinowealth: store firmware version in device files in the group name

It only makes sense, since it's what the section are identified by.
This commit is contained in:
Yaroslav Chvanov
2023-03-19 02:30:07 +03:00
parent 44279ddda3
commit 87f6e521e6
11 changed files with 30 additions and 35 deletions

View File

@@ -77,7 +77,10 @@ DpiRange=100:16000@100
# Device quirks
# Quirk=DOUBLE_DPI;STRIX_PROFILE
[Driver/sinowealth/devices/ADeviceNameWithoutSpaces]
# Replace `FEED` in the group name with firmware version of the device.
# To find the right value, see the output of ratbagd and search a message like:
# "ratbag error: Device with firmware version FEED is not supported"
[Driver/sinowealth/devices/FEED]
# Number of buttons.
# Default to 0.
Buttons=6
@@ -85,13 +88,6 @@ Buttons=6
# Device name
DeviceName=CoolVendor CoolMouse
# Firmware version of the device.
# This field is used for determining the mouse in the list.
# If not specified, the entry will be ignored.
# To find the right value, see the output of ratbagd and search a message like:
# "ratbag error: Device with firmware version XXX is not supported"
FwVersion=FEED
# The order of LED pins on the mouse.
# Change this to `RBG` if LED colors are weird.
# Use `None` if there are no LEDs on the mouse.

View File

@@ -4,9 +4,8 @@ DeviceMatch=usb:258a:0033
DeviceType=mouse
Driver=sinowealth
[Driver/sinowealth/devices/GloriousModelD]
[Driver/sinowealth/devices/V102]
Buttons=6
DeviceName=Glorious Model D
FwVersion=V102
LedType=RBG
SensorType=PMW3360

View File

@@ -4,9 +4,8 @@ DeviceMatch=usb:258a:0036
DeviceType=mouse
Driver=sinowealth
[Driver/sinowealth/devices/GloriousModelO]
[Driver/sinowealth/devices/V103]
Buttons=6
DeviceName=Glorious Model O/O- (updated firmware)
FwVersion=V103
LedType=RBG
SensorType=PMW3360

View File

@@ -4,36 +4,32 @@ DeviceType=mouse
Driver=sinowealth
Name=SinoWealth Generic Mouse (0027)
[Driver/sinowealth/devices/DreamMachinesDM5Blink]
[Driver/sinowealth/devices/3106]
Buttons=8
DeviceName=DreamMachines DM5 Blink
FwVersion=3106
LedType=RGB
SensorType=PMW3389
[Driver/sinowealth/devices/GWolvesHatiHTM]
[Driver/sinowealth/devices/V161]
Buttons=6
# Can be both `Ace` and `Classic` version.
DeviceName=G-Wolves Hati HT-M Wired
FwVersion=V161
LedType=None
# Can also be PMW3389
SensorType=PMW3360
[Driver/sinowealth/devices/GenesysXenon770]
[Driver/sinowealth/devices/3110]
# There are 5 main buttons.
# Side buttons are detachable.
# There can be either 3 or 9 buttons on the side.
# Going for the maximum count: 5 + 9 = 14.
Buttons=14
DeviceName=Genesys Xenon 770
FwVersion=3110
LedType=RGB
SensorType=PMW3327
[Driver/sinowealth/devices/GloriousModelOOld]
[Driver/sinowealth/devices/V102]
Buttons=6
DeviceName=Glorious Model O (old firmware)
FwVersion=V102
LedType=RBG
SensorType=PMW3360

View File

@@ -6,9 +6,8 @@ Name=SinoWealth Generic Mouse (0029)
# Configuration data size: 131 bytes.
# https://github.com/libratbag/libratbag/issues/1361
[Driver/sinowealth/devices/MachenikeM620]
[Driver/sinowealth/devices/V127]
Buttons=6
DeviceName=Machenike M620
FwVersion=V127
LedType=RGB
SensorType=PMW3389

View File

@@ -6,10 +6,9 @@ Name=Sinowealth Generic Mouse (0051)
# Configuration data size: 123 bytes.
# https://github.com/libratbag/libratbag/issues/1444.
[Driver/sinowealth/devices/TDaggerImperialTTGM310]
[Driver/sinowealth/devices/2642]
Buttons=8
DeviceName=T-Dagger Imperial T-TGM310
FwVersion=2642
LedType=RGB
Profiles=2
SensorType=PMW3212

View File

@@ -6,18 +6,16 @@ Name=SinoWealth Generic Mouse (1007)
# This does NOT work. See libratbag/libratbag#1296.
# For future: ID of A3050 sensor is 0x2, and maximum DPI is 4000.
#[Driver/sinowealth/devices/AntEsportsGM500]
#[Driver/sinowealth/devices/0910]
#Buttons=7
#DeviceName=Ant Esports GM500
#FwVersion=0910
#LedType=RBG
#SensorType=A3050
# Configuration size: 123 bytes.
# https://github.com/libratbag/libratbag/issues/1091
[Driver/sinowealth/devices/MarvoScorpionG961]
[Driver/sinowealth/devices/9677]
Buttons=6
DeviceName=Marvo Scorpion G961
FwVersion=9677
LedType=RGB
SensorType=PMW3327

View File

@@ -117,8 +117,6 @@ _Static_assert(SINOWEALTH_NUM_PROFILES_MAX <= 3, "Too many profiles enabled");
/* Maximum amount of real events in a macro. */
#define SINOWEALTH_MACRO_LENGTH_MAX 168
#define SINOWEALTH_FW_VERSION_LEN 4
static const unsigned int SINOWEALTH_DEBOUNCE_TIMES[] = {
4, 6, 8, 10, 12, 14, 16
};

View File

@@ -25,6 +25,8 @@
#include "libratbag-util.h"
#define SINOWEALTH_FW_VERSION_LEN 4
enum sinowealth_led_format {
SINOWEALTH_LED_TYPE_NONE,
SINOWEALTH_LED_TYPE_RBG,

View File

@@ -243,11 +243,21 @@ init_data_sinowealth(struct ratbag *ratbag,
for (size_t i = 0; i < group_count; ++i) {
const char *device_group = groups[i];
if (startswith(device_group, devices_group) == NULL)
const char* fw_version = startswith(device_group, devices_group);
if (fw_version == NULL)
continue;
rc = (int)strlen(fw_version);
if (rc != SINOWEALTH_FW_VERSION_LEN) {
log_error(ratbag,
"Group '%s': incorrect firmware version string length `%d` (must be `%d`)\n",
device_group, rc, SINOWEALTH_FW_VERSION_LEN);
continue;
}
struct sinowealth_device_data *device = zalloc(sizeof(struct sinowealth_device_data));
device->fw_version = strdup_safe(fw_version);
rc = g_key_file_get_integer(keyfile, device_group, "Buttons", &error);
if (rc != 0 && !error) {
device->button_count = rc;
@@ -259,9 +269,6 @@ init_data_sinowealth(struct ratbag *ratbag,
device->device_name = g_key_file_get_string(keyfile, device_group, "DeviceName", &error);
g_clear_error(&error);
device->fw_version = g_key_file_get_string(keyfile, device_group, "FwVersion", &error);
g_clear_error(&error);
_cleanup_free_ char *led_type_str = g_key_file_get_string(keyfile, device_group, "LedType", &error);
if (led_type_str) {
if (streq(led_type_str, "RGB")) {

View File

@@ -275,10 +275,10 @@ def validate_data_file_name(path: str):
)
SINOWEALTH_FW_VERSION_LEN = 4
SINOWEALTH_DEVICE_SECTION_PREFIX = "Driver/sinowealth/devices/"
SINOWEALTH_REQUIRED_KEYS = (
"DeviceName",
"FwVersion",
"LedType",
)
SINOWEALTH_PERMITTED_KEYS = (
@@ -310,6 +310,8 @@ def parse_data_file(path: str):
for device_section_name in data.sections():
if not device_section_name.startswith(SINOWEALTH_DEVICE_SECTION_PREFIX):
continue
fw_version = device_section_name[len(SINOWEALTH_DEVICE_SECTION_PREFIX) :]
assert len(fw_version) == SINOWEALTH_FW_VERSION_LEN
device_section = data[device_section_name]
for key in SINOWEALTH_REQUIRED_KEYS: