summaryrefslogtreecommitdiff
path: root/qt
authormickeyl <mickeyl>2003-05-26 18:22:40 (UTC)
committer mickeyl <mickeyl>2003-05-26 18:22:40 (UTC)
commitbafafde5e5777e6af8c5f7dcc93472d75e942a8f (patch) (unidiff)
tree3bc7de6766d39664f89c66c32160d52015b0aadf /qt
parent304b92e24c7a7da309977cd996fc89848d8899dc (diff)
downloadopie-bafafde5e5777e6af8c5f7dcc93472d75e942a8f.zip
opie-bafafde5e5777e6af8c5f7dcc93472d75e942a8f.tar.gz
opie-bafafde5e5777e6af8c5f7dcc93472d75e942a8f.tar.bz2
add improved version of QWSSimpadButtonHandler
this one now features automatic keyrepeat and adapts to rotation :-D
Diffstat (limited to 'qt') (more/less context) (ignore whitespace changes)
-rw-r--r--qt/qte234-for-opie091-simpad.patch69
1 files changed, 58 insertions, 11 deletions
diff --git a/qt/qte234-for-opie091-simpad.patch b/qt/qte234-for-opie091-simpad.patch
index fd535d4..93f4be3 100644
--- a/qt/qte234-for-opie091-simpad.patch
+++ b/qt/qte234-for-opie091-simpad.patch
@@ -22,14 +22,14 @@
22- if ((mouseFD = open( "/dev/h3600_tsraw", O_RDONLY | O_NDELAY)) < 0) { 22- if ((mouseFD = open( "/dev/h3600_tsraw", O_RDONLY | O_NDELAY)) < 0) {
23+ if ((mouseFD = open( "/dev/touchscreen/ucb1x00", O_RDONLY | O_NONBLOCK /*O_NDELAY*/)) < 0) { 23+ if ((mouseFD = open( "/dev/touchscreen/ucb1x00", O_RDONLY | O_NONBLOCK /*O_NDELAY*/)) < 0) {
24 # else 24 # else
25 if ((mouseFD = open( "/dev/h3600_ts", O_RDONLY | O_NDELAY)) < 0) { 25 if ((mouseFD = open( "/dev/h3600_ts", O_RDONLY | O_NDELAY)) < 0) {
26 # endif 26 # endif
27 --- src/kernel/qkeyboard_qws.cpp.origSat May 24 16:49:38 2003 27 --- src/kernel/qkeyboard_qws.cpp.origSat May 24 16:49:38 2003
28 +++ src/kernel/qkeyboard_qws.cppSat May 24 17:58:22 2003 28 +++ src/kernel/qkeyboard_qws.cppMon May 26 19:52:05 2003
29@@ -131,6 +131,46 @@ 29@@ -131,6 +131,53 @@
30 30
31 #endif // QNX6 31 #endif // QNX6
32 32
33+/* 33+/*
34+ * SIMpad switches handler 34+ * SIMpad switches handler
35+ * (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 35+ * (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
@@ -60,62 +60,83 @@
60+ virtual ~QWSsimpadButtonsHandler(); 60+ virtual ~QWSsimpadButtonsHandler();
61+ 61+
62+ bool isOpen() { return fd > 0; } 62+ bool isOpen() { return fd > 0; }
63+ 63+
64+ private slots: 64+ private slots:
65+ void readSwitchesData(); 65+ void readSwitchesData();
66+ void autoRepeat();
66+ 67+
67+ private: 68+ private:
68+ switches_mask_t switches; 69+ switches_mask_t switches;
70+
69+ int fd; 71+ int fd;
72+ int repeatdelay;
73+ int repeatperiod;
74+ int k;
75+
76+ QTimer* repeater;
70+ QSocketNotifier *notifier; 77+ QSocketNotifier *notifier;
71+}; 78+};
72+ 79+
73 #ifdef QT_QWS_SL5XXX 80 #ifdef QT_QWS_SL5XXX
74 static const QWSServer::KeyMap keyM[] = { 81 static const QWSServer::KeyMap keyM[] = {
75 { Qt::Key_unknown,0xffff , 0xffff , 0xffff }, // 00 82 { Qt::Key_unknown,0xffff , 0xffff , 0xffff }, // 00
76@@ -1440,7 +1480,11 @@ 83@@ -396,7 +443,7 @@
84 for the list of codes).
85 <li>\a modifiers is the set of modifier keys (see Qt::Modifier).
86 <li>\a isPress says whether this is a press or a release.
87- <li>\a autoRepeat says whether this event was generated by an auto-repeat
88+ <li>\a time says whether this event was generated by an auto-repeat
89 mechanism, or an actual key press.
90 </ul>
91 */
92@@ -1440,7 +1486,11 @@
77 } else { 93 } else {
78 type = spec; 94 type = spec;
79 } 95 }
80- 96-
81+ if ( type == "SIMpad" ) 97+ if ( type == "SIMpad" )
82+ { 98+ {
83+ qDebug( "QWSKeyboardHandler: using SIMpad keyboard handler..." ); 99+ qDebug( "QWSKeyboardHandler: using SIMpad keyboard handler..." );
84+ handler = new QWSsimpadButtonsHandler(); 100+ handler = new QWSsimpadButtonsHandler();
85+ } 101+ }
86 if ( type == "Buttons" ) { 102 if ( type == "Buttons" ) {
87 #if defined(QT_QWS_YOPY) 103 #if defined(QT_QWS_YOPY)
88 handler = new QWSyopyButtonsHandler(); 104 handler = new QWSyopyButtonsHandler();
89@@ -1469,6 +1513,72 @@ 105@@ -1469,6 +1519,103 @@
90 return keyM; 106 return keyM;
91 } 107 }
92 108
93-#endif // QT_NO_QWS_KEYBOARD 109-#endif // QT_NO_QWS_KEYBOARD
94 110+
95+/* 111+/*
96+ * SIMpad switches handler 112+ * SIMpad switches handler
97+ * (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 113+ * (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
98+ */ 114+ */
99+ 115
100+ 116
101+QWSsimpadButtonsHandler::QWSsimpadButtonsHandler() 117+QWSsimpadButtonsHandler::QWSsimpadButtonsHandler()
102+ :QWSKeyboardHandler(), fd( -1 ) 118+ :QWSKeyboardHandler(), fd( -1 ),
119+ repeatdelay( 400 ), repeatperiod( 80 )
103+{ 120+{
104+ qDebug( "SimpadButtonsHandler()" ); 121+ qDebug( "SimpadButtonsHandler()" );
105+ fd = ::open( SIMPAD_SWITCHES_DEVICE, O_RDWR | O_NDELAY, 0 ); 122+ fd = ::open( SIMPAD_SWITCHES_DEVICE, O_RDWR | O_NDELAY, 0 );
106+ if ( fd < 0 ) 123+ if ( fd < 0 )
107+ { 124+ {
108+ qWarning( "SimpadButtonsHandler(): can't open %s", SIMPAD_SWITCHES_DEVICE ); 125+ qWarning( "SimpadButtonsHandler(): can't open %s", SIMPAD_SWITCHES_DEVICE );
109+ return; 126+ return;
110+ } 127+ }
111+ 128+
112+ notifier = new QSocketNotifier( fd, QSocketNotifier::Read, this ); 129+ notifier = new QSocketNotifier( fd, QSocketNotifier::Read, this );
113+ connect( notifier, SIGNAL( activated(int) ),this, SLOT( readSwitchesData() ) ); 130+ connect( notifier, SIGNAL( activated(int) ),this, SLOT( readSwitchesData() ) );
131+
132+ repeater = new QTimer(this);
133+ connect(repeater, SIGNAL(timeout()), this, SLOT(autoRepeat()));
134+
114+} 135+}
115 136+
116+ 137+
117+QWSsimpadButtonsHandler::~QWSsimpadButtonsHandler() 138+QWSsimpadButtonsHandler::~QWSsimpadButtonsHandler()
118+{ 139+{
119+ qDebug( "~SimpadButtonsHandler()" ); 140+ qDebug( "~SimpadButtonsHandler()" );
120+ if ( fd > 0 ) 141+ if ( fd > 0 )
121+ { 142+ {
@@ -132,31 +153,57 @@
132+ if ( ::read( fd, &switches, sizeof switches ) < 0 ) 153+ if ( ::read( fd, &switches, sizeof switches ) < 0 )
133+ { 154+ {
134+ qWarning( "SimpadButtonsHandler() - switches read error!" ); 155+ qWarning( "SimpadButtonsHandler() - switches read error!" );
135+ return; 156+ return;
136+ } 157+ }
137+ 158+
138+ qDebug( "SimpadButtonsHandler() - EVENT = %04xd | %04xd", 159+ qDebug( "SimpadButtonsHandler() - SwitchEvent = %0x | %0x",
139+ switches.events[0], switches.states[0] ); 160+ switches.events[0], switches.states[0] );
140+ 161+
141+ bool press = switches.states[0]; // == switches.event[0]; 162+ bool press = switches.states[0]; // == switches.event[0];
142+ int code = switches.events[0]; 163+ int code = switches.events[0];
143+ int k = -1; 164+ k = -1;
144+ 165+
145+ switch(code) 166+ switch(code)
146+ { 167+ {
147+ case SIMPAD_SWITCH_UPPER: k = Qt::Key_Escape; break; 168+ case SIMPAD_SWITCH_UPPER: k = Qt::Key_Escape; break;
148+ case SIMPAD_SWITCH_UP: k = Qt::Key_Up; break; 169+ case SIMPAD_SWITCH_UP: k = Qt::Key_Up; break;
149+ case SIMPAD_SWITCH_DOWN: k = Qt::Key_Down; break; 170+ case SIMPAD_SWITCH_DOWN: k = Qt::Key_Down; break;
150+ case SIMPAD_SWITCH_LEFT: k = Qt::Key_Left; break; 171+ case SIMPAD_SWITCH_LEFT: k = Qt::Key_Left; break;
151+ case SIMPAD_SWITCH_RIGHT: k = Qt::Key_Right; break; 172+ case SIMPAD_SWITCH_RIGHT: k = Qt::Key_Right; break;
152+ case SIMPAD_SWITCH_LOWER: k = Qt::Key_Return; break; 173+ case SIMPAD_SWITCH_LOWER: k = Qt::Key_Return; break;
153+ default: k=-1; qWarning( "SimpadButtonsHandler() - unhandled event!" ); break; 174+ default: k=-1; qWarning( "SimpadButtonsHandler() - unhandled event!" ); break;
154+ } 175+ }
155+ 176+
177+ bool repeatable = ( k != SIMPAD_SWITCH_UPPER && k != SIMPAD_SWITCH_LOWER );
178+
179+ qDebug( "SimpadButtonsHandler() - Repeatable = %s", repeatable? "true":"false" );
180+
181+ if ( qt_screen->isTransformed() && k >= Qt::Key_Left && k <= Qt::Key_Down )
182+ {
183+ qDebug( "SimpadButtonsHandler() - We are transformed! Correcting..." );
184+ int oldK = k;
185+ k = xform_dirkey( k );
186+ qDebug( "SimpadButtonsHandler() - Old Key: %d - New Key %d", oldK, k );
187+ }
188+
189+ if ( repeatable && press )
190+ repeater->start( repeatdelay, true );
191+ else
192+ repeater->stop();
193+
156+ if ( k >= 0 ) 194+ if ( k >= 0 )
157+ { 195+ {
158+ qwsServer->processKeyEvent( 0, k, 0, press, false ); 196+ qwsServer->processKeyEvent( 0, k, 0, press, false );
159+ } 197+ }
160+} 198+}
161+ 199+
200+
201+void QWSsimpadButtonsHandler::autoRepeat()
202+{
203+ processKeyEvent( 0, k, 0, false, true );
204+ processKeyEvent( 0, k, 0, true, true );
205+ repeater->start(repeatperiod);
206+}
207+
208+
162+#endif // QT_NO_QWS_KEYBOARD 209+#endif // QT_NO_QWS_KEYBOARD