mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-01-22 05:57:53 -05:00
Implement getting lamp attributes for each lamp and disabling autonomous mode, work on multi update
This commit is contained in:
@@ -16,7 +16,25 @@ HIDLampArrayController::HIDLampArrayController(lamparray_hid_devs *devs_handle)
|
||||
{
|
||||
devs = devs_handle;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get LampArrayAttributesReport |
|
||||
\*-----------------------------------------------------*/
|
||||
GetLampArrayAttributesReport();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set LampAttributesRequestReport for LampId 0 |
|
||||
\*-----------------------------------------------------*/
|
||||
SetLampAttributesRequestReport(0);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get LampAttributesResponseReport for each LampId |
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned int LampId = 0; LampId < LampArray.LampCount; LampId++)
|
||||
{
|
||||
GetLampAttributesResponseReport();
|
||||
}
|
||||
|
||||
SetLampArrayControlReport(false);
|
||||
}
|
||||
|
||||
HIDLampArrayController::~HIDLampArrayController()
|
||||
@@ -36,24 +54,124 @@ std::string HIDLampArrayController::GetSerialString()
|
||||
|
||||
unsigned int HIDLampArrayController::GetLampCount()
|
||||
{
|
||||
return(lamp_count);
|
||||
return(LampArray.LampCount);
|
||||
}
|
||||
|
||||
void HIDLampArrayController::GetLampArrayAttributesReport()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
unsigned char usb_buf[sizeof(LampArrayAttributes) + 1];
|
||||
int report_size;
|
||||
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0] = 0x01;
|
||||
/*-----------------------------------------------------*\
|
||||
| First byte is the report ID |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = HID_LAMPARRAY_LAMP_ARRAY_ATTRIBUTES_REPORT_ID;
|
||||
|
||||
report_size = hid_get_feature_report(devs->hid_dev_LampArrayAttributesReport, usb_buf, sizeof(usb_buf));
|
||||
/*-----------------------------------------------------*\
|
||||
| Get the report |
|
||||
\*-----------------------------------------------------*/
|
||||
report_size = hid_get_feature_report(devs->hid_dev_LampArrayAttributesReport, usb_buf, sizeof(usb_buf));
|
||||
|
||||
lamp_count = (unsigned short)((usb_buf[2] << 8) | usb_buf[1]);
|
||||
bounding_width = (unsigned int)((usb_buf[6] << 24) | (usb_buf[5] << 16) | (usb_buf[4] << 8) | usb_buf[3]);
|
||||
bounding_height = (unsigned int)((usb_buf[10] << 24) | (usb_buf[9] << 16) | (usb_buf[8] << 8) | usb_buf[7]);
|
||||
bounding_depth = (unsigned int)((usb_buf[14] << 24) | (usb_buf[13] << 16) | (usb_buf[12] << 8) | usb_buf[11]);
|
||||
kind = (unsigned int)((usb_buf[18] << 24) | (usb_buf[17] << 16) | (usb_buf[16] << 8) | usb_buf[15]);
|
||||
min_interval = (unsigned int)((usb_buf[22] << 24) | (usb_buf[21] << 16) | (usb_buf[20] << 8) | usb_buf[19]);
|
||||
memcpy(&LampArray, &usb_buf[1], sizeof(LampArray));
|
||||
}
|
||||
|
||||
void HIDLampArrayController::GetLampAttributesResponseReport()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
int report_size;
|
||||
LampAttributes attributes;
|
||||
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| First byte is the report ID |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = HID_LAMPARRAY_LAMP_ATTRIBUTES_RESPONSE_REPORT_ID;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get the report |
|
||||
\*-----------------------------------------------------*/
|
||||
report_size = hid_get_feature_report(devs->hid_dev_LampAttributesResponseReport, usb_buf, sizeof(usb_buf));
|
||||
|
||||
memcpy(&attributes, &usb_buf[1], sizeof(attributes));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Store the attributes |
|
||||
\*-----------------------------------------------------*/
|
||||
Lamps.push_back(attributes);
|
||||
}
|
||||
|
||||
void HIDLampArrayController::SetLampArrayControlReport(unsigned char AutonomousMode)
|
||||
{
|
||||
unsigned char usb_buf[sizeof(LampArrayControl) + 1];
|
||||
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| First byte is the report ID |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = HID_LAMPARRAY_LAMP_ARRAY_CONTROL_REPORT_ID;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in control data |
|
||||
\*-----------------------------------------------------*/
|
||||
((LampArrayControl *)&usb_buf[1])->AutonomousMode = AutonomousMode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send the report |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(devs->hid_dev_LampArrayControlReport, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
|
||||
void HIDLampArrayController::SetLampAttributesRequestReport(unsigned short LampId)
|
||||
{
|
||||
unsigned char usb_buf[sizeof(LampAttributesRequest) + 1];
|
||||
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| First byte is the report ID |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = HID_LAMPARRAY_LAMP_ATTRIBUTES_REQUEST_REPORT_ID;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in request data |
|
||||
\*-----------------------------------------------------*/
|
||||
((LampAttributesRequest *)&usb_buf[1])->LampId = LampId;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send the report |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(devs->hid_dev_LampAttributesRequestReport, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
|
||||
void HIDLampArrayController::SetLampMultiUpdateReport(unsigned char LampCount, unsigned char LampUpdateFlags, unsigned char * LampIds, LampArrayColor * UpdateColors)
|
||||
{
|
||||
unsigned char usb_buf[sizeof(LampMultiUpdate) + 1];
|
||||
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| First byte is the report ID |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = HID_LAMPARRAY_LAMP_MULTI_UPDATE_REPORT_ID;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in multi update data |
|
||||
\*-----------------------------------------------------*/
|
||||
((LampMultiUpdate *)&usb_buf[1])->LampCount = LampCount;
|
||||
((LampMultiUpdate *)&usb_buf[1])->LampUpdateFlags = LampUpdateFlags;
|
||||
|
||||
for(unsigned char LampId = 0; LampId < LampCount; LampId++)
|
||||
{
|
||||
((LampMultiUpdate *)&usb_buf[1])->LampIds[LampId] = LampIds[LampId];
|
||||
((LampMultiUpdate *)&usb_buf[1])->UpdateColors[LampId] = UpdateColors[LampId];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send the report |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(devs->hid_dev_LampMultiUpdateReport, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user