File 04-add_ireset_feature.patch of Package hidpp

Add IReset feature

diff --git a/src/libhidpp/CMakeLists.txt b/src/libhidpp/CMakeLists.txt
index 3c854f0..5f42d91 100644
--- a/src/libhidpp/CMakeLists.txt
+++ b/src/libhidpp/CMakeLists.txt
@@ -57,6 +57,7 @@ set(LIBHIDPP_SOURCES
 	hidpp20/IBatteryLevelStatus.cpp
 	hidpp20/ISmartShift.cpp
 	hidpp20/IHiresScroll.cpp
+	hidpp20/IReset.cpp
 	hidpp20/ProfileDirectoryFormat.cpp
 	hidpp20/ProfileFormat.cpp
 	hidpp20/MemoryMapping.cpp
diff --git a/src/libhidpp/hidpp20/IReset.cpp b/src/libhidpp/hidpp20/IReset.cpp
new file mode 100644
index 0000000..94a9c19
--- /dev/null
+++ b/src/libhidpp/hidpp20/IReset.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2019 PixlOne
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "IReset.h"
+
+using namespace HIDPP20;
+
+uint16_t IReset::getProfile()
+{
+    auto results = call(GetProfile);
+    return (results[0] << 8) | results[1];
+}
+
+void IReset::reset (uint16_t profile)
+{
+    std::vector<uint8_t> params;
+    params.push_back((uint8_t)(profile >> 8));
+    params.push_back((uint8_t)(profile & 0xFF));
+
+    call(Reset, params);
+}
+
+IReset::IReset (Device *dev):
+        FeatureInterface (dev, ID, "Reset")
+{
+}
diff --git a/src/libhidpp/hidpp20/IReset.h b/src/libhidpp/hidpp20/IReset.h
new file mode 100644
index 0000000..901b716
--- /dev/null
+++ b/src/libhidpp/hidpp20/IReset.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2019 PixlOne
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef LIBHIDPP_HIDPP20_IRESET_H
+#define LIBHIDPP_HIDPP20_IRESET_H
+
+#include <hidpp20/FeatureInterface.h>
+
+namespace HIDPP20
+{
+    class IReset : public FeatureInterface
+    {
+    public:
+        static constexpr uint16_t ID = 0x0020;
+
+        enum Function
+        {
+            GetProfile = 0,
+            Reset = 1
+        };
+
+        IReset(Device *dev);
+
+        uint16_t getProfile();
+
+        void reset(uint16_t profile=0);
+    };
+}
+
+#endif
openSUSE Build Service is sponsored by