diff options
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/core/libLumina/LInputDevice.cpp | 88 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LInputDevice.h | 43 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LInputDevice.pri | 13 |
3 files changed, 144 insertions, 0 deletions
diff --git a/src-qt5/core/libLumina/LInputDevice.cpp b/src-qt5/core/libLumina/LInputDevice.cpp new file mode 100644 index 00000000..a760d19d --- /dev/null +++ b/src-qt5/core/libLumina/LInputDevice.cpp @@ -0,0 +1,88 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2016, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "LInputDevice.h" + +//Qt Library includes +#include <QString> +#include <QX11Info> +#include <QDebug> + +//XCB Library includes +#include <xcb/xcb.h> +#include <xcb/xcb_atom.h> +#include <xcb/xinput.h> + +// LInputDevice Class +LInputDevice::LInputDevice(unsigned int id, unsigned int type){ + devID = id; + devType = type; + //devName = name; +} + +LInputDevice::~LInputDevice(){ + +} + +unsigned int LInputDevice::devNumber(){ + return devID; +} + +bool LInputDevice::isPointer(){ + return (devType==XCB_INPUT_DEVICE_USE_IS_X_POINTER \ + || devType==XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_POINTER); +} + +bool LInputDevice::isKeyboard(){ + return (devType==XCB_INPUT_DEVICE_USE_IS_X_KEYBOARD \ + || devType==XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_KEYBOARD); +} + +bool LInputDevice::isExtension(){ + return (devType==XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_DEVICE \ + || devType==XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_KEYBOARD \ + || devType==XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_POINTER); +} + +QStringList LInputDevice::listProperties(){ + xcb_input_list_device_properties_cookie_t cookie = xcb_input_list_device_properties_unchecked(QX11Info::connection(), devID); + xcb_input_list_device_properties_reply_t *reply = xcb_input_list_device_properties_reply(QX11Info::connection(), cookie, NULL); + qDebug() << "Property List:"; + qDebug() << " - response_type:" << reply->response_type; + qDebug() << " - num atoms:" << reply->num_atoms; + qDebug() << " - length:" << reply->length; + qDebug() << " - sequence:" << reply->sequence; + //Done with data structure + ::free(reply); + //Return info + return QStringList(); +} +//====================== +// LInput Static Functions +//====================== +QList<LInputDevice*> LInput::listDevices(){ + QList<LInputDevice*> devices; + xcb_input_list_input_devices_cookie_t cookie = xcb_input_list_input_devices_unchecked(QX11Info::connection()); + xcb_input_list_input_devices_reply_t *reply = xcb_input_list_input_devices_reply(QX11Info::connection(), cookie, NULL); + if(reply==0){ return devices; } //error - nothing returned + //Use the iterator for going through the reply + xcb_input_device_info_iterator_t iter = xcb_input_list_input_devices_devices_iterator(reply); + //xcb_str_iterator_t nameiter = xcb_input_list_input_devices_names_iterator(reply); + + //Now step through the reply + QStringList info; + while(iter.data != 0 ){ + devices << new LInputDevice(iter.data->device_id, iter.data->device_use); + //qDebug() << "Input Device:" << iter.data->device_id; + //qDebug() << " - num_class_info:" << iter.data->num_class_info; + xcb_input_device_info_next(&iter); + //xcb_input_device_name_next(&nameiter); + } + //Free the reply (done with it) + ::free(reply); + //return the information + return devices; +} diff --git a/src-qt5/core/libLumina/LInputDevice.h b/src-qt5/core/libLumina/LInputDevice.h new file mode 100644 index 00000000..efbc41e7 --- /dev/null +++ b/src-qt5/core/libLumina/LInputDevice.h @@ -0,0 +1,43 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2016, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This class governs all the XCB input device interactions +// and provides simpler Qt-based functions for use elsewhere +//=========================================== +#ifndef _LUMINA_XCB_INPUT_DEVICES_H +#define _LUMINA_XCB_INPUT_DEVICES_H + +#include <QList> +#include <QString> +#include <QStringList> + +class LInputDevice{ +public: + LInputDevice(unsigned int id, unsigned int type); //don't use this directly - use the "listDevices()" function instead + ~LInputDevice(); + + //QString name(); //Return the name of this device + unsigned int devNumber(); + bool isPointer(); + bool isKeyboard(); + bool isExtension(); + + //List Properties of device + QStringList listProperties(); + +private: + unsigned int devID; //device ID number - assigned at class creation + unsigned int devType; //device "use" identifier - assigned at class creation + //QString devName; //device name - use this for cross-session management (id #'s can get changed every session) +}; + +//Static functions for overall management +class LInput{ + QList<LInputDevice*> listDevices(); //NOTE: Make sure you "free()" all the LInputDevice objects when finished + +}; + +#endif diff --git a/src-qt5/core/libLumina/LInputDevice.pri b/src-qt5/core/libLumina/LInputDevice.pri new file mode 100644 index 00000000..e90728ce --- /dev/null +++ b/src-qt5/core/libLumina/LInputDevice.pri @@ -0,0 +1,13 @@ + +QT *= x11extras + +LIBS *= -lc -lxcb -lxcb-xinput + +#LUtils Files +SOURCES *= $${PWD}/LInputDevice.cpp +HEADERS *= $${PWD}/LInputDevice.h + +INCLUDEPATH *= ${PWD} + +#include LUtils and LuminaOS +#include(LUtils.pri) |