From 2485c24560d54b9908e921e35994c8e22affe178 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 8 May 2022 22:35:09 +1000 Subject: [PATCH] Adding `DUMMY_DEVICE_DETECTORS` to supplement dynamic UDEV rules * USB devices that are **not** registering a detector that includes the VID and PID will need to specify these details separately to be added to the UDEV rules at compile time * Resolves #2440 --- .../BlinkyTapeControllerDetect.cpp | 5 +++++ .../CorsairHydroControllerDetect.cpp | 9 ++++++++- .../DygmaRaiseControllerDetect.cpp | 5 +++++ .../LianLiController/LianLiControllerDetect.cpp | 5 +++++ .../NZXTHuePlusControllerDetect.cpp | 5 +++++ scripts/build-udev-rules.sh | 10 +++++++--- 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Controllers/BlinkyTapeController/BlinkyTapeControllerDetect.cpp b/Controllers/BlinkyTapeController/BlinkyTapeControllerDetect.cpp index 2cc5a5d0..5c8f6b56 100644 --- a/Controllers/BlinkyTapeController/BlinkyTapeControllerDetect.cpp +++ b/Controllers/BlinkyTapeController/BlinkyTapeControllerDetect.cpp @@ -34,3 +34,8 @@ void DetectBlinkyTapeControllers(std::vector &rgb_controllers) } REGISTER_DETECTOR("BlinkyTape", DetectBlinkyTapeControllers); +/*---------------------------------------------------------------------------------------------------------*\ +| Entries for dynamic UDEV rules | +| | +| DUMMY_DEVICE_DETECTOR("BlinkyTape", DetectBlinkyTapeControllers, 0x1D50, 0x605E ) | +\*---------------------------------------------------------------------------------------------------------*/ diff --git a/Controllers/CorsairHydroController/CorsairHydroControllerDetect.cpp b/Controllers/CorsairHydroController/CorsairHydroControllerDetect.cpp index 08b31e03..f76282e9 100644 --- a/Controllers/CorsairHydroController/CorsairHydroControllerDetect.cpp +++ b/Controllers/CorsairHydroController/CorsairHydroControllerDetect.cpp @@ -71,10 +71,17 @@ void DetectCorsairHydroControllers(std::vector& rgb_controllers) RGBController_CorsairHydro* rgb_controller = new RGBController_CorsairHydro(controller); rgb_controller->name = device_list[device_idx].name; - + rgb_controllers.push_back(rgb_controller); } } } /* DetectCorsairHydroControllers() */ REGISTER_DETECTOR("Corsair Hydro Series", DetectCorsairHydroControllers); +/*---------------------------------------------------------------------------------------------------------*\ +| Entries for dynamic UDEV rules | +| | +| DUMMY_DEVICE_DETECTOR("Corsair Hydro Series", DetectCorsairHydroControllers, 0x1B1C, x0C12 ) | +| DUMMY_DEVICE_DETECTOR("Corsair Hydro Series", DetectCorsairHydroControllers, 0x1B1C, x0C13 ) | +| DUMMY_DEVICE_DETECTOR("Corsair Hydro Series", DetectCorsairHydroControllers, 0x1B1C, x0C15 ) | +\*---------------------------------------------------------------------------------------------------------*/ diff --git a/Controllers/DygmaRaiseController/DygmaRaiseControllerDetect.cpp b/Controllers/DygmaRaiseController/DygmaRaiseControllerDetect.cpp index ff3701c1..840a29f2 100644 --- a/Controllers/DygmaRaiseController/DygmaRaiseControllerDetect.cpp +++ b/Controllers/DygmaRaiseController/DygmaRaiseControllerDetect.cpp @@ -37,3 +37,8 @@ void DetectDygmaRaiseControllers(std::vector &rgb_controllers) } REGISTER_DETECTOR("Dygma Raise", DetectDygmaRaiseControllers); +/*---------------------------------------------------------------------------------------------------------*\ +| Entries for dynamic UDEV rules | +| | +| DUMMY_DEVICE_DETECTOR("Dygma Raise", DetectDygmaRaiseControllers, 0x1209, 0x2201 ) | +\*---------------------------------------------------------------------------------------------------------*/ diff --git a/Controllers/LianLiController/LianLiControllerDetect.cpp b/Controllers/LianLiController/LianLiControllerDetect.cpp index 941f3f3d..eb2cb2d7 100644 --- a/Controllers/LianLiController/LianLiControllerDetect.cpp +++ b/Controllers/LianLiController/LianLiControllerDetect.cpp @@ -77,3 +77,8 @@ void DetectLianLiUniHub(std::vector&) } REGISTER_DETECTOR("Lian Li Uni Hub", DetectLianLiUniHub); +/*---------------------------------------------------------------------------------------------------------*\ +| Entries for dynamic UDEV rules | +| | +| DUMMY_DEVICE_DETECTOR("Lian Li Uni Hub", DetectLianLiUniHub, 0x0CF2, 0x7750 ) | +\*---------------------------------------------------------------------------------------------------------*/ diff --git a/Controllers/NZXTHuePlusController/NZXTHuePlusControllerDetect.cpp b/Controllers/NZXTHuePlusController/NZXTHuePlusControllerDetect.cpp index acab5efc..7b821b80 100644 --- a/Controllers/NZXTHuePlusController/NZXTHuePlusControllerDetect.cpp +++ b/Controllers/NZXTHuePlusController/NZXTHuePlusControllerDetect.cpp @@ -34,3 +34,8 @@ void DetectNZXTHuePlusControllers(std::vector &rgb_controllers) } /* DetectHuePlusControllers() */ REGISTER_DETECTOR("NZXT Hue+", DetectNZXTHuePlusControllers); +/*---------------------------------------------------------------------------------------------------------*\ +| Entries for dynamic UDEV rules | +| | +| DUMMY_DEVICE_DETECTOR("NZXT Hue+", DetectNZXTHuePlusControllers, 0x04D8, 0x00DF ) | +\*---------------------------------------------------------------------------------------------------------*/ diff --git a/scripts/build-udev-rules.sh b/scripts/build-udev-rules.sh index ce856e21..cdd2da91 100755 --- a/scripts/build-udev-rules.sh +++ b/scripts/build-udev-rules.sh @@ -38,9 +38,10 @@ echo -e "$UDEV_HEADER" > "$UDEV_FILE" #-----------------------------------------------------------------------------# echo -e "Creating device list" HID_LIST=$(grep -hR -e "static\ HIDDeviceDetector" . | 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 "|" }') #Check the output of the hid_list -# echo -e "$HID_LIST" >> "hid_list.txt" +# echo -e "$HID_LIST\n$DUMMY_LIST" >> "hid_list.txt" #-----------------------------------------------------------------------------# # Create a list of RGBController.cpp classes including path # @@ -68,7 +69,7 @@ do while read -r detector do #Filter the list for all devices that use this detector - text=$(printf %s "$HID_LIST" | grep ${detector} | cut -d: -f 2- | sed -e 's/"//g') + text=$(printf '%s\n%s' "$HID_LIST" "$DUMMY_LIST" | grep ${detector} | cut -d: -f 2- | sed -e 's/"//g') #Replace the detector string with the list of devices detectors=${detectors/${detector}/${text}} @@ -88,7 +89,7 @@ do #Check to ensure that the vid and pid are not blank if [[ $vid = "" || $pid = "" ]]; then - echo -e "Blank VID or PID Skipping: ${udev_line}" + echo -e "Blank VID or PID Skipping: ${name} ${detector} ${udev_line}" else echo -e "$udev_line" >>"$UDEV_FILE" fi @@ -100,6 +101,9 @@ done <<< "$FILE_LIST" if [ -f "$UDEV_FILE" ]; then outpath=$(readlink -f "$UDEV_FILE") echo -e "Udev rules built at: $outpath" + + #Clean up the preprocessor files if the rules file was created successfully + rm *.{ii,s} else echo -e "Something went wrong. No Udev file was found" fi