3 # Patch managed by http://www.holgerschurig.de/patcher.html
6 --- qt-2.3.10/src/kernel/qwsmouse_qws.cpp~ramses-touchscreen
7 +++ qt-2.3.10/src/kernel/qwsmouse_qws.cpp
9 /****************************************************************************
10 -** $Id: qt/src/kernel/qwsmouse_qws.cpp 2.3.10 edited 2005-01-24 $
11 +** $Id: qt/src/kernel/qwsmouse_qws.cpp 2.3.7 edited 2003-02-04 $
13 ** Implementation of Qt/Embedded mouse drivers
18 #include <sys/ioctl.h>
19 -#include <sys/time.h>
20 #include <sys/types.h>
28 #if !defined(_OS_QNX6_)
30 -#ifdef QT_QWS_CASSIOPEIA
31 -#include <linux/tpanel.h>
40 -#if defined(QT_QWS_IPAQ) || defined(QT_QWS_K2)
41 -#define QT_QWS_IPAQ_RAW
43 - unsigned short pressure;
47 - struct timeval stamp;
49 -#elif defined(QT_QWS_SL5XXX)
50 -#define QT_QWS_SL5XXX_RAW
55 - long long millisecs;
57 -#define QT_QWS_TP_SAMPLE_SIZE 10
58 -#define QT_QWS_TP_MINIMUM_SAMPLES 4
59 -#define QT_QWS_TP_PRESSURE_THRESHOLD 500
60 -#define QT_QWS_TP_MOVE_LIMIT 50
61 -#define QT_QWS_TP_JITTER_LIMIT 2
62 -#elif defined(QT_QWS_SLC700)
63 -#define QT_QWS_SLC700_RAW
65 - unsigned short pressure;
68 - unsigned short millisecs;
70 -#define QT_QWS_TP_SAMPLE_SIZE 10
71 -#define QT_QWS_TP_MINIMUM_SAMPLES 4
72 -#define QT_QWS_TP_PRESSURE_THRESHOLD 500
73 -#define QT_QWS_TP_MOVE_LIMIT 50
74 -#define QT_QWS_TP_JITTER_LIMIT 2
77 -#ifndef QT_QWS_TP_SAMPLE_SIZE
78 -#define QT_QWS_TP_SAMPLE_SIZE 5
81 -#ifndef QT_QWS_TP_MINIMUM_SAMPLES
82 -#define QT_QWS_TP_MINIMUM_SAMPLES 5
83 +#ifndef QT_QWS_TP_PRESSURE_DOWN_THRESHOLD
84 +#define QT_QWS_TP_PRESSURE_DOWN_THRESHOLD 500
87 -#ifndef QT_QWS_TP_PRESSURE_THRESHOLD
88 -#define QT_QWS_TP_PRESSURE_THRESHOLD 1
89 +#ifndef QT_QWS_TP_PRESSURE_UP_THRESHOLD
90 +#define QT_QWS_TP_PRESSURE_UP_THRESHOLD 450
93 -#ifndef QT_QWS_TP_MOVE_LIMIT
94 -#define QT_QWS_TP_MOVE_LIMIT 100
95 +#ifndef QT_QWS_TP_TABLE_SIZE
96 +#define QT_QWS_TP_TABLE_SIZE 2
99 -#ifndef QT_QWS_TP_JITTER_LIMIT
100 -#define QT_QWS_TP_JITTER_LIMIT 2
101 +#ifndef QT_QWS_TP_MOVE_MAX
102 +#define QT_QWS_TP_MOVE_MAX 100
105 -//#define QWS_CUSTOMTOUCHPANEL
108 \class QWSMouseHandler qwsmouse_qws.h
109 \brief Mouse driver/handler for Qt/Embedded
111 enum MouseProtocol { Unknown = -1, Auto = 0,
112 MouseMan, IntelliMouse, Microsoft,
113 QVFBMouse, TPanel, BusMouse,
114 - FirstAuto = MouseMan,
115 - LastAuto = Microsoft };
118 static void limitToScreen( QPoint &pt )
120 @@ -186,810 +132,14 @@
123 static const MouseConfig mouseConfig[] = {
124 -#ifndef QT_NO_QWS_MOUSE_AUTO
127 -#ifndef QT_NO_QWS_MOUSE_PC
128 - { "MouseMan", MouseMan },
129 - { "IntelliMouse", IntelliMouse },
130 - { "USB", IntelliMouse },
131 - { "Microsoft", Microsoft },
133 -#ifndef QT_NO_QWS_VFB
134 { "QVFbMouse", QVFBMouse },
136 { "TPanel", TPanel },
137 - { "BusMouse", BusMouse },
141 -#ifndef QT_NO_QWS_MOUSE_AUTO
143 - * Automatic-detection mouse driver
146 -class QAutoMouseSubHandler {
148 - enum { max_buf=32 };
152 - uchar buffer[max_buf];
161 - virtual int tryData()=0;
164 - QAutoMouseSubHandler(int f) : fd(f)
166 - nbuf = bstate = goodness = badness = 0;
169 - int file() const { return fd; }
171 - void closeIfNot(int& f)
179 - void worse(int by=1) { badness+=by; }
180 - bool reliable() const { return goodness >= 5 && badness < 50; }
181 - int buttonState() const { return bstate; }
182 - bool motionPending() const { return motion!=QPoint(0,0); }
183 - QPoint takeMotion() { QPoint r=motion; motion=QPoint(0,0); return r; }
185 - void appendData(uchar* data, int length)
187 - memcpy(buffer+nbuf, data, length);
191 - enum UsageResult { Insufficient, Motion, Button };
193 - UsageResult useData()
195 - int pbstate = bstate;
199 - memmove( buffer, buffer+n, nbuf-n );
201 - return pbstate == bstate ? Motion : Button;
203 - return Insufficient;
207 -class QAutoMouseSubHandler_intellimouse : public QAutoMouseSubHandler {
210 - QAutoMouseSubHandler_intellimouse(int f) : QAutoMouseSubHandler(f)
220 - tcflush(fd,TCIOFLUSH);
221 - static const uchar initseq[] = { 243, 200, 243, 100, 243, 80 };
222 - static const uchar query[] = { 0xf2 };
223 - if (write(fd, initseq, sizeof(initseq))!=sizeof(initseq)) {
228 - tcflush(fd,TCIOFLUSH);
229 - if (write(fd, query, sizeof(query))!=sizeof(query)) {
234 - n = read(fd, reply, 20);
237 - switch ( reply[n-1] ) {
252 - if ( nbuf >= packetsize ) {
253 - //int overflow = (buffer[0]>>6 )& 0x03;
255 - if ( /*overflow ||*/ !(buffer[0] & 8) ) {
260 - QPoint((buffer[0] & 0x10) ? buffer[1]-256 : buffer[1],
261 - (buffer[0] & 0x20) ? 256-buffer[2] : -buffer[2]);
262 - int nbstate = buffer[0] & 0x7;
263 - if ( motion.x() || motion.y() || bstate != nbstate ) {
277 -class QAutoMouseSubHandler_serial : public QAutoMouseSubHandler {
279 - QAutoMouseSubHandler_serial(int f) : QAutoMouseSubHandler(f)
285 - void setflags(int f)
288 - tcgetattr(fd, &tty);
289 - tty.c_iflag = IGNBRK | IGNPAR;
292 - tty.c_cflag = f | CREAD | CLOCAL | HUPCL;
293 -#if !defined(_OS_FREEBSD_) && !defined(_OS_SOLARIS_)
296 - tty.c_cc[VTIME] = 0;
297 - tty.c_cc[VMIN] = 1;
298 - tcsetattr(fd, TCSANOW, &tty);
304 - int speed[4] = { B9600, B4800, B2400, B1200 };
306 - for (int n = 0; n < 4; n++) {
307 - setflags(CSTOPB | speed[n]);
308 - write(fd, "*q", 2);
314 -class QAutoMouseSubHandler_mousesystems : public QAutoMouseSubHandler_serial {
316 - // ##### This driver has not been tested
318 - QAutoMouseSubHandler_mousesystems(int f) : QAutoMouseSubHandler_serial(f)
325 - setflags(B1200|CS8|CSTOPB);
327 - if (write(fd, "R", 1)!=1) {
331 - tcflush(fd,TCIOFLUSH);
337 - if ( (buffer[0] & 0xf8) != 0x80 ) {
342 - QPoint((signed char)buffer[1] + (signed char)buffer[3],
343 - -(signed char)buffer[2] + (signed char)buffer[4]);
344 - int t = ~buffer[0];
345 - int nbstate = ((t&3) << 1) | ((t&4) >> 2);
346 - if ( motion.x() || motion.y() || bstate != nbstate ) {
359 -class QAutoMouseSubHandler_ms : public QAutoMouseSubHandler_serial {
362 - QAutoMouseSubHandler_ms(int f) : QAutoMouseSubHandler_serial(f)
370 - setflags(B1200|CS7);
372 - if (write(fd, "R", 1)!=1) {
376 - tcflush(fd,TCIOFLUSH);
381 - if ( !(buffer[0] & 0x40) ) {
382 - if ( buffer[0] == 0x20 && (bstate & Qt::MidButton) ) {
383 - mman=1; // mouseman extension
387 - int extra = mman&&(bstate & Qt::MidButton);
388 - if ( nbuf >= 3+extra ) {
390 - if ( buffer[0] == 0x40 && !bstate && !buffer[1] && !buffer[2] ) {
391 - nbstate = Qt::MidButton;
393 - nbstate = ((buffer[0] & 0x20) >> 5)
394 - | ((buffer[0] & 0x10) >> 3);
395 - if ( extra && buffer[3] == 0x20 )
396 - nbstate = Qt::MidButton;
399 - if ( buffer[1] & 0x40 ) {
404 - QPoint((signed char)((buffer[0]&0x3)<<6)
405 - |(signed char)(buffer[1]&0x3f),
406 - (signed char)((buffer[0]&0xc)<<4)
407 - |(signed char)(buffer[2]&0x3f));
408 - if ( motion.x() || motion.y() || bstate != nbstate ) {
423 -QAutoMouseHandler::UsageResult QAutoMouseHandler::useDev(Dev& d)
425 - if ( d.nbuf >= mouseData[d.protocol].bytesPerPacket ) {
431 - switch (mouseProtocol) {
435 - bstate = mb[0] & 0x7; // assuming Qt::*Button order
437 - int overflow = (mb[0]>>6 )& 0x03;
438 - if (mouseProtocol == MouseMan && overflow) {
439 - //### wheel events signalled with overflow bit, ignore for now
442 - bool xs = mb[0] & 0x10;
443 - bool ys = mb[0] & 0x20;
444 - dx = xs ? mb[1]-256 : mb[1];
445 - dy = ys ? mb[2]-256 : mb[2];
450 - if ( ((mb[0] & 0x20) >> 3) ) {
451 - bstate |= Qt::LeftButton;
453 - if ( ((mb[0] & 0x10) >> 4) ) {
454 - bstate |= Qt::RightButton;
457 - dx=(signed char)(((mb[0] & 0x03) << 6) | (mb[1] & 0x3f));
458 - dy=-(signed char)(((mb[0] & 0x0c) << 4) | (mb[2] & 0x3f));
468 -class QAutoMouseHandler : public QWSMouseHandler {
472 - QAutoMouseHandler();
473 - ~QAutoMouseHandler();
475 -#ifndef QT_NO_QWS_MOUSE_AUTO
477 - enum { max_dev=32 };
478 - QAutoMouseSubHandler *sub[max_dev];
479 - QList<QSocketNotifier> notifiers;
485 - void readMouseData(int);
488 -#ifndef QT_NO_QWS_MOUSE_AUTO
489 - void openDevices();
490 - void closeDevices();
491 - void notify(int fd);
492 - bool sendEvent(QAutoMouseSubHandler& h)
494 - if ( h.reliable() ) {
495 - mousePos += h.takeMotion();
496 - limitToScreen( mousePos );
498 -qDebug("%d,%d %c%c%c",
499 -mousePos.x(),mousePos.y(),
500 -(h.buttonState()&Qt::LeftButton)?'L':'.',
501 -(h.buttonState()&Qt::MidButton)?'M':'.',
502 -(h.buttonState()&Qt::RightButton)?'R':'.');
504 - emit mouseChanged(mousePos,h.buttonState());
508 - if ( h.buttonState() & (Qt::RightButton|Qt::MidButton) ) {
509 - // Strange for the user to press right or middle without
519 -QAutoMouseHandler::QAutoMouseHandler()
521 -#ifndef QT_NO_QWS_MOUSE_AUTO
522 - notifiers.setAutoDelete( TRUE );
528 -QAutoMouseHandler::~QAutoMouseHandler()
530 -#ifndef QT_NO_QWS_MOUSE_AUTO
535 -#ifndef QT_NO_QWS_MOUSE_AUTO
536 -void QAutoMouseHandler::openDevices()
540 - fd = open( "/dev/psaux", O_RDWR | O_NDELAY );
542 - sub[nsub++] = new QAutoMouseSubHandler_intellimouse(fd);
545 -#if !defined(QT_QWS_IPAQ) && !defined(QT_QWS_SL5XXX) && !defined(QT_QWS_K2) && !defined(QT_QWS_SLC700)
546 - char fn[] = "/dev/ttyS?";
547 - for (int ch='0'; ch<='3'; ch++) {
549 - fd = open( fn, O_RDWR | O_NDELAY );
551 - //sub[nsub++] = new QAutoMouseSubHandler_intellimouse(fd);
552 - sub[nsub++] = new QAutoMouseSubHandler_mousesystems(fd);
553 - sub[nsub++] = new QAutoMouseSubHandler_ms(fd);
561 -void QAutoMouseHandler::closeDevices()
564 - for (int i=0; i<nsub; i++) {
565 - sub[i]->closeIfNot(pfd);
571 -void QAutoMouseHandler::notify(int fd)
573 - QSocketNotifier *mouseNotifier
574 - = new QSocketNotifier( fd, QSocketNotifier::Read, this );
575 - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData(int)));
576 - notifiers.append( mouseNotifier );
580 -void QAutoMouseHandler::readMouseData(int fd)
582 -#ifndef QT_NO_QWS_MOUSE_AUTO
585 - int n = read(fd, buf, 8);
588 - for (int i=0; i<nsub; i++) {
589 - QAutoMouseSubHandler& h = *sub[i];
590 - if ( h.file() == fd ) {
591 - h.appendData(buf,n);
593 - switch ( h.useData() ) {
594 - case QAutoMouseSubHandler::Button:
597 - case QAutoMouseSubHandler::Insufficient:
599 - case QAutoMouseSubHandler::Motion:
608 - bool any_reliable=FALSE;
609 - for (int i=0; i<nsub; i++) {
610 - QAutoMouseSubHandler& h = *sub[i];
611 - if ( h.motionPending() )
613 - any_reliable = any_reliable || h.reliable();
615 - if ( any_reliable ) {
616 - // ... get rid of all unreliable ones? All bad ones?
617 - } else if ( retries < 2 ) {
618 - // Try again - maybe the mouse was being moved when we tried to init.
632 - * Standard mouse driver
636 - int bytesPerPacket;
639 -static const MouseData mouseData[] = {
640 - { 3 }, // dummy for auto protocal, correction made by add by YYD
642 - { 4 }, // intelliMouse
643 - { 3 }, // Microsoft
644 - { 0 }, // QVFBMouse,
646 - { 3 }, // BusMouse,
650 -class QWSMouseHandlerPrivate : public QWSMouseHandler {
653 - QWSMouseHandlerPrivate( MouseProtocol protocol, QString mouseDev );
654 - ~QWSMouseHandlerPrivate();
656 -#ifndef QT_NO_QWS_MOUSE_PC
658 - static const int mouseBufSize = 128;
661 - uchar mouseBuf[mouseBufSize];
662 - MouseProtocol mouseProtocol;
663 - void handleMouseData();
667 - void readMouseData();
674 -void QWSMouseHandlerPrivate::readMouseData()
676 -#ifndef QT_NO_QWS_MOUSE_PC
678 - if ( BusMouse == mouseProtocol ) {
679 - // a workaround of linux busmouse driver interface.
680 - // It'll only read 3 bytes a time and return all other buffer zeroed, thus cause protocol errors
682 - if ( mouseBufSize - mouseIdx < 3 )
684 - n = read( mouseFD, mouseBuf+mouseIdx, 3 );
691 - n = read(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx );
701 -#ifndef QT_NO_QWS_MOUSE_PC
705 -void QWSMouseHandlerPrivate::handleMouseData()
707 - static const int accel_limit = 5;
708 - static const int accel = 2;
712 - int dx = 0, dy = 0;
713 - bool sendEvent = false;
714 - int tdx = 0, tdy = 0;
716 - while ( mouseIdx-idx >= mouseData[mouseProtocol].bytesPerPacket ) {
717 - //qDebug( "Got mouse data" );
718 - uchar *mb = mouseBuf+idx;
723 - switch (mouseProtocol) {
728 - bstate |= Qt::LeftButton;
730 - bstate |= Qt::RightButton;
732 - bstate |= Qt::MidButton;
734 - int overflow = (mb[0]>>6 )& 0x03;
735 - if (mouseProtocol == MouseMan && overflow) {
736 - //### wheel events signalled with overflow bit, ignore for now
739 - bool xs = mb[0] & 0x10;
740 - bool ys = mb[0] & 0x20;
741 - dx = xs ? mb[1]-256 : mb[1];
742 - dy = ys ? mb[2]-256 : mb[2];
747 - if (mouseProtocol == MouseMan)
748 - printf("(%2d) %02x %02x %02x ", idx, mb[0], mb[1], mb[2]);
750 - printf("(%2d) %02x %02x %02x %02x ",idx,mb[0],mb[1],mb[2],mb[3]);
751 - const char *b1 = (mb[0] & 0x01) ? "b1":" ";//left
752 - const char *b2 = (mb[0] & 0x02) ? "b2":" ";//right
753 - const char *b3 = (mb[0] & 0x04) ? "b3":" ";//mid
756 - printf( "Overflow%d %s %s %s (%4d,%4d)\n", overflow,
757 - b1, b2, b3, mousePos.x(), mousePos.y() );
759 - printf( "%s %s %s (%+3d,%+3d) (%4d,%4d)\n",
760 - b1, b2, b3, dx, dy, mousePos.x(), mousePos.y() );
765 - if ( (mb[0] & 0x20) )
766 - bstate |= Qt::LeftButton;
767 - if ( (mb[0] & 0x10) )
768 - bstate |= Qt::RightButton;
770 - dx=(signed char)(((mb[0] & 0x03) << 6) | (mb[1] & 0x3f));
771 - dy=-(signed char)(((mb[0] & 0x0c) << 4) | (mb[2] & 0x3f));
776 - if ( !(mb[0] & 0x04) )
777 - bstate |= Qt::LeftButton;
778 - if ( !(mb[0] & 0x01) )
779 - bstate |= Qt::RightButton;
781 - dx=(signed char)mb[1];
782 - dy=(signed char)mb[2];
787 - qWarning( "Unknown mouse protocol in QWSMouseHandlerPrivate" );
791 - if ( QABS(dx) > accel_limit || QABS(dy) > accel_limit ) {
797 - if ( bstate != obstate ) {
798 - mousePos += QPoint(tdx,-tdy);
799 - limitToScreen( mousePos );
800 - emit mouseChanged(mousePos,bstate);
807 - idx += mouseData[mouseProtocol].bytesPerPacket;
810 - mousePos += QPoint(tdx,-tdy);
811 - limitToScreen( mousePos );
812 - emit mouseChanged(mousePos,bstate);
815 - int surplus = mouseIdx - idx;
816 - for ( int i = 0; i < surplus; i++ )
817 - mouseBuf[i] = mouseBuf[idx+i];
818 - mouseIdx = surplus;
823 -QWSMouseHandlerPrivate::QWSMouseHandlerPrivate( MouseProtocol protocol,
826 -#ifndef QT_NO_QWS_MOUSE_PC
827 - mouseProtocol = protocol;
829 - if ( mouseDev.isEmpty() )
830 - mouseDev = "/dev/mouse";
833 - mouseFD = open( mouseDev.local8Bit().data(), O_RDWR | O_NDELAY);
834 - if ( mouseFD < 0 ) {
835 - mouseFD = open( mouseDev.local8Bit().data(), O_RDONLY | O_NDELAY);
837 - qDebug( "Cannot open %s (%s)", mouseDev.ascii(),
840 - // Clear pending input
841 - tcflush(mouseFD,TCIFLUSH);
845 - switch (mouseProtocol) {
848 - write(mouseFD,"",1);
850 - write(mouseFD,"@EeI!",5);
853 - case IntelliMouse: {
855 - const unsigned char init1[] = { 243, 200, 243, 100, 243, 80 };
856 - const unsigned char init2[] = { 246, 230, 244, 243, 100, 232, 3 };
857 - write(mouseFD,init1,sizeof(init1));
859 - write(mouseFD,init2,sizeof(init2));
864 - struct termios tty;
866 - tcgetattr(mouseFD, &tty);
868 - tty.c_iflag = IGNBRK | IGNPAR;
871 -#if !defined(_OS_FREEBSD_) && !defined(_OS_SOLARIS_)
873 -#endif // _OS_FREEBSD_
874 - tty.c_cc[VTIME] = 0;
875 - tty.c_cc[VMIN] = 1;
876 - tty.c_cflag = B1200 | CS7 | CREAD | CLOCAL | HUPCL;
877 - tcsetattr(mouseFD, TCSAFLUSH, &tty); /* set parameters */
885 - qDebug("Unknown mouse protocol");
890 - char buf[] = { 246, 244 };
891 - write(mouseFD,buf,1);
892 - write(mouseFD,buf+1,1);
896 - tcflush(mouseFD,TCIFLUSH); // ### doesn't seem to work.
898 - tcflush(mouseFD,TCIFLUSH); // ### doesn't seem to work.
900 - char buf[100]; // busmouse driver will not read if bufsize < 3, YYD
901 - while (read(mouseFD, buf, 100) > 0) { } // eat unwanted replies
905 - QSocketNotifier *mouseNotifier;
906 - mouseNotifier = new QSocketNotifier( mouseFD, QSocketNotifier::Read, this );
907 - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
910 - Q_UNUSED(protocol);
911 - Q_UNUSED(mouseDev);
915 -QWSMouseHandlerPrivate::~QWSMouseHandlerPrivate()
917 -#ifndef QT_NO_QWS_MOUSE_PC
918 - if (mouseFD >= 0) {
919 - tcflush(mouseFD,TCIFLUSH); // yyd.
929 QCalibratedMouseHandler::QCalibratedMouseHandler()
930 : samples(5), currSample(0), numSamples(0)
932 if ( file.open( IO_WriteOnly ) ) {
933 QTextStream t( &file );
934 t << a << " " << b << " " << c << " ";
935 - t << d << " " << e << " " << f << " " << s;
936 + t << d << " " << e << " " << f << " " << s << endl;
942 if ( file.open( IO_ReadOnly ) ) {
943 QTextStream t( &file );
944 t >> a >> b >> c >> d >> e >> f >> s;
949 @@ -1073,12 +225,24 @@
953 +void QCalibratedMouseHandler::setCalibration(int aa, int bb, int cc, int dd, int ee, int ff, int ss)
964 QPoint QCalibratedMouseHandler::transform( const QPoint &p )
968 tp.setX( (a * p.x() + b * p.y() + c) / s );
969 tp.setY( (d * p.x() + e * p.y() + f) / s );
970 +//qDebug("QCalibratedMouseHandler::transform(%d,%d) -> %d,%d)", p.x(), p.y(), tp.x(), tp.y() );
974 @@ -1143,814 +307,192 @@
979 - * Handler for /dev/tpanel Linux kernel driver
982 -class QVrTPanelHandlerPrivate : public QCalibratedMouseHandler {
985 - QVrTPanelHandlerPrivate(MouseProtocol, QString dev);
986 - ~QVrTPanelHandlerPrivate();
990 - MouseProtocol mouseProtocol;
992 - void sendRelease();
993 - void readMouseData();
995 - static const int mouseBufSize = 1280;
998 - uchar mouseBuf[mouseBufSize];
1001 -#ifndef QT_QWS_CASSIOPEIA
1002 -QVrTPanelHandlerPrivate::QVrTPanelHandlerPrivate( MouseProtocol, QString ) :
1003 - QCalibratedMouseHandler()
1007 -QVrTPanelHandlerPrivate::QVrTPanelHandlerPrivate( MouseProtocol, QString dev ) :
1008 - QCalibratedMouseHandler()
1010 - if ( dev.isEmpty() )
1011 - dev = "/dev/tpanel";
1013 - if ((mouseFD = open( dev, O_RDONLY)) < 0) {
1014 - qFatal( "Cannot open %s (%s)", dev.latin1(), strerror(errno));
1019 - struct scanparam s;
1020 - s.interval = 20000;
1021 - s.settletime = 480;
1022 - if ( ioctl(mouseFD, TPSETSCANPARM, &s) < 0
1023 - || fcntl(mouseFD, F_SETFL, O_NONBLOCK) < 0 )
1024 - qWarning("Error initializing touch panel.");
1026 - QSocketNotifier *mouseNotifier;
1027 - mouseNotifier = new QSocketNotifier( mouseFD, QSocketNotifier::Read,
1029 - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
1031 - rtimer = new QTimer( this );
1032 - connect( rtimer, SIGNAL(timeout()), this, SLOT(sendRelease()));
1034 - setFilterSize( 3 );
1036 - printf("\033[?25l"); fflush(stdout); // VT100 cursor off
1040 -QVrTPanelHandlerPrivate::~QVrTPanelHandlerPrivate()
1046 -void QVrTPanelHandlerPrivate::sendRelease()
1048 - sendFiltered( mousePos, 0 );
1051 -void QVrTPanelHandlerPrivate::readMouseData()
1053 -#ifdef QT_QWS_CASSIOPEIA
1056 - static bool pressed = FALSE;
1060 - n = read(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx );
1063 - } while ( n > 0 && mouseIdx < mouseBufSize );
1066 - while ( mouseIdx-idx >= (int)sizeof( short ) * 6 ) {
1067 - uchar *mb = mouseBuf+idx;
1068 - ushort *data = (ushort *) mb;
1069 - if ( data[0] & 0x8000 ) {
1070 - if ( data[5] > 750 ) {
1071 - QPoint t(data[3]-data[4],data[2]-data[1]);
1072 - if ( sendFiltered( t, Qt::LeftButton ) )
1075 - rtimer->start( 200, TRUE ); // release unreliable
1077 - } else if ( pressed ) {
1078 - rtimer->start( 50, TRUE );
1081 - idx += sizeof( ushort ) * 6;
1083 +struct input_event {
1084 + struct timeval time;
1085 + unsigned short type;
1086 + unsigned short code;
1087 + unsigned int value;
1090 - int surplus = mouseIdx - idx;
1091 - for ( int i = 0; i < surplus; i++ )
1092 - mouseBuf[i] = mouseBuf[idx+i];
1093 - mouseIdx = surplus;
1097 +#define EV_ABS 0x03
1100 +#define ABS_PRESSURE 0x18
1103 -class QTPanelHandlerPrivate : public QCalibratedMouseHandler
1104 +class QInputEventHandler : public QCalibratedMouseHandler
1108 - QTPanelHandlerPrivate(MouseProtocol, QString dev);
1109 - ~QTPanelHandlerPrivate();
1110 + QInputEventHandler(MouseProtocol, QString dev);
1111 + ~QInputEventHandler();
1113 + virtual void calibrate( QWSPointerCalibrationData * );
1114 + virtual void setCalibration(int aa, int bb, int cc, int dd, int ee, int ff, int ss);
1117 - static const int mouseBufSize = 2048;
1123 - QPoint oldTotalMousePos;
1125 - QPointArray samples;
1126 - unsigned int currSample;
1127 - unsigned int lastSample;
1128 - unsigned int numSamples;
1131 - uchar mouseBuf[mouseBufSize];
1132 + struct input_event sample;
1133 + int myX, myY, myP, oldX, oldY, oldP;
1134 + int xtable[QT_QWS_TP_TABLE_SIZE];
1135 + int ytable[QT_QWS_TP_TABLE_SIZE];
1139 void readMouseData();
1143 -QTPanelHandlerPrivate::QTPanelHandlerPrivate( MouseProtocol, QString dev )
1144 - : samples(QT_QWS_TP_SAMPLE_SIZE), currSample(0), lastSample(0),
1145 - numSamples(0), skipCount(0)
1148 -#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_K2) || defined(QT_QWS_SLC700)
1149 -#if defined(QT_QWS_IPAQ)
1150 -# ifdef QT_QWS_IPAQ_RAW
1151 - if ((mouseFD = open( "/dev/h3600_tsraw", O_RDONLY | O_NDELAY)) < 0) {
1153 - if ((mouseFD = open( "/dev/h3600_ts", O_RDONLY | O_NDELAY)) < 0) {
1155 - qWarning( "Cannot open /dev/h3600_ts (%s)", strerror(errno));
1158 -#elif defined(QT_QWS_SL5XXX) || defined(QT_QWS_K2) || defined(QT_QWS_SLC700)
1159 -//# ifdef QT_QWS_SL5XXX_TSRAW
1161 - if ((mouseFD = open( "/dev/tsraw", O_RDONLY | O_NDELAY)) < 0) {
1162 - qWarning( "Cannot open /dev/tsraw (%s)", strerror(errno));
1166 - if ((mouseFD = open( "/dev/ts", O_RDONLY | O_NDELAY)) < 0) {
1167 - qWarning( "Cannot open /dev/ts (%s)", strerror(errno));
1171 -#elif defined(QT_QWS_SIMPAD )
1172 - if ((mouseFD = open( "/dev/touchscreen/ucb1x00", O_RDONLY | O_NONBLOCK )) < 0) {
1173 - qWarning( "Cannot open /dev/touchscreen/ucb1x00 (%s)", strerror(errno));
1178 - QSocketNotifier *mouseNotifier;
1179 - mouseNotifier = new QSocketNotifier( mouseFD, QSocketNotifier::Read,
1181 - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
1187 -QTPanelHandlerPrivate::~QTPanelHandlerPrivate()
1188 +QInputEventHandler::QInputEventHandler( MouseProtocol, QString )
1191 -#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_K2) || defined(QT_QWS_SLC700) || defined(QT_QWS_SIMPAD)
1198 -void QTPanelHandlerPrivate::readMouseData()
1199 +QInputEventHandler::~QInputEventHandler()
1201 -#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_K2) || defined(QT_QWS_SLC700) || defined(QT_QWS_SIMPAD)
1207 - n = read(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx );
1210 - } while ( n > 0 && mouseIdx < mouseBufSize );
1215 - // perhaps we shouldn't be reading EVERY SAMPLE.
1216 - while ( mouseIdx-idx >= (int)sizeof( TS_EVENT ) ) {
1217 - uchar *mb = mouseBuf+idx;
1218 - data = (TS_EVENT *) mb;
1219 - if(data->pressure >= QT_QWS_TP_PRESSURE_THRESHOLD) {
1220 -#if defined(QT_QWS_SL5XXX) || defined(QT_QWS_SLC700)
1221 - samples[currSample] = QPoint( 1000 - data->x, data->y );
1223 - samples[currSample] = QPoint( data->x, data->y );
1227 - if ( numSamples >= QT_QWS_TP_MINIMUM_SAMPLES ) {
1228 - int sampleCount = QMIN(numSamples + 1,samples.count());
1230 - // average the rest
1231 - mousePos = QPoint( 0, 0 );
1232 - QPoint totalMousePos = oldTotalMousePos;
1233 - totalMousePos += samples[currSample];
1234 - if(numSamples >= samples.count())
1235 - totalMousePos -= samples[lastSample];
1237 - mousePos = totalMousePos / (sampleCount - 1);
1239 -# if defined(QT_QWS_IPAQ_RAW) || defined(QT_QWS_SL5XXX_RAW)
1240 - mousePos = transform( mousePos );
1243 - oldmouse = mousePos;
1244 - QPoint dp = mousePos - oldmouse;
1245 - int dxSqr = dp.x() * dp.x();
1246 - int dySqr = dp.y() * dp.y();
1247 - if ( dxSqr + dySqr < (QT_QWS_TP_MOVE_LIMIT * QT_QWS_TP_MOVE_LIMIT) ) {
1248 - if ( waspressed ) {
1249 - if ( (dxSqr + dySqr > (QT_QWS_TP_JITTER_LIMIT * QT_QWS_TP_JITTER_LIMIT) ) || skipCount > 2) {
1250 - emit mouseChanged(mousePos,Qt::LeftButton);
1251 - oldmouse = mousePos;
1257 - emit mouseChanged(mousePos,Qt::LeftButton);
1258 - oldmouse=mousePos;
1262 - // save recuring information
1264 - if (numSamples >= samples.count())
1266 - oldTotalMousePos = totalMousePos;
1268 - numSamples--; // don't use this sample, it was bad.
1271 - // build up the average
1272 - oldTotalMousePos += samples[currSample];
1275 - if ( currSample >= samples.count() )
1277 - if ( lastSample >= samples.count() )
1284 - oldTotalMousePos = QPoint(0,0);
1285 - if ( waspressed ) {
1286 - emit mouseChanged(oldmouse,0);
1287 - oldmouse = QPoint( -100, -100 );
1291 - idx += sizeof( TS_EVENT );
1295 - int surplus = mouseIdx - idx;
1296 - for ( int i = 0; i < surplus; i++ )
1297 - mouseBuf[i] = mouseBuf[idx+i];
1298 - mouseIdx = surplus;
1302 -// YOPY touch panel support based on changes contributed by Ron Victorelli
1303 -// (victorrj at icubed.com) to Custom TP driver.
1305 -class QYopyTPanelHandlerPrivate : public QWSMouseHandler {
1308 - QYopyTPanelHandlerPrivate(MouseProtocol, QString dev);
1309 - ~QYopyTPanelHandlerPrivate();
1315 - void readMouseData();
1319 -QYopyTPanelHandlerPrivate::QYopyTPanelHandlerPrivate( MouseProtocol, QString )
1320 +void QInputEventHandler::setCalibration(int aa, int bb, int cc, int dd, int ee, int ff, int ss)
1323 - if ((mouseFD = open( "/dev/ts", O_RDONLY)) < 0) {
1324 - qWarning( "Cannot open /dev/ts (%s)", strerror(errno));
1330 - QSocketNotifier *mouseNotifier;
1331 - mouseNotifier = new QSocketNotifier( mouseFD, QSocketNotifier::Read,
1333 - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
1336 + QCalibratedMouseHandler::setCalibration(aa, bb, cc, dd, ee, ff, ss);
1338 -QYopyTPanelHandlerPrivate::~QYopyTPanelHandlerPrivate()
1342 + writeCalibration();
1347 -#define YOPY_XPOS(d) (d[1]&0x3FF)
1348 -#define YOPY_YPOS(d) (d[2]&0x3FF)
1349 -#define YOPY_PRES(d) (d[0]&0xFF)
1350 -#define YOPY_STAT(d) (d[3]&0x01 )
1352 -struct YopyTPdata {
1354 - unsigned char status;
1355 - unsigned short xpos;
1356 - unsigned short ypos;
1360 -void QYopyTPanelHandlerPrivate::readMouseData()
1361 +void QInputEventHandler::calibrate( QWSPointerCalibrationData *cd )
1368 - unsigned int yopDat[4];
1372 - ret=read(mouseFD,&yopDat,sizeof(yopDat));
1373 + QCalibratedMouseHandler::calibrate( cd );
1376 - data.status= ( YOPY_PRES(yopDat) ) ? 1 : 0;
1377 - data.xpos=YOPY_XPOS(yopDat);
1378 - data.ypos=YOPY_YPOS(yopDat);
1380 - q.setX(data.xpos);
1381 - q.setY(data.ypos);
1383 - if(data.status && !prevstate) {
1384 - emit mouseChanged(mousePos,Qt::LeftButton);
1385 - } else if( !data.status && prevstate ) {
1386 - emit mouseChanged(mousePos,0);
1388 - prevstate = data.status;
1391 - qDebug("Error %s",strerror(errno));
1394 + // write calibration data, and close and reopen
1395 + // tslib, in order to ensure it uses the new values
1396 + writeCalibration();
1401 -class QCustomTPanelHandlerPrivate : public QWSMouseHandler {
1404 - QCustomTPanelHandlerPrivate(MouseProtocol, QString dev);
1405 - ~QCustomTPanelHandlerPrivate();
1410 - void readMouseData();
1414 -QCustomTPanelHandlerPrivate::QCustomTPanelHandlerPrivate( MouseProtocol, QString )
1415 +void QInputEventHandler::init()
1417 -#ifdef QWS_CUSTOMTOUCHPANEL
1418 - if ((mouseFD = open( "/dev/ts", O_RDONLY)) < 0) {
1419 - qWarning( "Cannot open /dev/ts (%s)", strerror(errno));
1420 + if ((mouseFD = open( "/dev/input/event1", O_RDONLY)) < 0) {
1421 + qWarning( "Cannot open /dev/input/event1 (%s)", strerror(errno));
1427 QSocketNotifier *mouseNotifier;
1428 - mouseNotifier = new QSocketNotifier( mouseFD, QSocketNotifier::Read,
1430 + mouseNotifier = new QSocketNotifier( mouseFD, QSocketNotifier::Read, this );
1432 connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
1436 -QCustomTPanelHandlerPrivate::~QCustomTPanelHandlerPrivate()
1437 +void QInputEventHandler::fini()
1443 -struct CustomTPdata {
1445 - unsigned char status;
1446 - unsigned short xpos;
1447 - unsigned short ypos;
1451 -void QCustomTPanelHandlerPrivate::readMouseData()
1452 +void QInputEventHandler::readMouseData()
1454 -#ifdef QWS_CUSTOMTOUCHPANEL
1457 - CustomTPdata data;
1459 - unsigned char data2[5];
1463 - ret=read(mouseFD,data2,5);
1468 - data.status=data2[0];
1469 - data.xpos=(data2[1] << 8) | data2[2];
1470 - data.ypos=(data2[3] << 8) | data2[4];
1472 - q.setX(data.xpos);
1473 - q.setY(data.ypos);
1475 - if(data.status & 0x40) {
1476 - emit mouseChanged(mousePos,Qt::LeftButton);
1478 - emit mouseChanged(mousePos,0);
1479 + unsigned int size = read(mouseFD, &sample, sizeof(sample));
1480 + if (size < sizeof(sample)) {
1481 + qDebug("no input");
1484 + //qDebug("type,code,val: %d,%d,%d", sample.type, sample.code, sample.value);
1485 + if (sample.type == EV_ABS) {
1486 + if (sample.code == ABS_Y) {
1487 + myY = sample.value;
1490 + if (sample.code == ABS_X) {
1491 + myX = sample.value;
1494 + if (sample.code == ABS_PRESSURE) {
1495 + myP = sample.value;
1500 - qDebug("Error %s",strerror(errno));
1506 - * Virtual framebuffer mouse driver
1509 -#ifndef QT_NO_QWS_VFB
1510 -#include "qvfbhdr.h"
1511 -extern int qws_display_id;
1514 -class QVFbMouseHandlerPrivate : public QWSMouseHandler {
1517 - QVFbMouseHandlerPrivate(MouseProtocol, QString dev);
1518 - ~QVFbMouseHandlerPrivate();
1520 -#ifndef QT_NO_QWS_VFB
1521 - bool isOpen() const { return mouseFD > 0; }
1524 - static const int mouseBufSize = 128;
1527 - uchar mouseBuf[mouseBufSize];
1531 - void readMouseData();
1534 -QVFbMouseHandlerPrivate::QVFbMouseHandlerPrivate( MouseProtocol, QString mouseDev )
1536 -#ifndef QT_NO_QWS_VFB
1538 - if ( mouseDev.isEmpty() )
1539 - mouseDev = QString(QT_VFB_MOUSE_PIPE).arg(qws_display_id);
1541 - if ((mouseFD = open( mouseDev.local8Bit().data(), O_RDWR | O_NDELAY)) < 0) {
1542 - qDebug( "Cannot open %s (%s)", mouseDev.ascii(),
1545 - // Clear pending input
1547 - while (read(mouseFD, buf, 1) > 0) { }
1551 - QSocketNotifier *mouseNotifier;
1552 - mouseNotifier = new QSocketNotifier( mouseFD, QSocketNotifier::Read, this );
1553 - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
1558 -QVFbMouseHandlerPrivate::~QVFbMouseHandlerPrivate()
1560 -#ifndef QT_NO_QWS_VFB
1566 -void QVFbMouseHandlerPrivate::readMouseData()
1568 -#ifndef QT_NO_QWS_VFB
1571 - n = read(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx );
1574 - } while ( n > 0 );
1577 - while ( mouseIdx-idx >= int(sizeof( QPoint ) + sizeof( int )) ) {
1578 - uchar *mb = mouseBuf+idx;
1579 - QPoint *p = (QPoint *) mb;
1580 - mb += sizeof( QPoint );
1581 - int *bstate = (int *)mb;
1583 - limitToScreen( mousePos );
1584 - emit mouseChanged(mousePos, *bstate);
1585 - idx += sizeof( QPoint ) + sizeof( int );
1588 - int surplus = mouseIdx - idx;
1589 - for ( int i = 0; i < surplus; i++ )
1590 - mouseBuf[i] = mouseBuf[idx+i];
1591 - mouseIdx = surplus;
1596 - mouse handler for tslib
1597 - see http://cvs.arm.linux.org.uk/
1601 - Copyright (C) 2003, 2004, 2005 Texas Instruments, Inc.
1602 - Copyright (C) 2004, 2005 Holger Hans Peter Freyther
1603 - All rights reserved.
1605 - Redistribution and use in source and binary forms, with or without
1606 - modification, are permitted provided that the following conditions are met:
1608 - Redistributions of source code must retain the above copyright notice,
1609 - this list of conditions and the following disclaimer.
1611 - Redistributions in binary form must reproduce the above copyright
1612 - notice, this list of conditions and the following disclaimer in the
1613 - documentation and/or other materials provided with the distribution.
1615 - Neither the name Texas Instruments, Inc nor the names of its
1616 - contributors may be used to endorse or promote products derived
1617 - from this software without specific prior written permission.
1619 - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1620 - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1621 - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
1622 - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
1623 - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
1624 - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1625 - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1626 - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1627 - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1628 - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
1629 - IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1630 - POSSIBILITY OF SUCH DAMAGE.
1633 -class QTSLibHandlerPrivate : public QCalibratedMouseHandler
1637 - QTSLibHandlerPrivate();
1638 - ~QTSLibHandlerPrivate();
1640 - virtual void clearCalibration();
1641 - virtual void calibrate( QWSPointerCalibrationData * );
1642 - static int sortByX( const void*, const void* );
1643 - static int sortByY( const void*, const void* );
1647 - QSocketNotifier *m_notify;
1649 -#ifdef QT_QWS_TSLIB
1650 - struct tsdev *m_ts;
1654 - void interpolateSample();
1657 - void readMouseData();
1661 -QTSLibHandlerPrivate::QTSLibHandlerPrivate()
1662 - : m_raw(false), m_notify(0 )
1667 -QTSLibHandlerPrivate::~QTSLibHandlerPrivate()
1672 -void QTSLibHandlerPrivate::openTs()
1674 -#ifdef QT_QWS_TSLIB
1676 - if((tsdevice = getenv("TSLIB_TSDEVICE")) != NULL) {
1677 - m_ts = ts_open( tsdevice, 1 ); //1 = nonblocking, 0 = blocking mode
1679 - m_ts = ts_open( "/dev/ts", 1 );
1683 - qWarning( "Cannot open touchscreen (%s)", strerror( errno));
1687 - if (ts_config( m_ts)) {
1688 - qWarning( "Cannot configure touchscreen (%s)", strerror( errno));
1691 - m_notify = new QSocketNotifier( ts_fd(m_ts), QSocketNotifier::Read, this );
1692 - connect( m_notify, SIGNAL(activated(int)),this, SLOT(readMouseData()));
1696 -void QTSLibHandlerPrivate::closeTs()
1698 -#ifdef QT_QWS_TSLIB
1709 -void QTSLibHandlerPrivate::clearCalibration()
1714 -void QTSLibHandlerPrivate::calibrate( QWSPointerCalibrationData * cd)
1716 - QPoint dev_tl = cd->devPoints[ QWSPointerCalibrationData::TopLeft ];
1717 - QPoint dev_br = cd->devPoints[ QWSPointerCalibrationData::BottomRight ];
1718 - QPoint screen_tl = cd->screenPoints[ QWSPointerCalibrationData::TopLeft ];
1719 - QPoint screen_br = cd->screenPoints[ QWSPointerCalibrationData::BottomRight ];
1720 - int a, b, c, d, e, f, s;
1724 - a = s * (screen_tl.x() - screen_br.x() ) / (dev_tl.x() - dev_br.x());
1726 - c = s * screen_tl.x() - a * dev_tl.x();
1728 + if (oldP==0 && myP==0) {
1729 + //qDebug("uu %d,%d,%d", myX,myY,myP);
1734 - e = s * (screen_tl.y() - screen_br.y() ) / (dev_tl.y() - dev_br.y());
1735 - f = s * screen_tl.y() - e * dev_tl.y();
1737 + if (oldP==0 && myP>QT_QWS_TP_PRESSURE_DOWN_THRESHOLD) {
1738 + //qDebug("ud %d,%d,%d", myX,myY,myP);
1740 - QString calFile = "/etc/pointercal";
1741 -#ifndef QT_NO_TEXTSTREAM
1742 - QFile file( calFile );
1743 - if ( file.open( IO_WriteOnly ) ) {
1744 - QTextStream t( &file );
1745 - t << a << " " << b << " " << c << " ";
1746 - t << d << " " << e << " " << f << " " << s;
1747 - file.flush(); closeTs();
1752 - qDebug( "Could not save calibration: %s", calFile.latin1() );
1764 -void QTSLibHandlerPrivate::readMouseData()
1766 -#ifdef QT_QWS_TSLIB
1770 + if (oldP>QT_QWS_TP_PRESSURE_DOWN_THRESHOLD && myP>QT_QWS_TP_PRESSURE_UP_THRESHOLD) {
1771 + //qDebug("dd %d,%d,%d (%d,%d)", myX,myY,myP, oldX,oldY);
1774 - * After clear Calibration
1775 - * we're in raw mode and do some easy median
1779 - return interpolateSample();
1780 + int dxSqr = myX-oldX; dxSqr *= dxSqr;
1781 + int dySqr = myY-oldY; dySqr *= dySqr;
1784 + if (dxSqr+dySqr > QT_QWS_TP_MOVE_MAX*QT_QWS_TP_MOVE_MAX) {
1785 + //qWarning("distance too wide %d", dxSqr+dySqr);
1789 - static struct ts_sample sample;
1791 + if (ptr < QT_QWS_TP_TABLE_SIZE) {
1792 + xtable[ptr] = myX;
1793 + ytable[ptr++] = myY;
1797 - * Ok. We need to see if we can read more than one event
1798 - * We do this not to lose an update.
1801 - if ((ret = ts_read(m_ts, &sample, 1)) != 1 )
1803 + if (ptr == QT_QWS_TP_TABLE_SIZE) {
1807 + for (i=0; i<QT_QWS_TP_TABLE_SIZE; i++) {
1811 + xtable[i-1] = xtable[i];
1812 + ytable[i-1] = ytable[i];
1816 + mousePos = transform(QPoint(mx/QT_QWS_TP_TABLE_SIZE, my/QT_QWS_TP_TABLE_SIZE));
1818 + emit mouseChanged(mousePos, Qt::LeftButton);
1823 - QPoint pos( sample.x, sample.y );
1824 - mouseChanged( pos, sample.pressure != 0 ? 1 : 0 );
1828 + //qDebug("du %d,%d,%d", myX,myY,myP);
1829 + emit mouseChanged(mousePos, 0);
1834 - * Lets take all down events and then sort them
1835 - * and take the event in the middle.
1837 - * inspired by testutils.c
1839 -void QTSLibHandlerPrivate::interpolateSample() {
1840 -#ifdef QT_QWS_TSLIB
1841 -#define TSLIB_MAX_SAMPLES 25
1842 - static struct ts_sample samples[TSLIB_MAX_SAMPLES];
1844 - int read_samples = 0;
1848 - /* do not access negative arrays */
1852 - /* we're opened non-blocking */
1853 - if((ret= ts_read_raw(m_ts, &samples[index], 1 ) ) != 1 )
1854 - /* no event yet, so try again */
1859 - index = (index+1)%TSLIB_MAX_SAMPLES;
1860 - }while (samples[index == 0 ? (TSLIB_MAX_SAMPLES-1) : index-1].pressure != 0);
1863 - * If we've wrapped around each sample is used otherwise
1864 - * we will use the index
1866 - index = read_samples >= TSLIB_MAX_SAMPLES ?
1867 - (TSLIB_MAX_SAMPLES-1 ) : index;
1871 - * now let us use the median value
1872 - * even index does not have an item in the middle
1873 - * so let us take the average of n/2 and (n/2)-1 as the middle
1876 - ::qsort(samples, index, sizeof(ts_sample), QTSLibHandlerPrivate::sortByX);
1877 - x = (index % 2 ) ? samples[m].x :
1878 - ( samples[m-1].x + samples[m].x )/2;
1880 - ::qsort(samples, index, sizeof(ts_sample), QTSLibHandlerPrivate::sortByY);
1881 - y = (index % 2 ) ? samples[m].y :
1882 - ( samples[m-1].y + samples[m].y )/2;
1884 - emit mouseChanged( QPoint(x, y), 1 );
1885 - emit mouseChanged( QPoint(0, 0), 0 );
1889 -int QTSLibHandlerPrivate::sortByX( const void* one, const void* two) {
1890 -#ifdef QT_QWS_TSLIB
1891 - return reinterpret_cast<const struct ts_sample*>(one)->x -
1892 - reinterpret_cast<const struct ts_sample*>(two)->x;
1898 -int QTSLibHandlerPrivate::sortByY( const void* one, const void* two) {
1899 -#ifdef QT_QWS_TSLIB
1900 - return reinterpret_cast<const struct ts_sample*>(one)->y -
1901 - reinterpret_cast<const struct ts_sample*>(two)->y;
1909 * return a QWSMouseHandler that supports /a spec.
1910 @@ -1977,7 +519,7 @@
1912 if ( mouseProto == "USB" && mouseDev.isEmpty() )
1913 mouseDev = "/dev/input/mice";
1916 MouseProtocol mouseProtocol = Unknown;
1919 @@ -1988,50 +530,7 @@
1924 - QWSMouseHandler *handler = 0;
1926 - switch ( mouseProtocol ) {
1927 -#ifndef QT_NO_QWS_MOUSE_AUTO
1929 - handler = new QAutoMouseHandler();
1933 -#ifndef QT_NO_QWS_MOUSE_PC
1935 - case IntelliMouse:
1938 - handler = new QWSMouseHandlerPrivate( mouseProtocol, mouseDev );
1942 -#ifndef QT_NO_QWS_VFB
1944 - handler = new QVFbMouseHandlerPrivate( mouseProtocol, mouseDev );
1949 -#if defined(QWS_CUSTOMTOUCHPANEL)
1950 - handler = new QCustomTPanelHandlerPrivate(mouseProtocol,mouseDev);
1951 -#elif defined(QT_QWS_TSLIB)
1952 - handler = new QTSLibHandlerPrivate();
1953 -#elif defined(QT_QWS_YOPY)
1954 - handler = new QYopyTPanelHandlerPrivate(mouseProtocol,mouseDev);
1955 -#elif defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_K2) || defined(QT_QWS_SLC700) || defined(QT_QWS_SIMPAD)
1956 - handler = new QTPanelHandlerPrivate(mouseProtocol,mouseDev);
1957 -#elif defined(QT_QWS_CASSIOPEIA)
1958 - handler = new QVrTPanelHandlerPrivate( mouseProtocol, mouseDev );
1963 - qDebug( "Mouse type %s unsupported", spec.latin1() );
1967 + return new QInputEventHandler( mouseProtocol, mouseDev );
1970 #include "qwsmouse_qws.moc"
1971 --- qt-2.3.10/src/kernel/qwsmouse_qws.h~ramses-touchscreen
1972 +++ qt-2.3.10/src/kernel/qwsmouse_qws.h
1974 /****************************************************************************
1975 -** $Id: qt/src/kernel/qwsmouse_qws.h 2.3.10 edited 2005-01-24 $
1976 +** $Id: qt/src/kernel/qwsmouse_qws.h 2.3.7 edited 2001-10-03 $
1978 ** Definition of Qt/FB central server classes
1981 virtual void clearCalibration();
1982 virtual void calibrate( QWSPointerCalibrationData * );
1983 virtual void getCalibration( QWSPointerCalibrationData * );
1984 + virtual void setCalibration(int aa, int bb, int cc, int dd, int ee, int ff, int ss);
1987 void readCalibration();