]> git.vomp.tv Git - vompclient.git/commitdiff
Grab input devices exclsuively to avoid remote buttons going to console
authorChris Tallon <chris@vomp.tv>
Wed, 5 Feb 2020 19:53:26 +0000 (19:53 +0000)
committerChris Tallon <chris@vomp.tv>
Wed, 5 Feb 2020 19:53:26 +0000 (19:53 +0000)
remotelinux.cc

index 9018a3e31746dcace80da9683086509485333ccf..6367355994902692292e678b29e181afb4673fed 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/input.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
 #include <fcntl.h>
 #include <errno.h>
 
@@ -99,6 +100,9 @@ int RemoteLinux::init(const char*)
       {
         Log::getInstance()->log("Remote", Log::NOTICE, "Add /dev/input/event%d to List", eventid);
         devices.push_back(new_fd);
+
+        // Grab the device - make it exclusive to vomp. Fixes rubbish input going to console in background
+        ioctl(new_fd, EVIOCGRAB, 1);
       }
       else
       {
@@ -190,11 +194,14 @@ int RemoteLinux::initCec() {
 int RemoteLinux::shutdown()
 {
   if (!initted) return 0;
+
   deinitCec();
-  while (devices.size()) {
-         int cur_fd = devices.back();
-         devices.pop_back();
-         close(cur_fd);
+  while (devices.size())
+  {
+    int cur_fd = devices.back();
+    devices.pop_back();
+    ioctl(cur_fd, EVIOCGRAB, 0);
+    close(cur_fd);
   }
 
   initted = 0;