diff -ur qtbase-everywhere-src-5.12.4/src/platformsupport/input/libinput/libinput.pri qtbase-everywhere-src-5.12.4_/src/platformsupport/input/libinput/libinput.pri
--- qtbase-everywhere-src-5.12.4/src/platformsupport/input/libinput/libinput.pri	2019-06-12 23:59:14.000000000 +0300
+++ qtbase-everywhere-src-5.12.4_/src/platformsupport/input/libinput/libinput.pri	2019-09-15 23:22:28.077420548 +0300
@@ -1,3 +1,4 @@
+QT_FOR_PRIVATE += dbus
 HEADERS += \
     $$PWD/qlibinputhandler_p.h \
     $$PWD/qlibinputpointer_p.h \

diff -ur qtbase-everywhere-src-5.12.4-vanilla/src/platformsupport/input/input.pro qtbase-everywhere-src-5.12.4-patched/src/platformsupport/input/input.pro
--- qtbase-everywhere-src-5.12.4-vanilla/src/platformsupport/input/input.pro	2019-06-12 23:59:14.000000000 +0300
+++ qtbase-everywhere-src-5.12.4-patched/src/platformsupport/input/input.pro	2019-09-16 01:02:37.479007909 +0300
@@ -4,7 +4,6 @@
 QT = core-private gui-private devicediscovery_support-private
 CONFIG += static internal_module
 
-DEFINES += QT_NO_CAST_FROM_ASCII
 PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h
 
 qtConfig(evdev) {

diff -ur qtbase-everywhere-src-5.12.4/src/platformsupport/input/libinput/qlibinputhandler.cpp qtbase-everywhere-src-5.12.4-p/src/platformsupport/input/libinput/qlibinputhandler.cpp
--- qtbase-everywhere-src-5.12.4/src/platformsupport/input/libinput/qlibinputhandler.cpp	2019-06-12 23:59:14.000000000 +0300
+++ qtbase-everywhere-src-5.12.4-p/src/platformsupport/input/libinput/qlibinputhandler.cpp	2019-09-17 08:05:31.466945744 +0300
@@ -49,6 +49,11 @@
 #include <QtCore/private/qcore_unix_p.h>
 #include <private/qguiapplication_p.h>
 #include <private/qinputdevicemanager_p_p.h>
+#include <QtDBus/QDBusUnixFileDescriptor>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusPendingCall>
+#include <QtCore/qstringliteral.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -57,13 +62,94 @@
 static int liOpen(const char *path, int flags, void *user_data)
 {
     Q_UNUSED(user_data);
-    return qt_safe_open(path, flags);
+    qDebug() << "Trying to open device:" << path << "to be called without args";
+    struct stat st;
+   if (::stat(QString::fromLatin1(path), &st) < 0)
+    {
+        qDebug() << "Failed to stat path: not contuing fd = -1 ";
+        return -1;
+    }
+
+    const QString login1_service = QStringLiteral("org.freedesktop.login1");
+    const QString login1_path = QStringLiteral("/org/freedesktop/login1");
+    const static QString login1_session_interface = QStringLiteral("org.freedesktop.login1.Session");
+    
+
+    QDBusConnection bus = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "sytemConnection");
+    if (!bus.isConnected())
+        qDebug() << "DBus System not connected";
+	
+    QDBusMessage control_message = QDBusMessage::createMethodCall(login1_service,
+                                           "/org/freedesktop/login1/session/self",
+                                           login1_session_interface,
+                                           "TakeControl");
+    control_message.setArguments(QVariantList() << false);
+    
+    qDebug() << "ACQUIRING CONTROL, IF NO ERROR, CONTROL SHOULD BE AQCUIRED SUCCESFULLY" << bus.call(control_message, QDBus::Block, 1000000);
+
+
+
+   
+    
+    QDBusMessage message = QDBusMessage::createMethodCall(login1_service,
+                                           "/org/freedesktop/login1/session/self",
+                                           login1_session_interface,
+                                           "TakeDevice");
+    message.setArguments(QVariantList()
+                         << QVariant(major(st.st_rdev))
+                         << QVariant(minor(st.st_rdev)));
+
+    // Block until the device is taken
+    QDBusMessage reply = bus.call(message, QDBus::Block, 1000000);
+    if (reply.type() == QDBusMessage::ErrorMessage)
+    {
+        qDebug() << "ErrorMessage Couldnt takeDevice" ;
+        return -1;
+    }
+        qDebug() << "reply from takeDevice" << reply ;
+    int fd = reply.arguments().first().value<QDBusUnixFileDescriptor>().fileDescriptor();
+  // int fd = ::fcntl(reply.arguments().first().value<QDBusUnixFileDescriptor>().fileDescriptor(), F_SETFD, FD_CLOEXEC);
+
+    if (fd < 0)
+        return -1;
+                         
+                         
+
+    
+    
+
+    
+    qDebug() << "returning FD:" << fd; //fd is always 16?!
+    return ::fcntl(fd, F_DUPFD_CLOEXEC, 0);
 }
 
 static void liClose(int fd, void *user_data)
 {
     Q_UNUSED(user_data);
-    qt_safe_close(fd);
+    qDebug() << "Closing device, this is called right before libinput returns: couldn't create device: $device";
+    const QString login1_service = QStringLiteral("org.freedesktop.login1");
+    const QString login1_path = QStringLiteral("/org/freedesktop/login1");
+    const static QString login1_session_interface = QStringLiteral("org.freedesktop.login1.Session");
+    
+
+    QDBusConnection bus = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "sytemConnection");
+    struct stat st;
+    if (::fstat(fd, &st) < 0) 
+    {
+        qDebug() << "Failed to stat fd in liClose(): return";
+        return;
+    }
+
+    QDBusMessage message = QDBusMessage::createMethodCall(login1_service,
+                                           "/org/freedesktop/login1/session/self",
+                                           login1_session_interface,
+                                           "ReleaseDevice");
+
+    message.setArguments(QVariantList()
+                         << QVariant(major(st.st_rdev))
+                         << QVariant(minor(st.st_rdev)));
+
+    bus.asyncCall(message);
 }
 
 static const struct libinput_interface liInterface = {
