Updated UDEV rules script

* Improved device processing
* Updated shebang to improve compatibility
* Converted SteelSeriesControllerDetect to UNIX line endings
* Corrected hex literals in Artic and SteelSeries detection
This commit is contained in:
Chris M 2024-06-03 13:05:10 +10:00 committed by Adam Honse
parent f9c17c75c5
commit 3cf1f58f30
3 changed files with 369 additions and 368 deletions

View file

@ -47,5 +47,5 @@ REGISTER_DETECTOR("Arctic RGB controller", DetectArcticControllers);
/*---------------------------------------------------------------------------------------------------------*\
| Entries for dynamic UDEV rules |
| |
| DUMMY_DEVICE_DETECTOR("Arctic RGB controller", DetectArcticControllers, 0x1a86, 0x7523 ) |
| DUMMY_DEVICE_DETECTOR("Arctic RGB controller", DetectArcticControllers, 0x1A86, 0x7523 ) |
\*---------------------------------------------------------------------------------------------------------*/

View file

@ -36,7 +36,7 @@
#define STEELSERIES_AEROX_3_PID 0x1836
#define STEELSERIES_AEROX_9_PID 0x185A
#define STEELSERIES_RIVAL_100_PID 0x1702
#define STEELSERIES_RIVAL_100_DOTA_PID 0x170c
#define STEELSERIES_RIVAL_100_DOTA_PID 0x170C
#define STEELSERIES_RIVAL_105_PID 0x1814
#define STEELSERIES_RIVAL_106_PID 0x1816
#define STEELSERIES_RIVAL_110_PID 0x1729
@ -44,12 +44,12 @@
#define ACER_PREDATOR_RIVAL_300_PID 0x1714
#define STEELSERIES_RIVAL_300_CSGO_PID 0x1394
#define STEELSERIES_RIVAL_300_CSGO_STM32_PID 0x1716
#define STEELSERIES_RIVAL_300_CSGO_HYPERBEAST_PID 0x171a
#define STEELSERIES_RIVAL_300_CSGO_HYPERBEAST_PID 0x171A
#define STEELSERIES_RIVAL_300_DOTA_PID 0x1392
#define STEELSERIES_RIVAL_300_HP_PID 0x1718
#define STEELSERIES_RIVAL_300_BLACKOPS_PID 0x1710
#define STEELSERIES_RIVAL_310_PID 0x1720
#define STEELSERIES_RIVAL_310_CSGO_HOWL_PID 0x171e
#define STEELSERIES_RIVAL_310_CSGO_HOWL_PID 0x171E
#define STEELSERIES_RIVAL_310_PUBG_PID 0x1736
#define STEELSERIES_RIVAL_600_PID 0x1724
#define STEELSERIES_RIVAL_600_DOTA_2_PID 0x172E

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#-----------------------------------------------------------------------------#
# This script relies on the preprocessed *.ii and *.s files from #
# all "RGBController_" .cpp files and the detectors that call them #
@ -48,10 +48,11 @@ echo -e "$UDEV_HEADER" > "$UDEV_FILE"
# #
# | callback_function | VID | PID | Name | #
#-----------------------------------------------------------------------------#
DLM=$'\x01'
echo -e "Creating device list"
HID_LIST=$(grep -hR -e "static HIDDeviceDetector" . | cut -d '(' -f 2- | awk -F , '{ print $2 ":|" $3 "|" $4 "|" $1 "|" }')
HID_WRAPPER_LIST=$(grep -hR -e "static HIDWrappedDeviceDetector" . | cut -d '(' -f 2- | awk -F , '{ print $2 ":|" $3 "|" $4 "|" $1 "|" }')
DUMMY_LIST=$( grep -hR -e DUMMY_DEVICE_DETECTOR ${CONTROLLER_PATH} | cut -d '(' -f 2- | cut -d ')' -f 1 | awk -F , '{ print $2 ":|" $3 "|" $4 "|" $1 "|" }')
HID_LIST=$(grep -hR -e "static HIDDeviceDetector" . | sed -e "s/^.*\(\".*\"\), \(.*\), \([0-9ABCDEFx]*\), \([0-9ABCDEFx]*\),.*,.*,.*;$/\2${DLM}\3${DLM}\4${DLM}\1/g")
HID_WRAPPER_LIST=$(grep -hR -e "static HIDWrappedDeviceDetector" . | sed -e "s/^.*\(\".*\"\), \(.*\), \([0-9ABCDEFx]*\), \([0-9ABCDEFx]*\).*,.*,.*,.*;$/\2${DLM}\3${DLM}\4${DLM}\1/")
DUMMY_LIST=$(grep -hR -e DUMMY_DEVICE_DETECTOR\( ${CONTROLLER_PATH} | sed -e "s/^.*\(\".*\"\), \(.*\), \([0-9ABCDEFx]*\), \([0-9ABCDEFx]*\) ).*/\2${DLM}\3${DLM}\4${DLM}\1/")
#Check the output of the hid_list
# echo -e "$HID_LIST\n$DUMMY_LIST" >> "hid_list.txt"
@ -85,16 +86,16 @@ do
while read -r detector
do
#Filter the list for all devices that use this detector
text=$(printf '%s\n%s\n%s' "$HID_LIST" "$HID_WRAPPER_LIST" "$DUMMY_LIST" | grep ${detector} | cut -d: -f 2- | sed -e 's/"//g')
text=$(printf '%s\n%s\n%s' "$HID_LIST" "$HID_WRAPPER_LIST" "$DUMMY_LIST" | grep ${detector} | sed -e 's/"//g')
#Replace the detector string with the list of devices
detectors=${detectors/${detector}/${text}}
#Add a section heading for each RGBcontroller_
printf "#---------------------------------------------------------------#\n# %s - %s\n#---------------------------------------------------------------#\n" "$name" "$detector" >> "$UDEV_FILE"
printf "${UDEV_LINE}# %s - %s\n${UDEV_LINE}" "$name" "$detector" >> "$UDEV_FILE"
while read -r device
do
IFS='|' read null vid pid device_name null <<<"$device"
IFS="${DLM}" read null vid pid device_name null <<<"$device"
#Remove leading hex signifier from $vid and $pid
vid=${vid/0x/}