summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2005-08-31 10:21:12 (UTC)
committer mickeyl <mickeyl>2005-08-31 10:21:12 (UTC)
commitcde931654d1966be6989e6c8f3cfacb23e6822a2 (patch) (unidiff)
tree9a8244f4da0180a685554ebca0d7b628630fb42e /libopie2
parent142e7e82efa6dd45884805c34fadec2160225e4b (diff)
downloadopie-cde931654d1966be6989e6c8f3cfacb23e6822a2.zip
opie-cde931654d1966be6989e6c8f3cfacb23e6822a2.tar.gz
opie-cde931654d1966be6989e6c8f3cfacb23e6822a2.tar.bz2
- add support for the new Switches type in the Linux Input System (coming with 2.6.14)
- use the new Switches support to rewrite the hinge sensor handling on Zaurus models w/ 2.6 - add Switches support to SysInfo, OInputSystem, oinputsystemdemo
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp73
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h6
-rw-r--r--libopie2/opiecore/linux/oinputsystem.cpp38
-rw-r--r--libopie2/opiecore/linux/oinputsystem.h11
-rw-r--r--libopie2/opiecore/linux/oinputsystemenums.h405
-rw-r--r--libopie2/opiecore/linux_input.h25
-rw-r--r--libopie2/opiecore/oinputsystemenums.h13
7 files changed, 157 insertions, 414 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 33d5cd6..a75f566 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,142 +1,144 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 =. Copyright (C) 2002-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 4 =. Copyright (C) 2002-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; version 2 of the License. 11 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 12     ._= =}       :
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_zaurus.h" 30#include "odevice_zaurus.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/oinputsystem.h> 33#include <opie2/oinputsystem.h>
34#include <opie2/oresource.h> 34#include <opie2/oresource.h>
35 35
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/sound.h> 37#include <qpe/sound.h>
38 38
39/* QT */ 39/* QT */
40#include <qapplication.h> 40#include <qapplication.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qwindowsystem_qws.h> 43#include <qwindowsystem_qws.h>
44#include <qcopchannel_qws.h> 44#include <qcopchannel_qws.h>
45 45
46/* STD */ 46/* STD */
47#include <string.h>
48#include <errno.h>
47#include <fcntl.h> 49#include <fcntl.h>
48#include <math.h> 50#include <math.h>
49#include <stdlib.h> 51#include <stdlib.h>
50#include <signal.h> 52#include <signal.h>
51#include <sys/ioctl.h> 53#include <sys/ioctl.h>
52#include <sys/time.h> 54#include <sys/time.h>
53#include <unistd.h> 55#include <unistd.h>
54#ifndef QT_NO_SOUND 56#ifndef QT_NO_SOUND
55#include <linux/soundcard.h> 57#include <linux/soundcard.h>
56#endif 58#endif
57 59
58using namespace Opie::Core; 60using namespace Opie::Core;
59using namespace Opie::Core::Internal; 61using namespace Opie::Core::Internal;
60 62
61struct z_button z_buttons [] = { 63struct z_button z_buttons [] = {
62 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 64 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
63 "devicebuttons/z_calendar", 65 "devicebuttons/z_calendar",
64 "datebook", "nextView()", 66 "datebook", "nextView()",
65 "today", "raise()" }, 67 "today", "raise()" },
66 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 68 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
67 "devicebuttons/z_contact", 69 "devicebuttons/z_contact",
68 "addressbook", "raise()", 70 "addressbook", "raise()",
69 "addressbook", "beamBusinessCard()" }, 71 "addressbook", "beamBusinessCard()" },
70 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 72 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
71 "devicebuttons/z_home", 73 "devicebuttons/z_home",
72 "QPE/Launcher", "home()", 74 "QPE/Launcher", "home()",
73 "buttonsettings", "raise()" }, 75 "buttonsettings", "raise()" },
74 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 76 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
75 "devicebuttons/z_menu", 77 "devicebuttons/z_menu",
76 "QPE/TaskBar", "toggleMenu()", 78 "QPE/TaskBar", "toggleMenu()",
77 "QPE/TaskBar", "toggleStartMenu()" }, 79 "QPE/TaskBar", "toggleStartMenu()" },
78 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 80 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
79 "devicebuttons/z_mail", 81 "devicebuttons/z_mail",
80 "opiemail", "raise()", 82 "opiemail", "raise()",
81 "opiemail", "newMail()" }, 83 "opiemail", "newMail()" },
82}; 84};
83 85
84struct z_button z_buttons_c700 [] = { 86struct z_button z_buttons_c700 [] = {
85 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 87 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
86 "devicebuttons/z_calendar", 88 "devicebuttons/z_calendar",
87 "datebook", "nextView()", 89 "datebook", "nextView()",
88 "today", "raise()" }, 90 "today", "raise()" },
89 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 91 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
90 "devicebuttons/z_contact", 92 "devicebuttons/z_contact",
91 "addressbook", "raise()", 93 "addressbook", "raise()",
92 "addressbook", "beamBusinessCard()" }, 94 "addressbook", "beamBusinessCard()" },
93 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 95 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
94 "devicebuttons/z_home", 96 "devicebuttons/z_home",
95 "QPE/Launcher", "home()", 97 "QPE/Launcher", "home()",
96 "buttonsettings", "raise()" }, 98 "buttonsettings", "raise()" },
97 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 99 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
98 "devicebuttons/z_menu", 100 "devicebuttons/z_menu",
99 "QPE/TaskBar", "toggleMenu()", 101 "QPE/TaskBar", "toggleMenu()",
100 "QPE/TaskBar", "toggleStartMenu()" }, 102 "QPE/TaskBar", "toggleStartMenu()" },
101 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 103 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
102 "devicebuttons/z_mail", 104 "devicebuttons/z_mail",
103 "opiemail", "raise()", 105 "opiemail", "raise()",
104 "opiemail", "newMail()" }, 106 "opiemail", "newMail()" },
105 107
106 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), 108 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"),
107 "devicebuttons/z_hinge1", 109 "devicebuttons/z_hinge1",
108 "QPE/Rotation", "rotateDefault()",0}, 110 "QPE/Rotation", "rotateDefault()",0},
109 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), 111 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"),
110 "devicebuttons/z_hinge2", 112 "devicebuttons/z_hinge2",
111 "QPE/Rotation", "rotateDefault()",0}, 113 "QPE/Rotation", "rotateDefault()",0},
112 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), 114 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"),
113 "devicebuttons/z_hinge3", 115 "devicebuttons/z_hinge3",
114 "QPE/Rotation", "rotateDefault()",0}, 116 "QPE/Rotation", "rotateDefault()",0},
115}; 117};
116 118
117struct z_button z_buttons_6000 [] = { 119struct z_button z_buttons_6000 [] = {
118 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 120 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
119 "devicebuttons/z_calendar", 121 "devicebuttons/z_calendar",
120 "datebook", "nextView()", 122 "datebook", "nextView()",
121 "today", "raise()" }, 123 "today", "raise()" },
122 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 124 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
123 "devicebuttons/z_contact", 125 "devicebuttons/z_contact",
124 "addressbook", "raise()", 126 "addressbook", "raise()",
125 "addressbook", "beamBusinessCard()" }, 127 "addressbook", "beamBusinessCard()" },
126 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 128 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
127 "devicebuttons/z_home", 129 "devicebuttons/z_home",
128 "QPE/Launcher", "home()", 130 "QPE/Launcher", "home()",
129 "buttonsettings", "raise()" }, 131 "buttonsettings", "raise()" },
130 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 132 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
131 "devicebuttons/z_menu", 133 "devicebuttons/z_menu",
132 "QPE/TaskBar", "toggleMenu()", 134 "QPE/TaskBar", "toggleMenu()",
133 "QPE/TaskBar", "toggleStartMenu()" }, 135 "QPE/TaskBar", "toggleStartMenu()" },
134 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 136 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
135 "devicebuttons/z_mail", 137 "devicebuttons/z_mail",
136 "opiemail", "raise()", 138 "opiemail", "raise()",
137 "opiemail", "newMail()" }, 139 "opiemail", "newMail()" },
138 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Rotate Button"), 140 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Rotate Button"),
139 "devicebuttons/z_rotate", 141 "devicebuttons/z_rotate",
140 0, 142 0,
141 "QPE/Rotation", "rotateDefault()" }, 143 "QPE/Rotation", "rotateDefault()" },
142 { Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 144 { Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
@@ -211,194 +213,196 @@ void Zaurus::init(const QString& cpu_info)
211 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 213 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
212 } else if ( model == "SHARP Poodle" ) { 214 } else if ( model == "SHARP Poodle" ) {
213 d->m_model = Model_Zaurus_SLB600; 215 d->m_model = Model_Zaurus_SLB600;
214 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 216 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
215 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 217 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
216 d->m_model = Model_Zaurus_SL5500; 218 d->m_model = Model_Zaurus_SL5500;
217 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 219 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
218 } else if ( model == "SHARP Tosa" ) { 220 } else if ( model == "SHARP Tosa" ) {
219 d->m_model = Model_Zaurus_SL6000; 221 d->m_model = Model_Zaurus_SL6000;
220 d->m_modelstr = "Zaurus SL-6000"; 222 d->m_modelstr = "Zaurus SL-6000";
221 } else if ( model == "SHARP Spitz" ) { 223 } else if ( model == "SHARP Spitz" ) {
222 d->m_model = Model_Zaurus_SLC3000; 224 d->m_model = Model_Zaurus_SLC3000;
223 d->m_modelstr = "Zaurus SL-C3000"; 225 d->m_modelstr = "Zaurus SL-C3000";
224 } else if ( model == "SHARP Akita" ) { 226 } else if ( model == "SHARP Akita" ) {
225 d->m_model = Model_Zaurus_SLC1000; 227 d->m_model = Model_Zaurus_SLC1000;
226 d->m_modelstr = "Zaurus SL-C1000"; 228 d->m_modelstr = "Zaurus SL-C1000";
227 } else if ( model == "SHARP Borzoi" ) { 229 } else if ( model == "SHARP Borzoi" ) {
228 d->m_model = Model_Zaurus_SLC3100; 230 d->m_model = Model_Zaurus_SLC3100;
229 d->m_modelstr = "Zaurus SL-C3100"; 231 d->m_modelstr = "Zaurus SL-C3100";
230 } else { 232 } else {
231 d->m_model = Model_Zaurus_SL5500; 233 d->m_model = Model_Zaurus_SL5500;
232 d->m_modelstr = "Unknown Zaurus"; 234 d->m_modelstr = "Unknown Zaurus";
233 } 235 }
234 236
235 // set path to backlight device in kernel 2.6 237 // set path to backlight device in kernel 2.6
236 switch ( d->m_model ) 238 switch ( d->m_model )
237 { 239 {
238 case Model_Zaurus_SLB600: // fallthrough 240 case Model_Zaurus_SLB600: // fallthrough
239 case Model_Zaurus_SL5500: 241 case Model_Zaurus_SL5500:
240 m_backlightdev = "/sys/class/backlight/locomo-backlight/"; 242 m_backlightdev = "/sys/class/backlight/locomo-backlight/";
241 break; 243 break;
242 case Model_Zaurus_SL6000: 244 case Model_Zaurus_SL6000:
243 m_backlightdev = "/sys/class/backlight/tosa-bl/"; 245 m_backlightdev = "/sys/class/backlight/tosa-bl/";
244 break; 246 break;
245 default: 247 default:
246 m_backlightdev = "/sys/class/backlight/corgi-bl/"; 248 m_backlightdev = "/sys/class/backlight/corgi-bl/";
247 } 249 }
248 250
249 // set initial rotation 251 // set initial rotation
250 switch( d->m_model ) 252 switch( d->m_model )
251 { 253 {
252 case Model_Zaurus_SL6000: // fallthrough 254 case Model_Zaurus_SL6000: // fallthrough
253 case Model_Zaurus_SLA300: 255 case Model_Zaurus_SLA300:
254 d->m_rotation = Rot0; 256 d->m_rotation = Rot0;
255 break; 257 break;
256 case Model_Zaurus_SLC3100: // fallthrough 258 case Model_Zaurus_SLC3100: // fallthrough
257 case Model_Zaurus_SLC3000: // fallthrough 259 case Model_Zaurus_SLC3000: // fallthrough
258 case Model_Zaurus_SLC1000: // fallthrough 260 case Model_Zaurus_SLC1000: // fallthrough
259 case Model_Zaurus_SLC7x0: 261 case Model_Zaurus_SLC7x0:
260 d->m_rotation = rotation(); 262 d->m_rotation = rotation();
261 d->m_direction = direction(); 263 d->m_direction = direction();
262 break; 264 break;
263 case Model_Zaurus_SLB600: // fallthrough 265 case Model_Zaurus_SLB600: // fallthrough
264 case Model_Zaurus_SL5000: // fallthrough 266 case Model_Zaurus_SL5000: // fallthrough
265 case Model_Zaurus_SL5500: // fallthrough 267 case Model_Zaurus_SL5500: // fallthrough
266 default: 268 default:
267 d->m_rotation = Rot270; 269 d->m_rotation = Rot270;
268 } 270 }
269 271
270 // set default qte driver 272 // set default qte driver
271 switch( d->m_model ) 273 switch( d->m_model )
272 { 274 {
273 case Model_Zaurus_SLC7x0: 275 case Model_Zaurus_SLC7x0:
274 d->m_qteDriver = "W100"; 276 d->m_qteDriver = "W100";
275 break; 277 break;
276 default: 278 default:
277 d->m_qteDriver = "Transformed"; 279 d->m_qteDriver = "Transformed";
278 } 280 }
279 281
280 m_leds[0] = Led_Off; 282 m_leds[0] = Led_Off;
281 283
282 if ( m_embedix ) 284 if ( m_embedix )
283 qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); 285 qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr );
284 else 286 else
285 qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); 287 qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
286} 288}
287 289
288void Zaurus::initButtons() 290void Zaurus::initButtons()
289{ 291{
290 if ( d->m_buttons ) 292 if ( d->m_buttons )
291 return; 293 return;
292 294
293 d->m_buttons = new QValueList <ODeviceButton>; 295 d->m_buttons = new QValueList <ODeviceButton>;
294 296
295 struct z_button * pz_buttons; 297 struct z_button * pz_buttons;
296 int buttoncount; 298 int buttoncount;
297 switch ( d->m_model ) 299 switch ( d->m_model )
298 { 300 {
299 case Model_Zaurus_SL6000: 301 case Model_Zaurus_SL6000:
300 pz_buttons = z_buttons_6000; 302 pz_buttons = z_buttons_6000;
301 buttoncount = ARRAY_SIZE(z_buttons_6000); 303 buttoncount = ARRAY_SIZE(z_buttons_6000);
302 break; 304 break;
303 case Model_Zaurus_SLC3100: // fallthrough 305 case Model_Zaurus_SLC3100: // fallthrough
304 case Model_Zaurus_SLC3000: // fallthrough 306 case Model_Zaurus_SLC3000: // fallthrough
305 case Model_Zaurus_SLC1000: // fallthrough 307 case Model_Zaurus_SLC1000: // fallthrough
306 case Model_Zaurus_SLC7x0: 308 case Model_Zaurus_SLC7x0:
307 if ( isQWS( ) ) { 309 if ( isQWS( ) )
308 addPreHandler(this); // hinge-sensor-handler 310 { // setup hinge sensor stuff
311 addPreHandler(this);
312 initHingeSensor();
309 } 313 }
310 pz_buttons = z_buttons_c700; 314 pz_buttons = z_buttons_c700;
311 buttoncount = ARRAY_SIZE(z_buttons_c700); 315 buttoncount = ARRAY_SIZE(z_buttons_c700);
312 break; 316 break;
313 default: 317 default:
314 pz_buttons = z_buttons; 318 pz_buttons = z_buttons;
315 buttoncount = ARRAY_SIZE(z_buttons); 319 buttoncount = ARRAY_SIZE(z_buttons);
316 break; 320 break;
317 } 321 }
318 322
319 for ( int i = 0; i < buttoncount; i++ ) { 323 for ( int i = 0; i < buttoncount; i++ ) {
320 struct z_button *zb = pz_buttons + i; 324 struct z_button *zb = pz_buttons + i;
321 ODeviceButton b; 325 ODeviceButton b;
322 326
323 b.setKeycode( zb->code ); 327 b.setKeycode( zb->code );
324 b.setUserText( QObject::tr( "Button", zb->utext )); 328 b.setUserText( QObject::tr( "Button", zb->utext ));
325 b.setPixmap( OResource::loadPixmap( zb->pix )); 329 b.setPixmap( OResource::loadPixmap( zb->pix ));
326 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); 330 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
327 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); 331 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
328 d->m_buttons->append( b ); 332 d->m_buttons->append( b );
329 } 333 }
330 334
331 reloadButtonMapping(); 335 reloadButtonMapping();
332} 336}
333 337
334 338
335 339
336typedef struct sharp_led_status { 340typedef struct sharp_led_status {
337 int which; /* select which LED status is wanted. */ 341 int which; /* select which LED status is wanted. */
338 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 342 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
339} sharp_led_status; 343} sharp_led_status;
340 344
341void Zaurus::buzzer( int sound ) 345void Zaurus::buzzer( int sound )
342{ 346{
343#ifndef QT_NO_SOUND 347#ifndef QT_NO_SOUND
344 Sound *snd = 0; 348 Sound *snd = 0;
345 349
346 // All devices except SL5500 have a DSP device 350 // All devices except SL5500 have a DSP device
347 if ( d->m_model != Model_Zaurus_SL5000 351 if ( d->m_model != Model_Zaurus_SL5000
348 && d->m_model != Model_Zaurus_SL5500 ) { 352 && d->m_model != Model_Zaurus_SL5500 ) {
349 353
350 switch ( sound ){ 354 switch ( sound ){
351 case SHARP_BUZ_TOUCHSOUND: { 355 case SHARP_BUZ_TOUCHSOUND: {
352 static Sound touch_sound("touchsound"); 356 static Sound touch_sound("touchsound");
353 snd = &touch_sound; 357 snd = &touch_sound;
354 } 358 }
355 break; 359 break;
356 case SHARP_BUZ_KEYSOUND: { 360 case SHARP_BUZ_KEYSOUND: {
357 static Sound key_sound( "keysound" ); 361 static Sound key_sound( "keysound" );
358 snd = &key_sound; 362 snd = &key_sound;
359 } 363 }
360 break; 364 break;
361 case SHARP_BUZ_SCHEDULE_ALARM: 365 case SHARP_BUZ_SCHEDULE_ALARM:
362 default: { 366 default: {
363 static Sound alarm_sound("alarm"); 367 static Sound alarm_sound("alarm");
364 snd = &alarm_sound; 368 snd = &alarm_sound;
365 } 369 }
366 break; 370 break;
367 } 371 }
368 } 372 }
369 373
370 // If a soundname is defined, we expect that this device has 374 // If a soundname is defined, we expect that this device has
371 // sound capabilities.. Otherwise we expect to have the buzzer 375 // sound capabilities.. Otherwise we expect to have the buzzer
372 // device.. 376 // device..
373 if ( snd && snd->isFinished() ){ 377 if ( snd && snd->isFinished() ){
374 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 378 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
375 snd->play(); 379 snd->play();
376 } else if( !snd ) { 380 } else if( !snd ) {
377 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 381 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
378 382
379 if ( fd >= 0 ) { 383 if ( fd >= 0 ) {
380 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 384 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
381 ::close ( fd ); 385 ::close ( fd );
382 } 386 }
383 387
384 } 388 }
385#endif 389#endif
386} 390}
387 391
388 392
389void Zaurus::playAlarmSound() 393void Zaurus::playAlarmSound()
390{ 394{
391 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 395 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
392} 396}
393 397
394void Zaurus::playTouchSound() 398void Zaurus::playTouchSound()
395{ 399{
396 buzzer( SHARP_BUZ_TOUCHSOUND ); 400 buzzer( SHARP_BUZ_TOUCHSOUND );
397} 401}
398 402
399void Zaurus::playKeySound() 403void Zaurus::playKeySound()
400{ 404{
401 buzzer( SHARP_BUZ_KEYSOUND ); 405 buzzer( SHARP_BUZ_KEYSOUND );
402} 406}
403 407
404 408
@@ -569,170 +573,223 @@ Transformation Zaurus::rotation() const
569 // SLC7x0 needs a special case here, because we were able to set the W100 573 // SLC7x0 needs a special case here, because we were able to set the W100
570 // hardware default rotation on kernel 2.6 to Rot0 574 // hardware default rotation on kernel 2.6 to Rot0
571 case Model_Zaurus_SLC7x0: 575 case Model_Zaurus_SLC7x0:
572 { 576 {
573 OHingeStatus hs = readHingeSensor(); 577 OHingeStatus hs = readHingeSensor();
574 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); 578 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
575 579
576 if ( m_embedix ) 580 if ( m_embedix )
577 { 581 {
578 if ( hs == CASE_PORTRAIT ) rot = Rot0; 582 if ( hs == CASE_PORTRAIT ) rot = Rot0;
579 else if ( hs == CASE_UNKNOWN ) rot = Rot270; 583 else if ( hs == CASE_UNKNOWN ) rot = Rot270;
580 else rot = Rot270; 584 else rot = Rot270;
581 } 585 }
582 else 586 else
583 { 587 {
584 if ( hs == CASE_PORTRAIT ) rot = Rot90; 588 if ( hs == CASE_PORTRAIT ) rot = Rot90;
585 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 589 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
586 else rot = Rot0; 590 else rot = Rot0;
587 } 591 }
588 } 592 }
589 break; 593 break;
590 case Model_Zaurus_SL6000: 594 case Model_Zaurus_SL6000:
591 case Model_Zaurus_SLB600: 595 case Model_Zaurus_SLB600:
592 case Model_Zaurus_SLA300: 596 case Model_Zaurus_SLA300:
593 case Model_Zaurus_SL5500: 597 case Model_Zaurus_SL5500:
594 case Model_Zaurus_SL5000: 598 case Model_Zaurus_SL5000:
595 default: 599 default:
596 rot = d->m_rotation; 600 rot = d->m_rotation;
597 break; 601 break;
598 } 602 }
599 603
600 return rot; 604 return rot;
601} 605}
602ODirection Zaurus::direction() const 606ODirection Zaurus::direction() const
603{ 607{
604 ODirection dir; 608 ODirection dir;
605 609
606 switch ( d->m_model ) { 610 switch ( d->m_model ) {
607 case Model_Zaurus_SLC3100: // fallthrough 611 case Model_Zaurus_SLC3100: // fallthrough
608 case Model_Zaurus_SLC3000: // fallthrough 612 case Model_Zaurus_SLC3000: // fallthrough
609 case Model_Zaurus_SLC1000: // fallthrough 613 case Model_Zaurus_SLC1000: // fallthrough
610 case Model_Zaurus_SLC7x0: { 614 case Model_Zaurus_SLC7x0: {
611 OHingeStatus hs = readHingeSensor(); 615 OHingeStatus hs = readHingeSensor();
612 if ( hs == CASE_PORTRAIT ) dir = CCW; 616 if ( hs == CASE_PORTRAIT ) dir = CCW;
613 else if ( hs == CASE_UNKNOWN ) dir = CCW; 617 else if ( hs == CASE_UNKNOWN ) dir = CCW;
614 else dir = CW; 618 else dir = CW;
615 } 619 }
616 break; 620 break;
617 case Model_Zaurus_SL6000: 621 case Model_Zaurus_SL6000:
618 case Model_Zaurus_SLA300: 622 case Model_Zaurus_SLA300:
619 case Model_Zaurus_SLB600: 623 case Model_Zaurus_SLB600:
620 case Model_Zaurus_SL5500: 624 case Model_Zaurus_SL5500:
621 case Model_Zaurus_SL5000: 625 case Model_Zaurus_SL5000:
622 default: dir = d->m_direction; 626 default: dir = d->m_direction;
623 break; 627 break;
624 } 628 }
625 return dir; 629 return dir;
626 630
627} 631}
628 632
629bool Zaurus::hasHingeSensor() const 633bool Zaurus::hasHingeSensor() const
630{ 634{
631 return d->m_model == Model_Zaurus_SLC7x0 || 635 return d->m_model == Model_Zaurus_SLC7x0 ||
632 d->m_model == Model_Zaurus_SLC3100 || 636 d->m_model == Model_Zaurus_SLC3100 ||
633 d->m_model == Model_Zaurus_SLC3000 || 637 d->m_model == Model_Zaurus_SLC3000 ||
634 d->m_model == Model_Zaurus_SLC1000; 638 d->m_model == Model_Zaurus_SLC1000;
635} 639}
636 640
637OHingeStatus Zaurus::readHingeSensor() const 641OHingeStatus Zaurus::readHingeSensor() const
638{ 642{
639 if (m_embedix) 643 if (m_embedix)
640 { 644 {
641 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 645 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
642 if (handle == -1) 646 if (handle == -1)
643 { 647 {
644 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 648 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
645 return CASE_UNKNOWN; 649 return CASE_UNKNOWN;
646 } 650 }
647 else 651 else
648 { 652 {
649 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 653 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
650 ::close (handle); 654 ::close (handle);
651 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 655 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
652 { 656 {
653 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 657 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
654 return static_cast<OHingeStatus>( retval ); 658 return static_cast<OHingeStatus>( retval );
655 } 659 }
656 else 660 else
657 { 661 {
658 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 662 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
659 return CASE_UNKNOWN; 663 return CASE_UNKNOWN;
660 } 664 }
661 } 665 }
662 } 666 }
663 else 667 else
664 { 668 {
665 // corgi keyboard is event source 0 in OZ kernel 2.6 669 /*
670 * The corgi keyboard is event source 0 in OZ kernel 2.6.
671 * Hinge status is reported via Input System Switchs 0 and 1 like that:
672 *
673 * -------------------------
674 * | SW0 | SW1 | CASE |
675 * |-----|-----|-----------|
676 * | 0 0 Landscape |
677 * | 0 1 Portrait |
678 * | 1 0 Unknown |
679 * | 1 1 Closed |
680 * -------------------------
681 */
666 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); 682 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" );
667 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; 683 bool switch0 = true;
668 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; 684 bool switch1 = false;
669 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; 685 if ( keyboard )
670 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 686 {
671 return CASE_UNKNOWN; 687 switch0 = keyboard->isHeld( OInputDevice::Switch0 );
688 switch1 = keyboard->isHeld( OInputDevice::Switch1 );
689 }
690 if ( switch0 )
691 {
692 return switch1 ? CASE_CLOSED : CASE_UNKNOWN;
693 }
694 else
695 {
696 return switch1 ? CASE_PORTRAIT : CASE_LANDSCAPE;
697 }
698 }
699}
700
701void Zaurus::initHingeSensor()
702{
703 if ( m_embedix ) return;
704
705 m_hinge.setName( "/dev/input/event0" );
706 if ( !m_hinge.open( IO_ReadOnly ) )
707 {
708 qDebug( "Zaurus::init() - Couldn't open /dev/input/event0 for read (%s)", strerror( errno ) );
709 return;
710 }
711
712 QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this );
713 QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) );
714}
715
716void Zaurus::hingeSensorTriggered()
717{
718 qDebug( "Zaurus::hingeSensorTriggered() - got event" );
719 struct input_event e;
720 if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 )
721 {
722 qDebug( "Zaurus::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value );
723 if ( e.type != EV_SW ) return;
724 if ( readHingeSensor() != CASE_UNKNOWN )
725 {
726 qDebug( "Zaurus::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" );
727 QCopChannel::send( "QPE/Rotation", "rotateDefault()" );
728 }
672 } 729 }
673} 730}
674 731
675/* 732/*
676 * Take code from iPAQ device. 733 * Take code from iPAQ device.
677 * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. 734 * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction.
678 * I hope that is ok - Alwin 735 * I hope that is ok - Alwin
679 */ 736 */
680bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 737bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
681{ 738{
682 int newkeycode = keycode; 739 int newkeycode = keycode;
683 740
684 if ( !hasHingeSensor() ) return false; 741 if ( !hasHingeSensor() ) return false;
685 742
686 /* map cursor keys depending on the hinge status */ 743 /* map cursor keys depending on the hinge status */
687 switch ( keycode ) { 744 switch ( keycode ) {
688 // Rotate cursor keys 745 // Rotate cursor keys
689 case Key_Left : 746 case Key_Left :
690 case Key_Right: 747 case Key_Right:
691 case Key_Up : 748 case Key_Up :
692 case Key_Down : 749 case Key_Down :
693 { 750 {
694 if (rotation()==Rot90) { 751 if (rotation()==Rot90) {
695 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 752 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
696 } 753 }
697 } 754 }
698 break; 755 break;
699 756
700 } 757 }
701 if (newkeycode!=keycode) { 758 if (newkeycode!=keycode) {
702 if ( newkeycode != Key_unknown ) { 759 if ( newkeycode != Key_unknown ) {
703 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 760 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
704 } 761 }
705 return true; 762 return true;
706 } 763 }
707 return false; 764 return false;
708} 765}
709 766
710bool Zaurus::suspend() { 767bool Zaurus::suspend() {
711 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 768 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
712 return false; 769 return false;
713 770
714 bool res = false; 771 bool res = false;
715 QCopChannel::send( "QPE/System", "aboutToSuspend()" ); 772 QCopChannel::send( "QPE/System", "aboutToSuspend()" );
716 773
717 struct timeval tvs, tvn; 774 struct timeval tvs, tvn;
718 ::gettimeofday ( &tvs, 0 ); 775 ::gettimeofday ( &tvs, 0 );
719 776
720 ::sync(); // flush fs caches 777 ::sync(); // flush fs caches
721 res = ( ::system ( "apm --suspend" ) == 0 ); 778 res = ( ::system ( "apm --suspend" ) == 0 );
722 779
723 // This is needed because some apm implementations are asynchronous and we 780 // This is needed because some apm implementations are asynchronous and we
724 // can not be sure when exactly the device is really suspended 781 // can not be sure when exactly the device is really suspended
725 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 782 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
726 // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here. 783 // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here.
727 784
728 if ( res && m_embedix) { 785 if ( res && m_embedix) {
729 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 786 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
730 ::usleep ( 200 * 1000 ); 787 ::usleep ( 200 * 1000 );
731 ::gettimeofday ( &tvn, 0 ); 788 ::gettimeofday ( &tvn, 0 );
732 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); 789 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut );
733 } 790 }
734 791
735 QCopChannel::send( "QPE/System", "returnFromSuspend()" ); 792 QCopChannel::send( "QPE/System", "returnFromSuspend()" );
736 793
737 return res; 794 return res;
738} 795}
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index 677e29f..bf30bc6 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -1,145 +1,151 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 =. Copyright (C) 2002-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 4 =. Copyright (C) 2002-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; version 2 of the License. 11 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 12     ._= =}       :
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_ZAURUS 30#ifndef ODEVICE_ZAURUS
31#define ODEVICE_ZAURUS 31#define ODEVICE_ZAURUS
32 32
33#include "odevice_abstractmobiledevice.h" 33#include "odevice_abstractmobiledevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qfile.h>
36#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
37 38
38#ifndef ARRAY_SIZE 39#ifndef ARRAY_SIZE
39#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 40#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
40#endif 41#endif
41 42
42// _IO and friends are only defined in kernel headers ... 43// _IO and friends are only defined in kernel headers ...
43#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 44#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
44#define OD_IO(type,number) OD_IOC(0,type,number,0) 45#define OD_IO(type,number) OD_IOC(0,type,number,0)
45#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 46#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
46#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 47#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
47#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 48#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
48 49
49// Audio 50// Audio
50#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 51#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
51 52
52#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 53#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
53#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 54#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
54 55
55#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 56#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
56#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 57#define SHARP_BUZ_KEYSOUND 2 /* key sound */
57#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 58#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
58 59
59#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 60#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
60#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 61#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
61#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 62#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
62#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 63#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
63#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 64#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
64 65
65// LED 66// LED
66#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 67#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
67#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 68#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
68#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 69#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
69 70
70#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 71#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
71#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 72#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
72#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 73#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
73 74
74// Rotation and Power Management 75// Rotation and Power Management
75#define SHARP_IOCTL_GET_ROTATION 0x413c 76#define SHARP_IOCTL_GET_ROTATION 0x413c
76 77
77#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 78#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
78#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 79#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
79#define APM_EVT_POWER_BUTTON (1 << 0) 80#define APM_EVT_POWER_BUTTON (1 << 0)
80 81
81// Brightness Embedix 82// Brightness Embedix
82#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" 83#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl"
83#define SHARP_FL_IOCTL_ON 1 84#define SHARP_FL_IOCTL_ON 1
84#define SHARP_FL_IOCTL_OFF 2 85#define SHARP_FL_IOCTL_OFF 2
85#define SHARP_FL_IOCTL_STEP_CONTRAST 100 86#define SHARP_FL_IOCTL_STEP_CONTRAST 100
86#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 87#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101
87#define SHARP_FL_IOCTL_GET_STEP 102 88#define SHARP_FL_IOCTL_GET_STEP 102
88 89
89// Vesa Standard 90// Vesa Standard
90#define FB_BLANK_UNBLANK 0 91#define FB_BLANK_UNBLANK 0
91#define FB_BLANK_POWERDOWN 4 92#define FB_BLANK_POWERDOWN 4
92 93
93namespace Opie { 94namespace Opie {
94namespace Core { 95namespace Core {
95namespace Internal { 96namespace Internal {
96 97
97class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter 98class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
98{ 99{
99 protected: 100 protected:
100 virtual void init(const QString&); 101 virtual void init(const QString&);
101 virtual void initButtons(); 102 virtual void initButtons();
103 void initHingeSensor();
104
105 protected slots:
106 void hingeSensorTriggered();
102 107
103 public: 108 public:
104 virtual bool setDisplayBrightness( int b ); 109 virtual bool setDisplayBrightness( int b );
105 virtual bool setDisplayStatus( bool on ); 110 virtual bool setDisplayStatus( bool on );
106 virtual int displayBrightnessResolution() const; 111 virtual int displayBrightnessResolution() const;
107 112
108 virtual void playAlarmSound(); 113 virtual void playAlarmSound();
109 virtual void playKeySound(); 114 virtual void playKeySound();
110 virtual void playTouchSound(); 115 virtual void playTouchSound();
111 116
112 virtual QValueList <OLed> ledList() const; 117 virtual QValueList <OLed> ledList() const;
113 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 118 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
114 virtual OLedState ledState( OLed led ) const; 119 virtual OLedState ledState( OLed led ) const;
115 virtual bool setLedState( OLed led, OLedState st ); 120 virtual bool setLedState( OLed led, OLedState st );
116 121
117 virtual bool hasHingeSensor() const; 122 virtual bool hasHingeSensor() const;
118 virtual OHingeStatus readHingeSensor() const; 123 virtual OHingeStatus readHingeSensor() const;
119 124
120 virtual Transformation rotation() const; 125 virtual Transformation rotation() const;
121 virtual ODirection direction() const; 126 virtual ODirection direction() const;
122 virtual bool suspend(); 127 virtual bool suspend();
123 128
124 protected: 129 protected:
125 virtual void buzzer( int snd ); 130 virtual void buzzer( int snd );
126 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 131 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
127 132
128 QString m_backlightdev; 133 QString m_backlightdev;
129 OLedState m_leds[1]; 134 OLedState m_leds[1];
130 bool m_embedix; 135 bool m_embedix;
136 QFile m_hinge;
131}; 137};
132 138
133struct z_button { 139struct z_button {
134 Qt::Key code; 140 Qt::Key code;
135 char *utext; 141 char *utext;
136 char *pix; 142 char *pix;
137 char *fpressedservice; 143 char *fpressedservice;
138 char *fpressedaction; 144 char *fpressedaction;
139 char *fheldservice; 145 char *fheldservice;
140 char *fheldaction; 146 char *fheldaction;
141}; 147};
142} 148}
143} 149}
144} 150}
145#endif 151#endif
diff --git a/libopie2/opiecore/linux/oinputsystem.cpp b/libopie2/opiecore/linux/oinputsystem.cpp
index bad27ed..ebc417f 100644
--- a/libopie2/opiecore/linux/oinputsystem.cpp
+++ b/libopie2/opiecore/linux/oinputsystem.cpp
@@ -95,128 +95,166 @@ int OInputSystem::count() const
95 95
96 96
97OInputDevice* OInputSystem::device( const QString& device ) const 97OInputDevice* OInputSystem::device( const QString& device ) const
98{ 98{
99 return _devices[device]; 99 return _devices[device];
100} 100}
101 101
102 102
103OInputSystem* OInputSystem::instance() 103OInputSystem* OInputSystem::instance()
104{ 104{
105 if ( !_instance ) _instance = new OInputSystem(); 105 if ( !_instance ) _instance = new OInputSystem();
106 return _instance; 106 return _instance;
107} 107}
108 108
109 109
110OInputSystem::DeviceIterator OInputSystem::iterator() const 110OInputSystem::DeviceIterator OInputSystem::iterator() const
111{ 111{
112 return OInputSystem::DeviceIterator( _devices ); 112 return OInputSystem::DeviceIterator( _devices );
113} 113}
114 114
115/*====================================================================================== 115/*======================================================================================
116 * OInputDevice 116 * OInputDevice
117 *======================================================================================*/ 117 *======================================================================================*/
118 118
119OInputDevice::OInputDevice( QObject* parent, const char* name ) : QObject( parent, name ) 119OInputDevice::OInputDevice( QObject* parent, const char* name ) : QObject( parent, name )
120{ 120{
121 qDebug( "OInputDevice::OInputDevice( '%s' )", name ); 121 qDebug( "OInputDevice::OInputDevice( '%s' )", name );
122 122
123 _fd = ::open( name, O_RDONLY ); 123 _fd = ::open( name, O_RDONLY );
124 if ( _fd == -1 ) 124 if ( _fd == -1 )
125 { 125 {
126 qDebug( "OInputDevice::OInputDevice() - Warning: couldn't open %s (%s)", name, strerror( errno ) ); 126 qDebug( "OInputDevice::OInputDevice() - Warning: couldn't open %s (%s)", name, strerror( errno ) );
127 } 127 }
128} 128}
129 129
130 130
131OInputDevice::~OInputDevice() 131OInputDevice::~OInputDevice()
132{ 132{
133 qDebug( "OInputDevice::~OInputDevice()" ); 133 qDebug( "OInputDevice::~OInputDevice()" );
134} 134}
135 135
136 136
137QString OInputDevice::identity() const 137QString OInputDevice::identity() const
138{ 138{
139 char buf[BUFSIZE] = "<unknown>"; 139 char buf[BUFSIZE] = "<unknown>";
140 ::ioctl( _fd, EVIOCGNAME(sizeof buf), buf ); 140 ::ioctl( _fd, EVIOCGNAME(sizeof buf), buf );
141 return buf; 141 return buf;
142} 142}
143 143
144 144
145QString OInputDevice::path() const 145QString OInputDevice::path() const
146{ 146{
147 char buf[BUFSIZE] = "<unknown>"; 147 char buf[BUFSIZE] = "<unknown>";
148 ::ioctl( _fd, EVIOCGPHYS(sizeof buf), buf ); 148 ::ioctl( _fd, EVIOCGPHYS(sizeof buf), buf );
149 return buf; 149 return buf;
150} 150}
151 151
152 152
153QString OInputDevice::uniq() const 153QString OInputDevice::uniq() const
154{ 154{
155 char buf[BUFSIZE] = "<unknown>"; 155 char buf[BUFSIZE] = "<unknown>";
156 ::ioctl( _fd, EVIOCGUNIQ(sizeof buf), buf ); 156 ::ioctl( _fd, EVIOCGUNIQ(sizeof buf), buf );
157 return buf; 157 return buf;
158} 158}
159 159
160 160
161bool OInputDevice::hasFeature( Feature bit ) const 161bool OInputDevice::hasFeature( Feature bit ) const
162{ 162{
163 BIT_MASK( features, EV_MAX ); 163 BIT_MASK( features, EV_MAX );
164 164
165 if( ioctl( _fd, EVIOCGBIT( 0, EV_MAX ), features) < 0 ) 165 if( ioctl( _fd, EVIOCGBIT( 0, EV_MAX ), features) < 0 )
166 { 166 {
167 perror( "EVIOCGBIT" ); 167 perror( "EVIOCGBIT" );
168 return false; 168 return false;
169 } 169 }
170 else 170 else
171 return BIT_TEST( features, bit ); 171 return BIT_TEST( features, bit );
172} 172}
173 173
174 174
175bool OInputDevice::isHeld( Key bit ) const 175bool OInputDevice::isHeld( Key bit ) const
176{ 176{
177 BIT_MASK( keys, KEY_MAX ); 177 BIT_MASK( keys, KEY_MAX );
178 178
179 if( ioctl( _fd, EVIOCGKEY( sizeof(keys) ), keys ) < 0 ) 179 if( ioctl( _fd, EVIOCGKEY( sizeof(keys) ), keys ) < 0 )
180 { 180 {
181 perror( "EVIOCGKEY" ); 181 perror( "EVIOCGKEY" );
182 return false; 182 return false;
183 } 183 }
184 else 184 else
185 { 185 {
186 return BIT_TEST( keys, bit ); 186 return BIT_TEST( keys, bit );
187 } 187 }
188} 188}
189 189
190 190
191bool OInputDevice::isHeld( Switch bit ) const
192{
193 BIT_MASK( switches, SW_MAX );
194
195 if( ioctl( _fd, EVIOCGSW( sizeof(switches) ), switches ) < 0 )
196 {
197 perror( "EVIOCGSW" );
198 return false;
199 }
200 else
201 {
202 return BIT_TEST( switches, bit );
203 }
204}
205
206
191QString OInputDevice::globalKeyMask() const 207QString OInputDevice::globalKeyMask() const
192{ 208{
193 BIT_MASK( keys, KEY_MAX ); 209 BIT_MASK( keys, KEY_MAX );
194 210
195 if( ioctl( _fd, EVIOCGKEY( sizeof(keys) ), keys ) < 0 ) 211 if( ioctl( _fd, EVIOCGKEY( sizeof(keys) ), keys ) < 0 )
196 { 212 {
197 perror( "EVIOCGKEY" ); 213 perror( "EVIOCGKEY" );
198 return QString::null; 214 return QString::null;
199 } 215 }
200 else 216 else
201 { 217 {
202 QString keymask; 218 QString keymask;
203 for ( int i = 0; i < KEY_MAX; ++i ) 219 for ( int i = 0; i < KEY_MAX; ++i )
204 { 220 {
205 if ( BIT_TEST( keys, i ) ) keymask.append( QString().sprintf( "%0d, ", i ) ); 221 if ( BIT_TEST( keys, i ) ) keymask.append( QString().sprintf( "%0d, ", i ) );
206 } 222 }
207 return keymask; 223 return keymask;
208 224
209 } 225 }
210} 226}
211 227
212 228
229QString OInputDevice::globalSwitchMask() const
230{
231 BIT_MASK( switches, SW_MAX );
232
233 if( ioctl( _fd, EVIOCGSW( sizeof(switches) ), switches ) < 0 )
234 {
235 perror( "EVIOCGSW" );
236 return QString::null;
237 }
238 else
239 {
240 QString switchmask;
241 for ( int i = 0; i < SW_MAX; ++i )
242 {
243 if ( BIT_TEST( switches, i ) ) switchmask.append( QString().sprintf( "%0d, ", i ) );
244 }
245 return switchmask;
246
247 }
248}
249
250
213bool OInputDevice::isValid( const QString& path ) 251bool OInputDevice::isValid( const QString& path )
214{ 252{
215 char buf[BUFSIZE] = "<unknown>"; 253 char buf[BUFSIZE] = "<unknown>";
216 int fd = ::open( (const char*) path, O_RDONLY ); 254 int fd = ::open( (const char*) path, O_RDONLY );
217 if ( fd < 0 ) return false; 255 if ( fd < 0 ) return false;
218 int res = ::ioctl( fd, EVIOCGNAME(sizeof buf), buf ); 256 int res = ::ioctl( fd, EVIOCGNAME(sizeof buf), buf );
219 ::close( fd ); 257 ::close( fd );
220 return res >= 0; 258 return res >= 0;
221} 259}
222 260
diff --git a/libopie2/opiecore/linux/oinputsystem.h b/libopie2/opiecore/linux/oinputsystem.h
index 9676e73..fb5f498 100644
--- a/libopie2/opiecore/linux/oinputsystem.h
+++ b/libopie2/opiecore/linux/oinputsystem.h
@@ -1,142 +1,151 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29#ifndef OINPUTSYSTEM_H 29#ifndef OINPUTSYSTEM_H
30#define OINPUTSYSTEM_H 30#define OINPUTSYSTEM_H
31 31
32#include "linux_input.h" 32#include "linux_input.h"
33 33
34/* QT */ 34/* QT */
35#include <qobject.h> 35#include <qobject.h>
36#include <qdict.h> 36#include <qdict.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40 40
41class OInputDevice; 41class OInputDevice;
42 42
43/** 43/**
44 * @brief A container class for the Linux input device subsystem 44 * @brief A container class for the Linux input device subsystem
45 * 45 *
46 * This class provides access to all available input system devices of your device. 46 * This class provides access to all available input system devices of your device.
47 * 47 *
48 * @author Michael 'Mickey' Lauer <mickey@Vanille.de> 48 * @author Michael 'Mickey' Lauer <mickey@Vanille.de>
49 */ 49 */
50class OInputSystem : public QObject 50class OInputSystem : public QObject
51{ 51{
52 public: 52 public:
53 typedef QDict<OInputDevice> DeviceMap; 53 typedef QDict<OInputDevice> DeviceMap;
54 typedef QDictIterator<OInputDevice> DeviceIterator; 54 typedef QDictIterator<OInputDevice> DeviceIterator;
55 55
56 /** 56 /**
57 * @returns the number of available input devices 57 * @returns the number of available input devices
58 */ 58 */
59 int count() const; 59 int count() const;
60 /** 60 /**
61 * @returns a pointer to the (one and only) @ref OInputSystem instance. 61 * @returns a pointer to the (one and only) @ref OInputSystem instance.
62 */ 62 */
63 static OInputSystem* instance(); 63 static OInputSystem* instance();
64 /** 64 /**
65 * @returns an iterator usable for iterating through all network interfaces. 65 * @returns an iterator usable for iterating through all network interfaces.
66 */ 66 */
67 DeviceIterator iterator() const; 67 DeviceIterator iterator() const;
68 /** 68 /**
69 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found 69 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found
70 * @see OAudioInterface 70 * @see OAudioInterface
71 */ 71 */
72 OInputDevice* device( const QString& interface ) const; 72 OInputDevice* device( const QString& interface ) const;
73 /** 73 /**
74 * @internal Rebuild the internal interface database 74 * @internal Rebuild the internal interface database
75 * @note Sometimes it might be useful to call this from client code, 75 * @note Sometimes it might be useful to call this from client code,
76 */ 76 */
77 void synchronize(); 77 void synchronize();
78 /** 78 /**
79 * @internal destructor 79 * @internal destructor
80 */ 80 */
81 ~OInputSystem(); 81 ~OInputSystem();
82 82
83 protected: 83 protected:
84 OInputSystem(); 84 OInputSystem();
85 85
86 static OInputSystem* _instance; 86 static OInputSystem* _instance;
87 DeviceMap _devices; 87 DeviceMap _devices;
88}; 88};
89 89
90 90
91class OInputDevice : public QObject 91class OInputDevice : public QObject
92{ 92{
93 public: 93 public:
94 OInputDevice( QObject* parent, const char* name = 0 ); 94 OInputDevice( QObject* parent, const char* name = 0 );
95 ~OInputDevice(); 95 ~OInputDevice();
96 96
97 #include "oinputsystemenums.h" 97 #include <opie2/oinputsystemenums.h>
98 98
99 public: 99 public:
100 /** 100 /**
101 * @returns the identity string of this input device 101 * @returns the identity string of this input device
102 */ 102 */
103 QString identity() const; 103 QString identity() const;
104 /** 104 /**
105 * @returns the path of this input device 105 * @returns the path of this input device
106 */ 106 */
107 QString path() const; 107 QString path() const;
108 /** 108 /**
109 * @returns a unique identifier for this input device 109 * @returns a unique identifier for this input device
110 * @note Only a few devices support this 110 * @note Only a few devices support this
111 */ 111 */
112 QString uniq() const; 112 QString uniq() const;
113 /** 113 /**
114 * @returns whether a certain @a Feature is being supported by this device 114 * @returns whether a certain @a Feature is being supported by this device
115 */ 115 */
116 bool hasFeature( Feature ) const; 116 bool hasFeature( Feature ) const;
117 /** 117 /**
118 * @returns whether a given @a Key or Button is being held at the moment 118 * @returns whether a given @a Key or Button is being held at the moment
119 */ 119 */
120 bool isHeld( Key ) const; 120 bool isHeld( Key ) const;
121 /** 121 /**
122 * @returns whether a given @a Switch is being held at the moment
123 */
124 bool isHeld( Switch ) const;
125 /**
122 * @internal 126 * @internal
123 * @returns a string containing a printable form of the global keymask 127 * @returns a string containing a printable form of the global keymask
124 */ 128 */
129 QString globalSwitchMask() const;
130 /**
131 * @internal
132 * @returns a string containing a printable form of the global switchmask
133 */
125 QString globalKeyMask() const; 134 QString globalKeyMask() const;
126 /** 135 /**
127 * @internal 136 * @internal
128 * @returns whether a certain @a path corresponds to an input device 137 * @returns whether a certain @a path corresponds to an input device
129 */ 138 */
130 static bool isValid( const QString& path ); 139 static bool isValid( const QString& path );
131 140
132 private: 141 private:
133 int _fd; 142 int _fd;
134 input_id _id; 143 input_id _id;
135 144
136}; 145};
137 146
138} 147}
139} 148}
140 149
141#endif // OINPUTSYSTEM_H 150#endif // OINPUTSYSTEM_H
142 151
diff --git a/libopie2/opiecore/linux/oinputsystemenums.h b/libopie2/opiecore/linux/oinputsystemenums.h
deleted file mode 100644
index 3461e5a..0000000
--- a/libopie2/opiecore/linux/oinputsystemenums.h
+++ b/dev/null
@@ -1,405 +0,0 @@
1
2 enum Feature
3 {
4 Synchronous = EV_SYN,
5 Keys = EV_KEY,
6 Relative = EV_REL,
7 Absolute = EV_ABS,
8 Miscellaneous = EV_MSC,
9 Leds = EV_LED,
10 Sound = EV_SND,
11 AutoRepeat = EV_REP,
12 ForceFeedback = EV_FF,
13 PowerManagement = EV_PWR,
14 ForceFeedbackStatus = EV_FF_STATUS,
15 };
16
17 enum Bus
18 {
19 PCI = BUS_PCI,
20 ISAPNP = BUS_ISAPNP,
21 HIL = BUS_HIL,
22 BLUETOOTH = BUS_BLUETOOTH,
23 ISA = BUS_ISA,
24 I8042 = BUS_I8042,
25 XTKBD = BUS_XTKBD,
26 RS232 = BUS_RS232,
27 GAMEPORT = BUS_GAMEPORT,
28 PARPORT = BUS_PARPORT,
29 AMIGA = BUS_AMIGA,
30 ADB = BUS_ADB,
31 I2C = BUS_I2C,
32 HOST = BUS_HOST,
33 };
34
35 enum Key
36 {
37 Key_RESERVED = 0,
38 Key_ESC = 1,
39 Key_1 = 2,
40 Key_2 = 3,
41 Key_3 = 4,
42 Key_4 = 5,
43 Key_5 = 6,
44 Key_6 = 7,
45 Key_7 = 8,
46 Key_8 = 9,
47 Key_9 = 10,
48 Key_0 = 11,
49 Key_MINUS = 12,
50 Key_EQUAL = 13,
51 Key_BACKSPACE = 14,
52 Key_TAB = 15,
53 Key_Q = 16,
54 Key_W = 17,
55 Key_E = 18,
56 Key_R = 19,
57 Key_T = 20,
58 Key_Y = 21,
59 Key_U = 22,
60 Key_I = 23,
61 Key_O = 24,
62 Key_P = 25,
63 Key_LEFTBRACE = 26,
64 Key_RIGHTBRACE = 27,
65 Key_ENTER = 28,
66 Key_LEFTCTRL = 29,
67 Key_A = 30,
68 Key_S = 31,
69 Key_D = 32,
70 Key_F = 33,
71 Key_G = 34,
72 Key_H = 35,
73 Key_J = 36,
74 Key_K = 37,
75 Key_L = 38,
76 Key_SEMICOLON = 39,
77 Key_APOSTROPHE = 40,
78 Key_GRAVE = 41,
79 Key_LEFTSHIFT = 42,
80 Key_BACKSLASH = 43,
81 Key_Z = 44,
82 Key_X = 45,
83 Key_C = 46,
84 Key_V = 47,
85 Key_B = 48,
86 Key_N = 49,
87 Key_M = 50,
88 Key_COMMA = 51,
89 Key_DOT = 52,
90 Key_SLASH = 53,
91 Key_RIGHTSHIFT = 54,
92 Key_KPASTERISK = 55,
93 Key_LEFTALT = 56,
94 Key_SPACE = 57,
95 Key_CAPSLOCK = 58,
96 Key_F1 = 59,
97 Key_F2 = 60,
98 Key_F3 = 61,
99 Key_F4 = 62,
100 Key_F5 = 63,
101 Key_F6 = 64,
102 Key_F7 = 65,
103 Key_F8 = 66,
104 Key_F9 = 67,
105 Key_F10 = 68,
106 Key_NUMLOCK = 69,
107 Key_SCROLLLOCK = 70,
108 Key_KP7 = 71,
109 Key_KP8 = 72,
110 Key_KP9 = 73,
111 Key_KPMINUS = 74,
112 Key_KP4 = 75,
113 Key_KP5 = 76,
114 Key_KP6 = 77,
115 Key_KPPLUS = 78,
116 Key_KP1 = 79,
117 Key_KP2 = 80,
118 Key_KP3 = 81,
119 Key_KP0 = 82,
120 Key_KPDOT = 83,
121
122 Key_ZENKAKUHANKAKU= 85,
123 Key_102ND = 86,
124 Key_F11 = 87,
125 Key_F12 = 88,
126 Key_RO = 89,
127 Key_KATAKANA = 90,
128 Key_HIRAGANA = 91,
129 Key_HENKAN = 92,
130 Key_KATAKANAHIRAGANA= 93,
131 Key_MUHENKAN = 94,
132 Key_KPJPCOMMA = 95,
133 Key_KPENTER = 96,
134 Key_RIGHTCTRL = 97,
135 Key_KPSLASH = 98,
136 Key_SYSRQ = 99,
137 Key_RIGHTALT = 100,
138 Key_LINEFEED = 101,
139 Key_HOME = 102,
140 Key_UP = 103,
141 Key_PAGEUP = 104,
142 Key_LEFT = 105,
143 Key_RIGHT = 106,
144 Key_END = 107,
145 Key_DOWN = 108,
146 Key_PAGEDOWN = 109,
147 Key_INSERT = 110,
148 Key_DELETE = 111,
149 Key_MACRO = 112,
150 Key_MUTE = 113,
151 Key_VOLUMEDOWN = 114,
152 Key_VOLUMEUP = 115,
153 Key_POWER = 116,
154 Key_KPEQUAL = 117,
155 Key_KPPLUSMINUS = 118,
156 Key_PAUSE = 119,
157
158 Key_KPCOMMA = 121,
159 Key_HANGUEL = 122,
160 Key_HANJA = 123,
161 Key_YEN = 124,
162 Key_LEFTMETA = 125,
163 Key_RIGHTMETA = 126,
164 Key_COMPOSE = 127,
165
166 Key_STOP = 128,
167 Key_AGAIN = 129,
168 Key_PROPS = 130,
169 Key_UNDO = 131,
170 Key_FRONT = 132,
171 Key_COPY = 133,
172 Key_OPEN = 134,
173 Key_PASTE = 135,
174 Key_FIND = 136,
175 Key_CUT = 137,
176 Key_HELP = 138,
177 Key_MENU = 139,
178 Key_CALC = 140,
179 Key_SETUP = 141,
180 Key_SLEEP = 142,
181 Key_WAKEUP = 143,
182 Key_FILE = 144,
183 Key_SENDFILE = 145,
184 Key_DELETEFILE = 146,
185 Key_XFER = 147,
186 Key_PROG1 = 148,
187 Key_PROG2 = 149,
188 Key_WWW = 150,
189 Key_MSDOS = 151,
190 Key_COFFEE = 152,
191 Key_DIRECTION = 153,
192 Key_CYCLEWINDOWS= 154,
193 Key_MAIL = 155,
194 Key_BOOKMARKS = 156,
195 Key_COMPUTER = 157,
196 Key_BACK = 158,
197 Key_FORWARD = 159,
198 Key_CLOSECD = 160,
199 Key_EJECTCD = 161,
200 Key_EJECTCLOSECD= 162,
201 Key_NEXTSONG = 163,
202 Key_PLAYPAUSE = 164,
203 Key_PREVIOUSSONG= 165,
204 Key_STOPCD = 166,
205 Key_RECORD = 167,
206 Key_REWIND = 168,
207 Key_PHONE = 169,
208 Key_ISO = 170,
209 Key_CONFIG = 171,
210 Key_HOMEPAGE = 172,
211 Key_REFRESH = 173,
212 Key_EXIT = 174,
213 Key_MOVE = 175,
214 Key_EDIT = 176,
215 Key_SCROLLUP = 177,
216 Key_SCROLLDOWN = 178,
217 Key_KPLEFTPAREN = 179,
218 Key_KPRIGHTPAREN= 180,
219
220 Key_F13 = 183,
221 Key_F14 = 184,
222 Key_F15 = 185,
223 Key_F16 = 186,
224 Key_F17 = 187,
225 Key_F18 = 188,
226 Key_F19 = 189,
227 Key_F20 = 190,
228 Key_F21 = 191,
229 Key_F22 = 192,
230 Key_F23 = 193,
231 Key_F24 = 194,
232
233 Key_PLAYCD = 200,
234 Key_PAUSECD = 201,
235 Key_PROG3 = 202,
236 Key_PROG4 = 203,
237 Key_SUSPEND = 205,
238 Key_CLOSE = 206,
239 Key_PLAY = 207,
240 Key_FASTFORWARD = 208,
241 Key_BASSBOOST = 209,
242 Key_PRINT = 210,
243 Key_HP = 211,
244 Key_CAMERA = 212,
245 Key_SOUND = 213,
246 Key_QUESTION = 214,
247 Key_EMAIL = 215,
248 Key_CHAT = 216,
249 Key_SEARCH = 217,
250 Key_CONNECT = 218,
251 Key_FINANCE = 219,
252 Key_SPORT = 220,
253 Key_SHOP = 221,
254 Key_ALTERASE = 222,
255 Key_CANCEL = 223,
256 Key_BRIGHTNESSDOWN= 224,
257 Key_BRIGHTNESSUP= 225,
258 Key_MEDIA = 226,
259
260 Key_UNKNOWN = 240,
261
262 Button_MISC = 0x100,
263 Button_0 = 0x100,
264 Button_1 = 0x101,
265 Button_2 = 0x102,
266 Button_3 = 0x103,
267 Button_4 = 0x104,
268 Button_5 = 0x105,
269 Button_6 = 0x106,
270 Button_7 = 0x107,
271 Button_8 = 0x108,
272 Button_9 = 0x109,
273
274 Button_MOUSE = 0x110,
275 Button_LEFT = 0x110,
276 Button_RIGHT = 0x111,
277 Button_MIDDLE = 0x112,
278 Button_SIDE = 0x113,
279 Button_EXTRA = 0x114,
280 Button_FORWARD = 0x115,
281 Button_BACK = 0x116,
282 Button_TASK = 0x117,
283
284 Button_JOYSTICK = 0x120,
285 Button_TRIGGER = 0x120,
286 Button_THUMB = 0x121,
287 Button_THUMB2 = 0x122,
288 Button_TOP = 0x123,
289 Button_TOP2 = 0x124,
290 Button_PINKIE = 0x125,
291 Button_BASE = 0x126,
292 Button_BASE2 = 0x127,
293 Button_BASE3 = 0x128,
294 Button_BASE4 = 0x129,
295 Button_BASE5 = 0x12a,
296 Button_BASE6 = 0x12b,
297 Button_DEAD = 0x12f,
298
299 Button_GAMEPAD = 0x130,
300 Button_A = 0x130,
301 Button_B = 0x131,
302 Button_C = 0x132,
303 Button_X = 0x133,
304 Button_Y = 0x134,
305 Button_Z = 0x135,
306 Button_TL = 0x136,
307 Button_TR = 0x137,
308 Button_TL2 = 0x138,
309 Button_TR2 = 0x139,
310 Button_SELECT = 0x13a,
311 Button_START = 0x13b,
312 Button_MODE = 0x13c,
313 Button_THUMBL = 0x13d,
314 Button_THUMBR = 0x13e,
315
316 Button_DIGI = 0x140,
317 Button_TOOL_PEN = 0x140,
318 Button_TOOL_RUBBER = 0x141,
319 Button_TOOL_BRUSH = 0x142,
320 Button_TOOL_PENCIL = 0x143,
321 Button_TOOL_AIRBRUSH= 0x144,
322 Button_TOOL_FINGER = 0x145,
323 Button_TOOL_MOUSE = 0x146,
324 Button_TOOL_LENS = 0x147,
325 Button_TOUCH = 0x14a,
326 Button_STYLUS = 0x14b,
327 Button_STYLUS2 = 0x14c,
328 Button_TOOL_DOUBLETAP= 0x14d,
329 Button_TOOL_TRIPLETAP= 0x14e,
330
331 Button_WHEEL = 0x150,
332 Button_GEAR_DOWN = 0x150,
333 Button_GEAR_UP = 0x151,
334
335 Key_OK = 0x160,
336 Key_SELECT = 0x161,
337 Key_GOTO = 0x162,
338 Key_CLEAR = 0x163,
339 Key_POWER2 = 0x164,
340 Key_OPTION = 0x165,
341 Key_INFO = 0x166,
342 Key_TIME = 0x167,
343 Key_VENDOR = 0x168,
344 Key_ARCHIVE = 0x169,
345 Key_PROGRAM = 0x16a,
346 Key_CHANNEL = 0x16b,
347 Key_FAVORITES = 0x16c,
348 Key_EPG = 0x16d,
349 Key_PVR = 0x16e,
350 Key_MHP = 0x16f,
351 Key_LANGUAGE = 0x170,
352 Key_TITLE = 0x171,
353 Key_SUBTITLE = 0x172,
354 Key_ANGLE = 0x173,
355 Key_ZOOM = 0x174,
356 Key_MODE = 0x175,
357 Key_KEYBOARD = 0x176,
358 Key_SCREEN = 0x177,
359 Key_PC = 0x178,
360 Key_TV = 0x179,
361 Key_TV2 = 0x17a,
362 Key_VCR = 0x17b,
363 Key_VCR2 = 0x17c,
364 Key_SAT = 0x17d,
365 Key_SAT2 = 0x17e,
366 Key_CD = 0x17f,
367 Key_TAPE = 0x180,
368 Key_RADIO = 0x181,
369 Key_TUNER = 0x182,
370 Key_PLAYER = 0x183,
371 Key_TEXT = 0x184,
372 Key_DVD = 0x185,
373 Key_AUX = 0x186,
374 Key_MP3 = 0x187,
375 Key_AUDIO = 0x188,
376 Key_VIDEO = 0x189,
377 Key_DIRECTORY = 0x18a,
378 Key_LIST = 0x18b,
379 Key_MEMO = 0x18c,
380 Key_CALENDAR = 0x18d,
381 Key_RED = 0x18e,
382 Key_GREEN = 0x18f,
383 Key_YELLOW = 0x190,
384 Key_BLUE = 0x191,
385 Key_CHANNELUP = 0x192,
386 Key_CHANNELDOWN = 0x193,
387 Key_FIRST = 0x194,
388 Key_LAST = 0x195,
389 Key_AB = 0x196,
390 Key_NEXT = 0x197,
391 Key_RESTART = 0x198,
392 Key_SLOW = 0x199,
393 Key_SHUFFLE = 0x19a,
394 Key_BREAK = 0x19b,
395 Key_PREVIOUS = 0x19c,
396 Key_DIGITS = 0x19d,
397 Key_TEEN = 0x19e,
398 Key_TWEN = 0x19f,
399
400 Key_DEL_EOL = 0x1c0,
401 Key_DEL_EOS = 0x1c1,
402 Key_INS_LINE = 0x1c2,
403 Key_DEL_LINE = 0x1c3,
404 };
405
diff --git a/libopie2/opiecore/linux_input.h b/libopie2/opiecore/linux_input.h
index b7a30bb..2df8a59 100644
--- a/libopie2/opiecore/linux_input.h
+++ b/libopie2/opiecore/linux_input.h
@@ -1,184 +1,186 @@
1#ifndef _INPUT_H 1#ifndef _INPUT_H
2#define _INPUT_H 2#define _INPUT_H
3 3
4/* 4/*
5 * Copyright (c) 1999-2002 Vojtech Pavlik 5 * Copyright (c) 1999-2002 Vojtech Pavlik
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by 8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation. 9 * the Free Software Foundation.
10 */ 10 */
11 11
12#ifdef __KERNEL__ 12#ifdef __KERNEL__
13#include <linux/time.h> 13#include <linux/time.h>
14#include <linux/list.h> 14#include <linux/list.h>
15#else 15#else
16#include <sys/time.h> 16#include <sys/time.h>
17#include <sys/ioctl.h> 17#include <sys/ioctl.h>
18#include <asm/types.h> 18#include <asm/types.h>
19#endif 19#endif
20 20
21/* 21/*
22 * The event structure itself 22 * The event structure itself
23 */ 23 */
24 24
25struct input_event { 25struct input_event {
26 struct timeval time; 26 struct timeval time;
27 __u16 type; 27 __u16 type;
28 __u16 code; 28 __u16 code;
29 __s32 value; 29 __s32 value;
30}; 30};
31 31
32/* 32/*
33 * Protocol version. 33 * Protocol version.
34 */ 34 */
35 35
36 #define EV_VERSION 0x010000 36 #define EV_VERSION 0x010000
37 37
38/* 38/*
39 * IOCTLs (0x00 - 0x7f) 39 * IOCTLs (0x00 - 0x7f)
40 */ 40 */
41 41
42struct input_id { 42struct input_id {
43 __u16 bustype; 43 __u16 bustype;
44 __u16 vendor; 44 __u16 vendor;
45 __u16 product; 45 __u16 product;
46 __u16 version; 46 __u16 version;
47}; 47};
48 48
49struct input_absinfo { 49struct input_absinfo {
50 __s32 value; 50 __s32 value;
51 __s32 minimum; 51 __s32 minimum;
52 __s32 maximum; 52 __s32 maximum;
53 __s32 fuzz; 53 __s32 fuzz;
54 __s32 flat; 54 __s32 flat;
55}; 55};
56 56
57 #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ 57 #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */
58 #define EVIOCGID _IOR('E', 0x02, struct input_id)/* get device ID */ 58 #define EVIOCGID _IOR('E', 0x02, struct input_id)/* get device ID */
59 #define EVIOCGKEYCODE _IOR('E', 0x04, int[2]) /* get keycode */ 59 #define EVIOCGKEYCODE _IOR('E', 0x04, int[2]) /* get keycode */
60 #define EVIOCSKEYCODE _IOW('E', 0x04, int[2]) /* set keycode */ 60 #define EVIOCSKEYCODE _IOW('E', 0x04, int[2]) /* set keycode */
61 61
62 #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ 62 #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */
63 #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ 63 #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */
64 #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */ 64 #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */
65 65
66 #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */ 66 #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */
67 #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ 67 #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */
68 #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ 68 #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */
69 #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */
69 70
70 #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len)/* get event bits */ 71 #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len)/* get event bits */
71 #define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */ 72 #define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */
72 #define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */ 73 #define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */
73 74
74 #define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect))/* send a force effect to a force feedback device */ 75 #define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect))/* send a force effect to a force feedback device */
75 #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ 76 #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */
76 #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ 77 #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */
77 78
78 #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ 79 #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */
79 80
80/* 81/*
81 * Event types 82 * Event types
82 */ 83 */
83 84
84 #define EV_SYN 0x00 85 #define EV_SYN 0x00
85 #define EV_KEY 0x01 86 #define EV_KEY 0x01
86 #define EV_REL 0x02 87 #define EV_REL 0x02
87 #define EV_ABS 0x03 88 #define EV_ABS 0x03
88 #define EV_MSC 0x04 89 #define EV_MSC 0x04
90 #define EV_SW 0x05
89 #define EV_LED 0x11 91 #define EV_LED 0x11
90 #define EV_SND 0x12 92 #define EV_SND 0x12
91 #define EV_REP 0x14 93 #define EV_REP 0x14
92 #define EV_FF 0x15 94 #define EV_FF 0x15
93 #define EV_PWR 0x16 95 #define EV_PWR 0x16
94 #define EV_FF_STATUS 0x17 96 #define EV_FF_STATUS 0x17
95 #define EV_MAX 0x1f 97 #define EV_MAX 0x1f
96 98
97/* 99/*
98 * Synchronization events. 100 * Synchronization events.
99 */ 101 */
100 102
101 #define SYN_REPORT 0 103 #define SYN_REPORT 0
102 #define SYN_CONFIG 1 104 #define SYN_CONFIG 1
103 105
104/* 106/*
105 * Keys and buttons 107 * Keys and buttons
106 */ 108 */
107 109
108 #define KEY_RESERVED 0 110 #define KEY_RESERVED 0
109 #define KEY_ESC 1 111 #define KEY_ESC 1
110 #define KEY_1 2 112 #define KEY_1 2
111 #define KEY_2 3 113 #define KEY_2 3
112 #define KEY_3 4 114 #define KEY_3 4
113 #define KEY_4 5 115 #define KEY_4 5
114 #define KEY_5 6 116 #define KEY_5 6
115 #define KEY_6 7 117 #define KEY_6 7
116 #define KEY_7 8 118 #define KEY_7 8
117 #define KEY_8 9 119 #define KEY_8 9
118 #define KEY_9 10 120 #define KEY_9 10
119 #define KEY_0 11 121 #define KEY_0 11
120 #define KEY_MINUS 12 122 #define KEY_MINUS 12
121 #define KEY_EQUAL 13 123 #define KEY_EQUAL 13
122 #define KEY_BACKSPACE 14 124 #define KEY_BACKSPACE 14
123 #define KEY_TAB 15 125 #define KEY_TAB 15
124 #define KEY_Q 16 126 #define KEY_Q 16
125 #define KEY_W 17 127 #define KEY_W 17
126 #define KEY_E 18 128 #define KEY_E 18
127 #define KEY_R 19 129 #define KEY_R 19
128 #define KEY_T 20 130 #define KEY_T 20
129 #define KEY_Y 21 131 #define KEY_Y 21
130 #define KEY_U 22 132 #define KEY_U 22
131 #define KEY_I 23 133 #define KEY_I 23
132 #define KEY_O 24 134 #define KEY_O 24
133 #define KEY_P 25 135 #define KEY_P 25
134 #define KEY_LEFTBRACE 26 136 #define KEY_LEFTBRACE 26
135 #define KEY_RIGHTBRACE 27 137 #define KEY_RIGHTBRACE 27
136 #define KEY_ENTER 28 138 #define KEY_ENTER 28
137 #define KEY_LEFTCTRL 29 139 #define KEY_LEFTCTRL 29
138 #define KEY_A 30 140 #define KEY_A 30
139 #define KEY_S 31 141 #define KEY_S 31
140 #define KEY_D 32 142 #define KEY_D 32
141 #define KEY_F 33 143 #define KEY_F 33
142 #define KEY_G 34 144 #define KEY_G 34
143 #define KEY_H 35 145 #define KEY_H 35
144 #define KEY_J 36 146 #define KEY_J 36
145 #define KEY_K 37 147 #define KEY_K 37
146 #define KEY_L 38 148 #define KEY_L 38
147 #define KEY_SEMICOLON 39 149 #define KEY_SEMICOLON 39
148 #define KEY_APOSTROPHE 40 150 #define KEY_APOSTROPHE 40
149 #define KEY_GRAVE 41 151 #define KEY_GRAVE 41
150 #define KEY_LEFTSHIFT 42 152 #define KEY_LEFTSHIFT 42
151 #define KEY_BACKSLASH 43 153 #define KEY_BACKSLASH 43
152 #define KEY_Z 44 154 #define KEY_Z 44
153 #define KEY_X 45 155 #define KEY_X 45
154 #define KEY_C 46 156 #define KEY_C 46
155 #define KEY_V 47 157 #define KEY_V 47
156 #define KEY_B 48 158 #define KEY_B 48
157 #define KEY_N 49 159 #define KEY_N 49
158 #define KEY_M 50 160 #define KEY_M 50
159 #define KEY_COMMA 51 161 #define KEY_COMMA 51
160 #define KEY_DOT 52 162 #define KEY_DOT 52
161 #define KEY_SLASH 53 163 #define KEY_SLASH 53
162 #define KEY_RIGHTSHIFT 54 164 #define KEY_RIGHTSHIFT 54
163 #define KEY_KPASTERISK 55 165 #define KEY_KPASTERISK 55
164 #define KEY_LEFTALT 56 166 #define KEY_LEFTALT 56
165 #define KEY_SPACE 57 167 #define KEY_SPACE 57
166 #define KEY_CAPSLOCK 58 168 #define KEY_CAPSLOCK 58
167 #define KEY_F1 59 169 #define KEY_F1 59
168 #define KEY_F2 60 170 #define KEY_F2 60
169 #define KEY_F3 61 171 #define KEY_F3 61
170 #define KEY_F4 62 172 #define KEY_F4 62
171 #define KEY_F5 63 173 #define KEY_F5 63
172 #define KEY_F6 64 174 #define KEY_F6 64
173 #define KEY_F7 65 175 #define KEY_F7 65
174 #define KEY_F8 66 176 #define KEY_F8 66
175 #define KEY_F9 67 177 #define KEY_F9 67
176 #define KEY_F10 68 178 #define KEY_F10 68
177 #define KEY_NUMLOCK 69 179 #define KEY_NUMLOCK 69
178 #define KEY_SCROLLLOCK 70 180 #define KEY_SCROLLLOCK 70
179 #define KEY_KP7 71 181 #define KEY_KP7 71
180 #define KEY_KP8 72 182 #define KEY_KP8 72
181 #define KEY_KP9 73 183 #define KEY_KP9 73
182 #define KEY_KPMINUS 74 184 #define KEY_KPMINUS 74
183 #define KEY_KP4 75 185 #define KEY_KP4 75
184 #define KEY_KP5 76 186 #define KEY_KP5 76
@@ -428,192 +430,206 @@ struct input_absinfo {
428 #define KEY_KEYBOARD 0x176 430 #define KEY_KEYBOARD 0x176
429 #define KEY_SCREEN 0x177 431 #define KEY_SCREEN 0x177
430 #define KEY_PC 0x178 432 #define KEY_PC 0x178
431 #define KEY_TV 0x179 433 #define KEY_TV 0x179
432 #define KEY_TV2 0x17a 434 #define KEY_TV2 0x17a
433 #define KEY_VCR 0x17b 435 #define KEY_VCR 0x17b
434 #define KEY_VCR2 0x17c 436 #define KEY_VCR2 0x17c
435 #define KEY_SAT 0x17d 437 #define KEY_SAT 0x17d
436 #define KEY_SAT2 0x17e 438 #define KEY_SAT2 0x17e
437 #define KEY_CD 0x17f 439 #define KEY_CD 0x17f
438 #define KEY_TAPE 0x180 440 #define KEY_TAPE 0x180
439 #define KEY_RADIO 0x181 441 #define KEY_RADIO 0x181
440 #define KEY_TUNER 0x182 442 #define KEY_TUNER 0x182
441 #define KEY_PLAYER 0x183 443 #define KEY_PLAYER 0x183
442 #define KEY_TEXT 0x184 444 #define KEY_TEXT 0x184
443 #define KEY_DVD 0x185 445 #define KEY_DVD 0x185
444 #define KEY_AUX 0x186 446 #define KEY_AUX 0x186
445 #define KEY_MP3 0x187 447 #define KEY_MP3 0x187
446 #define KEY_AUDIO 0x188 448 #define KEY_AUDIO 0x188
447 #define KEY_VIDEO 0x189 449 #define KEY_VIDEO 0x189
448 #define KEY_DIRECTORY 0x18a 450 #define KEY_DIRECTORY 0x18a
449 #define KEY_LIST 0x18b 451 #define KEY_LIST 0x18b
450 #define KEY_MEMO 0x18c 452 #define KEY_MEMO 0x18c
451 #define KEY_CALENDAR 0x18d 453 #define KEY_CALENDAR 0x18d
452 #define KEY_RED 0x18e 454 #define KEY_RED 0x18e
453 #define KEY_GREEN 0x18f 455 #define KEY_GREEN 0x18f
454 #define KEY_YELLOW 0x190 456 #define KEY_YELLOW 0x190
455 #define KEY_BLUE 0x191 457 #define KEY_BLUE 0x191
456 #define KEY_CHANNELUP 0x192 458 #define KEY_CHANNELUP 0x192
457 #define KEY_CHANNELDOWN 0x193 459 #define KEY_CHANNELDOWN 0x193
458 #define KEY_FIRST 0x194 460 #define KEY_FIRST 0x194
459 #define KEY_LAST 0x195 461 #define KEY_LAST 0x195
460 #define KEY_AB 0x196 462 #define KEY_AB 0x196
461 #define KEY_NEXT 0x197 463 #define KEY_NEXT 0x197
462 #define KEY_RESTART 0x198 464 #define KEY_RESTART 0x198
463 #define KEY_SLOW 0x199 465 #define KEY_SLOW 0x199
464 #define KEY_SHUFFLE 0x19a 466 #define KEY_SHUFFLE 0x19a
465 #define KEY_BREAK 0x19b 467 #define KEY_BREAK 0x19b
466 #define KEY_PREVIOUS 0x19c 468 #define KEY_PREVIOUS 0x19c
467 #define KEY_DIGITS 0x19d 469 #define KEY_DIGITS 0x19d
468 #define KEY_TEEN 0x19e 470 #define KEY_TEEN 0x19e
469 #define KEY_TWEN 0x19f 471 #define KEY_TWEN 0x19f
470 472
471 #define KEY_DEL_EOL 0x1c0 473 #define KEY_DEL_EOL 0x1c0
472 #define KEY_DEL_EOS 0x1c1 474 #define KEY_DEL_EOS 0x1c1
473 #define KEY_INS_LINE 0x1c2 475 #define KEY_INS_LINE 0x1c2
474 #define KEY_DEL_LINE 0x1c3 476 #define KEY_DEL_LINE 0x1c3
475 477
476 #define KEY_MAX 0x1ff 478 #define KEY_MAX 0x1ff
477 479
478/* 480/*
479 * Relative axes 481 * Relative axes
480 */ 482 */
481 483
482 #define REL_X 0x00 484 #define REL_X 0x00
483 #define REL_Y 0x01 485 #define REL_Y 0x01
484 #define REL_Z 0x02 486 #define REL_Z 0x02
485 #define REL_HWHEEL 0x06 487 #define REL_HWHEEL 0x06
486 #define REL_DIAL 0x07 488 #define REL_DIAL 0x07
487 #define REL_WHEEL 0x08 489 #define REL_WHEEL 0x08
488 #define REL_MISC 0x09 490 #define REL_MISC 0x09
489 #define REL_MAX 0x0f 491 #define REL_MAX 0x0f
490 492
491/* 493/*
492 * Absolute axes 494 * Absolute axes
493 */ 495 */
494 496
495 #define ABS_X 0x00 497 #define ABS_X 0x00
496 #define ABS_Y 0x01 498 #define ABS_Y 0x01
497 #define ABS_Z 0x02 499 #define ABS_Z 0x02
498 #define ABS_RX 0x03 500 #define ABS_RX 0x03
499 #define ABS_RY 0x04 501 #define ABS_RY 0x04
500 #define ABS_RZ 0x05 502 #define ABS_RZ 0x05
501 #define ABS_THROTTLE 0x06 503 #define ABS_THROTTLE 0x06
502 #define ABS_RUDDER 0x07 504 #define ABS_RUDDER 0x07
503 #define ABS_WHEEL 0x08 505 #define ABS_WHEEL 0x08
504 #define ABS_GAS 0x09 506 #define ABS_GAS 0x09
505 #define ABS_BRAKE 0x0a 507 #define ABS_BRAKE 0x0a
506 #define ABS_HAT0X 0x10 508 #define ABS_HAT0X 0x10
507 #define ABS_HAT0Y 0x11 509 #define ABS_HAT0Y 0x11
508 #define ABS_HAT1X 0x12 510 #define ABS_HAT1X 0x12
509 #define ABS_HAT1Y 0x13 511 #define ABS_HAT1Y 0x13
510 #define ABS_HAT2X 0x14 512 #define ABS_HAT2X 0x14
511 #define ABS_HAT2Y 0x15 513 #define ABS_HAT2Y 0x15
512 #define ABS_HAT3X 0x16 514 #define ABS_HAT3X 0x16
513 #define ABS_HAT3Y 0x17 515 #define ABS_HAT3Y 0x17
514 #define ABS_PRESSURE 0x18 516 #define ABS_PRESSURE 0x18
515 #define ABS_DISTANCE 0x19 517 #define ABS_DISTANCE 0x19
516 #define ABS_TILT_X 0x1a 518 #define ABS_TILT_X 0x1a
517 #define ABS_TILT_Y 0x1b 519 #define ABS_TILT_Y 0x1b
518 #define ABS_TOOL_WIDTH 0x1c 520 #define ABS_TOOL_WIDTH 0x1c
519 #define ABS_VOLUME 0x20 521 #define ABS_VOLUME 0x20
520 #define ABS_MISC 0x28 522 #define ABS_MISC 0x28
521 #define ABS_MAX 0x3f 523 #define ABS_MAX 0x3f
522 524
523/* 525/*
526 * Switch events
527 */
528
529 #define SW_0 0x00
530 #define SW_1 0x01
531 #define SW_2 0x02
532 #define SW_3 0x03
533 #define SW_4 0x04
534 #define SW_5 0x05
535 #define SW_6 0x06
536 #define SW_7 0x07
537 #define SW_MAX 0x0f
538
539/*
524 * Misc events 540 * Misc events
525 */ 541 */
526 542
527 #define MSC_SERIAL 0x00 543 #define MSC_SERIAL 0x00
528 #define MSC_PULSELED 0x01 544 #define MSC_PULSELED 0x01
529 #define MSC_GESTURE 0x02 545 #define MSC_GESTURE 0x02
530 #define MSC_MAX 0x07 546 #define MSC_MAX 0x07
531 547
532/* 548/*
533 * LEDs 549 * LEDs
534 */ 550 */
535 551
536 #define LED_NUML 0x00 552 #define LED_NUML 0x00
537 #define LED_CAPSL 0x01 553 #define LED_CAPSL 0x01
538 #define LED_SCROLLL 0x02 554 #define LED_SCROLLL 0x02
539 #define LED_COMPOSE 0x03 555 #define LED_COMPOSE 0x03
540 #define LED_KANA 0x04 556 #define LED_KANA 0x04
541 #define LED_SLEEP 0x05 557 #define LED_SLEEP 0x05
542 #define LED_SUSPEND 0x06 558 #define LED_SUSPEND 0x06
543 #define LED_MUTE 0x07 559 #define LED_MUTE 0x07
544 #define LED_MISC 0x08 560 #define LED_MISC 0x08
545 #define LED_MAX 0x0f 561 #define LED_MAX 0x0f
546 562
547/* 563/*
548 * Autorepeat values 564 * Autorepeat values
549 */ 565 */
550 566
551 #define REP_DELAY 0x00 567 #define REP_DELAY 0x00
552 #define REP_PERIOD 0x01 568 #define REP_PERIOD 0x01
553 #define REP_MAX 0x01 569 #define REP_MAX 0x01
554 570
555/* 571/*
556 * Sounds 572 * Sounds
557 */ 573 */
558 574
559 #define SND_CLICK 0x00 575 #define SND_CLICK 0x00
560 #define SND_BELL 0x01 576 #define SND_BELL 0x01
561 #define SND_TONE 0x02 577 #define SND_TONE 0x02
562 #define SND_MAX 0x07 578 #define SND_MAX 0x07
563 579
564/* 580/*
565 * IDs. 581 * IDs.
566 */ 582 */
567 583
568 #define ID_BUS 0 584 #define ID_BUS 0
569 #define ID_VENDOR 1 585 #define ID_VENDOR 1
570 #define ID_PRODUCT 2 586 #define ID_PRODUCT 2
571 #define ID_VERSION 3 587 #define ID_VERSION 3
572 588
573 #define BUS_PCI 0x01 589 #define BUS_PCI 0x01
574 #define BUS_ISAPNP 0x02 590 #define BUS_ISAPNP 0x02
575 #define BUS_USB 0x03 591 #define BUS_USB 0x03
576 #define BUS_HIL 0x04 592 #define BUS_HIL 0x04
577 #define BUS_BLUETOOTH 0x05 593 #define BUS_BLUETOOTH 0x05
578 594
579 #define BUS_ISA 0x10 595 #define BUS_ISA 0x10
580 #define BUS_I8042 0x11 596 #define BUS_I8042 0x11
581 #define BUS_XTKBD 0x12 597 #define BUS_XTKBD 0x12
582 #define BUS_RS232 0x13 598 #define BUS_RS232 0x13
583 #define BUS_GAMEPORT 0x14 599 #define BUS_GAMEPORT 0x14
584 #define BUS_PARPORT 0x15 600 #define BUS_PARPORT 0x15
585 #define BUS_AMIGA 0x16 601 #define BUS_AMIGA 0x16
586 #define BUS_ADB 0x17 602 #define BUS_ADB 0x17
587 #define BUS_I2C 0x18 603 #define BUS_I2C 0x18
588 #define BUS_HOST 0x19 604 #define BUS_HOST 0x19
589 605
590/* 606/*
591 * Values describing the status of an effect 607 * Values describing the status of an effect
592 */ 608 */
593 #define FF_STATUS_STOPPED0x00 609 #define FF_STATUS_STOPPED0x00
594 #define FF_STATUS_PLAYING0x01 610 #define FF_STATUS_PLAYING0x01
595 #define FF_STATUS_MAX 0x01 611 #define FF_STATUS_MAX 0x01
596 612
597/* 613/*
598 * Structures used in ioctls to upload effects to a device 614 * Structures used in ioctls to upload effects to a device
599 * The first structures are not passed directly by using ioctls. 615 * The first structures are not passed directly by using ioctls.
600 * They are sub-structures of the actually sent structure (called ff_effect) 616 * They are sub-structures of the actually sent structure (called ff_effect)
601 */ 617 */
602 618
603struct ff_replay { 619struct ff_replay {
604 __u16 length; /* Duration of an effect in ms. All other times are also expressed in ms */ 620 __u16 length; /* Duration of an effect in ms. All other times are also expressed in ms */
605 __u16 delay; /* Time to wait before to start playing an effect */ 621 __u16 delay; /* Time to wait before to start playing an effect */
606}; 622};
607 623
608struct ff_trigger { 624struct ff_trigger {
609 __u16 button; /* Number of button triggering an effect */ 625 __u16 button; /* Number of button triggering an effect */
610 __u16 interval; /* Time to wait before an effect can be re-triggered (ms) */ 626 __u16 interval; /* Time to wait before an effect can be re-triggered (ms) */
611}; 627};
612 628
613struct ff_envelope { 629struct ff_envelope {
614 __u16 attack_length;/* Duration of attack (ms) */ 630 __u16 attack_length;/* Duration of attack (ms) */
615 __u16 attack_level;/* Level at beginning of attack */ 631 __u16 attack_level;/* Level at beginning of attack */
616 __u16 fade_length;/* Duration of fade (ms) */ 632 __u16 fade_length;/* Duration of fade (ms) */
617 __u16 fade_level;/* Level at end of fade */ 633 __u16 fade_level;/* Level at end of fade */
618}; 634};
619 635
@@ -697,292 +713,301 @@ struct ff_effect {
697 struct ff_periodic_effect periodic; 713 struct ff_periodic_effect periodic;
698 struct ff_condition_effect condition[2]; /* One for each axis */ 714 struct ff_condition_effect condition[2]; /* One for each axis */
699 struct ff_rumble_effect rumble; 715 struct ff_rumble_effect rumble;
700 } u; 716 } u;
701}; 717};
702 718
703/* 719/*
704 * Force feedback effect types 720 * Force feedback effect types
705 */ 721 */
706 722
707 #define FF_RUMBLE0x50 723 #define FF_RUMBLE0x50
708 #define FF_PERIODIC0x51 724 #define FF_PERIODIC0x51
709 #define FF_CONSTANT0x52 725 #define FF_CONSTANT0x52
710 #define FF_SPRING0x53 726 #define FF_SPRING0x53
711 #define FF_FRICTION0x54 727 #define FF_FRICTION0x54
712 #define FF_DAMPER0x55 728 #define FF_DAMPER0x55
713 #define FF_INERTIA0x56 729 #define FF_INERTIA0x56
714 #define FF_RAMP 0x57 730 #define FF_RAMP 0x57
715 731
716/* 732/*
717 * Force feedback periodic effect types 733 * Force feedback periodic effect types
718 */ 734 */
719 735
720 #define FF_SQUARE0x58 736 #define FF_SQUARE0x58
721 #define FF_TRIANGLE0x59 737 #define FF_TRIANGLE0x59
722 #define FF_SINE 0x5a 738 #define FF_SINE 0x5a
723 #define FF_SAW_UP0x5b 739 #define FF_SAW_UP0x5b
724 #define FF_SAW_DOWN0x5c 740 #define FF_SAW_DOWN0x5c
725 #define FF_CUSTOM0x5d 741 #define FF_CUSTOM0x5d
726 742
727/* 743/*
728 * Set ff device properties 744 * Set ff device properties
729 */ 745 */
730 746
731 #define FF_GAIN 0x60 747 #define FF_GAIN 0x60
732 #define FF_AUTOCENTER0x61 748 #define FF_AUTOCENTER0x61
733 749
734 #define FF_MAX 0x7f 750 #define FF_MAX 0x7f
735 751
736#ifdef __KERNEL__ 752#ifdef __KERNEL__
737 753
738/* 754/*
739 * In-kernel definitions. 755 * In-kernel definitions.
740 */ 756 */
741 757
742#include <linux/fs.h> 758#include <linux/fs.h>
743#include <linux/timer.h> 759#include <linux/timer.h>
744 760
745#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) 761#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
746 #define BIT(x)(1UL<<((x)%BITS_PER_LONG)) 762 #define BIT(x)(1UL<<((x)%BITS_PER_LONG))
747#define LONG(x) ((x)/BITS_PER_LONG) 763#define LONG(x) ((x)/BITS_PER_LONG)
748 764
749#define INPUT_KEYCODE(dev, scancode) ((dev->keycodesize == 1) ? ((u8*)dev->keycode)[scancode] : \ 765#define INPUT_KEYCODE(dev, scancode) ((dev->keycodesize == 1) ? ((u8*)dev->keycode)[scancode] : \
750 ((dev->keycodesize == 2) ? ((u16*)dev->keycode)[scancode] : (((u32*)dev->keycode)[scancode]))) 766 ((dev->keycodesize == 2) ? ((u16*)dev->keycode)[scancode] : (((u32*)dev->keycode)[scancode])))
751 767
752 #define SET_INPUT_KEYCODE(dev, scancode, val) \ 768 #define SET_INPUT_KEYCODE(dev, scancode, val) \
753 ({ unsigned __old; \ 769 ({ unsigned __old; \
754 switch (dev->keycodesize) { \ 770 switch (dev->keycodesize) { \
755 case 1: { \ 771 case 1: { \
756 u8 *k = (u8 *)dev->keycode;\ 772 u8 *k = (u8 *)dev->keycode;\
757 __old = k[scancode]; \ 773 __old = k[scancode]; \
758 k[scancode] = val; \ 774 k[scancode] = val; \
759 break; \ 775 break; \
760 } \ 776 } \
761 case 2: { \ 777 case 2: { \
762 u16 *k = (u16 *)dev->keycode;\ 778 u16 *k = (u16 *)dev->keycode;\
763 __old = k[scancode]; \ 779 __old = k[scancode]; \
764 k[scancode] = val; \ 780 k[scancode] = val; \
765 break; \ 781 break; \
766 } \ 782 } \
767 default: { \ 783 default: { \
768 u32 *k = (u32 *)dev->keycode;\ 784 u32 *k = (u32 *)dev->keycode;\
769 __old = k[scancode]; \ 785 __old = k[scancode]; \
770 k[scancode] = val; \ 786 k[scancode] = val; \
771 break; \ 787 break; \
772 } \ 788 } \
773 } \ 789 } \
774 __old; }) 790 __old; })
775 791
776struct input_dev { 792struct input_dev {
777 793
778 void *private; 794 void *private;
779 795
780 char *name; 796 char *name;
781 char *phys; 797 char *phys;
782 char *uniq; 798 char *uniq;
783 struct input_id id; 799 struct input_id id;
784 800
785 unsigned long evbit[NBITS(EV_MAX)]; 801 unsigned long evbit[NBITS(EV_MAX)];
786 unsigned long keybit[NBITS(KEY_MAX)]; 802 unsigned long keybit[NBITS(KEY_MAX)];
787 unsigned long relbit[NBITS(REL_MAX)]; 803 unsigned long relbit[NBITS(REL_MAX)];
788 unsigned long absbit[NBITS(ABS_MAX)]; 804 unsigned long absbit[NBITS(ABS_MAX)];
789 unsigned long mscbit[NBITS(MSC_MAX)]; 805 unsigned long mscbit[NBITS(MSC_MAX)];
790 unsigned long ledbit[NBITS(LED_MAX)]; 806 unsigned long ledbit[NBITS(LED_MAX)];
791 unsigned long sndbit[NBITS(SND_MAX)]; 807 unsigned long sndbit[NBITS(SND_MAX)];
792 unsigned long ffbit[NBITS(FF_MAX)]; 808 unsigned long ffbit[NBITS(FF_MAX)];
809 unsigned long swbit[NBITS(SW_MAX)];
793 int ff_effects_max; 810 int ff_effects_max;
794 811
795 unsigned int keycodemax; 812 unsigned int keycodemax;
796 unsigned int keycodesize; 813 unsigned int keycodesize;
797 void *keycode; 814 void *keycode;
798 815
799 unsigned int repeat_key; 816 unsigned int repeat_key;
800 struct timer_list timer; 817 struct timer_list timer;
801 818
802 struct pm_dev *pm_dev; 819 struct pm_dev *pm_dev;
803 struct pt_regs *regs; 820 struct pt_regs *regs;
804 int state; 821 int state;
805 822
806 int sync; 823 int sync;
807 824
808 int abs[ABS_MAX + 1]; 825 int abs[ABS_MAX + 1];
809 int rep[REP_MAX + 1]; 826 int rep[REP_MAX + 1];
810 827
811 unsigned long key[NBITS(KEY_MAX)]; 828 unsigned long key[NBITS(KEY_MAX)];
812 unsigned long led[NBITS(LED_MAX)]; 829 unsigned long led[NBITS(LED_MAX)];
813 unsigned long snd[NBITS(SND_MAX)]; 830 unsigned long snd[NBITS(SND_MAX)];
831 unsigned long sw[NBITS(SW_MAX)];
814 832
815 int absmax[ABS_MAX + 1]; 833 int absmax[ABS_MAX + 1];
816 int absmin[ABS_MAX + 1]; 834 int absmin[ABS_MAX + 1];
817 int absfuzz[ABS_MAX + 1]; 835 int absfuzz[ABS_MAX + 1];
818 int absflat[ABS_MAX + 1]; 836 int absflat[ABS_MAX + 1];
819 837
820 int (*open)(struct input_dev *dev); 838 int (*open)(struct input_dev *dev);
821 void (*close)(struct input_dev *dev); 839 void (*close)(struct input_dev *dev);
822 int (*accept)(struct input_dev *dev, struct file *file); 840 int (*accept)(struct input_dev *dev, struct file *file);
823 int (*flush)(struct input_dev *dev, struct file *file); 841 int (*flush)(struct input_dev *dev, struct file *file);
824 int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); 842 int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
825 int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect); 843 int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect);
826 int (*erase_effect)(struct input_dev *dev, int effect_id); 844 int (*erase_effect)(struct input_dev *dev, int effect_id);
827 845
828 struct input_handle *grab; 846 struct input_handle *grab;
829 struct device *dev; 847 struct device *dev;
830 848
831 struct list_headh_list; 849 struct list_headh_list;
832 struct list_headnode; 850 struct list_headnode;
833}; 851};
834 852
835/* 853/*
836 * Structure for hotplug & device<->driver matching. 854 * Structure for hotplug & device<->driver matching.
837 */ 855 */
838 856
839 #define INPUT_DEVICE_ID_MATCH_BUS1 857 #define INPUT_DEVICE_ID_MATCH_BUS1
840 #define INPUT_DEVICE_ID_MATCH_VENDOR2 858 #define INPUT_DEVICE_ID_MATCH_VENDOR2
841 #define INPUT_DEVICE_ID_MATCH_PRODUCT4 859 #define INPUT_DEVICE_ID_MATCH_PRODUCT4
842 #define INPUT_DEVICE_ID_MATCH_VERSION8 860 #define INPUT_DEVICE_ID_MATCH_VERSION8
843 861
844 #define INPUT_DEVICE_ID_MATCH_EVBIT0x010 862 #define INPUT_DEVICE_ID_MATCH_EVBIT0x010
845 #define INPUT_DEVICE_ID_MATCH_KEYBIT0x020 863 #define INPUT_DEVICE_ID_MATCH_KEYBIT0x020
846 #define INPUT_DEVICE_ID_MATCH_RELBIT0x040 864 #define INPUT_DEVICE_ID_MATCH_RELBIT0x040
847 #define INPUT_DEVICE_ID_MATCH_ABSBIT0x080 865 #define INPUT_DEVICE_ID_MATCH_ABSBIT0x080
848 #define INPUT_DEVICE_ID_MATCH_MSCIT0x100 866 #define INPUT_DEVICE_ID_MATCH_MSCIT0x100
849 #define INPUT_DEVICE_ID_MATCH_LEDBIT0x200 867 #define INPUT_DEVICE_ID_MATCH_LEDBIT0x200
850 #define INPUT_DEVICE_ID_MATCH_SNDBIT0x400 868 #define INPUT_DEVICE_ID_MATCH_SNDBIT0x400
851 #define INPUT_DEVICE_ID_MATCH_FFBIT0x800 869 #define INPUT_DEVICE_ID_MATCH_FFBIT0x800
870 #define INPUT_DEVICE_ID_MATCH_SWBIT0x1000
852 871
853#define INPUT_DEVICE_ID_MATCH_DEVICE\ 872#define INPUT_DEVICE_ID_MATCH_DEVICE\
854 (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT) 873 (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT)
855#define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION\ 874#define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION\
856 (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION) 875 (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION)
857 876
858struct input_device_id { 877struct input_device_id {
859 878
860 unsigned long flags; 879 unsigned long flags;
861 880
862 struct input_id id; 881 struct input_id id;
863 882
864 unsigned long evbit[NBITS(EV_MAX)]; 883 unsigned long evbit[NBITS(EV_MAX)];
865 unsigned long keybit[NBITS(KEY_MAX)]; 884 unsigned long keybit[NBITS(KEY_MAX)];
866 unsigned long relbit[NBITS(REL_MAX)]; 885 unsigned long relbit[NBITS(REL_MAX)];
867 unsigned long absbit[NBITS(ABS_MAX)]; 886 unsigned long absbit[NBITS(ABS_MAX)];
868 unsigned long mscbit[NBITS(MSC_MAX)]; 887 unsigned long mscbit[NBITS(MSC_MAX)];
869 unsigned long ledbit[NBITS(LED_MAX)]; 888 unsigned long ledbit[NBITS(LED_MAX)];
870 unsigned long sndbit[NBITS(SND_MAX)]; 889 unsigned long sndbit[NBITS(SND_MAX)];
871 unsigned long ffbit[NBITS(FF_MAX)]; 890 unsigned long ffbit[NBITS(FF_MAX)];
891 unsigned long swbit[NBITS(SW_MAX)];
872 892
873 unsigned long driver_info; 893 unsigned long driver_info;
874}; 894};
875 895
876struct input_handle; 896struct input_handle;
877 897
878struct input_handler { 898struct input_handler {
879 899
880 void *private; 900 void *private;
881 901
882 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); 902 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
883 struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id); 903 struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id);
884 void (*disconnect)(struct input_handle *handle); 904 void (*disconnect)(struct input_handle *handle);
885 905
886 struct file_operations *fops; 906 struct file_operations *fops;
887 int minor; 907 int minor;
888 char *name; 908 char *name;
889 909
890 struct input_device_id *id_table; 910 struct input_device_id *id_table;
891 struct input_device_id *blacklist; 911 struct input_device_id *blacklist;
892 912
893 struct list_headh_list; 913 struct list_headh_list;
894 struct list_headnode; 914 struct list_headnode;
895}; 915};
896 916
897struct input_handle { 917struct input_handle {
898 918
899 void *private; 919 void *private;
900 920
901 int open; 921 int open;
902 char *name; 922 char *name;
903 923
904 struct input_dev *dev; 924 struct input_dev *dev;
905 struct input_handler *handler; 925 struct input_handler *handler;
906 926
907 struct list_headd_node; 927 struct list_headd_node;
908 struct list_headh_node; 928 struct list_headh_node;
909}; 929};
910 930
911#define to_dev(n) container_of(n,struct input_dev,node) 931#define to_dev(n) container_of(n,struct input_dev,node)
912#define to_handler(n) container_of(n,struct input_handler,node); 932#define to_handler(n) container_of(n,struct input_handler,node);
913#define to_handle(n) container_of(n,struct input_handle,d_node) 933#define to_handle(n) container_of(n,struct input_handle,d_node)
914#define to_handle_h(n) container_of(n,struct input_handle,h_node) 934#define to_handle_h(n) container_of(n,struct input_handle,h_node)
915 935
916static inline void init_input_dev(struct input_dev *dev) 936static inline void init_input_dev(struct input_dev *dev)
917{ 937{
918 INIT_LIST_HEAD(&dev->h_list); 938 INIT_LIST_HEAD(&dev->h_list);
919 INIT_LIST_HEAD(&dev->node); 939 INIT_LIST_HEAD(&dev->node);
920} 940}
921 941
922void input_register_device(struct input_dev *); 942void input_register_device(struct input_dev *);
923void input_unregister_device(struct input_dev *); 943void input_unregister_device(struct input_dev *);
924 944
925void input_register_handler(struct input_handler *); 945void input_register_handler(struct input_handler *);
926void input_unregister_handler(struct input_handler *); 946void input_unregister_handler(struct input_handler *);
927 947
928int input_grab_device(struct input_handle *); 948int input_grab_device(struct input_handle *);
929void input_release_device(struct input_handle *); 949void input_release_device(struct input_handle *);
930 950
931int input_open_device(struct input_handle *); 951int input_open_device(struct input_handle *);
932void input_close_device(struct input_handle *); 952void input_close_device(struct input_handle *);
933 953
934int input_accept_process(struct input_handle *handle, struct file *file); 954int input_accept_process(struct input_handle *handle, struct file *file);
935int input_flush_device(struct input_handle* handle, struct file* file); 955int input_flush_device(struct input_handle* handle, struct file* file);
936 956
937void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); 957void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
938 958
939static inline void input_report_key(struct input_dev *dev, unsigned int code, int value) 959static inline void input_report_key(struct input_dev *dev, unsigned int code, int value)
940{ 960{
941 input_event(dev, EV_KEY, code, !!value); 961 input_event(dev, EV_KEY, code, !!value);
942} 962}
943 963
944static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value) 964static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value)
945{ 965{
946 input_event(dev, EV_REL, code, value); 966 input_event(dev, EV_REL, code, value);
947} 967}
948 968
949static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value) 969static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value)
950{ 970{
951 input_event(dev, EV_ABS, code, value); 971 input_event(dev, EV_ABS, code, value);
952} 972}
953 973
954static inline void input_report_ff(struct input_dev *dev, unsigned int code, int value) 974static inline void input_report_ff(struct input_dev *dev, unsigned int code, int value)
955{ 975{
956 input_event(dev, EV_FF, code, value); 976 input_event(dev, EV_FF, code, value);
957} 977}
958 978
959static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value) 979static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value)
960{ 980{
961 input_event(dev, EV_FF_STATUS, code, value); 981 input_event(dev, EV_FF_STATUS, code, value);
962} 982}
963 983
984static inline void input_report_switch(struct input_dev *dev, unsigned int code, int value)
985{
986 input_event(dev, EV_SW, code, !!value);
987}
988
964static inline void input_regs(struct input_dev *dev, struct pt_regs *regs) 989static inline void input_regs(struct input_dev *dev, struct pt_regs *regs)
965{ 990{
966 dev->regs = regs; 991 dev->regs = regs;
967} 992}
968 993
969static inline void input_sync(struct input_dev *dev) 994static inline void input_sync(struct input_dev *dev)
970{ 995{
971 input_event(dev, EV_SYN, SYN_REPORT, 0); 996 input_event(dev, EV_SYN, SYN_REPORT, 0);
972 dev->regs = NULL; 997 dev->regs = NULL;
973} 998}
974 999
975static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) 1000static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
976{ 1001{
977 dev->absmin[axis] = min; 1002 dev->absmin[axis] = min;
978 dev->absmax[axis] = max; 1003 dev->absmax[axis] = max;
979 dev->absfuzz[axis] = fuzz; 1004 dev->absfuzz[axis] = fuzz;
980 dev->absflat[axis] = flat; 1005 dev->absflat[axis] = flat;
981 1006
982 dev->absbit[LONG(axis)] |= BIT(axis); 1007 dev->absbit[LONG(axis)] |= BIT(axis);
983} 1008}
984 1009
985extern struct class_simple *input_class; 1010extern struct class_simple *input_class;
986 1011
987#endif 1012#endif
988#endif 1013#endif
diff --git a/libopie2/opiecore/oinputsystemenums.h b/libopie2/opiecore/oinputsystemenums.h
index 3461e5a..728423a 100644
--- a/libopie2/opiecore/oinputsystemenums.h
+++ b/libopie2/opiecore/oinputsystemenums.h
@@ -1,130 +1,143 @@
1 1
2 enum Feature 2 enum Feature
3 { 3 {
4 Synchronous = EV_SYN, 4 Synchronous = EV_SYN,
5 Keys = EV_KEY, 5 Keys = EV_KEY,
6 Relative = EV_REL, 6 Relative = EV_REL,
7 Absolute = EV_ABS, 7 Absolute = EV_ABS,
8 Miscellaneous = EV_MSC, 8 Miscellaneous = EV_MSC,
9 Switches = EV_SW,
9 Leds = EV_LED, 10 Leds = EV_LED,
10 Sound = EV_SND, 11 Sound = EV_SND,
11 AutoRepeat = EV_REP, 12 AutoRepeat = EV_REP,
12 ForceFeedback = EV_FF, 13 ForceFeedback = EV_FF,
13 PowerManagement = EV_PWR, 14 PowerManagement = EV_PWR,
14 ForceFeedbackStatus = EV_FF_STATUS, 15 ForceFeedbackStatus = EV_FF_STATUS,
15 }; 16 };
16 17
17 enum Bus 18 enum Bus
18 { 19 {
19 PCI = BUS_PCI, 20 PCI = BUS_PCI,
20 ISAPNP = BUS_ISAPNP, 21 ISAPNP = BUS_ISAPNP,
21 HIL = BUS_HIL, 22 HIL = BUS_HIL,
22 BLUETOOTH = BUS_BLUETOOTH, 23 BLUETOOTH = BUS_BLUETOOTH,
23 ISA = BUS_ISA, 24 ISA = BUS_ISA,
24 I8042 = BUS_I8042, 25 I8042 = BUS_I8042,
25 XTKBD = BUS_XTKBD, 26 XTKBD = BUS_XTKBD,
26 RS232 = BUS_RS232, 27 RS232 = BUS_RS232,
27 GAMEPORT = BUS_GAMEPORT, 28 GAMEPORT = BUS_GAMEPORT,
28 PARPORT = BUS_PARPORT, 29 PARPORT = BUS_PARPORT,
29 AMIGA = BUS_AMIGA, 30 AMIGA = BUS_AMIGA,
30 ADB = BUS_ADB, 31 ADB = BUS_ADB,
31 I2C = BUS_I2C, 32 I2C = BUS_I2C,
32 HOST = BUS_HOST, 33 HOST = BUS_HOST,
33 }; 34 };
34 35
36 enum Switch
37 {
38 Switch0 = SW_0,
39 Switch1 = SW_1,
40 Switch2 = SW_2,
41 Switch3 = SW_3,
42 Switch4 = SW_4,
43 Switch5 = SW_5,
44 Switch6 = SW_6,
45 Switch7 = SW_7,
46 };
47
35 enum Key 48 enum Key
36 { 49 {
37 Key_RESERVED = 0, 50 Key_RESERVED = 0,
38 Key_ESC = 1, 51 Key_ESC = 1,
39 Key_1 = 2, 52 Key_1 = 2,
40 Key_2 = 3, 53 Key_2 = 3,
41 Key_3 = 4, 54 Key_3 = 4,
42 Key_4 = 5, 55 Key_4 = 5,
43 Key_5 = 6, 56 Key_5 = 6,
44 Key_6 = 7, 57 Key_6 = 7,
45 Key_7 = 8, 58 Key_7 = 8,
46 Key_8 = 9, 59 Key_8 = 9,
47 Key_9 = 10, 60 Key_9 = 10,
48 Key_0 = 11, 61 Key_0 = 11,
49 Key_MINUS = 12, 62 Key_MINUS = 12,
50 Key_EQUAL = 13, 63 Key_EQUAL = 13,
51 Key_BACKSPACE = 14, 64 Key_BACKSPACE = 14,
52 Key_TAB = 15, 65 Key_TAB = 15,
53 Key_Q = 16, 66 Key_Q = 16,
54 Key_W = 17, 67 Key_W = 17,
55 Key_E = 18, 68 Key_E = 18,
56 Key_R = 19, 69 Key_R = 19,
57 Key_T = 20, 70 Key_T = 20,
58 Key_Y = 21, 71 Key_Y = 21,
59 Key_U = 22, 72 Key_U = 22,
60 Key_I = 23, 73 Key_I = 23,
61 Key_O = 24, 74 Key_O = 24,
62 Key_P = 25, 75 Key_P = 25,
63 Key_LEFTBRACE = 26, 76 Key_LEFTBRACE = 26,
64 Key_RIGHTBRACE = 27, 77 Key_RIGHTBRACE = 27,
65 Key_ENTER = 28, 78 Key_ENTER = 28,
66 Key_LEFTCTRL = 29, 79 Key_LEFTCTRL = 29,
67 Key_A = 30, 80 Key_A = 30,
68 Key_S = 31, 81 Key_S = 31,
69 Key_D = 32, 82 Key_D = 32,
70 Key_F = 33, 83 Key_F = 33,
71 Key_G = 34, 84 Key_G = 34,
72 Key_H = 35, 85 Key_H = 35,
73 Key_J = 36, 86 Key_J = 36,
74 Key_K = 37, 87 Key_K = 37,
75 Key_L = 38, 88 Key_L = 38,
76 Key_SEMICOLON = 39, 89 Key_SEMICOLON = 39,
77 Key_APOSTROPHE = 40, 90 Key_APOSTROPHE = 40,
78 Key_GRAVE = 41, 91 Key_GRAVE = 41,
79 Key_LEFTSHIFT = 42, 92 Key_LEFTSHIFT = 42,
80 Key_BACKSLASH = 43, 93 Key_BACKSLASH = 43,
81 Key_Z = 44, 94 Key_Z = 44,
82 Key_X = 45, 95 Key_X = 45,
83 Key_C = 46, 96 Key_C = 46,
84 Key_V = 47, 97 Key_V = 47,
85 Key_B = 48, 98 Key_B = 48,
86 Key_N = 49, 99 Key_N = 49,
87 Key_M = 50, 100 Key_M = 50,
88 Key_COMMA = 51, 101 Key_COMMA = 51,
89 Key_DOT = 52, 102 Key_DOT = 52,
90 Key_SLASH = 53, 103 Key_SLASH = 53,
91 Key_RIGHTSHIFT = 54, 104 Key_RIGHTSHIFT = 54,
92 Key_KPASTERISK = 55, 105 Key_KPASTERISK = 55,
93 Key_LEFTALT = 56, 106 Key_LEFTALT = 56,
94 Key_SPACE = 57, 107 Key_SPACE = 57,
95 Key_CAPSLOCK = 58, 108 Key_CAPSLOCK = 58,
96 Key_F1 = 59, 109 Key_F1 = 59,
97 Key_F2 = 60, 110 Key_F2 = 60,
98 Key_F3 = 61, 111 Key_F3 = 61,
99 Key_F4 = 62, 112 Key_F4 = 62,
100 Key_F5 = 63, 113 Key_F5 = 63,
101 Key_F6 = 64, 114 Key_F6 = 64,
102 Key_F7 = 65, 115 Key_F7 = 65,
103 Key_F8 = 66, 116 Key_F8 = 66,
104 Key_F9 = 67, 117 Key_F9 = 67,
105 Key_F10 = 68, 118 Key_F10 = 68,
106 Key_NUMLOCK = 69, 119 Key_NUMLOCK = 69,
107 Key_SCROLLLOCK = 70, 120 Key_SCROLLLOCK = 70,
108 Key_KP7 = 71, 121 Key_KP7 = 71,
109 Key_KP8 = 72, 122 Key_KP8 = 72,
110 Key_KP9 = 73, 123 Key_KP9 = 73,
111 Key_KPMINUS = 74, 124 Key_KPMINUS = 74,
112 Key_KP4 = 75, 125 Key_KP4 = 75,
113 Key_KP5 = 76, 126 Key_KP5 = 76,
114 Key_KP6 = 77, 127 Key_KP6 = 77,
115 Key_KPPLUS = 78, 128 Key_KPPLUS = 78,
116 Key_KP1 = 79, 129 Key_KP1 = 79,
117 Key_KP2 = 80, 130 Key_KP2 = 80,
118 Key_KP3 = 81, 131 Key_KP3 = 81,
119 Key_KP0 = 82, 132 Key_KP0 = 82,
120 Key_KPDOT = 83, 133 Key_KPDOT = 83,
121 134
122 Key_ZENKAKUHANKAKU= 85, 135 Key_ZENKAKUHANKAKU= 85,
123 Key_102ND = 86, 136 Key_102ND = 86,
124 Key_F11 = 87, 137 Key_F11 = 87,
125 Key_F12 = 88, 138 Key_F12 = 88,
126 Key_RO = 89, 139 Key_RO = 89,
127 Key_KATAKANA = 90, 140 Key_KATAKANA = 90,
128 Key_HIRAGANA = 91, 141 Key_HIRAGANA = 91,
129 Key_HENKAN = 92, 142 Key_HENKAN = 92,
130 Key_KATAKANAHIRAGANA= 93, 143 Key_KATAKANAHIRAGANA= 93,