Move detection functions into their own files
This commit is contained in:
parent
d5a32eb743
commit
9126ded32e
7 changed files with 569 additions and 546 deletions
|
|
@ -8,12 +8,17 @@ TEMPLATE = app
|
|||
SOURCES += \
|
||||
OpenAuraSDK/i2c_smbus.cpp \
|
||||
OpenAuraSDK/AuraController.cpp \
|
||||
OpenAuraSDK/AuraControllerDetect.cpp \
|
||||
OpenAuraSDK/OpenAuraSDK.cpp \
|
||||
OpenAuraSDK/i2c_smbus_linux.cpp \
|
||||
OpenAuraSDK/OpenAuraSDKQtDialog.cpp \
|
||||
OpenAuraSDK/CorsairController.cpp \
|
||||
OpenAuraSDK/CorsairControllerDetect.cpp \
|
||||
OpenAuraSDK/CorsairProController.cpp \
|
||||
OpenAuraSDK/CorsairProControllerDetect.cpp \
|
||||
OpenAuraSDK/HyperXController.cpp \
|
||||
OpenAuraSDK/HyperXControllerDetect.cpp \
|
||||
OpenAuraSDK/OpenRazerDetect.cpp \
|
||||
OpenAuraSDK/RGBController_Aura.cpp \
|
||||
OpenAuraSDK/RGBController_Corsair.cpp \
|
||||
OpenAuraSDK/RGBController_CorsairPro.cpp \
|
||||
|
|
|
|||
125
OpenAuraSDK/AuraControllerDetect.cpp
Normal file
125
OpenAuraSDK/AuraControllerDetect.cpp
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
#include "AuraController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Aura.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForAuraController *
|
||||
* *
|
||||
* Tests the given address to see if an Aura 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 TestForAuraController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != (i - 0xA0))
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForAuraController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraControllers *
|
||||
* *
|
||||
* Detect Aura controllers on the enumerated I2C busses. Searches for Aura-enabled *
|
||||
* RAM at 0x77 and tries to initialize their slot addresses, then searches for them *
|
||||
* at their correct initialized addresses. Also looks for motherboard controller at *
|
||||
* address 0x4E. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
AuraController* new_aura;
|
||||
RGBController_Aura* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Remap Aura-enabled RAM modules on 0x77
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
int res = busses[bus]->i2c_smbus_write_quick(0x77, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
AuraController temp_controller(busses[bus], 0x77);
|
||||
|
||||
temp_controller.AuraRegisterWrite(AURA_REG_SLOT_INDEX, slot);
|
||||
temp_controller.AuraRegisterWrite(AURA_REG_I2C_ADDRESS, 0xE0 + (slot << 1));
|
||||
}
|
||||
|
||||
// Add Aura-enabled controllers at their remapped addresses
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
if (TestForAuraController(busses[bus], 0x70 + slot))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x70 + slot);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x40
|
||||
if (TestForAuraController(busses[bus], 0x40))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x40);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x4E
|
||||
if (TestForAuraController(busses[bus], 0x4E))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x4E);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x4F
|
||||
if (TestForAuraController(busses[bus], 0x4F))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x4F);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x66
|
||||
if (TestForAuraController(busses[bus], 0x66))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x66);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectAuraControllers() */
|
||||
109
OpenAuraSDK/CorsairControllerDetect.cpp
Normal file
109
OpenAuraSDK/CorsairControllerDetect.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
#include "CorsairController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Corsair.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairController *
|
||||
* *
|
||||
* Tests the given address to see if a Corsair controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCorsairController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != 0xBA)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairControllers *
|
||||
* *
|
||||
* Detect Corsair controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
CorsairController* new_corsair;
|
||||
RGBController_Corsair* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for Corsair controller at 0x58
|
||||
if (TestForCorsairController(busses[bus], 0x58))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x58);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x59
|
||||
if (TestForCorsairController(busses[bus], 0x59))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x59);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5A
|
||||
if (TestForCorsairController(busses[bus], 0x5A))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5A);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5B
|
||||
if (TestForCorsairController(busses[bus], 0x5B))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5B);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5C
|
||||
if (TestForCorsairController(busses[bus], 0x5C))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5C);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5D
|
||||
if (TestForCorsairController(busses[bus], 0x5D))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5D);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairControllers() */
|
||||
127
OpenAuraSDK/CorsairProControllerDetect.cpp
Normal file
127
OpenAuraSDK/CorsairProControllerDetect.cpp
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
#include "CorsairProController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairPro.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairProController *
|
||||
* *
|
||||
* Tests the given address to see if a Corsair Pro controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x24);
|
||||
|
||||
if (res != 0x02)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x25);
|
||||
|
||||
if (res != 0x02)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x43);
|
||||
|
||||
if (res != 0x1C)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x44);
|
||||
|
||||
if (res != 0x03)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairProController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairProControllers *
|
||||
* *
|
||||
* Detect Corsair Pro controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
CorsairProController* new_corsair_pro;
|
||||
RGBController_CorsairPro* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for Corsair controller at 0x58
|
||||
if (TestForCorsairProController(busses[bus], 0x58))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x58);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x59
|
||||
if (TestForCorsairProController(busses[bus], 0x59))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x59);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5A
|
||||
if (TestForCorsairProController(busses[bus], 0x5A))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5A);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5B
|
||||
if (TestForCorsairProController(busses[bus], 0x5B))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5B);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5C
|
||||
if (TestForCorsairProController(busses[bus], 0x5C))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5C);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5D
|
||||
if (TestForCorsairProController(busses[bus], 0x5D))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5D);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairProControllers() */
|
||||
70
OpenAuraSDK/HyperXControllerDetect.cpp
Normal file
70
OpenAuraSDK/HyperXControllerDetect.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#include "HyperXController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_HyperX.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForHyperXController *
|
||||
* *
|
||||
* Tests the given address to see if a HyperX controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForHyperXController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != i)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForHyperXController() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHyperXControllers *
|
||||
* *
|
||||
* Detect HyperX controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
HyperXController* new_hyperx;
|
||||
RGBController_HyperX* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for HyperX controller at 0x27
|
||||
if (TestForHyperXController(busses[bus], 0x27))
|
||||
{
|
||||
new_hyperx = new HyperXController(busses[bus], 0x27);
|
||||
new_controller = new RGBController_HyperX(new_hyperx);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectHyperXControllers() */
|
||||
|
|
@ -7,15 +7,7 @@
|
|||
\******************************************************************************************/
|
||||
|
||||
#include "AuraController.h"
|
||||
#include "CorsairController.h"
|
||||
#include "CorsairProController.h"
|
||||
#include "HyperXController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Aura.h"
|
||||
#include "RGBController_Corsair.h"
|
||||
#include "RGBController_CorsairPro.h"
|
||||
#include "RGBController_HyperX.h"
|
||||
#include "RGBController_OpenRazer.h"
|
||||
#include "RGBController_AorusGPU.h"
|
||||
#include "RGBController_LEDStrip.h"
|
||||
#include "i2c_smbus.h"
|
||||
|
|
@ -44,10 +36,6 @@
|
|||
|
||||
#endif /* WIN32 */
|
||||
|
||||
std::vector<AuraController*> aura_controllers;
|
||||
std::vector<CorsairController*> corsair_controllers;
|
||||
std::vector<CorsairProController*> corsair_pro_controllers;
|
||||
std::vector<HyperXController*> hyperx_controllers;
|
||||
std::vector<i2c_smbus_interface*> busses;
|
||||
std::vector<RGBController*> rgb_controllers;
|
||||
|
||||
|
|
@ -333,507 +321,6 @@ void DetectI2CBusses()
|
|||
|
||||
#endif /* WIN32 */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForAuraController *
|
||||
* *
|
||||
* Tests the given address to see if an Aura 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 TestForAuraController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != (i - 0xA0))
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForAuraController() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairController *
|
||||
* *
|
||||
* Tests the given address to see if a Corsair controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCorsairController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != 0xBA)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairController() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairProController *
|
||||
* *
|
||||
* Tests the given address to see if a Corsair Pro controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x24);
|
||||
|
||||
if (res != 0x02)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x25);
|
||||
|
||||
if (res != 0x02)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x43);
|
||||
|
||||
if (res != 0x1C)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x44);
|
||||
|
||||
if (res != 0x03)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairProController() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForHyperXController *
|
||||
* *
|
||||
* Tests the given address to see if a HyperX controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForHyperXController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != i)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForHyperXController() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraControllers *
|
||||
* *
|
||||
* Detect Aura controllers on the enumerated I2C busses. Searches for Aura-enabled *
|
||||
* RAM at 0x77 and tries to initialize their slot addresses, then searches for them *
|
||||
* at their correct initialized addresses. Also looks for motherboard controller at *
|
||||
* address 0x4E. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraControllers()
|
||||
{
|
||||
AuraController* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Remap Aura-enabled RAM modules on 0x77
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
int res = busses[bus]->i2c_smbus_write_quick(0x77, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
AuraController temp_controller(busses[bus], 0x77);
|
||||
|
||||
temp_controller.AuraRegisterWrite(AURA_REG_SLOT_INDEX, slot);
|
||||
temp_controller.AuraRegisterWrite(AURA_REG_I2C_ADDRESS, 0xE0 + (slot << 1));
|
||||
}
|
||||
|
||||
// Add Aura-enabled controllers at their remapped addresses
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
if (TestForAuraController(busses[bus], 0x70 + slot))
|
||||
{
|
||||
new_controller = new AuraController(busses[bus], 0x70 + slot);
|
||||
aura_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x40
|
||||
if (TestForAuraController(busses[bus], 0x40))
|
||||
{
|
||||
new_controller = new AuraController(busses[bus], 0x40);
|
||||
aura_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x4E
|
||||
if (TestForAuraController(busses[bus], 0x4E))
|
||||
{
|
||||
new_controller = new AuraController(busses[bus], 0x4E);
|
||||
aura_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x4F
|
||||
if (TestForAuraController(busses[bus], 0x4F))
|
||||
{
|
||||
new_controller = new AuraController(busses[bus], 0x4F);
|
||||
aura_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x66
|
||||
if (TestForAuraController(busses[bus], 0x66))
|
||||
{
|
||||
new_controller = new AuraController(busses[bus], 0x66);
|
||||
aura_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectAuraControllers() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairControllers *
|
||||
* *
|
||||
* Detect Corsair controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairControllers()
|
||||
{
|
||||
CorsairController* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for Corsair controller at 0x58
|
||||
if (TestForCorsairController(busses[bus], 0x58))
|
||||
{
|
||||
new_controller = new CorsairController(busses[bus], 0x58);
|
||||
corsair_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x59
|
||||
if (TestForCorsairController(busses[bus], 0x59))
|
||||
{
|
||||
new_controller = new CorsairController(busses[bus], 0x59);
|
||||
corsair_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5A
|
||||
if (TestForCorsairController(busses[bus], 0x5A))
|
||||
{
|
||||
new_controller = new CorsairController(busses[bus], 0x5A);
|
||||
corsair_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5B
|
||||
if (TestForCorsairController(busses[bus], 0x5B))
|
||||
{
|
||||
new_controller = new CorsairController(busses[bus], 0x5B);
|
||||
corsair_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5C
|
||||
if (TestForCorsairController(busses[bus], 0x5C))
|
||||
{
|
||||
new_controller = new CorsairController(busses[bus], 0x5C);
|
||||
corsair_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5D
|
||||
if (TestForCorsairController(busses[bus], 0x5D))
|
||||
{
|
||||
new_controller = new CorsairController(busses[bus], 0x5D);
|
||||
corsair_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairControllers() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairProControllers *
|
||||
* *
|
||||
* Detect Corsair Pro controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairProControllers()
|
||||
{
|
||||
CorsairProController* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for Corsair controller at 0x58
|
||||
if (TestForCorsairProController(busses[bus], 0x58))
|
||||
{
|
||||
new_controller = new CorsairProController(busses[bus], 0x58);
|
||||
corsair_pro_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x59
|
||||
if (TestForCorsairProController(busses[bus], 0x59))
|
||||
{
|
||||
new_controller = new CorsairProController(busses[bus], 0x59);
|
||||
corsair_pro_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5A
|
||||
if (TestForCorsairProController(busses[bus], 0x5A))
|
||||
{
|
||||
new_controller = new CorsairProController(busses[bus], 0x5A);
|
||||
corsair_pro_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5B
|
||||
if (TestForCorsairProController(busses[bus], 0x5B))
|
||||
{
|
||||
new_controller = new CorsairProController(busses[bus], 0x5B);
|
||||
corsair_pro_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5C
|
||||
if (TestForCorsairProController(busses[bus], 0x5C))
|
||||
{
|
||||
new_controller = new CorsairProController(busses[bus], 0x5C);
|
||||
corsair_pro_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5D
|
||||
if (TestForCorsairProController(busses[bus], 0x5D))
|
||||
{
|
||||
new_controller = new CorsairProController(busses[bus], 0x5D);
|
||||
corsair_pro_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairProControllers() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHyperXControllers *
|
||||
* *
|
||||
* Detect HyperX controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHyperXControllers()
|
||||
{
|
||||
HyperXController* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for HyperX controller at 0x27
|
||||
if (TestForHyperXController(busses[bus], 0x27))
|
||||
{
|
||||
new_controller = new HyperXController(busses[bus], 0x27);
|
||||
hyperx_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectHyperXControllers() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectOpenRazerControllers *
|
||||
* *
|
||||
* Detect devices supported by the OpenRazer kernel drivers *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectOpenRazerControllers()
|
||||
{
|
||||
char driver_path[512];
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
int test_fd;
|
||||
bool done = false;
|
||||
int driver_to_read = 0;
|
||||
|
||||
while(driver_to_read < 7)
|
||||
{
|
||||
switch(driver_to_read)
|
||||
{
|
||||
case 0:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerkbd/");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razermouse/");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerfirefly/");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razermug/");
|
||||
break;
|
||||
|
||||
case 4:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razercore/");
|
||||
break;
|
||||
|
||||
case 5:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerkraken/");
|
||||
break;
|
||||
|
||||
case 6:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razermousemat/");
|
||||
break;
|
||||
}
|
||||
|
||||
done = false;
|
||||
|
||||
dir = opendir(driver_path);
|
||||
|
||||
if(dir == NULL)
|
||||
{
|
||||
closedir(dir);
|
||||
|
||||
driver_to_read++;
|
||||
continue;
|
||||
}
|
||||
|
||||
ent = readdir(dir);
|
||||
|
||||
while(ent != NULL)
|
||||
{
|
||||
if(ent->d_type == DT_DIR || ent->d_type == DT_LNK)
|
||||
{
|
||||
if(!strcmp(ent->d_name, "."))
|
||||
{
|
||||
if(done == false)
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(!strcmp(ent->d_name, "..") || !strcmp(ent->d_name, "module"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
int device_type;
|
||||
char device_string[1024];
|
||||
strcpy(device_string, driver_path);
|
||||
strcat(device_string, ent->d_name);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(device_string);
|
||||
|
||||
if(razer_rgb->device != RGBController_OpenRazer::RAZER_NO_DEVICE)
|
||||
{
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete razer_rgb;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ent = readdir(dir);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
driver_to_read++;
|
||||
}
|
||||
|
||||
} /* DetectOpenRazerControllers() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
|
|
@ -946,6 +433,11 @@ void DumpAuraRegisters(AuraController * controller)
|
|||
|
||||
} /* DumpAuraRegisters() */
|
||||
|
||||
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
|
|
@ -959,41 +451,13 @@ void DetectRGBControllers(void)
|
|||
{
|
||||
DetectI2CBusses();
|
||||
|
||||
DetectAuraControllers();
|
||||
DetectCorsairControllers();
|
||||
DetectCorsairProControllers();
|
||||
DetectHyperXControllers();
|
||||
|
||||
for (int i = 0; i < aura_controllers.size(); i++)
|
||||
{
|
||||
RGBController_Aura* aura_rgb = new RGBController_Aura(aura_controllers[i]);
|
||||
|
||||
rgb_controllers.push_back(aura_rgb);
|
||||
}
|
||||
|
||||
for (int i = 0; i < corsair_controllers.size(); i++)
|
||||
{
|
||||
RGBController_Corsair* corsair_rgb = new RGBController_Corsair(corsair_controllers[i]);
|
||||
|
||||
rgb_controllers.push_back(corsair_rgb);
|
||||
}
|
||||
|
||||
for (int i = 0; i < corsair_pro_controllers.size(); i++)
|
||||
{
|
||||
RGBController_CorsairPro* corsair_rgb = new RGBController_CorsairPro(corsair_pro_controllers[i]);
|
||||
|
||||
rgb_controllers.push_back(corsair_rgb);
|
||||
}
|
||||
|
||||
for (int i = 0; i < hyperx_controllers.size(); i++)
|
||||
{
|
||||
RGBController_HyperX* hyperx_rgb = new RGBController_HyperX(hyperx_controllers[i]);
|
||||
|
||||
rgb_controllers.push_back(hyperx_rgb);
|
||||
}
|
||||
DetectAuraControllers(busses, rgb_controllers);
|
||||
DetectCorsairControllers(busses, rgb_controllers);
|
||||
DetectCorsairProControllers(busses, rgb_controllers);
|
||||
DetectHyperXControllers(busses, rgb_controllers);
|
||||
|
||||
#ifndef WIN32
|
||||
DetectOpenRazerControllers();
|
||||
DetectOpenRazerControllers(rgb_controllers);
|
||||
#endif
|
||||
|
||||
//This is for testing Aorus GPU
|
||||
|
|
|
|||
123
OpenAuraSDK/OpenRazerDetect.cpp
Normal file
123
OpenAuraSDK/OpenRazerDetect.cpp
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#include "RGBController.h"
|
||||
#include "RGBController_OpenRazer.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectOpenRazerControllers *
|
||||
* *
|
||||
* Detect devices supported by the OpenRazer kernel drivers *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
char driver_path[512];
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
int test_fd;
|
||||
bool done = false;
|
||||
int driver_to_read = 0;
|
||||
|
||||
while(driver_to_read < 7)
|
||||
{
|
||||
switch(driver_to_read)
|
||||
{
|
||||
case 0:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerkbd/");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razermouse/");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerfirefly/");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razermug/");
|
||||
break;
|
||||
|
||||
case 4:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razercore/");
|
||||
break;
|
||||
|
||||
case 5:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerkraken/");
|
||||
break;
|
||||
|
||||
case 6:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razermousemat/");
|
||||
break;
|
||||
}
|
||||
|
||||
done = false;
|
||||
|
||||
dir = opendir(driver_path);
|
||||
|
||||
if(dir == NULL)
|
||||
{
|
||||
closedir(dir);
|
||||
|
||||
driver_to_read++;
|
||||
continue;
|
||||
}
|
||||
|
||||
ent = readdir(dir);
|
||||
|
||||
while(ent != NULL)
|
||||
{
|
||||
if(ent->d_type == DT_DIR || ent->d_type == DT_LNK)
|
||||
{
|
||||
if(!strcmp(ent->d_name, "."))
|
||||
{
|
||||
if(done == false)
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(!strcmp(ent->d_name, "..") || !strcmp(ent->d_name, "module"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
int device_type;
|
||||
char device_string[1024];
|
||||
strcpy(device_string, driver_path);
|
||||
strcat(device_string, ent->d_name);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(device_string);
|
||||
|
||||
if(razer_rgb->device != RGBController_OpenRazer::RAZER_NO_DEVICE)
|
||||
{
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete razer_rgb;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ent = readdir(dir);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
driver_to_read++;
|
||||
}
|
||||
|
||||
} /* DetectOpenRazerControllers() */
|
||||
Loading…
Add table
Add a link
Reference in a new issue