Move main function to its own file, add checks to prevent UI updates if no devices were detected
This commit is contained in:
parent
18bf0ce013
commit
06f21865c6
6 changed files with 134 additions and 75 deletions
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include <tchar.h>
|
||||
#include <regex>
|
||||
#include "OpenAuraSDKDialog.h"
|
||||
#include "I2CDetectDialog.h"
|
||||
#include "i2c_smbus_piix4.h"
|
||||
#include "i2c_smbus_i801.h"
|
||||
|
|
@ -33,7 +32,6 @@
|
|||
#pragma comment(lib, "inpout32.lib")
|
||||
#else /* WIN32 */
|
||||
|
||||
#include "OpenAuraSDKQtDialog.h"
|
||||
#include "i2c_smbus_linux.h"
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -41,9 +39,9 @@
|
|||
|
||||
#endif /* WIN32 */
|
||||
|
||||
std::vector<AuraController *> aura_controllers;
|
||||
std::vector<AuraController*> aura_controllers;
|
||||
std::vector<CorsairController*> corsair_controllers;
|
||||
std::vector<i2c_smbus_interface *> busses;
|
||||
std::vector<i2c_smbus_interface*> busses;
|
||||
std::vector<RGBController*> rgb_controllers;
|
||||
|
||||
#ifdef WIN32
|
||||
|
|
@ -555,8 +553,6 @@ std::string DetectI2C(i2c_smbus_interface * bus, int mode)
|
|||
char line[128];
|
||||
std::string text;
|
||||
|
||||
freopen("i2cdetect.txt", "a", stdout);
|
||||
|
||||
sprintf(line, " 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
text.append(line);
|
||||
|
||||
|
|
@ -645,13 +641,13 @@ void DumpAuraRegisters(AuraController * controller)
|
|||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* main *
|
||||
* DetectRGBConrollers *
|
||||
* *
|
||||
* Main function. Detects busses and Aura controllers, then opens the main window *
|
||||
* Detect and populate RGB Controllers vector *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
void DetectRGBControllers(void)
|
||||
{
|
||||
DetectI2CBusses();
|
||||
|
||||
|
|
@ -674,7 +670,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
//This is only for testing, hard-coding the OpenRazer path for my mouse
|
||||
#if 0
|
||||
RGBController_OpenRazer* razer_rgb = new RGBController_OpenRazer("/sys/bus/hid/drivers/razermouse/0003:1532:0046.0004");
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer("/sys/bus/hid/drivers/razermouse/0003:1532:0046.0004");
|
||||
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
|
||||
|
|
@ -689,23 +685,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
//This is for testing Aorus GPU
|
||||
#if 0
|
||||
RGBController_AorusGPU* aorus_rgb = new RGBController_AorusGPU();
|
||||
RGBController_AorusGPU * aorus_rgb = new RGBController_AorusGPU();
|
||||
|
||||
rgb_controllers.push_back(aorus_rgb);
|
||||
#endif
|
||||
|
||||
#if WIN32
|
||||
OpenAuraSDKDialog dlg(busses, rgb_controllers);
|
||||
dlg.DoModal();
|
||||
|
||||
return 0;
|
||||
|
||||
#else
|
||||
QApplication a(argc, argv);
|
||||
|
||||
Ui::OpenAuraSDKQtDialog dlg(busses, rgb_controllers);
|
||||
dlg.show();
|
||||
|
||||
return a.exec();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -8,4 +8,5 @@
|
|||
#define MODE_FUNC 3
|
||||
|
||||
std::string DetectI2C(i2c_smbus_interface * bus, int mode);
|
||||
void DumpAuraRegisters(AuraController * controller);
|
||||
void DumpAuraRegisters(AuraController * controller);
|
||||
void DetectRGBControllers();
|
||||
|
|
@ -202,6 +202,7 @@
|
|||
<ClCompile Include="i2c_smbus_i801.cpp" />
|
||||
<ClCompile Include="i2c_smbus_nuvoton_nct6793d.cpp" />
|
||||
<ClCompile Include="i2c_smbus_piix4.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="OpenAuraSDKDialog.cpp" />
|
||||
<ClCompile Include="RGBController_AorusGPU.cpp" />
|
||||
<ClCompile Include="RGBController_Aura.cpp" />
|
||||
|
|
|
|||
|
|
@ -104,6 +104,9 @@
|
|||
<ClCompile Include="RGBController_AorusGPU.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Resource.rc">
|
||||
|
|
|
|||
|
|
@ -44,27 +44,29 @@ BOOL OpenAuraSDKDialog::OnInitDialog()
|
|||
|
||||
controller_box->SetCurSel(0);
|
||||
|
||||
for (int i = 0; i < controllers[0]->modes.size(); i++)
|
||||
if (controllers.size() > 0)
|
||||
{
|
||||
mode_box->AddString(controllers[0]->modes[i].name.c_str());
|
||||
for (int i = 0; i < controllers[0]->modes.size(); i++)
|
||||
{
|
||||
mode_box->AddString(controllers[0]->modes[i].name.c_str());
|
||||
}
|
||||
|
||||
mode_box->SetCurSel(controllers[0]->GetMode());
|
||||
|
||||
for (int i = 0; i < controllers[0]->zones.size(); i++)
|
||||
{
|
||||
zone_box->AddString(controllers[0]->zones[i].name.c_str());
|
||||
}
|
||||
|
||||
zone_box->SetCurSel(0);
|
||||
|
||||
for (int i = 0; i < controllers[0]->leds.size(); i++)
|
||||
{
|
||||
led_box->AddString(controllers[0]->leds[i].name.c_str());
|
||||
}
|
||||
|
||||
led_box->SetCurSel(0);
|
||||
}
|
||||
|
||||
mode_box->SetCurSel(controllers[0]->GetMode());
|
||||
|
||||
for (int i = 0; i < controllers[0]->zones.size(); i++)
|
||||
{
|
||||
zone_box->AddString(controllers[0]->zones[i].name.c_str());
|
||||
}
|
||||
|
||||
zone_box->SetCurSel(0);
|
||||
|
||||
for (int i = 0; i < controllers[0]->leds.size(); i++)
|
||||
{
|
||||
led_box->AddString(controllers[0]->leds[i].name.c_str());
|
||||
}
|
||||
|
||||
led_box->SetCurSel(0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -99,32 +101,35 @@ void OpenAuraSDKDialog::OnCbnCloseupComboOpenaurasdkDevice()
|
|||
CComboBox* zone_box = (CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_ZONE);
|
||||
CComboBox* led_box = (CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_LED);
|
||||
|
||||
mode_box->ResetContent();
|
||||
|
||||
for (int i = 0; i < controllers[controller_box->GetCurSel()]->modes.size(); i++)
|
||||
if (controllers.size() > 0)
|
||||
{
|
||||
mode_box->AddString(controllers[controller_box->GetCurSel()]->modes[i].name.c_str());
|
||||
mode_box->ResetContent();
|
||||
|
||||
for (int i = 0; i < controllers[controller_box->GetCurSel()]->modes.size(); i++)
|
||||
{
|
||||
mode_box->AddString(controllers[controller_box->GetCurSel()]->modes[i].name.c_str());
|
||||
}
|
||||
|
||||
mode_box->SetCurSel(controllers[controller_box->GetCurSel()]->GetMode());
|
||||
|
||||
zone_box->ResetContent();
|
||||
|
||||
for (int i = 0; i < controllers[controller_box->GetCurSel()]->zones.size(); i++)
|
||||
{
|
||||
zone_box->AddString(controllers[controller_box->GetCurSel()]->zones[i].name.c_str());
|
||||
}
|
||||
|
||||
zone_box->SetCurSel(0);
|
||||
|
||||
led_box->ResetContent();
|
||||
|
||||
for (int i = 0; i < controllers[controller_box->GetCurSel()]->leds.size(); i++)
|
||||
{
|
||||
led_box->AddString(controllers[controller_box->GetCurSel()]->leds[i].name.c_str());
|
||||
}
|
||||
|
||||
led_box->SetCurSel(0);
|
||||
}
|
||||
|
||||
mode_box->SetCurSel(controllers[controller_box->GetCurSel()]->GetMode());
|
||||
|
||||
zone_box->ResetContent();
|
||||
|
||||
for (int i = 0; i < controllers[controller_box->GetCurSel()]->zones.size(); i++)
|
||||
{
|
||||
zone_box->AddString(controllers[controller_box->GetCurSel()]->zones[i].name.c_str());
|
||||
}
|
||||
|
||||
zone_box->SetCurSel(0);
|
||||
|
||||
led_box->ResetContent();
|
||||
|
||||
for (int i = 0; i < controllers[controller_box->GetCurSel()]->leds.size(); i++)
|
||||
{
|
||||
led_box->AddString(controllers[controller_box->GetCurSel()]->leds[i].name.c_str());
|
||||
}
|
||||
|
||||
led_box->SetCurSel(0);
|
||||
}
|
||||
|
||||
void OpenAuraSDKDialog::OnCbnCloseupComboOpenaurasdkMode()
|
||||
|
|
@ -132,7 +137,10 @@ void OpenAuraSDKDialog::OnCbnCloseupComboOpenaurasdkMode()
|
|||
CComboBox* controller_box = (CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_DEVICE);
|
||||
CComboBox* mode_box = (CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_MODE);
|
||||
|
||||
controllers[controller_box->GetCurSel()]->SetMode(mode_box->GetCurSel());
|
||||
if (controllers.size() > 0)
|
||||
{
|
||||
controllers[controller_box->GetCurSel()]->SetMode(mode_box->GetCurSel());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -147,7 +155,10 @@ void OpenAuraSDKDialog::OnBnClickedButtonOpenaurasdkSetZone()
|
|||
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B)
|
||||
);
|
||||
|
||||
controllers[controller_box->GetCurSel()]->SetAllZoneLEDs(zone_box->GetCurSel(), color);
|
||||
if (controllers.size() > 0)
|
||||
{
|
||||
controllers[controller_box->GetCurSel()]->SetAllZoneLEDs(zone_box->GetCurSel(), color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -162,7 +173,10 @@ void OpenAuraSDKDialog::OnBnClickedButtonOpenaurasdkSetColorsLed()
|
|||
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B)
|
||||
);
|
||||
|
||||
controllers[controller_box->GetCurSel()]->SetLED(led_box->GetCurSel(), color);
|
||||
if (controllers.size() > 0)
|
||||
{
|
||||
controllers[controller_box->GetCurSel()]->SetLED(led_box->GetCurSel(), color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -176,5 +190,8 @@ void OpenAuraSDKDialog::OnBnClickedButtonOpenaurasdkSetColorsDevice()
|
|||
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B)
|
||||
);
|
||||
|
||||
controllers[controller_box->GetCurSel()]->SetAllLEDs(color);
|
||||
}
|
||||
if (controllers.size() > 0)
|
||||
{
|
||||
controllers[controller_box->GetCurSel()]->SetAllLEDs(color);
|
||||
}
|
||||
}
|
||||
55
OpenAuraSDK/main.cpp
Normal file
55
OpenAuraSDK/main.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/******************************************************************************************\
|
||||
* *
|
||||
* main.cpp *
|
||||
* *
|
||||
* Main function for OpenAuraSDK GUI project *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#include "OpenAuraSDK.h"
|
||||
#include "RGBController.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include "OpenAuraSDKDialog.h"
|
||||
|
||||
#else /* WIN32 */
|
||||
|
||||
#include "OpenAuraSDKQtDialog.h"
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
extern std::vector<i2c_smbus_interface*> busses;
|
||||
extern std::vector<RGBController*> rgb_controllers;
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* main *
|
||||
* *
|
||||
* Main function. Detects busses and Aura controllers, then opens the main window *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
DetectRGBControllers();
|
||||
|
||||
#if WIN32
|
||||
OpenAuraSDKDialog dlg(busses, rgb_controllers);
|
||||
dlg.DoModal();
|
||||
|
||||
return 0;
|
||||
|
||||
#else
|
||||
QApplication a(argc, argv);
|
||||
|
||||
Ui::OpenAuraSDKQtDialog dlg(busses, rgb_controllers);
|
||||
dlg.show();
|
||||
|
||||
return a.exec();
|
||||
#endif
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue