--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/CadMouseConfig.h Sun Aug 18 23:30:01 2019 +0200
@@ -0,0 +1,82 @@
+#pragma once
+
+#include <type_traits>
+
+#include "HID.h"
+
+enum class Frequency : uint8_t {
+ Hz_0125 = 8,
+ Hz_0250 = 4,
+ Hz_0500 = 2,
+ Hz_1000 = 1
+};
+
+using FrequencyType = std::underlying_type<Frequency>::type;
+
+class CadMouseConfig {
+private:
+ bool liftOffDetection = true;
+ bool smartScrolling = false;
+ Frequency frequency = Frequency::Hz_1000;
+public:
+
+ void setFrequency(Frequency frequency) {
+ this->frequency = frequency;
+ }
+
+ void setLiftOffDetection(bool liftOffDetection) {
+ this->liftOffDetection = liftOffDetection;
+ }
+
+ void setSmartScrolling(bool smartScrolling) {
+ this->smartScrolling = smartScrolling;
+ }
+
+ Packet serialize() {
+ Packet data;
+ data.reserve(32);
+
+ data.push_back(0x10); // report ID
+ data.push_back(0x00); // option
+
+ data.push_back(0x1c); // speed
+
+ data.push_back(liftOffDetection ? 0x00 : 0x1f);
+
+ if (smartScrolling) {
+ data.push_back(0x00);
+ data.push_back(0x00);
+ data.push_back(0x00);
+ data.push_back(0x01);
+ } else {
+ data.push_back(0x01);
+ data.push_back(0xff);
+ data.push_back(0x00);
+ data.push_back(0x00);
+ }
+
+ for (int i = 0; i < 8; i++) data.push_back(0x00); // constant padding or magic
+
+ // magic constants or unknown fields
+ data.push_back(0x00);
+ data.push_back(0x03);
+ data.push_back(0x00);
+ data.push_back(0x0a);
+ data.push_back(0x0b);
+ data.push_back(0x0c);
+ data.push_back(0x0c);
+ data.push_back(0x0e);
+ data.push_back(0x0d);
+ data.push_back(0x2f);
+ data.push_back(0x00);
+ data.push_back(0x1e);
+
+ data.push_back(0x00);
+ data.push_back(0x00);
+ data.push_back(0x00);
+ data.push_back(static_cast<FrequencyType> (frequency));
+
+ return data;
+ }
+
+};