summaryrefslogtreecommitdiff
path: root/core
authormickeyl <mickeyl>2005-09-03 20:36:38 (UTC)
committer mickeyl <mickeyl>2005-09-03 20:36:38 (UTC)
commit62ae8e732a5d4e5b23d060185c0655b1666be59c (patch) (side-by-side diff)
tree71e6d1530036731274f8ea0262423e74e86fe9f7 /core
parentde950b18690b8981a2bddaca68cbd5d48c71f689 (diff)
downloadopie-62ae8e732a5d4e5b23d060185c0655b1666be59c.zip
opie-62ae8e732a5d4e5b23d060185c0655b1666be59c.tar.gz
opie-62ae8e732a5d4e5b23d060185c0655b1666be59c.tar.bz2
switch to 5-point calibration to make it work on some newer Zaurii
this goes hand in hand with the integration of the RMK tslib calibration algorithm into Qt/Embedded 2.3.x. Patch courtesy Richard Purdie.
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/calibrate/calibrate.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/apps/calibrate/calibrate.cpp b/core/apps/calibrate/calibrate.cpp
index 5f52bdc..53388f1 100644
--- a/core/apps/calibrate/calibrate.cpp
+++ b/core/apps/calibrate/calibrate.cpp
@@ -103,49 +103,49 @@ void Calibrate::reset()
location = QWSPointerCalibrationData::TopLeft;
crossPos = fromDevice( cd.screenPoints[ location ] );
#endif
}
QPoint Calibrate::fromDevice( const QPoint &p )
{
#ifdef QWS
return qt_screen->mapFromDevice ( p, QSize( qt_screen->deviceWidth ( ), qt_screen->deviceHeight() ) );
#else
return QPoint();
#endif
}
bool Calibrate::sanityCheck()
{
#ifdef QWS
QPoint tl = cd.devPoints[QWSPointerCalibrationData::TopLeft];
QPoint tr = cd.devPoints[QWSPointerCalibrationData::TopRight];
QPoint bl = cd.devPoints[QWSPointerCalibrationData::BottomLeft];
QPoint br = cd.devPoints[QWSPointerCalibrationData::BottomRight];
// not needed anywhere .. just calculate it, so it's there
- cd.devPoints[QWSPointerCalibrationData::Center] = QRect( tl, br ).normalize().center();
+ //cd.devPoints[QWSPointerCalibrationData::Center] = QRect( tl, br ).normalize().center();
int dlx = QABS( bl. x ( ) - tl. x ( ));
int dly = QABS( bl. y ( ) - tl. y ( ));
int drx = QABS( br. x ( ) - tr. x ( ));
int dry = QABS( br. y ( ) - tr. y ( ));
int dtx = QABS( tr. x ( ) - tl. x ( ));
int dty = QABS( tr. y ( ) - tl. y ( ));
int dbx = QABS( br. x ( ) - bl. x ( ));
int dby = QABS( br. y ( ) - bl. y ( ));
int dl = (int) ::sqrt (( dlx * dlx ) + ( dly * dly )); // calculate vector lengths for all sides
int dr = (int) ::sqrt (( drx * drx ) + ( dry * dry ));
int dt = (int) ::sqrt (( dtx * dtx ) + ( dty * dty ));
int db = (int) ::sqrt (( dbx * dbx ) + ( dby * dby ));
// Calculate leeway for x/y (we do not care if diff1/diff2 is for x or y here !)
int diff1 = QABS( dl - dr );
int avg1 = ( dl + dr ) / 2;
int diff2 = QABS( dt - db );
int avg2 = ( dt + db ) / 2;
// Calculate leeway for "real" vector length against "manhattan" vector length
// This is a check, if the rect is rotated (other then 0/90/180/270)
// It needs to be performed only for the triange (bl, tl, tr)
@@ -154,97 +154,97 @@ bool Calibrate::sanityCheck()
if (( diff1 > ( avg1 / 20 )) || // 5% leeway
( diff2 > ( avg2 / 20 )) ||
( diff3 > ( avg3 / 20 )))
return false;
else
return true;
#else
return true;
#endif
}
void Calibrate::moveCrosshair( QPoint pt )
{
showCross = FALSE;
repaint( crossPos.x() - 14, crossPos.y() - 14, 28, 28 );
showCross = TRUE;
crossPos = pt;
repaint( crossPos.x() - 14, crossPos.y() - 14, 28, 28 );
}
void Calibrate::paintEvent( QPaintEvent * )
{
QPainter p( this );
- int y = height() / 3;
+ int y = height() / 2;
p.drawText( 0, y + height() / 8, width(), height() - y, AlignHCenter,
tr( "Touch the crosshairs firmly and\n"
"accurately to calibrate your screen." ) );
if ( !showCross ) return;
#if 0
if ( crosshair.isNull() ) {
#endif
p.setPen( QColor( 0, 0, 155 ) );
p.drawEllipse( crossPos.x()-8, crossPos.y()-8, 16, 16 );
p.setPen( QColor( 250, 220, 220 ) );
p.drawRoundRect( crossPos.x()-12, crossPos.y()-12, 24, 24, 75, 75 );
p.setPen( QColor( 0, 0, 120 ) );
p.drawRect( crossPos.x() - 1, crossPos.y() - 14, 2, 13 );
p.drawRect( crossPos.x() - 1, crossPos.y() + 1, 2, 13 );
p.drawRect( crossPos.x() - 14, crossPos.y() - 1, 13, 2 );
p.drawRect( crossPos.x() + 1, crossPos.y() - 1, 13, 2 );
#if 0
}
else p.drawPixmap( crossPos.x(), crossPos.y(), crosshair );
#endif
}
void Calibrate::mousePressEvent( QMouseEvent *e )
{
#ifdef QWS
// map to device coordinates
QPoint devPos = qt_screen->mapToDevice( e->pos(), QSize( qt_screen->width(), qt_screen->height() ) );
if ( penPos.isNull() )
penPos = devPos;
else
penPos = QPoint( ( penPos.x() + devPos.x() ) / 2,
( penPos.y() + devPos.y() ) / 2 );
#endif
}
void Calibrate::mouseReleaseEvent( QMouseEvent * )
{
#ifdef QWS
if ( timer->isActive() )
return ;
bool doMove = TRUE;
cd.devPoints[ location ] = penPos;
- if ( location < QWSPointerCalibrationData::TopRight ) {
+ if ( location < QWSPointerCalibrationData::Center ) {
location = (QWSPointerCalibrationData::Location) ( int( location ) + 1 );
}
else {
if ( sanityCheck() ) {
reset();
goodcd = cd;
hide();
emit accept();
doMove = FALSE;
}
else {
location = QWSPointerCalibrationData::TopLeft;
}
}
if ( doMove ) {
QPoint target = fromDevice( cd.screenPoints[ location ] );
dx = ( target.x() - crossPos.x() ) / 10;
dy = ( target.y() - crossPos.y() ) / 10;
timer->start( 30 );
}
#endif
}