Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
This post has been edited 1 times, last edit by "emmdom" (Sep 2nd 2005, 5:35pm)
This post has been edited 1 times, last edit by "emmdom" (Feb 27th 2007, 10:21pm)
|
|
Source code |
1 2 3 4 5 |
\fn ( QWSPointerCalibrationData * )
This method is reimplemented in the calibrated mouse handler to
set calibration information (from, for instance, the Qtopia
calibration screen). This version does nothing.
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
#include "calibration.h"
#include <qwindowsystem_qws.h>
#include <qpainter.h>
#include <qgfx_qws.h> // for qt_screen
#include <qfile.h>
#include <qtimer.h>
#include <qapplication.h>
Calibration::Calibration() : QDialog( 0, 0, TRUE, WStyle_Customize | WStyle_StaysOnTop)
{
QRect desk = qApp->desktop()->geometry();
setGeometry( 0, 0, desk.width(), desk.height() );
setFocusPolicy( StrongFocus );
setFocus();
backup = 0;
idx = 0;
data = new QWSPointerCalibrationData;
int w = qt_screen->deviceWidth();
int h = qt_screen->deviceHeight();
int delta = QMIN(w, h)/20;
data->screenPoints[QWSPointerCalibrationData::TopLeft] = QPoint(delta, delta);
data->screenPoints[QWSPointerCalibrationData::BottomLeft] = QPoint(delta, h-delta);
data->screenPoints[QWSPointerCalibrationData::BottomRight] = QPoint(w-delta, h-delta);
data->screenPoints[QWSPointerCalibrationData::TopRight] = QPoint(w-delta, delta);
data->screenPoints[QWSPointerCalibrationData::Center] = QPoint(w/2, h/2);
/* data->screenPoints[QWSPointerCalibrationData::TopLeft] = QPoint(delta, delta);
data->screenPoints[QWSPointerCalibrationData::BottomLeft] = QPoint(delta, w-delta);
data->screenPoints[QWSPointerCalibrationData::BottomRight] = QPoint(h-delta, w-delta);
data->screenPoints[QWSPointerCalibrationData::TopRight] = QPoint(h-delta, delta);
data->screenPoints[QWSPointerCalibrationData::Center] = QPoint(h/2, w/2);
*/
/* data->screenPoints[QWSPointerCalibrationData::TopLeft] = QPoint(delta, delta);
data->screenPoints[QWSPointerCalibrationData::BottomLeft] = QPoint(w-delta, delta);
data->screenPoints[QWSPointerCalibrationData::BottomRight] = QPoint(h-delta, w-delta);
data->screenPoints[QWSPointerCalibrationData::TopRight] = QPoint(delta,h-delta);
data->screenPoints[QWSPointerCalibrationData::Center] = QPoint(h/2, w/2);
*/
for (int i = 0; i < 5; ++i)
displayPoints[i] = qt_screen->mapFromDevice( data->screenPoints[i], QSize(w, h) );
}
Calibration::~Calibration()
{
delete data;
delete backup;
}
void Calibration::paintEvent(QPaintEvent*)
{
QPainter p(this);
p.fillRect(rect(), blue);
QPoint cp = data->screenPoints[idx];
p.fillRect(cp.x()-6, cp.y()-1, 13, 3, black);
p.fillRect(cp.x()-1, cp.y()-6, 3, 13, black);
}
void Calibration::mouseReleaseEvent(QMouseEvent *me)
{
// qDebug("Calibration::mouseReleaseEvent (%d,%d) idx %d", me->pos().x(), me->pos().y(), idx);
data->devPoints[idx] = qt_screen->mapToDevice( me->pos(),
QSize(qt_screen->width(), qt_screen->height()) );
++idx;
if (idx >= 5){
accept();
repaint();}
else
repaint();
}
void Calibration::show()
{
if ( !isVisible() && QWSServer::mouseHandler() ) {
idx = 0;
delete backup;
backup = 0;
if (QFile::exists("/etc/pointercal")) {
backup = new QWSPointerCalibrationData;
QWSServer::mouseHandler()->getCalibration(backup);
}
QWSServer::mouseHandler()->clearCalibration();
}
grabMouse();
QDialog::show();
setActiveWindow();
}
static void showCalibration(const QWSPointerCalibrationData *data)
{
int i;
qDebug("screenPoints:");
for (i=0;i<5;i++){
QPoint p = data->screenPoints[i];
qDebug(" %d: (%d %d)", i, p.x(), p.y());
}
qDebug("devPoints:");
for (i=0;i<5;i++){
QPoint p = data->devPoints[i];
qDebug(" %d: (%d %d)", i, p.x(), p.y());
}
}
void Calibration::accept()
{
if ( idx == 5 ) {
qDebug("Calibrating device");
showCalibration(data);
QWSServer::mouseHandler()->calibrate(data);
QWSPointerCalibrationData cal;
QWSServer::mouseHandler()->getCalibration(&cal);
qDebug("Actual device calibration:");
showCalibration(&cal);
}
QDialog::accept();
}
void Calibration::reject()
{
if (backup)
QWSServer::mouseHandler()->calibrate(backup);
QDialog::reject();
}
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#ifndef CALIBRATION_H
#define CALIBRATION_H
#include <qdialog.h>
#include <qmouse_qws.h>
class QWSPointerCalibrationData;
class Calibration : public QDialog
{
Q_OBJECT
public:
Calibration();
~Calibration();
void show();
protected:
void paintEvent(QPaintEvent*);
void mouseReleaseEvent(QMouseEvent*);
void accept();
void reject();
private:
int idx;
//const QWSPointerCalibrationData cal;
QWSPointerCalibrationData *data;
QPoint displayPoints[5];
QWSPointerCalibrationData *backup;
};
#endif
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate( QWSLinuxTPMouseHandler *h )
: mouseFD(-1), samples(QT_QWS_TP_SAMPLE_SIZE), currSample(0), lastSample(0),
numSamples(0), skipCount(0), handler(h)
{
printf("\n inside ltp handler private \n");
#if defined(QT_QWS_IPAQ)
# ifdef QT_QWS_IPAQ_RAW
if ((mouseFD = open( "/dev/h3600_tsraw", O_RDONLY | O_NDELAY)) < 0) {
# else
if ((mouseFD = open( "/dev/h3600_ts", O_RDONLY | O_NDELAY)) < 0) {
# endif
qWarning( "Cannot open /dev/h3600_ts (%s)", strerror(errno));
return;
}
#elif defined(QT_QWS_EBX)
//# ifdef QT_QWS_EBX_TSRAW
# if 0
if ((mouseFD = open( "/dev/tsraw", O_RDONLY | O_NDELAY)) < 0) {
qWarning( "Cannot open /dev/tsraw (%s)", strerror(errno));
return;
}
# else
if ((mouseFD = open( "/dev/ts", O_RDONLY | O_NDELAY)) < 0) {
qWarning( "Cannot open /dev/ts (%s)", strerror(errno));
return;
}
# endif
#endif
mouseFD = open( "/dev/ttyS1", O_RDONLY | O_NDELAY);
printf("\n MOUSEFD :%d",mouseFD);
if(mouseFD==0)
printf("\n device openneeee \n");
else printf("\n cannot oepn touch screen \n");
QSocketNotifier *mouseNotifier;
mouseNotifier = new QSocketNotifier( mouseFD, QSocketNotifier::Read, this );
printf("\n after socket notifier \n");
connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
waspressed=FALSE;
mouseIdx = 0;
printf("\n after mouseidx \n");
}
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 |
mousePos = totalMousePos / (sampleCount - 1);
# if defined(QT_QWS_IPAQ_RAW) || defined(QT_QWS_EBX_RAW)
mousePos = handler->transform( mousePos );
# endif
if(!waspressed)
oldmouse = mousePos;
QPoint dp = mousePos - oldmouse;
int dxSqr = dp.x() * dp.x();
int dySqr = dp.y() * dp.y();
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate( QWSLinuxTPMouseHandler *h )
: mouseFD(-1), samples(QT_QWS_TP_SAMPLE_SIZE), currSample(0), lastSample(0),
numSamples(0), skipCount(0), handler(h)
{
#if defined(QT_QWS_IPAQ)
# ifdef QT_QWS_IPAQ_RAW
if ((mouseFD = open( "/dev/h3600_tsraw", O_RDONLY | O_NDELAY)) < 0) {
# else
if ((mouseFD = open( "/dev/h3600_ts", O_RDONLY | O_NDELAY)) < 0) {
# endif
qWarning( "Cannot open /dev/h3600_ts (%s)", strerror(errno));
return;
}
#elif defined(QT_QWS_EBX)
//# ifdef QT_QWS_EBX_TSRAW
# if 0
if ((mouseFD = open( "/dev/tsraw", O_RDONLY | O_NDELAY)) < 0) {
qWarning( "Cannot open /dev/tsraw (%s)", strerror(errno));
return;
}
# else
if ((mouseFD = open( "/dev/ts", O_RDONLY | O_NDELAY)) < 0) {
qWarning( "Cannot open /dev/ts (%s)", strerror(errno));
return;
}
# endif
#endif
QSocketNotifier *mouseNotifier;
mouseNotifier = new QSocketNotifier( mouseFD, QSocketNotifier::Read,
this );
connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
waspressed=FALSE;
mouseIdx = 0;
}
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate( QWSLinuxTPMouseHandler *h )
: samples(QT_QWS_TP_SAMPLE_SIZE), currSample(0), lastSample(0),
numSamples(0), skipCount(0), handler(h)
{ //I am changing this to /dev/digi changing back to ts in order to fix a problem
if ((mouseFD = open( "/dev/ts", O_RDONLY | O_NDELAY)) < 0) {
qWarning( "Cannot open /dev/ts (%s)", strerror(errno));
return;
}
QSocketNotifier *mouseNotifier;
mouseNotifier = new QSocketNotifier( mouseFD, QSocketNotifier::Read,
this );
connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
waspressed=FALSE;
mouseIdx = 0;
}
|