summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Side-by-side diff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp87
1 files changed, 78 insertions, 9 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 17ae389..a134810 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1306,87 +1306,97 @@ int iPAQ::readLightSensor ( )
::close ( fd );
}
return val;
}
int iPAQ::lightSensorResolution ( ) const
{
return 256;
}
/**************************************************
*
* Zaurus
*
**************************************************/
void Zaurus::init ( )
{
d-> m_vendorstr = "Sharp";
d-> m_vendor = Vendor_Sharp;
- QFile f ( "/proc/filesystems" );
+ // QFile f ( "/proc/filesystems" );
QString model;
- if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
+ // It isn't a good idea to check the system configuration to
+ // detect the distribution !
+ // Otherwise it may happen that any other distribution is detected as openzaurus, just
+ // because it uses a jffs2 filesystem..
+ // (eilers)
+ // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
+ QFile f ("/etc/oz_version");
+ if ( f.exists() ){
d-> m_vendorstr = "OpenZaurus Team";
d-> m_systemstr = "OpenZaurus";
d-> m_system = System_OpenZaurus;
- f. close ( );
+ // f. close ( );
- f. setName ( "/etc/oz_version" );
+ // f. setName ( "/etc/oz_version" );
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
f. close ( );
}
}
else {
d-> m_systemstr = "Zaurus";
d-> m_system = System_Zaurus;
}
f. setName ( "/proc/cpuinfo" );
if ( f. open ( IO_ReadOnly ) ) {
QTextStream ts ( &f );
QString line;
while( line = ts. readLine ( ) ) {
if ( line. left ( 8 ) == "Hardware" )
break;
}
int loc = line. find ( ":" );
if ( loc != -1 )
model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
}
if ( model == "SHARP Corgi" ) {
d-> m_model = Model_Zaurus_SLC700;
d-> m_modelstr = "Zaurus SL-C700";
- } else if ( model == "SHARP Poodle" ) {
+ } else if ( model == "SHARP Shepherd" ) {
+ d-> m_model = Model_Zaurus_SLC700; // Do we need a special type for the C750 ? (eilers)
+ d-> m_modelstr = "Zaurus SL-C750";
+ }else if ( model == "SHARP Poodle" ) {
d-> m_model = Model_Zaurus_SLB600;
d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
} else if ( model = "Sharp-Collie" ) {
d-> m_model = Model_Zaurus_SL5500;
d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
} else {
d-> m_model = Model_Zaurus_SL5500;
d-> m_modelstr = "Zaurus (Model unknown)";
}
bool flipstate = false;
switch ( d-> m_model ) {
case Model_Zaurus_SLA300:
d-> m_rotation = Rot0;
break;
case Model_Zaurus_SLC700:
// Note: need to 1) set flipstate based on physical screen orientation
// and 2) check to see if the user overrode the rotation direction
// using appearance, and if so, remove that item from the Config to
// ensure the rotate applet flips us back to the previous state.
if ( flipstate ) {
// 480x640
d-> m_rotation = Rot0;
d-> m_direction = CW;
@@ -1493,54 +1503,113 @@ void Zaurus::initButtons ( )
#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
typedef struct sharp_led_status {
int which; /* select which LED status is wanted. */
int status; /* set new led status if you call SHARP_LED_SETSTATUS */
} sharp_led_status;
#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
// #include <asm/sharp_apm.h> // including kernel headers is evil ...
#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
#define APM_EVT_POWER_BUTTON (1 << 0)
#define FL_IOCTL_STEP_CONTRAST 100
void Zaurus::buzzer ( int sound )
{
- int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
+ // Not all devices have real sound.
+#ifndef QT_NO_SOUND
+ switch ( d-> m_model ) {
+ case Model_Zaurus_SLC700:{
+ int fd;
+ int vol;
+ bool vol_reset = false;
+
+ QString soundname;
+
+ switch ( sound ){
+ case SHARP_BUZ_SCHEDULE_ALARM:
+ soundname = "alarm";
+ break;
+ case SHARP_BUZ_TOUCHSOUND:
+ soundname = "touchsound";
+ break;
+ case SHARP_BUZ_KEYSOUND:
+ soundname = "keysound";
+ break;
+ default:
+ soundname = "alarm";
+
+ }
- if ( fd >= 0 ) {
- ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
- ::close ( fd );
+ Sound snd ( soundname );
+
+ if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
+ if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
+ Config cfg ( "qpe" );
+ cfg. setGroup ( "Volume" );
+
+ int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
+ if ( volalarm < 0 )
+ volalarm = 0;
+ else if ( volalarm > 100 )
+ volalarm = 100;
+ volalarm |= ( volalarm << 8 );
+
+ if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
+ vol_reset = true;
+ }
+ }
+
+ snd. play ( );
+ while ( !snd. isFinished ( ))
+ qApp-> processEvents ( );
+
+ if ( fd >= 0 ) {
+ if ( vol_reset )
+ ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
+ ::close ( fd );
+ }
+ break;
}
+ default:{ // Devices with buzzer
+ int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
+
+ if ( fd >= 0 ) {
+ ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
+ ::close ( fd );
+ }
+ }
+ }
+#endif
}
void Zaurus::alarmSound ( )
{
buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
}
void Zaurus::touchSound ( )
{
buzzer ( SHARP_BUZ_TOUCHSOUND );
}
void Zaurus::keySound ( )
{
buzzer ( SHARP_BUZ_KEYSOUND );
}
QValueList <OLed> Zaurus::ledList ( ) const
{
QValueList <OLed> vl;
vl << Led_Mail;
return vl;