From c4dfb8030c1f65e925ef2733bfc61fc01fcd80c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=81o=C5=9B?= Date: Wed, 10 Apr 2024 16:50:32 +0200 Subject: [PATCH] Enable device discovery using evdev on VxWorks Provide VxWorks-specific implementation of keyboard and mouse device discovery, and enable usage of evdev on this platform. Task-number: QTBUG-115777 Change-Id: I9370ac085aa58c72e2d39731b78ebd854f5aad9a Reviewed-by: Laszlo Agocs --- src/gui/configure.cmake | 10 +++ .../qdevicediscovery_static.cpp | 69 ++++++++++++++++++- .../input/shared/qevdevutil.cpp | 8 ++- 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/src/gui/configure.cmake b/src/gui/configure.cmake index 4a5bc443ec9..db627d7453a 100644 --- a/src/gui/configure.cmake +++ b/src/gui/configure.cmake @@ -363,15 +363,25 @@ qt_config_compile_test(evdev CODE "#if defined(__FreeBSD__) # include +#elif defined(__VXWORKS__) +#include +typedef EV_DEV_EVENT input_event; #else # include # include #endif enum { +#if defined(__VXWORKS__) + e1 = EV_DEV_ABS, + e2 = EV_DEV_PTR_ABS_X, + e3 = EV_DEV_PTR_ABS_Y, + e4 = EV_DEV_PTR_BTN_TOUCH, +#else e1 = ABS_PRESSURE, e2 = ABS_X, e3 = REL_X, e4 = SYN_REPORT, +#endif }; int main(void) diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp index 03a77aaae7b..963696444b6 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp @@ -13,6 +13,9 @@ #ifdef Q_OS_FREEBSD #include +#elif defined(Q_OS_VXWORKS) +#include +#define ABS_X EV_DEV_PTR_ABS_X #else #include #endif @@ -40,10 +43,12 @@ #define LONG_BITS (sizeof(long) * 8 ) #define LONG_FIELD_SIZE(bits) ((bits / LONG_BITS) + 1) +#if !defined(Q_OS_VXWORKS) static bool testBit(long bit, const long *field) { return (field[bit / LONG_BITS] >> bit % LONG_BITS) & 1; } +#endif QT_BEGIN_NAMESPACE @@ -65,6 +70,37 @@ QDeviceDiscoveryStatic::QDeviceDiscoveryStatic(QDeviceTypes types, QObject *pare QStringList QDeviceDiscoveryStatic::scanConnectedDevices() { QStringList devices; + +#if defined(Q_OS_VXWORKS) + + QStringList inputDevices; + UINT32 devCount = 0; + static const char* device = "/input/event"; + int fd = QT_OPEN(device, O_RDONLY | O_NDELAY, 0); + if (fd >= 0) { + if (ERROR == ioctl(fd, EV_DEV_IO_GET_DEV_COUNT, (char *)&devCount)) { + qWarning() << "DeviceDiscovery cannot open device" << device; + return devices; + } + for (UINT32 i=0; i