aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core')
-rw-r--r--src-qt5/core/libLumina/LInputDevice.cpp40
-rw-r--r--src-qt5/core/libLumina/LInputDevice.h11
2 files changed, 42 insertions, 9 deletions
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 <xcb/xcb.h>
#include <xcb/xcb_atom.h>
#include <xcb/xinput.h>
+#include <xcb/xproto.h>
-// 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<xcb_get_atom_name_cookie_t> cookies;
+ for(int i=0; i<reply->num_atoms; i++){ cookies << xcb_get_atom_name(QX11Info::connection(), atoms[i]); }
+ for(int i=0; i<reply->num_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 <QList>
#include <QString>
#include <QStringList>
+#include <QHash>
+#include <QVariant>
+
+#include <xcb/xproto.h>
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<QString, xcb_atom_t> devProps; //Known device properties <name, atom>
+
+ void getProperties();
//QString devName; //device name - use this for cross-session management (id #'s can get changed every session)
};
bgstack15