3 # Patch managed by http://www.holgerschurig.de/patcher.html
6 --- qt-2.3.10/src/kernel/qkeyboard_qws.cpp~simpad.patch
7 +++ qt-2.3.10/src/kernel/qkeyboard_qws.cpp
9 #include <qapplication.h>
10 #include <qsocketnotifier.h>
11 #include <qnamespace.h>
12 +#include <qdatetime.h>
21 + * SIMpad switches handler
22 + * (C) 2003-2005 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
27 +#include <linux/switches.h>
28 +#define SIMPAD_SWITCHES_DEVICE "/dev/misc/switches"
30 +// switches from left top to right down over the SIMpad surface
32 +#define SIMPAD_SWITCH_POWER 0x02
33 +#define SIMPAD_SWITCH_UPPER 0x10
34 +#define SIMPAD_SWITCH_UP 0x20
35 +#define SIMPAD_SWITCH_DOWN 0x40
36 +#define SIMPAD_SWITCH_LEFT 0x80
37 +#define SIMPAD_SWITCH_RIGHT 0x100
38 +#define SIMPAD_SWITCH_LOWER 0x8
40 +class QWSsimpadButtonsHandler : public QWSKeyboardHandler
45 + QWSsimpadButtonsHandler();
46 + virtual ~QWSsimpadButtonsHandler();
48 + bool isOpen() { return fd > 0; }
51 + void readSwitchesData();
55 + switches_mask_t switches;
61 + int lastCode; // last native code
62 + int lastPress; // last press/release state
64 + int k; // last emitted Qt key code
65 + int shiftKeyPressed; // true if one of the SHIFT keys has been pressed and not yet released
66 + bool shiftUsed; // true if SHIFT has been used
68 + QTime eventTimer; // tracks time between raw events
70 + QSocketNotifier *notifier;
75 #include <asm/sharp_char.h>
77 @@ -1775,9 +1830,11 @@
82 if ( type == "Buttons" ) {
83 -#if defined(QT_QWS_YOPY)
84 +#if defined(QT_QWS_SIMPAD)
85 + qDebug( "QWSKeyboardHandler: using SIMpad switches handler..." );
86 + handler = new QWSsimpadButtonsHandler();
87 +#elif defined(QT_QWS_YOPY)
88 handler = new QWSyopyButtonsHandler();
89 #elif defined(QT_QWS_CASSIOPEIA)
90 handler = new QWSVr41xxButtonsHandler();
91 @@ -1812,6 +1869,218 @@
95 -#endif // QT_NO_QWS_KEYBOARD
98 + * SIMpad switches handler
99 + * (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
103 +QWSsimpadButtonsHandler::QWSsimpadButtonsHandler()
104 + :QWSKeyboardHandler(), fd( -1 ),
105 + repeatdelay( 700 ), repeatperiod( 80 ),
106 + lastCode( 0 ), lastPress( 0 ),
107 + k( -1 ), shiftKeyPressed( 0 ), shiftUsed( false )
109 + qDebug( "SimpadButtonsHandler() - V4.1" );
110 + fd = ::open( SIMPAD_SWITCHES_DEVICE, O_RDWR | O_NDELAY, 0 );
113 + qWarning( "SimpadButtonsHandler(): can't open %s", SIMPAD_SWITCHES_DEVICE );
117 + notifier = new QSocketNotifier( fd, QSocketNotifier::Read, this );
118 + connect( notifier, SIGNAL( activated(int) ),this, SLOT( readSwitchesData() ) );
120 + repeater = new QTimer(this);
121 + connect(repeater, SIGNAL(timeout()), this, SLOT(autoRepeat()));
126 +QWSsimpadButtonsHandler::~QWSsimpadButtonsHandler()
128 + qDebug( "~SimpadButtonsHandler()" );
137 +void QWSsimpadButtonsHandler::readSwitchesData()
139 + qDebug( "SimpadButtonsHandler() - detected switches action" );
141 + if ( ::read( fd, &switches, sizeof switches ) < 0 )
143 + qWarning( "SimpadButtonsHandler() - switches read error!" );
147 + qDebug( "SimpadButtonsHandler() - Shift: %0x [used: %0x] + Event = %0x | %0x",
148 + shiftKeyPressed, shiftUsed, switches.events[0], switches.states[0] );
150 + bool press = switches.states[0]; // == switches.event[0];
151 + int code = switches.events[0];
153 + //=========================================================================
156 + * Work around a bug in the kernel keyboard driver emitting
157 + * bogus events when pressing multiple switches at once
160 + if ( lastCode == 0 )
162 + // first press ever
163 + eventTimer.start();
169 + int interval = eventTimer.restart();
170 + qDebug( "event interval = %d", interval );
171 + if ( code == lastCode && interval < 10 )
173 + qDebug( "event interval too small - ignoring bogus event" );
174 + qDebug( "did I say i hate buggy kernel drivers? :-D" );
183 + * Actually it may also be a hardware problem, but I really don't like
184 + * to review kernel code for further inquiry. So just being lazy and
185 + * do the workaround in user space :-D
188 + //=====================================================================
190 + if ( shiftKeyPressed )
192 + // a shift key obviously is being held
193 + qDebug( "while shift key is being held..." );
195 + if ( code != shiftKeyPressed )
197 + // another key is being touched - that means shift mode for us!
198 + qDebug( " another key is being touched -> shift use now = true" );
202 + if ( shiftKeyPressed == SIMPAD_SWITCH_LOWER ) // SHIFT 1
204 + qDebug( " shift mode 1" );
207 + case SIMPAD_SWITCH_UP: k = Qt::Key_F9; break; // Shift1-Up = Calendar
208 + case SIMPAD_SWITCH_DOWN: k = Qt::Key_F10; break; // Shift1-Down = Contacts
209 + case SIMPAD_SWITCH_LEFT: k = Qt::Key_F13; break; // Shift1-Left = Mail
210 + case SIMPAD_SWITCH_RIGHT: k = Qt::Key_F11; break; // Shift1-Up = Menu
211 + case SIMPAD_SWITCH_UPPER: k = Qt::Key_F12; break; // Shift1-Upper = Home
212 + default: k=-1; qWarning( "SimpadButtonsHandler() - unhandled event for Shift 1 !" ); break;
215 + else if ( shiftKeyPressed == SIMPAD_SWITCH_UPPER ) // SHIFT 2
217 + qDebug( " shift mode 2" );
220 + case SIMPAD_SWITCH_UP: k = Qt::Key_F5; break; // Shift2-Up = F5
221 + case SIMPAD_SWITCH_DOWN: k = Qt::Key_F6; break; // Shift2-Down = F6
222 + case SIMPAD_SWITCH_LEFT: k = Qt::Key_F7; break; // Shift2-Left = F7
223 + case SIMPAD_SWITCH_RIGHT: k = Qt::Key_F8; break; // Shift2-Up = F8
224 + case SIMPAD_SWITCH_LOWER: k = Qt::Key_F9; break; // Shift2-Lower = F9
225 + default: k=-1; qWarning( "SimpadButtonsHandler() - unhandled event for Shift 2!" ); break;
231 + qDebug( " shift key has been released. checking if being used..." );
232 + shiftKeyPressed = 0;
236 + qDebug( " ... has _not_ being used -> really emit the key" );
237 + k = ( code == SIMPAD_SWITCH_UPPER ? Qt::Key_Escape : Qt::Key_Return );
238 + qDebug( "Emitting key = %d (pressed)", k );
239 + processKeyEvent( 0, k, 0, true, true );
240 + qDebug( "Emitting key = %d (released)", k );
241 + processKeyEvent( 0, k, 0, false, true );
246 + qDebug( " ... has being used -> doing nothing" );
253 + qDebug( "standard mode - no shift yet..." );
257 + case SIMPAD_SWITCH_UP: k = Qt::Key_Up; break;
258 + case SIMPAD_SWITCH_DOWN: k = Qt::Key_Down; break;
259 + case SIMPAD_SWITCH_LEFT: k = Qt::Key_Left; break;
260 + case SIMPAD_SWITCH_RIGHT: k = Qt::Key_Right; break;
261 + case SIMPAD_SWITCH_POWER: k = Qt::Key_F34; break; // Power Button
263 + case SIMPAD_SWITCH_UPPER: k=-1; shiftKeyPressed = press? code:0; shiftUsed = false; qDebug( "shiftkey pressed now = %d", shiftKeyPressed ); return;
264 + case SIMPAD_SWITCH_LOWER: k=-1; shiftKeyPressed = press? code:0; shiftUsed = false; qDebug( "shiftkey pressed now = %d", shiftKeyPressed ); return;
266 + default: k=-1; qWarning( "SimpadButtonsHandler() - unhandled event!" ); break;
272 + qDebug( "no key to emit - returning." );
276 + bool repeatable = ( k == Qt::Key_Up || k == Qt::Key_Down ||
277 + k == Qt::Key_Right || k == Qt::Key_Left );
279 + qDebug( "key to emit = %d [%s] [repeat=%s]", k,
280 + press ? "press" : "release",
281 + repeatable ? "true":"false" );
283 + if ( qt_screen->isTransformed() && k >= Qt::Key_Left && k <= Qt::Key_Down )
285 + qDebug( "SimpadButtonsHandler() - We are transformed! Correcting..." );
287 + k = xform_dirkey( k );
288 + qDebug( "SimpadButtonsHandler() - Old Key: %d - New Key %d", oldK, k );
291 + if ( repeatable && press )
292 + repeater->start( repeatdelay, true );
296 + qwsServer->processKeyEvent( 0, k, 0, press, false );
300 +void QWSsimpadButtonsHandler::autoRepeat()
302 + qDebug( "Emitting key = %d (released)", k );
303 + processKeyEvent( 0, k, 0, false, true );
304 + qDebug( "Emitting key = %d (pressed)", k );
305 + processKeyEvent( 0, k, 0, true, true );
306 + repeater->start(repeatperiod);
310 +#endif // QT_NO_QWS_KEYBOARD
311 --- qt-2.3.10/src/kernel/qwsmouse_qws.cpp~simpad.patch
312 +++ qt-2.3.10/src/kernel/qwsmouse_qws.cpp
316 #include <sys/ioctl.h>
317 +#include <sys/time.h>
318 #include <sys/types.h>
319 #include <sys/stat.h>
325 + struct timeval stamp;
327 #elif defined(QT_QWS_SL5XXX)
328 #define QT_QWS_SL5XXX_RAW
329 @@ -1310,6 +1312,11 @@
333 +#elif defined(QT_QWS_SIMPAD )
334 + if ((mouseFD = open( "/dev/touchscreen/ucb1x00", O_RDONLY | O_NONBLOCK )) < 0) {
335 + qWarning( "Cannot open /dev/touchscreen/ucb1x00 (%s)", strerror(errno));
340 QSocketNotifier *mouseNotifier;