Skip to content

Commit

Permalink
Add Illumination events parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
hadess committed Sep 15, 2024
1 parent 70bceb9 commit ec68745
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/libhidpp/hidpp20/IIllumination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,38 @@ void IIllumination::setColorTemperature(uint16_t value)
writeBE<uint16_t> (params, 0, value);
call (SetColorTemperature, params);
}

bool IIllumination::illuminationChangeEvent (const HIDPP::Report &event)
{
assert (event.function () == IIllumination::IlluminationChangeEvent);
auto params = event.parameterBegin ();
return readLE<uint8_t> (params) != 0;
}

uint16_t brightnessChangeEvent (const HIDPP::Report &event)
{
assert (event.function () == IIllumination::BrightnessChangeEvent);
auto params = event.parameterBegin ();
return readBE<uint16_t> (params);
}

uint16_t colorTemperatureChangeEvent (const HIDPP::Report &event)
{
assert (event.function () == IIllumination::ColorTemperatureChangeEvent);
auto params = event.parameterBegin ();
return readBE<uint16_t> (params);
}

uint16_t brightnessEffectiveMaxChangeEvent (const HIDPP::Report &event)
{
assert (event.function () == IIllumination::BrightnessEffectiveMaxChangeEvent);
auto params = event.parameterBegin ();
return readBE<uint16_t> (params);
}

uint16_t brightnessClampedEvent (const HIDPP::Report &event)
{
assert (event.function () == IIllumination::BrightnessClampedEvent);
auto params = event.parameterBegin ();
return readBE<uint16_t> (params);
}
35 changes: 35 additions & 0 deletions src/libhidpp/hidpp20/IIllumination.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ class IIllumination: public FeatureInterface
GetBrightnessEffectiveMax = 12,
};

enum Event {
IlluminationChangeEvent = 0,
BrightnessChangeEvent = 1,
ColorTemperatureChangeEvent = 2,
BrightnessEffectiveMaxChangeEvent = 3,
BrightnessClampedEvent = 4,
};

enum Flags {
hasEvents = 1 << 0,
hasLinearLevels = 1 << 1,
Expand Down Expand Up @@ -110,6 +118,33 @@ class IIllumination: public FeatureInterface
* Set the Illumination color temperature.
*/
void setColorTemperature(uint16_t value);

/**
* Parse an illumination change event.
*/
bool illuminationChangeEvent (const HIDPP::Report &event);

/**
* Parse a brightness change event.
*/
uint16_t brightnessChangeEvent (const HIDPP::Report &event);

/**
* Parse a color temperature change event.
*/
uint16_t colorTemperatureChangeEvent (const HIDPP::Report &event);

/**
* Parse a change in the effective maximum brightness.
*/
uint16_t brightnessEffectiveMaxChangeEvent (const HIDPP::Report &event);

/**
* Parse a notification of a recent request to set the
* brightness to a value larger than the current effective
* maximum brightness.
*/
uint16_t brightnessClampedEvent (const HIDPP::Report &event);
};

}
Expand Down

0 comments on commit ec68745

Please sign in to comment.