44 #ifndef QT_NO_QWS_MOUSE_PC 58 #include <private/qcore_unix_p.h> 63 #include <sys/ioctl.h> 64 #include <sys/types.h> 115 void initState() { nbuf = bstate = goodness = badness = 0; }
117 void worse(
int by=1) { badness+=by; }
118 bool reliable()
const {
return goodness >= 5 && badness < 50; }
126 memcpy(buffer+nbuf, data, length);
136 #ifdef QWS_MOUSE_DEBUG 138 fprintf(stderr,
"QWSPcMouseSubHandler tryData read %d bytes:", n);
139 for (
int i=0; i<n; ++i)
140 fprintf(stderr,
" %02x", buffer[i]);
141 fprintf(stderr,
"\n");
146 memmove(buffer, buffer+n, nbuf-n);
167 if (tcflush(
fd,TCIOFLUSH) == -1) {
168 #ifdef QWS_MOUSE_DEBUG 169 perror(
"QWSPcMouseSubHandler_intellimouse: pre-init tcflush");
172 static const uchar initseq[] = { 243, 200, 243, 100, 243, 80 };
173 static const uchar query[] = { 0xf2 };
174 if (
QT_WRITE(
fd, initseq,
sizeof(initseq))!=
sizeof(initseq)) {
179 if (tcflush(
fd,TCIOFLUSH) == -1) {
180 #ifdef QWS_MOUSE_DEBUG 181 perror(
"QWSPcMouseSubHandler_intellimouse: post-init tcflush");
184 if (
QT_WRITE(
fd, query,
sizeof(query))!=
sizeof(query)) {
192 switch (reply[n-1]) {
207 if (
nbuf >= packetsize) {
211 #ifdef QWS_MOUSE_DEBUG 212 qDebug(
"Intellimouse: skipping (overflow)");
220 int nbstate =
buffer[0] & 0x7;
221 #ifdef QWS_MOUSE_DEBUG 224 wheel = packetsize > 3 ? -(
signed char)
buffer[3] : 0;
225 if (wheel < -2 || wheel > 2)
228 #ifdef QWS_MOUSE_DEBUG 229 qDebug(
"Intellimouse: motion %d,%d, state %d, raw wheel %d, wheel %d",
motion.
x(),
motion.
y(), nbstate, debugwheel,
wheel);
255 if (tcflush(
fd,TCIOFLUSH) == -1) {
256 #ifdef QWS_MOUSE_DEBUG 257 perror(
"QWSPcMouseSubHandler_mouseman: initial tcflush");
264 static const unsigned char ibuf[] = { 246, 244 };
267 if (tcflush(
fd,TCIOFLUSH) == -1) {
268 #ifdef QWS_MOUSE_DEBUG 269 perror(
"QWSPcMouseSubHandler_mouseman: tcflush");
289 int overflow = (
buffer[0]>>6)& 0x03;
295 bool xs =
buffer[0] & 0x10;
296 bool ys =
buffer[0] & 0x20;
326 if (tcgetattr(
fd, &tty) == -1) {
327 #ifdef QWS_MOUSE_DEBUG 328 perror(
"QWSPcMouseSubHandler_serial: tcgetattr");
331 tty.c_iflag = IGNBRK | IGNPAR;
334 tty.c_cflag = f | CREAD | CLOCAL | HUPCL;
340 if (tcsetattr(
fd, TCSANOW, &tty) == -1) {
341 #ifdef QWS_MOUSE_DEBUG 342 perror(
"QWSPcMouseSubHandler_serial: tcgetattr");
350 int speed[4] = { B9600, B4800, B2400, B1200 };
352 for (
int n = 0; n < 4; n++) {
353 setflags(CSTOPB | speed[n]);
371 setflags(B1200|CS8|CSTOPB);
377 if (tcflush(
fd,TCIOFLUSH) == -1) {
378 #ifdef QT_QWS_VNC_DEBUG 379 perror(
"QWSPcMouseSubHandler_mousesystems: tcflush");
387 if ((
buffer[0] & 0xf8) != 0x80) {
393 -(
signed char)buffer[2] + (
signed char)buffer[4]);
395 int nbstate = ((t&3) << 1) | ((t&4) >> 2);
426 if (tcflush(
fd,TCIOFLUSH) == -1) {
427 #ifdef QWS_MOUSE_DEBUG 428 perror(
"QWSPcMouseSubHandler_ms: tcflush");
435 if (!(
buffer[0] & 0x40)) {
442 if (
nbuf >= 3+extra) {
447 nbstate = ((
buffer[0] & 0x20) >> 5)
448 | ((
buffer[0] & 0x10) >> 3);
449 if (extra &&
buffer[3] == 0x20)
459 |(
signed char)(
buffer[1]&0x3f),
460 (
signed char)((
buffer[0]&0xc)<<4)
461 |(
signed char)(
buffer[2]&0x3f));
496 void readMouseData(
int);
544 index = args.
indexOf(accelRegex);
552 index = args.
indexOf(accelLimitRegex);
677 qCritical(
"Error opening mouse device '%s': %s",
696 const char fn[4][11] = {
"/dev/ttyS0",
"/dev/ttyS1",
"/dev/ttyS2",
"/dev/ttyS3" };
697 for (
int ch = 0; ch < 4; ++ch) {
713 for (
int i=0; i<
nsub; i++) {
729 for (
int i=0; i<
nsub; i++)
750 int n = read(fd, buf, 8);
753 for (
int i=0; i<
nsub; i++) {
755 if (h.
file() == fd) {
773 bool any_reliable=
false;
774 for (
int i=0; i<
nsub; i++) {
778 any_reliable = any_reliable || h.
reliable();
792 #include "qmousepc_qws.moc" 794 #endif // QT_NO_MOUSE_PC
Q_GUI_EXPORT QScreen * qt_screen
QWSPcMouseSubHandler_mouseman(int f)
int height() const
Returns the logical height of the framebuffer in pixels.
QString cap(int nth=0) const
Returns the text captured by the nth subexpression.
bool motionPending() const
#define QT_END_NAMESPACE
This macro expands to.
bool sendEvent(QWSPcMouseSubHandler &h)
The QRegExp class provides pattern matching using regular expressions.
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 ...
void resume()
Implement this function to resume reading and handling mouse events, e.
QWSPcMouseSubHandler(int f)
The QByteArray class provides an array of bytes.
The QWSMouseHandler class is a base class for mouse drivers in Qt for Embedded Linux.
~QWSPcMouseHandlerPrivate()
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QWSPcMouseSubHandler_serial(int f)
The QString class provides a Unicode character string.
const QPoint & pos() const
Returns the current mouse position.
void mouseChanged(const QPoint &pos, int bstate, int wheel=0)
Notifies the system of a new mouse event.
Q_DECL_CONSTEXPR T qAbs(const T &t)
The QObject class is the base class of all Qt objects.
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
virtual QSize mapToDevice(const QSize &) const
Maps the given size from the coordinate space used by the application to the framebuffer coordinate s...
Q_CORE_EXPORT void qDebug(const char *,...)
int width() const
Returns the logical width of the framebuffer in pixels.
void append(const T &t)
Inserts value at the end of the list.
int indexOf(const QRegExp &rx, int from=0) const
Returns the index position of the first exact match of rx in the list, searching forward from index p...
#define QT_BEGIN_NAMESPACE
This macro expands to.
QWSPcMouseSubHandler_intellimouse(int f)
QList< QSocketNotifier * > notifiers
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...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
QWSPcMouseSubHandler_ms(int f)
static const char * data(const QByteArray &arr)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
void clear()
Removes all items from the list.
QWSPcMouseHandlerPrivate * d
void appendData(uchar *data, int length)
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString join(const QString &sep) const
Joins all the string list's strings into a single string with each element separated by the given sep...
QWSPcMouseSubHandler * sub[max_dev]
virtual bool isTransformed() const
Returns true if the screen is transformed (for instance, rotated 90 degrees); otherwise returns false...
void suspend()
Implement this function to suspend reading and handling of mouse events, e.
The QPoint class defines a point in the plane using integer precision.
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
double toDouble(bool *ok=0) const
Returns the string converted to a double value.
int size() const
Returns the number of items in the list.
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.
QWSPcMouseHandler(const QString &=QString(), const QString &=QString())
int y() const
Returns the y coordinate of this point.
virtual ~QWSPcMouseSubHandler()
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QSize class defines the size of a two-dimensional object using integer point precision.
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...
int x() const
Returns the x coordinate of this point.
QWSPcMouseHandler * handler
QImageIOHandler * handler
void limitToScreen(QPoint &pt)
Ensures that the given position is within the screen's boundaries, changing the position if necessary...
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QWSPcMouseHandlerPrivate(QWSPcMouseHandler *h, const QString &, const QString &)
Q_CORE_EXPORT void qCritical(const char *,...)
The QList class is a template class that provides lists.
QWSPcMouseSubHandler_mousesystems(int f)
void removeAt(int i)
Removes the item at index position i.