From 44c2f396902ee2a9da898fd3965a7c5600d20118 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 17 Nov 2016 13:53:55 -0500 Subject: Commit some more work on the new input device framework. Got the properties getting listed now, just need to figure out how to read/set the various properties (no documentation on what the various inputs are for the XCB functions to do that). --- src-qt5/core/libLumina/LInputDevice.cpp | 40 ++++++++++++++++++++++++++------- src-qt5/core/libLumina/LInputDevice.h | 11 ++++++++- 2 files changed, 42 insertions(+), 9 deletions(-) (limited to 'src-qt5/core/libLumina') diff --git a/src-qt5/core/libLumina/LInputDevice.cpp b/src-qt5/core/libLumina/LInputDevice.cpp index 79f5c27f..d141e39a 100644 --- a/src-qt5/core/libLumina/LInputDevice.cpp +++ b/src-qt5/core/libLumina/LInputDevice.cpp @@ -15,12 +15,17 @@ #include #include #include +#include -// LInputDevice Class +//=================== +// LInputDevice Class +//=================== +// === PUBLIC === LInputDevice::LInputDevice(unsigned int id, unsigned int type){ devID = id; devType = type; //devName = name; + getProperties(); //need to populate the name/atom correlations for properties } LInputDevice::~LInputDevice(){ @@ -47,18 +52,37 @@ bool LInputDevice::isExtension(){ || devType==XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_POINTER); } +// Property Management QStringList LInputDevice::listProperties(){ + return devProps.keys(); +} + +QVariant LInputDevice::propertyValue(QString prop){ + if(!devProps.contains(prop)){ return QVariant(); } + //Now generate the property request + // xcb_input_get_device_property_cookie_t cookie = xcb_input_get_device_property_unchecked( QX11Info::connection(), devProps.value(prop), \ +// XCB_ATOM_ATOM, 0, 1000, devID, NULL); + QVariant result; + return result; +} + +// === PRIVATE === +void LInputDevice::getProperties(){ + devProps.clear(); 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; + //Get the atoms + xcb_atom_t *atoms = xcb_input_list_device_properties_atoms(reply); + //qDebug() << "Property Response Type:" << reply->response_type; //Always seems to be "1" + QList cookies; + for(int i=0; inum_atoms; i++){ cookies << xcb_get_atom_name(QX11Info::connection(), atoms[i]); } + for(int i=0; inum_atoms; i++){ + xcb_get_atom_name_reply_t *nr = xcb_get_atom_name_reply(QX11Info::connection(), cookies[i], NULL); + devProps.insert(QString::fromUtf8( xcb_get_atom_name_name(nr), xcb_get_atom_name_name_length(nr) ),atoms[i] ); + ::free(nr); + } //Done with data structure ::free(reply); - //Return info - return QStringList(); } //====================== // LInput Static Functions diff --git a/src-qt5/core/libLumina/LInputDevice.h b/src-qt5/core/libLumina/LInputDevice.h index 1293ea92..f7a4713c 100644 --- a/src-qt5/core/libLumina/LInputDevice.h +++ b/src-qt5/core/libLumina/LInputDevice.h @@ -13,24 +13,33 @@ #include #include #include +#include +#include + +#include class LInputDevice{ public: LInputDevice(unsigned int id, unsigned int type); //don't use this directly - use the "listDevices()" function instead ~LInputDevice(); + //Device Information //QString name(); //Return the name of this device unsigned int devNumber(); bool isPointer(); bool isKeyboard(); bool isExtension(); - //List Properties of device + //Property Management QStringList listProperties(); + QVariant propertyValue(QString prop); private: unsigned int devID; //device ID number - assigned at class creation unsigned int devType; //device "use" identifier - assigned at class creation + QHash devProps; //Known device properties + + void getProperties(); //QString devName; //device name - use this for cross-session management (id #'s can get changed every session) }; -- cgit