author | mickeyl <mickeyl> | 2003-05-24 16:11:25 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-24 16:11:25 (UTC) |
commit | 5667ded1d4583cfb79b2ddfd7aaae0e58ed6d552 (patch) (unidiff) | |
tree | 761118ba87a2f97a526acac7e53b1b664c541282 /qt | |
parent | 3fb06f85a52b6fcbece50ed30c196efc2a91e8ce (diff) | |
download | opie-5667ded1d4583cfb79b2ddfd7aaae0e58ed6d552.zip opie-5667ded1d4583cfb79b2ddfd7aaae0e58ed6d552.tar.gz opie-5667ded1d4583cfb79b2ddfd7aaae0e58ed6d552.tar.bz2 |
add QWSsimpadButtonHandler and patch it into qte
-rw-r--r-- | qt/qte234-for-opie091-simpad.patch | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/qt/qte234-for-opie091-simpad.patch b/qt/qte234-for-opie091-simpad.patch index e2e323a..fd535d4 100644 --- a/qt/qte234-for-opie091-simpad.patch +++ b/qt/qte234-for-opie091-simpad.patch | |||
@@ -24,3 +24,139 @@ | |||
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 | ||
28 | +++ src/kernel/qkeyboard_qws.cppSat May 24 17:58:22 2003 | ||
29 | @@ -131,6 +131,46 @@ | ||
30 | |||
31 | #endif // QNX6 | ||
32 | |||
33 | +/* | ||
34 | + * SIMpad switches handler | ||
35 | + * (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
36 | + */ | ||
37 | + | ||
38 | +//TODO: guard this against inclusion with #ifdef QT_QWS_SIMPAD | ||
39 | + | ||
40 | +#include <linux/switches.h> | ||
41 | +#define SIMPAD_SWITCHES_DEVICE "/dev/misc/switches" | ||
42 | + | ||
43 | +// switches from top to down over the SIMpad surface | ||
44 | + | ||
45 | +#define SIMPAD_SWITCH_UPPER 0x10 | ||
46 | + | ||
47 | +#define SIMPAD_SWITCH_UP 0x20 | ||
48 | +#define SIMPAD_SWITCH_DOWN 0x40 | ||
49 | +#define SIMPAD_SWITCH_LEFT 0x80 | ||
50 | +#define SIMPAD_SWITCH_RIGHT 0x100 | ||
51 | + | ||
52 | +#define SIMPAD_SWITCH_LOWER 0x8 | ||
53 | + | ||
54 | +class QWSsimpadButtonsHandler : public QWSKeyboardHandler | ||
55 | +{ | ||
56 | + Q_OBJECT | ||
57 | + | ||
58 | + public: | ||
59 | + QWSsimpadButtonsHandler(); | ||
60 | + virtual ~QWSsimpadButtonsHandler(); | ||
61 | + | ||
62 | + bool isOpen() { return fd > 0; } | ||
63 | + | ||
64 | + private slots: | ||
65 | + void readSwitchesData(); | ||
66 | + | ||
67 | + private: | ||
68 | + switches_mask_t switches; | ||
69 | + int fd; | ||
70 | + QSocketNotifier *notifier; | ||
71 | +}; | ||
72 | + | ||
73 | #ifdef QT_QWS_SL5XXX | ||
74 | static const QWSServer::KeyMap keyM[] = { | ||
75 | { Qt::Key_unknown,0xffff , 0xffff , 0xffff }, // 00 | ||
76 | @@ -1440,7 +1480,11 @@ | ||
77 | } else { | ||
78 | type = spec; | ||
79 | } | ||
80 | - | ||
81 | + if ( type == "SIMpad" ) | ||
82 | + { | ||
83 | + qDebug( "QWSKeyboardHandler: using SIMpad keyboard handler..." ); | ||
84 | + handler = new QWSsimpadButtonsHandler(); | ||
85 | + } | ||
86 | if ( type == "Buttons" ) { | ||
87 | #if defined(QT_QWS_YOPY) | ||
88 | handler = new QWSyopyButtonsHandler(); | ||
89 | @@ -1469,6 +1513,72 @@ | ||
90 | return keyM; | ||
91 | } | ||
92 | |||
93 | -#endif // QT_NO_QWS_KEYBOARD | ||
94 | |||
95 | +/* | ||
96 | + * SIMpad switches handler | ||
97 | + * (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
98 | + */ | ||
99 | + | ||
100 | + | ||
101 | +QWSsimpadButtonsHandler::QWSsimpadButtonsHandler() | ||
102 | + :QWSKeyboardHandler(), fd( -1 ) | ||
103 | +{ | ||
104 | + qDebug( "SimpadButtonsHandler()" ); | ||
105 | + fd = ::open( SIMPAD_SWITCHES_DEVICE, O_RDWR | O_NDELAY, 0 ); | ||
106 | + if ( fd < 0 ) | ||
107 | + { | ||
108 | + qWarning( "SimpadButtonsHandler(): can't open %s", SIMPAD_SWITCHES_DEVICE ); | ||
109 | + return; | ||
110 | + } | ||
111 | + | ||
112 | + notifier = new QSocketNotifier( fd, QSocketNotifier::Read, this ); | ||
113 | + connect( notifier, SIGNAL( activated(int) ),this, SLOT( readSwitchesData() ) ); | ||
114 | +} | ||
115 | |||
116 | + | ||
117 | +QWSsimpadButtonsHandler::~QWSsimpadButtonsHandler() | ||
118 | +{ | ||
119 | + qDebug( "~SimpadButtonsHandler()" ); | ||
120 | + if ( fd > 0 ) | ||
121 | + { | ||
122 | + ::close( fd ); | ||
123 | + fd = -1; | ||
124 | + } | ||
125 | +} | ||
126 | + | ||
127 | + | ||
128 | +void QWSsimpadButtonsHandler::readSwitchesData() | ||
129 | +{ | ||
130 | + qDebug( "SimpadButtonsHandler() - detected switches action" ); | ||
131 | + | ||
132 | + if ( ::read( fd, &switches, sizeof switches ) < 0 ) | ||
133 | + { | ||
134 | + qWarning( "SimpadButtonsHandler() - switches read error!" ); | ||
135 | + return; | ||
136 | + } | ||
137 | + | ||
138 | + qDebug( "SimpadButtonsHandler() - EVENT = %04xd | %04xd", | ||
139 | + switches.events[0], switches.states[0] ); | ||
140 | + | ||
141 | + bool press = switches.states[0]; // == switches.event[0]; | ||
142 | + int code = switches.events[0]; | ||
143 | + int k = -1; | ||
144 | + | ||
145 | + switch(code) | ||
146 | + { | ||
147 | + case SIMPAD_SWITCH_UPPER: k = Qt::Key_Escape; break; | ||
148 | + case SIMPAD_SWITCH_UP: k = Qt::Key_Up; break; | ||
149 | + case SIMPAD_SWITCH_DOWN: k = Qt::Key_Down; break; | ||
150 | + case SIMPAD_SWITCH_LEFT: k = Qt::Key_Left; break; | ||
151 | + case SIMPAD_SWITCH_RIGHT: k = Qt::Key_Right; break; | ||
152 | + case SIMPAD_SWITCH_LOWER: k = Qt::Key_Return; break; | ||
153 | + default: k=-1; qWarning( "SimpadButtonsHandler() - unhandled event!" ); break; | ||
154 | + } | ||
155 | + | ||
156 | + if ( k >= 0 ) | ||
157 | + { | ||
158 | + qwsServer->processKeyEvent( 0, k, 0, press, false ); | ||
159 | + } | ||
160 | +} | ||
161 | + | ||
162 | +#endif // QT_NO_QWS_KEYBOARD | ||