45 #include <QSocketNotifier> 46 #include <QStringList> 48 #include <qplatformdefs.h> 49 #include <private/qcore_unix_p.h> 53 #include <linux/input.h> 100 : m_handler(h), m_notify(0), m_x(0), m_y(0), m_buttons(0)
108 foreach (
const QString &arg, args) {
117 ::ioctl(
m_fd, EVIOCGRAB, grab);
143 struct ::input_event buffer[32];
147 int bytesRead =
QT_READ(
m_fd, reinterpret_cast<char *>(buffer) + n,
sizeof(buffer) - n);
148 if (bytesRead == 0) {
149 qWarning(
"Got EOF from the input device.");
152 if (bytesRead == -1) {
154 qWarning(
"Could not read from input device: %s", strerror(
errno));
159 if (n %
sizeof(buffer[0]) == 0)
162 n /=
sizeof(buffer[0]);
164 for (
int i = 0; i < n; ++i) {
165 struct ::input_event *
data = &buffer[i];
167 bool unknown =
false;
168 if (data->type == EV_ABS) {
169 if (data->code == ABS_X) {
171 }
else if (data->code == ABS_Y) {
176 }
else if (data->type == EV_REL) {
177 if (data->code == REL_X) {
179 }
else if (data->code == REL_Y) {
184 }
else if (data->type == EV_KEY && data->code == BTN_TOUCH) {
186 }
else if (data->type == EV_KEY) {
188 switch (data->code) {
197 }
else if (data->type == EV_SYN && data->code == SYN_REPORT) {
202 }
else if (data->type == EV_MSC && data->code == MSC_SCAN) {
209 qWarning(
"unknown mouse event type=%x, code=%x, value=%x", data->type, data->code, data->value);
216 #include "qmouselinuxinput_qws.moc" QPoint transform(const QPoint &)
Transforms the given position from device coordinates to screen coordinates, and returns the transfor...
Q_GUI_EXPORT QScreen * qt_screen
#define QT_END_NAMESPACE
This macro expands to.
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
The QWSCalibratedMouseHandler class provides mouse calibration and noise reduction in Qt for Embedded...
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
void mouseChanged(const QPoint &pos, int bstate, int wheel=0)
Notifies the system of a new mouse event.
The QObject class is the base class of all Qt objects.
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
void setObjectName(const QString &name)
#define QT_BEGIN_NAMESPACE
This macro expands to.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
The QStringList class provides a list of strings.
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
The QPoint class defines a point in the plane using integer precision.
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
void limitToScreen(QPoint &pt)
Ensures that the given position is within the screen's boundaries, changing the position if necessary...
#define qPrintable(string)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
#define forever
This macro is provided for convenience for writing infinite loops.