diff --git a/src/libhidpp/hidpp20/IReprogControlsV4.cpp b/src/libhidpp/hidpp20/IReprogControlsV4.cpp index d4367bb..816b28b 100644 --- a/src/libhidpp/hidpp20/IReprogControlsV4.cpp +++ b/src/libhidpp/hidpp20/IReprogControlsV4.cpp @@ -19,6 +19,7 @@ #include "IReprogControlsV4.h" #include +#include using namespace HIDPP20; @@ -70,3 +71,23 @@ void IReprogControlsV4::setControlReporting (uint16_t control_id, uint8_t flags, call (SetControlReporting, params); } +std::vector IReprogControlsV4::divertedButtonEvent (const HIDPP::Report &event) +{ + assert (event.function () == DivertedButtonEvent); + std::vector buttons; + auto params = event.parameterBegin (); + for (unsigned int i = 0; i < 4; ++i) { + uint16_t control_id = readBE (params + 2*i); + if (control_id == 0) + break; + buttons.push_back (control_id); + } + return buttons; +} + +IReprogControlsV4::Move IReprogControlsV4::divertedRawXYEvent (const HIDPP::Report &event) +{ + assert (event.function () == DivertedRawXYEvent); + auto params = event.parameterBegin (); + return Move { readBE (params+0), readBE (params+2) }; +} diff --git a/src/libhidpp/hidpp20/IReprogControlsV4.h b/src/libhidpp/hidpp20/IReprogControlsV4.h index 2ccae47..a5054f5 100644 --- a/src/libhidpp/hidpp20/IReprogControlsV4.h +++ b/src/libhidpp/hidpp20/IReprogControlsV4.h @@ -116,6 +116,14 @@ class IReprogControlsV4: public FeatureInterface * \see ControlReportingFlags. */ void setControlReporting (uint16_t control_id, uint8_t flags, uint16_t remap); + + static std::vector divertedButtonEvent (const HIDPP::Report &event); + + struct Move + { + int16_t x, y; + }; + static Move divertedRawXYEvent (const HIDPP::Report &event); }; }