File 06-add_wirelessdevicestatus_feature_interface.patch of Package hidpp

Add WirelessDeviceStatus feature interface

diff --git a/src/libhidpp/CMakeLists.txt b/src/libhidpp/CMakeLists.txt
index 5f42d91..d1b784e 100644
--- a/src/libhidpp/CMakeLists.txt
+++ b/src/libhidpp/CMakeLists.txt
@@ -58,6 +58,7 @@ set(LIBHIDPP_SOURCES
 	hidpp20/ISmartShift.cpp
 	hidpp20/IHiresScroll.cpp
 	hidpp20/IReset.cpp
+	hidpp20/IWirelessDeviceStatus.cpp
 	hidpp20/ProfileDirectoryFormat.cpp
 	hidpp20/ProfileFormat.cpp
 	hidpp20/MemoryMapping.cpp
diff --git a/src/libhidpp/hidpp20/IWirelessDeviceStatus.cpp b/src/libhidpp/hidpp20/IWirelessDeviceStatus.cpp
new file mode 100644
index 0000000..f5bc1b8
--- /dev/null
+++ b/src/libhidpp/hidpp20/IWirelessDeviceStatus.cpp
@@ -0,0 +1,38 @@
+/*
+ * 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 <cassert>
+#include "IWirelessDeviceStatus.h"
+
+using namespace HIDPP20;
+
+IWirelessDeviceStatus::Status IWirelessDeviceStatus::statusBroadcastEvent (const HIDPP::Report &event)
+{
+    assert (event.function () == StatusBroadcast);
+    Status status = {};
+    auto params = event.parameterBegin();
+    status.Reconnection = params[0];
+    status.ReconfNeeded = params[1];
+    status.PowerSwitch = params[2];
+    return status;
+}
+
+IWirelessDeviceStatus::IWirelessDeviceStatus (Device *dev):
+        FeatureInterface (dev, ID, "WirelessDeviceStatus")
+{
+}
diff --git a/src/libhidpp/hidpp20/IWirelessDeviceStatus.h b/src/libhidpp/hidpp20/IWirelessDeviceStatus.h
new file mode 100644
index 0000000..9072002
--- /dev/null
+++ b/src/libhidpp/hidpp20/IWirelessDeviceStatus.h
@@ -0,0 +1,48 @@
+/*
+ * 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_IWIRELESSDEVICESTATUS_H
+#define LIBHIDPP_HIDPP20_IWIRELESSDEVICESTATUS_H
+
+#include <hidpp20/FeatureInterface.h>
+
+namespace HIDPP20
+{
+    class IWirelessDeviceStatus : public FeatureInterface
+    {
+    public:
+        static constexpr uint16_t ID = 0x1d4b;
+
+        enum Event {
+            StatusBroadcast = 0
+        };
+
+        struct Status
+        {
+            bool Reconnection;
+            bool ReconfNeeded;
+            bool PowerSwitch;
+        };
+
+        static Status statusBroadcastEvent (const HIDPP::Report &event);
+
+        IWirelessDeviceStatus(Device* dev);
+    };
+}
+
+#endif
openSUSE Build Service is sponsored by