summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/apps/calibrate/calibrate.cpp60
1 files changed, 18 insertions, 42 deletions
diff --git a/core/apps/calibrate/calibrate.cpp b/core/apps/calibrate/calibrate.cpp
index 7b60e64..54fa8ec 100644
--- a/core/apps/calibrate/calibrate.cpp
+++ b/core/apps/calibrate/calibrate.cpp
@@ -44,3 +44,4 @@ Calibrate::Calibrate(QWidget* parent, const char * name, WFlags wf) :
44 logo.convertFromImage(Resource::loadImage("launcher/opielogo").smoothScale(w,w)); 44 logo.convertFromImage(Resource::loadImage("launcher/opielogo").smoothScale(w,w));
45 } else { 45 }
46 else {
46 logo = Resource::loadPixmap( "launcher/opielogo" ); 47 logo = Resource::loadPixmap( "launcher/opielogo" );
@@ -93,4 +94,3 @@ QPoint Calibrate::fromDevice( const QPoint &p )
93{ 94{
94 return qt_screen->mapFromDevice( p, 95 return qt_screen->mapFromDevice ( p, QSize( qt_screen->deviceWidth ( ), qt_screen->deviceHeight() ) );
95 QSize(qt_screen->deviceWidth(), qt_screen->deviceHeight()) );
96} 96}
@@ -99,22 +99,10 @@ bool Calibrate::sanityCheck()
99{ 99{
100 QPoint tl = cd.devPoints[QWSPointerCalibrationData::TopLeft]; 100 QRect r ( cd.devPoints[ QWSPointerCalibrationData::TopLeft ], cd.devPoints[ QWSPointerCalibrationData::BottomRight ] );
101 QPoint tr = cd.devPoints[QWSPointerCalibrationData::TopRight]; 101 r = r. normalize ( ); // This should also handle rotated TS controllers
102 QPoint bl = cd.devPoints[QWSPointerCalibrationData::BottomLeft];
103 QPoint br = cd.devPoints[QWSPointerCalibrationData::BottomRight];
104
105 int vl = QABS( tl.y() - bl.y() );
106 int vr = QABS( tr.y() - br.y() );
107 int diff = QABS( vl - vr );
108 int avg = ( vl + vr ) / 2;
109 if ( diff > avg / 20 ) // 5% leeway
110 return FALSE;
111 102
112 int ht = QABS( tl.x() - tr.x() ); 103 cd. devPoints [QWSPointerCalibrationData::TopRight] = r. topRight ( );
113 int hb = QABS( br.x() - bl.x() ); 104 cd. devPoints [QWSPointerCalibrationData::BottomLeft] = r. bottomLeft ( );
114 diff = QABS( ht - hb ); 105 cd. devPoints [QWSPointerCalibrationData::Center] = r. center ( );
115 avg = ( ht + hb ) / 2;
116 if ( diff > avg / 20 ) // 5% leeway
117 return FALSE;
118 106
119 return TRUE; 107 return true;
120} 108}
@@ -123,11 +111,2 @@ void Calibrate::moveCrosshair( QPoint pt )
123{ 111{
124/*
125 QPainter p( this );
126 p.drawPixmap( crossPos.x()-8, crossPos.y()-8, saveUnder );
127 saveUnder = QPixmap::grabWindow( winId(), pt.x()-8, pt.y()-8, 16, 16 );
128 p.drawRect( pt.x()-1, pt.y()-8, 2, 7 );
129 p.drawRect( pt.x()-1, pt.y()+1, 2, 7 );
130 p.drawRect( pt.x()-8, pt.y()-1, 7, 2 );
131 p.drawRect( pt.x()+1, pt.y()-1, 7, 2 );
132*/
133 showCross = FALSE; 112 showCross = FALSE;
@@ -156,3 +135,4 @@ void Calibrate::paintEvent( QPaintEvent * )
156 135
157 QFont f = p.font(); f.setBold(TRUE); 136 QFont f = p.font();
137 f.setBold( TRUE );
158 p.setFont( f ); 138 p.setFont( f );
@@ -161,7 +141,2 @@ void Calibrate::paintEvent( QPaintEvent * )
161 141
162/*
163 saveUnder = QPixmap::grabWindow( winId(), crossPos.x()-8, crossPos.y()-8,
164 16, 16 );
165 moveCrosshair( crossPos );
166*/
167 if ( showCross ) { 142 if ( showCross ) {
@@ -177,4 +152,3 @@ void Calibrate::mousePressEvent( QMouseEvent *e )
177 // map to device coordinates 152 // map to device coordinates
178 QPoint devPos = qt_screen->mapToDevice( e->pos(), 153 QPoint devPos = qt_screen->mapToDevice( e->pos(), QSize( qt_screen->width(), qt_screen->height() ) );
179 QSize(qt_screen->width(), qt_screen->height()) );
180 if ( penPos.isNull() ) 154 if ( penPos.isNull() )
@@ -194,5 +168,6 @@ void Calibrate::mouseReleaseEvent( QMouseEvent * )
194 cd.devPoints[location] = penPos; 168 cd.devPoints[location] = penPos;
195 if ( location < QWSPointerCalibrationData::LastLocation ) { 169 if ( location == QWSPointerCalibrationData::TopLeft ) {
196 location = (QWSPointerCalibrationData::Location)((int)location + 1); 170 location = QWSPointerCalibrationData::BottomRight;
197 } else { 171 }
172 else {
198 if ( sanityCheck() ) { 173 if ( sanityCheck() ) {
@@ -203,3 +178,4 @@ void Calibrate::mouseReleaseEvent( QMouseEvent * )
203 doMove = FALSE; 178 doMove = FALSE;
204 } else { 179 }
180 else {
205 location = QWSPointerCalibrationData::TopLeft; 181 location = QWSPointerCalibrationData::TopLeft;