Implement getting lamp attributes for each lamp and disabling autonomous mode, work on multi update

This commit is contained in:
Adam Honse
2024-05-07 00:13:49 -05:00
parent 82f54ba227
commit bce77303c2
2 changed files with 212 additions and 17 deletions

View File

@@ -16,6 +16,17 @@
#include "RGBController.h"
/*---------------------------------------------------------*\
| Struct packing macro for GCC and MSVC |
\*---------------------------------------------------------*/
#ifdef __GNUC__
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif
#ifdef _MSC_VER
#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop))
#endif
typedef struct
{
hid_device * hid_dev_LampArray;
@@ -27,6 +38,68 @@ typedef struct
hid_device * hid_dev_LampArrayControlReport;
} lamparray_hid_devs;
PACK(struct LampArrayAttributes
{
unsigned short LampCount;
unsigned int BoundingBoxWidthInMillimeters;
unsigned int BoundingBoxHeightInMillimeters;
unsigned int BoundingBoxDepthInMillimeters;
unsigned int LampArrayKind;
unsigned int MinUpdateIntervalInMilliseconds;
});
PACK(struct LampArrayColor
{
unsigned char RedChannel;
unsigned char GreenChannel;
unsigned char BlueChannel;
unsigned char IntensityChannel;
});
PACK(struct LampArrayControl
{
unsigned char AutonomousMode;
});
PACK(struct LampAttributes
{
unsigned short LampId;
unsigned int PositionXInMillimeters;
unsigned int PositionYInMillimeters;
unsigned int PositionZInMillimeters;
unsigned int UpdateLatencyInMilliseconds;
unsigned int LampPurposes;
unsigned char RedLevelCount;
unsigned char GreenLevelCount;
unsigned char BlueLevelCount;
unsigned char IntensityLevelCount;
unsigned char IsProgrammable;
unsigned char LampKey;
});
PACK(struct LampAttributesRequest
{
unsigned short LampId;
});
#define LAMP_MULTI_UPDATE_LAMP_COUNT 8
PACK(struct LampMultiUpdate
{
unsigned char LampCount;
unsigned char LampUpdateFlags;
unsigned char LampIds[LAMP_MULTI_UPDATE_LAMP_COUNT];
LampArrayColor UpdateColors[LAMP_MULTI_UPDATE_LAMP_COUNT];
});
enum
{
HID_LAMPARRAY_LAMP_ARRAY_ATTRIBUTES_REPORT_ID = 0x01, /* LampArrayAttributesReport ID */
HID_LAMPARRAY_LAMP_ATTRIBUTES_REQUEST_REPORT_ID = 0x02, /* LampAttributesRequestReport ID */
HID_LAMPARRAY_LAMP_ATTRIBUTES_RESPONSE_REPORT_ID = 0x03, /* LampAttributesResponseReport ID */
HID_LAMPARRAY_LAMP_MULTI_UPDATE_REPORT_ID = 0x04, /* LampMultiUpdateReport ID */
HID_LAMPARRAY_LAMP_ARRAY_CONTROL_REPORT_ID = 0x06, /* LampArrayControlReport ID */
};
enum
{
HID_LAMPARRAY_KIND_UNDEFINED = 0x00, /* Undefined */
@@ -35,7 +108,7 @@ enum
HID_LAMPARRAY_KIND_GAME_CONTROLLER = 0x03, /* LampArrayKindGameController */
HID_LAMPARRAY_KIND_PERIPHERAL = 0x04, /* LampArrayKindPeripheral */
HID_LAMPARRAY_KIND_SCENE = 0x05, /* LampArrayKindScene */
HID_LAMPARRAY_KIND_NOTIFICATIOn = 0x06, /* LampArrayKindNotification */
HID_LAMPARRAY_KIND_NOTIFICATION = 0x06, /* LampArrayKindNotification */
HID_LAMPARRAY_KIND_CHASSIS = 0x07, /* LampArrayKindChassis */
HID_LAMPARRAY_KIND_WEARABLE = 0x08, /* LampArrayKindWearable */
HID_LAMPARRAY_KIND_FURNITURE = 0x09, /* LampArrayKindFurniture */
@@ -56,17 +129,21 @@ public:
private:
void GetLampArrayAttributesReport();
void GetLampAttributesResponseReport();
void SetLampArrayControlReport(unsigned char AutonomousMode);
void SetLampAttributesRequestReport(unsigned short LampId);
void SetLampMultiUpdateReport(unsigned char LampCount, unsigned char LampUpdateFlags, unsigned char * LampIds, LampArrayColor * UpdateColors);
lamparray_hid_devs * devs;
std::string location;
/*-----------------------------------------------------*\
| Vector to store lamp attributes for each lamp |
\*-----------------------------------------------------*/
std::vector<LampAttributes> Lamps;
/*-----------------------------------------------------*\
| Parameters from LampArrayAttributesReport |
\*-----------------------------------------------------*/
unsigned short lamp_count;
unsigned int bounding_width;
unsigned int bounding_height;
unsigned int bounding_depth;
unsigned int kind;
unsigned int min_interval;
LampArrayAttributes LampArray;
};