mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-20 13:57:26 -04:00
Move HID detector calls to RunHIDDetector/RunHIDWrappedDetector functions and return controller list from detector functions
This commit is contained in:
@@ -20,19 +20,20 @@
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for Crucial RAM |
|
||||
\*----------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for |
|
||||
| Crucial RAM |
|
||||
\*---------------------------------------------------------*/
|
||||
#define CRUCIAL_ADDRESS_COUNT 8
|
||||
|
||||
static const unsigned char crucial_addresses[] =
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| These addresses have been disabled due to conflict |
|
||||
| with ASUS Aura DRAM. Since the detection scheme is |
|
||||
| the same, Aura RAM will be detected as Crucial. |
|
||||
| We need to improve the Crucial detection scheme. |
|
||||
\*-----------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| These addresses have been disabled due to conflict with |
|
||||
| ENE DRAM. Since the detection scheme is the same, ENE |
|
||||
| RAM will be detected as Crucial. We need to improve the |
|
||||
| Crucial detection scheme. |
|
||||
\*---------------------------------------------------------*/
|
||||
0x39,
|
||||
0x3A,
|
||||
0x3B,
|
||||
@@ -57,16 +58,6 @@ std::string concatHexArray(const unsigned char array[], int count, const char sp
|
||||
}
|
||||
#define TESTING_ADDRESSES concatHexArray(crucial_addresses, CRUCIAL_ADDRESS_COUNT, "|").c_str()
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* CrucialRegisterRead *
|
||||
* *
|
||||
* A standalone version of the AuraSMBusController::AuraRegisterRead function for *
|
||||
* access to Aura devices without instancing the AuraSMBusController class or reading *
|
||||
* the config table from the device. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
unsigned char CrucialRegisterRead(i2c_smbus_interface* bus, crucial_dev_id dev, crucial_register reg)
|
||||
{
|
||||
//Write Aura register
|
||||
@@ -76,16 +67,6 @@ unsigned char CrucialRegisterRead(i2c_smbus_interface* bus, crucial_dev_id dev,
|
||||
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCrucialController *
|
||||
* *
|
||||
* Tests the given address to see if an Crucial controller exists there. First does a*
|
||||
* quick write to test for a response, and if so does a simple read at 0xA0 to test *
|
||||
* for incrementing values 0...F which was observed at this location during data dump *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCrucialController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
@@ -145,8 +126,7 @@ bool TestForCrucialController(i2c_smbus_interface* bus, unsigned char address)
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCrucialController() */
|
||||
}
|
||||
|
||||
void CrucialRegisterWrite(i2c_smbus_interface* bus, unsigned char dev, unsigned short reg, unsigned char val)
|
||||
{
|
||||
@@ -157,19 +137,10 @@ void CrucialRegisterWrite(i2c_smbus_interface* bus, unsigned char dev, unsigned
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCrucialControllers *
|
||||
* *
|
||||
* Detect Crucial controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses)
|
||||
DetectedControllers DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses)
|
||||
{
|
||||
DetectedControllers detected_controllers;
|
||||
|
||||
for(unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
int address_list_idx = -1;
|
||||
@@ -223,7 +194,7 @@ void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses)
|
||||
CrucialController* controller = new CrucialController(busses[bus], crucial_addresses[address_list_idx]);
|
||||
RGBController_Crucial* rgb_controller = new RGBController_Crucial(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(1ms);
|
||||
@@ -231,6 +202,7 @@ void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses)
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCrucialControllers() */
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
REGISTER_I2C_DETECTOR("Crucial Ballistix", DetectCrucialControllers);
|
||||
|
||||
Reference in New Issue
Block a user