-rw-r--r-- | libopie2/opiecore/device/odevice.h | 3 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 96 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 5 |
3 files changed, 64 insertions, 40 deletions
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index 93d7d22..bbc32fa 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -35,96 +35,97 @@ | |||
35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | 35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qnamespace.h> | 38 | #include <qnamespace.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | 41 | ||
42 | 42 | ||
43 | #include <qstrlist.h> | 43 | #include <qstrlist.h> |
44 | #include <qwindowsystem_qws.h> | 44 | #include <qwindowsystem_qws.h> |
45 | 45 | ||
46 | 46 | ||
47 | class Sound; | 47 | class Sound; |
48 | 48 | ||
49 | namespace Opie{ | 49 | namespace Opie{ |
50 | namespace Core{ | 50 | namespace Core{ |
51 | 51 | ||
52 | class ODeviceData; | 52 | class ODeviceData; |
53 | /** | 53 | /** |
54 | * The available devices | 54 | * The available devices |
55 | */ | 55 | */ |
56 | enum OModel { | 56 | enum OModel { |
57 | Model_Unknown, // = 0 | 57 | Model_Unknown, // = 0 |
58 | 58 | ||
59 | Model_Series_Mask = 0xff000000, | 59 | Model_Series_Mask = 0xff000000, |
60 | 60 | ||
61 | Model_iPAQ = ( 1 << 24 ), | 61 | Model_iPAQ = ( 1 << 24 ), |
62 | 62 | ||
63 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 63 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
64 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 64 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
65 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 65 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
66 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 66 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
67 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 67 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
68 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 68 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
69 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), | 69 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), |
70 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), | 70 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), |
71 | 71 | ||
72 | Model_Jornada = ( 6 << 24 ), | 72 | Model_Jornada = ( 6 << 24 ), |
73 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), | 73 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), |
74 | 74 | ||
75 | Model_Zaurus = ( 2 << 24 ), | 75 | Model_Zaurus = ( 2 << 24 ), |
76 | 76 | ||
77 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 77 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
78 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | 78 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), |
79 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), | 79 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), |
80 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), | 80 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), |
81 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), | 81 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), |
82 | Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), | 82 | Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), |
83 | Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x000007 ), | ||
83 | 84 | ||
84 | Model_SIMpad = ( 3 << 24 ), | 85 | Model_SIMpad = ( 3 << 24 ), |
85 | 86 | ||
86 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), | 87 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), |
87 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), | 88 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), |
88 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), | 89 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), |
89 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), | 90 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), |
90 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), | 91 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), |
91 | 92 | ||
92 | Model_Ramses = ( 4 << 24 ), | 93 | Model_Ramses = ( 4 << 24 ), |
93 | 94 | ||
94 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), | 95 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), |
95 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), | 96 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), |
96 | Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ), | 97 | Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ), |
97 | 98 | ||
98 | Model_Yopy = ( 5 << 24 ), | 99 | Model_Yopy = ( 5 << 24 ), |
99 | 100 | ||
100 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), | 101 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), |
101 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), | 102 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), |
102 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), | 103 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), |
103 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), | 104 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), |
104 | 105 | ||
105 | Model_Beagle = ( 6 << 24 ), | 106 | Model_Beagle = ( 6 << 24 ), |
106 | 107 | ||
107 | Model_Beagle_All = ( Model_Beagle | 0xffffff ), | 108 | Model_Beagle_All = ( Model_Beagle | 0xffffff ), |
108 | Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), | 109 | Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), |
109 | 110 | ||
110 | Model_GenuineIntel = ( 7 << 24 ) | 111 | Model_GenuineIntel = ( 7 << 24 ) |
111 | 112 | ||
112 | }; | 113 | }; |
113 | 114 | ||
114 | /** | 115 | /** |
115 | * The vendor of the device | 116 | * The vendor of the device |
116 | */ | 117 | */ |
117 | enum OVendor { | 118 | enum OVendor { |
118 | Vendor_Unknown, | 119 | Vendor_Unknown, |
119 | 120 | ||
120 | Vendor_HP, | 121 | Vendor_HP, |
121 | Vendor_Sharp, | 122 | Vendor_Sharp, |
122 | Vendor_SIEMENS, | 123 | Vendor_SIEMENS, |
123 | Vendor_MundN, | 124 | Vendor_MundN, |
124 | Vendor_GMate, | 125 | Vendor_GMate, |
125 | Vendor_MasterIA, | 126 | Vendor_MasterIA, |
126 | Vendor_GenuineIntel | 127 | Vendor_GenuineIntel |
127 | }; | 128 | }; |
128 | 129 | ||
129 | /** | 130 | /** |
130 | * The System used | 131 | * The System used |
@@ -316,64 +317,64 @@ public: | |||
316 | /** | 317 | /** |
317 | * Reassigns the held action for \a button. To return to the factory | 318 | * Reassigns the held action for \a button. To return to the factory |
318 | * default pass an empty string as \a qcopMessage. | 319 | * default pass an empty string as \a qcopMessage. |
319 | */ | 320 | */ |
320 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 321 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
321 | 322 | ||
322 | /** | 323 | /** |
323 | * How long (in ms) you have to press a button for a "hold" action | 324 | * How long (in ms) you have to press a button for a "hold" action |
324 | */ | 325 | */ |
325 | uint buttonHoldTime() const; | 326 | uint buttonHoldTime() const; |
326 | 327 | ||
327 | signals: | 328 | signals: |
328 | void buttonMappingChanged(); | 329 | void buttonMappingChanged(); |
329 | 330 | ||
330 | private slots: | 331 | private slots: |
331 | void systemMessage ( const QCString &, const QByteArray & ); | 332 | void systemMessage ( const QCString &, const QByteArray & ); |
332 | void playingStopped(); | 333 | void playingStopped(); |
333 | 334 | ||
334 | protected: | 335 | protected: |
335 | void addPreHandler(QWSServer::KeyboardFilter*aFilter); | 336 | void addPreHandler(QWSServer::KeyboardFilter*aFilter); |
336 | void remPreHandler(QWSServer::KeyboardFilter*aFilter); | 337 | void remPreHandler(QWSServer::KeyboardFilter*aFilter); |
337 | void reloadButtonMapping(); | 338 | void reloadButtonMapping(); |
338 | void changeMixerForAlarm( int mixer, const char* file, Sound *snd); | 339 | void changeMixerForAlarm( int mixer, const char* file, Sound *snd); |
339 | 340 | ||
340 | /* ugly virtual hook */ | 341 | /* ugly virtual hook */ |
341 | virtual void virtual_hook( int id, void* data ); | 342 | virtual void virtual_hook( int id, void* data ); |
342 | }; | 343 | }; |
343 | 344 | ||
344 | class ODeviceData { | 345 | class ODeviceData { |
345 | 346 | ||
346 | public: | 347 | public: |
347 | QString m_vendorstr; | 348 | QString m_vendorstr; |
348 | OVendor m_vendor; | 349 | OVendor m_vendor; |
349 | 350 | ||
350 | QString m_modelstr; | 351 | QString m_modelstr; |
351 | OModel m_model; | 352 | OModel m_model; |
352 | 353 | ||
353 | QString m_systemstr; | 354 | QString m_systemstr; |
354 | OSystem m_system; | 355 | OSystem m_system; |
355 | 356 | ||
356 | QString m_sysverstr; | 357 | QString m_sysverstr; |
357 | 358 | ||
358 | Transformation m_rotation; | 359 | Transformation m_rotation; |
359 | ODirection m_direction; | 360 | ODirection m_direction; |
360 | 361 | ||
361 | QValueList <ODeviceButton> *m_buttons; | 362 | QValueList <ODeviceButton> *m_buttons; |
362 | uint m_holdtime; | 363 | uint m_holdtime; |
363 | QStrList *m_cpu_frequencies; | 364 | QStrList *m_cpu_frequencies; |
364 | boolm_initializedButtonQcop : 1; | 365 | bool m_initializedButtonQcop : 1; |
365 | 366 | ||
366 | /* values for changeMixerForAlarm */ | 367 | /* values for changeMixerForAlarm */ |
367 | int m_sound, m_vol, m_mixer; | 368 | int m_sound, m_vol, m_mixer; |
368 | }; | 369 | }; |
369 | 370 | ||
370 | extern bool isQWS(); | 371 | extern bool isQWS(); |
371 | extern QCString makeChannel ( const char *str ); | 372 | extern QCString makeChannel ( const char *str ); |
372 | } | 373 | } |
373 | } | 374 | } |
374 | 375 | ||
375 | 376 | ||
376 | 377 | ||
377 | 378 | ||
378 | #endif | 379 | #endif |
379 | 380 | ||
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index fb23e1d..75a2fdc 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -124,467 +124,489 @@ void Zaurus::init(const QString& cpu_info) | |||
124 | { | 124 | { |
125 | d->m_vendorstr = "Sharp"; | 125 | d->m_vendorstr = "Sharp"; |
126 | d->m_vendor = Vendor_Sharp; | 126 | d->m_vendor = Vendor_Sharp; |
127 | d->m_systemstr = "Zaurus"; | 127 | d->m_systemstr = "Zaurus"; |
128 | d->m_system = System_Zaurus; | 128 | d->m_system = System_Zaurus; |
129 | m_embedix = true; | 129 | m_embedix = true; |
130 | } | 130 | } |
131 | else | 131 | else |
132 | { | 132 | { |
133 | d->m_vendorstr = "OpenZaurus Team"; | 133 | d->m_vendorstr = "OpenZaurus Team"; |
134 | d->m_systemstr = "OpenZaurus"; | 134 | d->m_systemstr = "OpenZaurus"; |
135 | d->m_system = System_OpenZaurus; | 135 | d->m_system = System_OpenZaurus; |
136 | // sysver already gathered | 136 | // sysver already gathered |
137 | 137 | ||
138 | // OpenZaurus sometimes uses the embedix kernel, check if this is one | 138 | // OpenZaurus sometimes uses the embedix kernel, check if this is one |
139 | FILE *uname = popen("uname -r", "r"); | 139 | FILE *uname = popen("uname -r", "r"); |
140 | QFile f; | 140 | QFile f; |
141 | QString line; | 141 | QString line; |
142 | if ( f.open(IO_ReadOnly, uname) ) { | 142 | if ( f.open(IO_ReadOnly, uname) ) { |
143 | QTextStream ts ( &f ); | 143 | QTextStream ts ( &f ); |
144 | line = ts. readLine(); | 144 | line = ts. readLine(); |
145 | int loc = line. find ( "embedix" ); | 145 | int loc = line. find ( "embedix" ); |
146 | if ( loc != -1 ) | 146 | if ( loc != -1 ) |
147 | m_embedix = true; | 147 | m_embedix = true; |
148 | else | 148 | else |
149 | m_embedix = false; | 149 | m_embedix = false; |
150 | f.close(); | 150 | f.close(); |
151 | } | 151 | } |
152 | pclose(uname); | 152 | pclose(uname); |
153 | } | 153 | } |
154 | 154 | ||
155 | // check the Zaurus model | 155 | // check the Zaurus model |
156 | QString model; | 156 | QString model; |
157 | int loc = cpu_info.find( ":" ); | 157 | int loc = cpu_info.find( ":" ); |
158 | if ( loc != -1 ) | 158 | if ( loc != -1 ) |
159 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 159 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
160 | else | 160 | else |
161 | model = cpu_info; | 161 | model = cpu_info; |
162 | 162 | ||
163 | if ( model == "SHARP Corgi" ) { | 163 | if ( model == "SHARP Corgi" ) { |
164 | d->m_model = Model_Zaurus_SLC7x0; | 164 | d->m_model = Model_Zaurus_SLC7x0; |
165 | d->m_modelstr = "Zaurus SL-C700"; | 165 | d->m_modelstr = "Zaurus SL-C700"; |
166 | } else if ( model == "SHARP Shepherd" ) { | 166 | } else if ( model == "SHARP Shepherd" ) { |
167 | d->m_model = Model_Zaurus_SLC7x0; | 167 | d->m_model = Model_Zaurus_SLC7x0; |
168 | d->m_modelstr = "Zaurus SL-C750"; | 168 | d->m_modelstr = "Zaurus SL-C750"; |
169 | } else if ( model == "SHARP Husky" ) { | 169 | } else if ( model == "SHARP Husky" ) { |
170 | d->m_model = Model_Zaurus_SLC7x0; | 170 | d->m_model = Model_Zaurus_SLC7x0; |
171 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 171 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
172 | } else if ( model == "SHARP Boxer" ) { | ||
173 | d->m_model = Model_Zaurus_SLC7x0; | ||
174 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | ||
172 | } else if ( model == "SHARP Poodle" ) { | 175 | } else if ( model == "SHARP Poodle" ) { |
173 | d->m_model = Model_Zaurus_SLB600; | 176 | d->m_model = Model_Zaurus_SLB600; |
174 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 177 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
175 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 178 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
176 | d->m_model = Model_Zaurus_SL5500; | 179 | d->m_model = Model_Zaurus_SL5500; |
177 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 180 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
178 | } else if ( model == "SHARP Tosa" ) { | 181 | } else if ( model == "SHARP Tosa" ) { |
179 | d->m_model = Model_Zaurus_SL6000; | 182 | d->m_model = Model_Zaurus_SL6000; |
180 | d->m_modelstr = "Zaurus SL-6000"; | 183 | d->m_modelstr = "Zaurus SL-6000"; |
184 | } else if ( model == "SHARP Spitz" ) { | ||
185 | d->m_model = Model_Zaurus_SLC3000; | ||
186 | d->m_modelstr = "Zaurus SL-C3000"; | ||
181 | } else { | 187 | } else { |
182 | d->m_model = Model_Zaurus_SL5500; | 188 | d->m_model = Model_Zaurus_SL5500; |
183 | d->m_modelstr = "Unkown Zaurus"; | 189 | d->m_modelstr = "Unknown Zaurus"; |
184 | } | 190 | } |
185 | 191 | ||
186 | // set initial rotation | 192 | // set initial rotation |
187 | switch( d->m_model ) { | 193 | switch( d->m_model ) { |
188 | case Model_Zaurus_SL6000: // fallthrough | 194 | case Model_Zaurus_SL6000: // fallthrough |
189 | case Model_Zaurus_SLA300: | 195 | case Model_Zaurus_SLA300: |
190 | d->m_rotation = Rot0; | 196 | d->m_rotation = Rot0; |
191 | break; | 197 | break; |
198 | case Model_Zaurus_SLC3000: // fallthrough | ||
192 | case Model_Zaurus_SLC7x0: | 199 | case Model_Zaurus_SLC7x0: |
193 | d->m_rotation = rotation(); | 200 | d->m_rotation = rotation(); |
194 | d->m_direction = direction(); | 201 | d->m_direction = direction(); |
195 | break; | 202 | break; |
196 | case Model_Zaurus_SLB600: // fallthrough | 203 | case Model_Zaurus_SLB600: // fallthrough |
204 | case Model_Zaurus_SL5000: // fallthrough | ||
197 | case Model_Zaurus_SL5500: // fallthrough | 205 | case Model_Zaurus_SL5500: // fallthrough |
198 | case Model_Zaurus_SL5000: | ||
199 | default: | 206 | default: |
200 | d->m_rotation = Rot270; | 207 | d->m_rotation = Rot270; |
201 | break; | 208 | break; |
202 | } | 209 | } |
203 | m_leds [0] = Led_Off; | 210 | m_leds[0] = Led_Off; |
204 | } | 211 | } |
205 | 212 | ||
206 | void Zaurus::initButtons() | 213 | void Zaurus::initButtons() |
207 | { | 214 | { |
208 | if ( d->m_buttons ) | 215 | if ( d->m_buttons ) |
209 | return; | 216 | return; |
210 | 217 | ||
211 | d->m_buttons = new QValueList <ODeviceButton>; | 218 | d->m_buttons = new QValueList <ODeviceButton>; |
212 | 219 | ||
213 | struct z_button * pz_buttons; | 220 | struct z_button * pz_buttons; |
214 | int buttoncount; | 221 | int buttoncount; |
215 | switch ( d->m_model ) { | 222 | switch ( d->m_model ) { |
216 | case Model_Zaurus_SLC7x0: | 223 | case Model_Zaurus_SLC7x0: |
217 | pz_buttons = z_buttons_c700; | 224 | pz_buttons = z_buttons_c700; |
218 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 225 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
219 | break; | 226 | break; |
220 | default: | 227 | default: |
221 | pz_buttons = z_buttons; | 228 | pz_buttons = z_buttons; |
222 | buttoncount = ARRAY_SIZE(z_buttons); | 229 | buttoncount = ARRAY_SIZE(z_buttons); |
223 | break; | 230 | break; |
224 | } | 231 | } |
225 | 232 | ||
226 | for ( int i = 0; i < buttoncount; i++ ) { | 233 | for ( int i = 0; i < buttoncount; i++ ) { |
227 | struct z_button *zb = pz_buttons + i; | 234 | struct z_button *zb = pz_buttons + i; |
228 | ODeviceButton b; | 235 | ODeviceButton b; |
229 | 236 | ||
230 | b. setKeycode ( zb->code ); | 237 | b. setKeycode ( zb->code ); |
231 | b. setUserText ( QObject::tr ( "Button", zb->utext )); | 238 | b. setUserText ( QObject::tr ( "Button", zb->utext )); |
232 | b. setPixmap ( Resource::loadPixmap ( zb->pix )); | 239 | b. setPixmap ( Resource::loadPixmap ( zb->pix )); |
233 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), | 240 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), |
234 | zb->fpressedaction )); | 241 | zb->fpressedaction )); |
235 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), | 242 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), |
236 | zb->fheldaction )); | 243 | zb->fheldaction )); |
237 | 244 | ||
238 | d->m_buttons->append ( b ); | 245 | d->m_buttons->append ( b ); |
239 | } | 246 | } |
240 | 247 | ||
241 | reloadButtonMapping(); | 248 | reloadButtonMapping(); |
242 | } | 249 | } |
243 | 250 | ||
244 | 251 | ||
245 | 252 | ||
246 | typedef struct sharp_led_status { | 253 | typedef struct sharp_led_status { |
247 | int which; /* select which LED status is wanted. */ | 254 | int which; /* select which LED status is wanted. */ |
248 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 255 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
249 | } sharp_led_status; | 256 | } sharp_led_status; |
250 | 257 | ||
251 | void Zaurus::buzzer( int sound ) | 258 | void Zaurus::buzzer( int sound ) |
252 | { | 259 | { |
253 | #ifndef QT_NO_SOUND | 260 | #ifndef QT_NO_SOUND |
254 | Sound *snd = 0; | 261 | Sound *snd = 0; |
255 | 262 | ||
256 | // Not all devices have real sound | 263 | // All devices except SL5500 have a DSP device |
257 | if ( d->m_model == Model_Zaurus_SLC7x0 | 264 | if ( d->m_model != Model_Zaurus_SL5000 |
258 | || d->m_model == Model_Zaurus_SLB600 | 265 | && d->m_model != Model_Zaurus_SL5500 ) { |
259 | || d->m_model == Model_Zaurus_SL6000 ) { | ||
260 | 266 | ||
261 | switch ( sound ){ | 267 | switch ( sound ){ |
262 | case SHARP_BUZ_TOUCHSOUND: { | 268 | case SHARP_BUZ_TOUCHSOUND: { |
263 | static Sound touch_sound("touchsound"); | 269 | static Sound touch_sound("touchsound"); |
264 | snd = &touch_sound; | 270 | snd = &touch_sound; |
265 | } | 271 | } |
266 | break; | 272 | break; |
267 | case SHARP_BUZ_KEYSOUND: { | 273 | case SHARP_BUZ_KEYSOUND: { |
268 | static Sound key_sound( "keysound" ); | 274 | static Sound key_sound( "keysound" ); |
269 | snd = &key_sound; | 275 | snd = &key_sound; |
270 | } | 276 | } |
271 | break; | 277 | break; |
272 | case SHARP_BUZ_SCHEDULE_ALARM: | 278 | case SHARP_BUZ_SCHEDULE_ALARM: |
273 | default: { | 279 | default: { |
274 | static Sound alarm_sound("alarm"); | 280 | static Sound alarm_sound("alarm"); |
275 | snd = &alarm_sound; | 281 | snd = &alarm_sound; |
276 | } | 282 | } |
277 | break; | 283 | break; |
278 | } | 284 | } |
279 | } | 285 | } |
280 | 286 | ||
281 | // If a soundname is defined, we expect that this device has | 287 | // If a soundname is defined, we expect that this device has |
282 | // sound capabilities.. Otherwise we expect to have the buzzer | 288 | // sound capabilities.. Otherwise we expect to have the buzzer |
283 | // device.. | 289 | // device.. |
284 | if ( snd && snd->isFinished() ){ | 290 | if ( snd && snd->isFinished() ){ |
285 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 291 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
286 | snd->play(); | 292 | snd->play(); |
287 | } else if( !snd ) { | 293 | } else if( !snd ) { |
288 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 294 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
289 | 295 | ||
290 | if ( fd >= 0 ) { | 296 | if ( fd >= 0 ) { |
291 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 297 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
292 | ::close ( fd ); | 298 | ::close ( fd ); |
293 | } | 299 | } |
294 | 300 | ||
295 | } | 301 | } |
296 | #endif | 302 | #endif |
297 | } | 303 | } |
298 | 304 | ||
299 | 305 | ||
300 | void Zaurus::playAlarmSound() | 306 | void Zaurus::playAlarmSound() |
301 | { | 307 | { |
302 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 308 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
303 | } | 309 | } |
304 | 310 | ||
305 | void Zaurus::playTouchSound() | 311 | void Zaurus::playTouchSound() |
306 | { | 312 | { |
307 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 313 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
308 | } | 314 | } |
309 | 315 | ||
310 | void Zaurus::playKeySound() | 316 | void Zaurus::playKeySound() |
311 | { | 317 | { |
312 | buzzer( SHARP_BUZ_KEYSOUND ); | 318 | buzzer( SHARP_BUZ_KEYSOUND ); |
313 | } | 319 | } |
314 | 320 | ||
315 | 321 | ||
316 | QValueList <OLed> Zaurus::ledList() const | 322 | QValueList <OLed> Zaurus::ledList() const |
317 | { | 323 | { |
318 | QValueList <OLed> vl; | 324 | QValueList <OLed> vl; |
319 | vl << Led_Mail; | 325 | vl << Led_Mail; |
320 | return vl; | 326 | return vl; |
321 | } | 327 | } |
322 | 328 | ||
323 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 329 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const |
324 | { | 330 | { |
325 | QValueList <OLedState> vl; | 331 | QValueList <OLedState> vl; |
326 | 332 | ||
327 | if ( l == Led_Mail ) | 333 | if ( l == Led_Mail ) |
328 | vl << Led_Off << Led_On << Led_BlinkSlow; | 334 | vl << Led_Off << Led_On << Led_BlinkSlow; |
329 | return vl; | 335 | return vl; |
330 | } | 336 | } |
331 | 337 | ||
332 | OLedState Zaurus::ledState ( OLed which ) const | 338 | OLedState Zaurus::ledState( OLed which ) const |
333 | { | 339 | { |
334 | if ( which == Led_Mail ) | 340 | if ( which == Led_Mail ) |
335 | return m_leds [0]; | 341 | return m_leds [0]; |
336 | else | 342 | else |
337 | return Led_Off; | 343 | return Led_Off; |
338 | } | 344 | } |
339 | 345 | ||
340 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 346 | bool Zaurus::setLedState( OLed which, OLedState st ) |
341 | { | 347 | { |
342 | if (!m_embedix) // Currently not supported on non_embedix kernels | 348 | // Currently not supported on non_embedix kernels |
349 | if (!m_embedix) | ||
350 | { | ||
351 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); | ||
343 | return false; | 352 | return false; |
353 | } | ||
344 | 354 | ||
345 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 355 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
346 | 356 | ||
347 | if ( which == Led_Mail ) { | 357 | if ( which == Led_Mail ) { |
348 | if ( fd >= 0 ) { | 358 | if ( fd >= 0 ) { |
349 | struct sharp_led_status leds; | 359 | struct sharp_led_status leds; |
350 | ::memset ( &leds, 0, sizeof( leds )); | 360 | ::memset ( &leds, 0, sizeof( leds )); |
351 | leds. which = SHARP_LED_MAIL_EXISTS; | 361 | leds. which = SHARP_LED_MAIL_EXISTS; |
352 | bool ok = true; | 362 | bool ok = true; |
353 | 363 | ||
354 | switch ( st ) { | 364 | switch ( st ) { |
355 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 365 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
356 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 366 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
357 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 367 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
358 | default : ok = false; | 368 | default : ok = false; |
359 | } | 369 | } |
360 | 370 | ||
361 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 371 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
362 | m_leds [0] = st; | 372 | m_leds [0] = st; |
363 | return true; | 373 | return true; |
364 | } | 374 | } |
365 | } | 375 | } |
366 | } | 376 | } |
367 | return false; | 377 | return false; |
368 | } | 378 | } |
369 | 379 | ||
370 | bool Zaurus::setSoftSuspend ( bool soft ) | 380 | bool Zaurus::setSoftSuspend ( bool soft ) |
371 | { | 381 | { |
372 | if (!m_embedix) { | 382 | if (!m_embedix) { |
373 | /* non-Embedix kernels dont have kernel autosuspend */ | 383 | /* non-Embedix kernels dont have kernel autosuspend */ |
374 | return ODevice::setSoftSuspend( soft ); | 384 | return ODevice::setSoftSuspend( soft ); |
375 | } | 385 | } |
376 | 386 | ||
377 | bool res = false; | 387 | bool res = false; |
378 | int fd; | 388 | int fd; |
379 | 389 | ||
380 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 390 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
381 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 391 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
382 | 392 | ||
383 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 393 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
384 | 394 | ||
385 | if ( sources >= 0 ) { | 395 | if ( sources >= 0 ) { |
386 | if ( soft ) | 396 | if ( soft ) |
387 | sources &= ~APM_EVT_POWER_BUTTON; | 397 | sources &= ~APM_EVT_POWER_BUTTON; |
388 | else | 398 | else |
389 | sources |= APM_EVT_POWER_BUTTON; | 399 | sources |= APM_EVT_POWER_BUTTON; |
390 | 400 | ||
391 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 401 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
392 | res = true; | 402 | res = true; |
393 | else | 403 | else |
394 | perror ( "APM_IOCGEVTSRC" ); | 404 | perror ( "APM_IOCGEVTSRC" ); |
395 | } | 405 | } |
396 | else | 406 | else |
397 | perror ( "APM_IOCGEVTSRC" ); | 407 | perror ( "APM_IOCGEVTSRC" ); |
398 | 408 | ||
399 | ::close ( fd ); | 409 | ::close ( fd ); |
400 | } | 410 | } |
401 | else | 411 | else |
402 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 412 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
403 | 413 | ||
404 | return res; | 414 | return res; |
405 | } | 415 | } |
406 | 416 | ||
407 | bool Zaurus::setDisplayBrightness( int bright ) | 417 | bool Zaurus::setDisplayBrightness( int bright ) |
408 | { | 418 | { |
409 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 419 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
410 | bool res = false; | 420 | bool res = false; |
411 | 421 | ||
412 | if ( bright > 255 ) bright = 255; | 422 | if ( bright > 255 ) bright = 255; |
413 | if ( bright < 0 ) bright = 0; | 423 | if ( bright < 0 ) bright = 0; |
414 | 424 | ||
415 | if ( m_embedix ) | 425 | if ( m_embedix ) |
416 | { | 426 | { |
417 | int numberOfSteps = displayBrightnessResolution(); | 427 | int numberOfSteps = displayBrightnessResolution(); |
418 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 428 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
419 | if ( fd ) | 429 | if ( fd ) |
420 | { | 430 | { |
421 | int val = ( bright * numberOfSteps ) / 255; | 431 | int val = ( bright * numberOfSteps ) / 255; |
422 | res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | 432 | res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
423 | ::close ( fd ); | 433 | ::close ( fd ); |
424 | } | 434 | } |
425 | } | 435 | } |
426 | else | 436 | else |
427 | { | 437 | { |
428 | qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); | 438 | qDebug( "Zaurus::setDisplayBrightness: ODevice handling for non-embedix kernels not yet implemented" ); |
429 | } | 439 | } |
430 | return res; | 440 | return res; |
431 | } | 441 | } |
432 | 442 | ||
433 | bool Zaurus::setDisplayStatus( bool on ) | 443 | bool Zaurus::setDisplayStatus( bool on ) |
434 | { | 444 | { |
435 | bool res = false; | 445 | bool res = false; |
436 | if ( m_embedix ) | 446 | if ( m_embedix ) |
437 | { | 447 | { |
438 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 448 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
439 | if ( fd ) | 449 | if ( fd ) |
440 | { | 450 | { |
441 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | 451 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; |
442 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | 452 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); |
443 | ::close ( fd ); | 453 | ::close ( fd ); |
444 | } | 454 | } |
445 | } | 455 | } |
446 | else | 456 | else |
447 | { | 457 | { |
448 | qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); | 458 | qDebug( "Zaurus::setDisplayStatus: ODevice handling for non-embedix kernels not yet implemented" ); |
449 | } | 459 | } |
450 | return res; | 460 | return res; |
451 | } | 461 | } |
452 | 462 | ||
453 | bool Zaurus::suspend() | 463 | bool Zaurus::suspend() |
454 | { | 464 | { |
455 | qDebug("ODevice::suspend"); | 465 | qDebug("ODevice::suspend"); |
456 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 466 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
457 | return false; | 467 | return false; |
458 | 468 | ||
459 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 469 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
460 | return false; | 470 | return false; |
461 | 471 | ||
462 | bool res = false; | 472 | bool res = false; |
463 | ODevice::sendSuspendmsg(); | 473 | ODevice::sendSuspendmsg(); |
464 | 474 | ||
465 | struct timeval tvs, tvn; | 475 | struct timeval tvs, tvn; |
466 | ::gettimeofday ( &tvs, 0 ); | 476 | ::gettimeofday ( &tvs, 0 ); |
467 | 477 | ||
468 | ::sync(); // flush fs caches | 478 | ::sync(); // flush fs caches |
469 | res = ( ::system ( "apm --suspend" ) == 0 ); | 479 | res = ( ::system ( "apm --suspend" ) == 0 ); |
470 | 480 | ||
471 | // This is needed because the apm implementation is asynchronous and we | 481 | // This is needed because the apm implementation is asynchronous and we |
472 | // can not be sure when exactly the device is really suspended | 482 | // can not be sure when exactly the device is really suspended |
473 | if ( res ) { | 483 | if ( res ) { |
474 | do { // Yes, wait 15 seconds. This APM sucks big time. | 484 | do { // Yes, wait 15 seconds. This APM sucks big time. |
475 | ::usleep ( 200 * 1000 ); | 485 | ::usleep ( 200 * 1000 ); |
476 | ::gettimeofday ( &tvn, 0 ); | 486 | ::gettimeofday ( &tvn, 0 ); |
477 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 487 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
478 | } | 488 | } |
479 | 489 | ||
480 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 490 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
481 | return res; | 491 | return res; |
482 | } | 492 | } |
483 | 493 | ||
484 | 494 | ||
485 | Transformation Zaurus::rotation() const | 495 | Transformation Zaurus::rotation() const |
486 | { | 496 | { |
487 | Transformation rot; | 497 | Transformation rot; |
488 | int handle = 0; | 498 | int handle = 0; |
489 | int retval = 0; | 499 | int retval = 0; |
490 | 500 | ||
491 | switch ( d->m_model ) { | 501 | switch ( d->m_model ) { |
502 | case Model_Zaurus_SLC3000: // fallthrough | ||
492 | case Model_Zaurus_SLC7x0: | 503 | case Model_Zaurus_SLC7x0: |
493 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 504 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
494 | if (handle == -1) { | 505 | if (handle == -1) { |
495 | return Rot270; | 506 | return Rot270; |
496 | } else { | 507 | } else { |
497 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 508 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
498 | ::close (handle); | 509 | ::close (handle); |
499 | 510 | ||
500 | if (retval == 2 ) | 511 | if (retval == 2 ) |
501 | rot = Rot0; | 512 | rot = Rot0; |
502 | else | 513 | else |
503 | rot = Rot270; | 514 | rot = Rot270; |
504 | } | 515 | } |
505 | break; | 516 | break; |
506 | case Model_Zaurus_SLA300: | 517 | case Model_Zaurus_SL6000: |
507 | case Model_Zaurus_SLB600: | 518 | case Model_Zaurus_SLB600: |
519 | case Model_Zaurus_SLA300: | ||
508 | case Model_Zaurus_SL5500: | 520 | case Model_Zaurus_SL5500: |
509 | case Model_Zaurus_SL5000: | 521 | case Model_Zaurus_SL5000: |
510 | default: | 522 | default: |
511 | rot = d->m_rotation; | 523 | rot = d->m_rotation; |
512 | break; | 524 | break; |
513 | } | 525 | } |
514 | 526 | ||
515 | return rot; | 527 | return rot; |
516 | } | 528 | } |
517 | ODirection Zaurus::direction() const | 529 | ODirection Zaurus::direction() const |
518 | { | 530 | { |
519 | ODirection dir; | 531 | ODirection dir; |
520 | int handle = 0; | 532 | int handle = 0; |
521 | int retval = 0; | 533 | int retval = 0; |
522 | switch ( d->m_model ) { | 534 | switch ( d->m_model ) { |
535 | case Model_Zaurus_SLC3000: // fallthrough | ||
523 | case Model_Zaurus_SLC7x0: | 536 | case Model_Zaurus_SLC7x0: |
524 | handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); | 537 | handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); |
525 | if (handle == -1) { | 538 | if (handle == -1) { |
526 | dir = CW; | 539 | dir = CW; |
527 | } else { | 540 | } else { |
528 | retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION ); | 541 | retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION ); |
529 | ::close (handle); | 542 | ::close (handle); |
530 | if (retval == 2 ) | 543 | if (retval == 2 ) |
531 | dir = CCW; | 544 | dir = CCW; |
532 | else | 545 | else |
533 | dir = CW; | 546 | dir = CW; |
534 | } | 547 | } |
535 | break; | 548 | break; |
549 | case Model_Zaurus_SL6000: | ||
536 | case Model_Zaurus_SLA300: | 550 | case Model_Zaurus_SLA300: |
537 | case Model_Zaurus_SLB600: | 551 | case Model_Zaurus_SLB600: |
538 | case Model_Zaurus_SL5500: | 552 | case Model_Zaurus_SL5500: |
539 | case Model_Zaurus_SL5000: | 553 | case Model_Zaurus_SL5000: |
540 | default: dir = d->m_direction; | 554 | default: dir = d->m_direction; |
541 | break; | 555 | break; |
542 | } | 556 | } |
543 | return dir; | 557 | return dir; |
544 | 558 | ||
545 | } | 559 | } |
546 | 560 | ||
547 | int Zaurus::displayBrightnessResolution() const | 561 | int Zaurus::displayBrightnessResolution() const |
548 | { | 562 | { |
549 | if (m_embedix) | 563 | if (m_embedix) |
550 | { | 564 | { |
551 | int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | 565 | int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); |
552 | if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 ); | 566 | if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 ); |
553 | else return 1; | 567 | else return 1; |
554 | } | 568 | } |
555 | else | 569 | else |
556 | { | 570 | { |
557 | qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); | 571 | qDebug( "Zaurus::displayBrightnessResolution: ODevice handling for non-embedix kernels not yet implemented" ); |
558 | return 1; | 572 | return 1; |
559 | } | 573 | } |
560 | } | 574 | } |
561 | 575 | ||
562 | bool Zaurus::hasHingeSensor() const | 576 | bool Zaurus::hasHingeSensor() const |
563 | { | 577 | { |
564 | return d->m_model == Model_Zaurus_SLC7x0; | 578 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; |
565 | } | 579 | } |
566 | 580 | ||
567 | OHingeStatus Zaurus::readHingeSensor() | 581 | OHingeStatus Zaurus::readHingeSensor() |
568 | { | 582 | { |
569 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 583 | if (m_embedix) |
570 | if (handle == -1) | ||
571 | { | ||
572 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | ||
573 | return CASE_UNKNOWN; | ||
574 | } | ||
575 | else | ||
576 | { | 584 | { |
577 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 585 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
578 | ::close (handle); | 586 | if (handle == -1) |
579 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | ||
580 | { | 587 | { |
581 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 588 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
582 | return static_cast<OHingeStatus>( retval ); | 589 | return CASE_UNKNOWN; |
583 | } | 590 | } |
584 | else | 591 | else |
585 | { | 592 | { |
586 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 593 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
587 | return CASE_UNKNOWN; | 594 | ::close (handle); |
595 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | ||
596 | { | ||
597 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | ||
598 | return static_cast<OHingeStatus>( retval ); | ||
599 | } | ||
600 | else | ||
601 | { | ||
602 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | ||
603 | return CASE_UNKNOWN; | ||
604 | } | ||
588 | } | 605 | } |
589 | } | 606 | } |
607 | else | ||
608 | { | ||
609 | qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" ); | ||
610 | return CASE_UNKNOWN; | ||
611 | } | ||
590 | } | 612 | } |
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h index 37ab876..ed9cf67 100644 --- a/libopie2/opiecore/device/odevice_zaurus.h +++ b/libopie2/opiecore/device/odevice_zaurus.h | |||
@@ -41,97 +41,98 @@ | |||
41 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 41 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
42 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 42 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
43 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 43 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
44 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 44 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
45 | 45 | ||
46 | // Audio | 46 | // Audio |
47 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 47 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
48 | 48 | ||
49 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 49 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
50 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 50 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
51 | 51 | ||
52 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 52 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
53 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 53 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
54 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 54 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
55 | 55 | ||
56 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 56 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
57 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 57 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
58 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 58 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
59 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 59 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
60 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 60 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
61 | 61 | ||
62 | // LED | 62 | // LED |
63 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 63 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
64 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 64 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
65 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 65 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
66 | 66 | ||
67 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 67 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
68 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 68 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
69 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 69 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
70 | 70 | ||
71 | // Rotation and Power Management | 71 | // Rotation and Power Management |
72 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 72 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
73 | 73 | ||
74 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 74 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
75 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 75 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
76 | #define APM_EVT_POWER_BUTTON (1 << 0) | 76 | #define APM_EVT_POWER_BUTTON (1 << 0) |
77 | 77 | ||
78 | // Brightness | 78 | // Brightness |
79 | #define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" | 79 | #define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" |
80 | #define SHARP_FL_IOCTL_ON 1 | 80 | #define SHARP_FL_IOCTL_ON 1 |
81 | #define SHARP_FL_IOCTL_OFF 2 | 81 | #define SHARP_FL_IOCTL_OFF 2 |
82 | #define SHARP_FL_IOCTL_STEP_CONTRAST 100 | 82 | #define SHARP_FL_IOCTL_STEP_CONTRAST 100 |
83 | #define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 | 83 | #define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 |
84 | #define SHARP_FL_IOCTL_GET_STEP 102 | 84 | #define SHARP_FL_IOCTL_GET_STEP 102 |
85 | 85 | ||
86 | namespace Opie { | 86 | namespace Opie { |
87 | namespace Core { | 87 | namespace Core { |
88 | namespace Internal { | 88 | namespace Internal { |
89 | |||
89 | class Zaurus : public ODevice | 90 | class Zaurus : public ODevice |
90 | { | 91 | { |
91 | protected: | 92 | protected: |
92 | virtual void init(const QString&); | 93 | virtual void init(const QString&); |
93 | virtual void initButtons(); | 94 | virtual void initButtons(); |
94 | 95 | ||
95 | public: | 96 | public: |
96 | virtual bool setSoftSuspend( bool soft ); | 97 | virtual bool setSoftSuspend( bool soft ); |
97 | 98 | ||
98 | virtual bool setDisplayBrightness( int b ); | 99 | virtual bool setDisplayBrightness( int b ); |
99 | virtual bool setDisplayStatus( bool on ); | 100 | virtual bool setDisplayStatus( bool on ); |
100 | virtual int displayBrightnessResolution() const; | 101 | virtual int displayBrightnessResolution() const; |
101 | 102 | ||
102 | virtual void playAlarmSound(); | 103 | virtual void playAlarmSound(); |
103 | virtual void playKeySound(); | 104 | virtual void playKeySound(); |
104 | virtual void playTouchSound(); | 105 | virtual void playTouchSound(); |
105 | 106 | ||
106 | virtual QValueList <OLed> ledList() const; | 107 | virtual QValueList <OLed> ledList() const; |
107 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 108 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
108 | virtual OLedState ledState( OLed led ) const; | 109 | virtual OLedState ledState( OLed led ) const; |
109 | virtual bool setLedState( OLed led, OLedState st ); | 110 | virtual bool setLedState( OLed led, OLedState st ); |
110 | 111 | ||
111 | virtual bool hasHingeSensor() const; | 112 | virtual bool hasHingeSensor() const; |
112 | virtual OHingeStatus readHingeSensor(); | 113 | virtual OHingeStatus readHingeSensor(); |
113 | 114 | ||
114 | virtual bool suspend(); | 115 | virtual bool suspend(); |
115 | virtual Transformation rotation() const; | 116 | virtual Transformation rotation() const; |
116 | virtual ODirection direction() const; | 117 | virtual ODirection direction() const; |
117 | 118 | ||
118 | protected: | 119 | protected: |
119 | virtual void buzzer ( int snd ); | 120 | virtual void buzzer( int snd ); |
120 | 121 | ||
121 | OLedState m_leds [1]; | 122 | OLedState m_leds[1]; |
122 | bool m_embedix; | 123 | bool m_embedix; |
123 | }; | 124 | }; |
124 | 125 | ||
125 | struct z_button { | 126 | struct z_button { |
126 | Qt::Key code; | 127 | Qt::Key code; |
127 | char *utext; | 128 | char *utext; |
128 | char *pix; | 129 | char *pix; |
129 | char *fpressedservice; | 130 | char *fpressedservice; |
130 | char *fpressedaction; | 131 | char *fpressedaction; |
131 | char *fheldservice; | 132 | char *fheldservice; |
132 | char *fheldaction; | 133 | char *fheldaction; |
133 | }; | 134 | }; |
134 | } | 135 | } |
135 | } | 136 | } |
136 | } | 137 | } |
137 | #endif | 138 | #endif |