Add QEvdev prefix in evdevtouch and update readme

Now that the code is in platformsupport we need to avoid too generic
names so rename the classes a bit.

Change-Id: I7241aa1a3449be772de369ebd08df01e886dbfa3
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
This commit is contained in:
Laszlo Agocs 2012-06-01 10:17:28 +03:00 committed by Qt by Nokia
parent 5933205cfc
commit bb4e8e37d2
4 changed files with 47 additions and 42 deletions

View File

@ -61,15 +61,15 @@ QT_BEGIN_NAMESPACE
#define ABS_MT_SLOT 0x2f #define ABS_MT_SLOT 0x2f
#endif #endif
class QTouchScreenData class QEvdevTouchScreenData
{ {
public: public:
QTouchScreenData(QTouchScreenHandler *q_ptr, const QStringList &args); QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, const QStringList &args);
void processInputEvent(input_event *data); void processInputEvent(input_event *data);
void assignIds(); void assignIds();
QTouchScreenHandler *q; QEvdevTouchScreenHandler *q;
int m_lastEventType; int m_lastEventType;
QList<QWindowSystemInterface::TouchPoint> m_touchPoints; QList<QWindowSystemInterface::TouchPoint> m_touchPoints;
@ -106,7 +106,7 @@ public:
bool m_typeB; bool m_typeB;
}; };
QTouchScreenData::QTouchScreenData(QTouchScreenHandler *q_ptr, const QStringList &args) QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, const QStringList &args)
: q(q_ptr), : q(q_ptr),
m_lastEventType(-1), m_lastEventType(-1),
m_currentSlot(0), m_currentSlot(0),
@ -118,7 +118,7 @@ QTouchScreenData::QTouchScreenData(QTouchScreenHandler *q_ptr, const QStringList
m_forceToActiveWindow = args.contains(QLatin1String("force_window")); m_forceToActiveWindow = args.contains(QLatin1String("force_window"));
} }
void QTouchScreenData::registerDevice() void QEvdevTouchScreenData::registerDevice()
{ {
m_device = new QTouchDevice; m_device = new QTouchDevice;
m_device->setName(hw_name); m_device->setName(hw_name);
@ -138,7 +138,7 @@ static inline bool testBit(long bit, const long *array)
return (array[bit / LONG_BITS] >> bit % LONG_BITS) & 1; return (array[bit / LONG_BITS] >> bit % LONG_BITS) & 1;
} }
QTouchScreenHandler::QTouchScreenHandler(const QString &spec, QObject *parent) QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &spec, QObject *parent)
: QObject(parent), m_notify(0), m_fd(-1), d(0) : QObject(parent), m_notify(0), m_fd(-1), d(0)
#ifdef USE_MTDEV #ifdef USE_MTDEV
, m_mtdev(0) , m_mtdev(0)
@ -193,7 +193,7 @@ QTouchScreenHandler::QTouchScreenHandler(const QString &spec, QObject *parent)
} }
#endif #endif
d = new QTouchScreenData(this, args); d = new QEvdevTouchScreenData(this, args);
input_absinfo absInfo; input_absinfo absInfo;
memset(&absInfo, 0, sizeof(input_absinfo)); memset(&absInfo, 0, sizeof(input_absinfo));
@ -235,7 +235,7 @@ QTouchScreenHandler::QTouchScreenHandler(const QString &spec, QObject *parent)
d->registerDevice(); d->registerDevice();
} }
QTouchScreenHandler::~QTouchScreenHandler() QEvdevTouchScreenHandler::~QEvdevTouchScreenHandler()
{ {
#ifdef USE_MTDEV #ifdef USE_MTDEV
if (m_mtdev) { if (m_mtdev) {
@ -250,7 +250,7 @@ QTouchScreenHandler::~QTouchScreenHandler()
delete d; delete d;
} }
void QTouchScreenHandler::readData() void QEvdevTouchScreenHandler::readData()
{ {
::input_event buffer[32]; ::input_event buffer[32];
int n = 0; int n = 0;
@ -289,7 +289,7 @@ void QTouchScreenHandler::readData()
d->processInputEvent(&buffer[i]); d->processInputEvent(&buffer[i]);
} }
void QTouchScreenData::processInputEvent(input_event *data) void QEvdevTouchScreenData::processInputEvent(input_event *data)
{ {
if (data->type == EV_ABS) { if (data->type == EV_ABS) {
@ -400,7 +400,7 @@ void QTouchScreenData::processInputEvent(input_event *data)
m_lastEventType = data->type; m_lastEventType = data->type;
} }
int QTouchScreenData::findClosestContact(const QHash<int, Contact> &contacts, int x, int y, int *dist) int QEvdevTouchScreenData::findClosestContact(const QHash<int, Contact> &contacts, int x, int y, int *dist)
{ {
int minDist = -1, id = -1; int minDist = -1, id = -1;
for (QHash<int, Contact>::const_iterator it = contacts.constBegin(), ite = contacts.constEnd(); for (QHash<int, Contact>::const_iterator it = contacts.constBegin(), ite = contacts.constEnd();
@ -419,7 +419,7 @@ int QTouchScreenData::findClosestContact(const QHash<int, Contact> &contacts, in
return id; return id;
} }
void QTouchScreenData::assignIds() void QEvdevTouchScreenData::assignIds()
{ {
QHash<int, Contact> candidates = m_lastContacts, pending = m_contacts, newContacts; QHash<int, Contact> candidates = m_lastContacts, pending = m_contacts, newContacts;
int maxId = -1; int maxId = -1;
@ -453,7 +453,7 @@ void QTouchScreenData::assignIds()
m_contacts = newContacts; m_contacts = newContacts;
} }
void QTouchScreenData::reportPoints() void QEvdevTouchScreenData::reportPoints()
{ {
QRect winRect; QRect winRect;
if (m_forceToActiveWindow) { if (m_forceToActiveWindow) {
@ -493,21 +493,21 @@ void QTouchScreenData::reportPoints()
} }
QTouchScreenHandlerThread::QTouchScreenHandlerThread(const QString &spec) QEvdevTouchScreenHandlerThread::QEvdevTouchScreenHandlerThread(const QString &spec, QObject *parent)
: m_spec(spec), m_handler(0) : QThread(parent), m_spec(spec), m_handler(0)
{ {
start(); start();
} }
QTouchScreenHandlerThread::~QTouchScreenHandlerThread() QEvdevTouchScreenHandlerThread::~QEvdevTouchScreenHandlerThread()
{ {
quit(); quit();
wait(); wait();
} }
void QTouchScreenHandlerThread::run() void QEvdevTouchScreenHandlerThread::run()
{ {
m_handler = new QTouchScreenHandler(m_spec); m_handler = new QEvdevTouchScreenHandler(m_spec);
exec(); exec();
delete m_handler; delete m_handler;
m_handler = 0; m_handler = 0;

View File

@ -53,18 +53,18 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QSocketNotifier; class QSocketNotifier;
class QTouchScreenData; class QEvdevTouchScreenData;
#ifdef USE_MTDEV #ifdef USE_MTDEV
struct mtdev; struct mtdev;
#endif #endif
class QTouchScreenHandler : public QObject class QEvdevTouchScreenHandler : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
QTouchScreenHandler(const QString &spec = QString(), QObject *parent = 0); QEvdevTouchScreenHandler(const QString &spec = QString(), QObject *parent = 0);
~QTouchScreenHandler(); ~QEvdevTouchScreenHandler();
private slots: private slots:
void readData(); void readData();
@ -72,23 +72,23 @@ private slots:
private: private:
QSocketNotifier *m_notify; QSocketNotifier *m_notify;
int m_fd; int m_fd;
QTouchScreenData *d; QEvdevTouchScreenData *d;
#ifdef USE_MTDEV #ifdef USE_MTDEV
mtdev *m_mtdev; mtdev *m_mtdev;
#endif #endif
}; };
class QTouchScreenHandlerThread : public QThread class QEvdevTouchScreenHandlerThread : public QThread
{ {
public: public:
QTouchScreenHandlerThread(const QString &spec); QEvdevTouchScreenHandlerThread(const QString &spec, QObject *parent = 0);
~QTouchScreenHandlerThread(); ~QEvdevTouchScreenHandlerThread();
void run(); void run();
QTouchScreenHandler *handler() { return m_handler; } QEvdevTouchScreenHandler *handler() { return m_handler; }
private: private:
QString m_spec; QString m_spec;
QTouchScreenHandler *m_handler; QEvdevTouchScreenHandler *m_handler;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -1,12 +1,17 @@
Generic plug-in for evdev touch (ABS_MT) events. Generic plug-in for evdev multiple touch (ABS_MT) events.
Supports protocol type A & B. Supports protocol type A & B.
Type B is supported both directly and via libmtdev. Type B is supported both directly and via libmtdev.
Single-touch devices reporting ABS_X and Y only are not supported
by this plugin. Use tslib or evdevmouse instead.
The protocol type will be detected automatically. The protocol type will be detected automatically.
To enable libmtdev support uncomment the USE_MTDEV define in To enable libmtdev support uncomment the USE_MTDEV define in
evdevtouch.pro. evdevtouch.pro.
Tested with the following kernel drivers: bcm5974, hid_magicmouse. Tested with the following kernel drivers:
bcm5974 (type A)
hid_magicmouse (type A with ABS_MT_TRACKING_ID) (type B over libmtdev)
wacom (type B)
To use this "driver", pass -plugin EvdevTouch on the command line. To use this "driver", pass -plugin EvdevTouch on the command line.
@ -24,9 +29,9 @@ Only touch events are generated, mouse events are not. Be aware however
that ignored touch events will generate a mouse event from the first that ignored touch events will generate a mouse event from the first
touch point by default. See AA_SynthesizeMouseForUnhandledTouchEvents. touch point by default. See AA_SynthesizeMouseForUnhandledTouchEvents.
If no evdev events are read, disable the synaptics driver from X or If no evdev events are read, X may be grabbing the device.
temporarily disable the device by running Disable the synaptics driver from X or temporarily disable the device
xinput set-prop <device> <device enabled property> 0. by running xinput set-prop <device> <device enabled property> 0.
Use xinput list and xinput list-props to figure out the values. Use xinput list and xinput list-props to figure out the values.
When not running on a windowing system (eglfs, kms, etc.) and having a When not running on a windowing system (eglfs, kms, etc.) and having a
@ -38,5 +43,5 @@ If the input device cannot be accessed, set up a udev rule.
For example: For example:
sudo cp 70-qtouchscreen.rules /etc/udev/rules.d sudo cp 70-qtouchscreen.rules /etc/udev/rules.d
sudo udevadm trigger --subsystem-match=input sudo udevadm trigger --subsystem-match=input
The udev rule matches any touchpad or touchscreen device. If there are The sample udev rule matches any touchpad or touchscreen device.
multiple ones, specify the device manually as described above. If there are multiple ones, specify the device manually as described above.

View File

@ -44,32 +44,32 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QTouchScreenPlugin : public QGenericPlugin class QEvdevTouchScreenPlugin : public QGenericPlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevtouch.json") Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevtouch.json")
public: public:
QTouchScreenPlugin(); QEvdevTouchScreenPlugin();
QStringList keys() const; QStringList keys() const;
QObject* create(const QString &key, const QString &specification); QObject* create(const QString &key, const QString &specification);
}; };
QTouchScreenPlugin::QTouchScreenPlugin() QEvdevTouchScreenPlugin::QEvdevTouchScreenPlugin()
{ {
} }
QStringList QTouchScreenPlugin::keys() const QStringList QEvdevTouchScreenPlugin::keys() const
{ {
return QStringList() << "EvdevTouch"; return QStringList() << "EvdevTouch";
} }
QObject* QTouchScreenPlugin::create(const QString &key, QObject* QEvdevTouchScreenPlugin::create(const QString &key,
const QString &spec) const QString &spec)
{ {
if (!key.compare(QLatin1String("EvdevTouch"), Qt::CaseInsensitive)) if (!key.compare(QLatin1String("EvdevTouch"), Qt::CaseInsensitive))
return new QTouchScreenHandlerThread(spec); return new QEvdevTouchScreenHandlerThread(spec);
return 0; return 0;
} }