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.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index c0b6efa..4258d60 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -487,97 +487,97 @@ ODevice::ODevice ( )
d-> m_rotation = Rot0;
d-> m_direction = CW;
d-> m_holdtime = 1000; // 1000ms
d-> m_buttons = 0;
d-> m_cpu_frequencies = new QStrList;
}
void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
{
if ( msg == "deviceButtonMappingChanged()" ) {
reloadButtonMapping ( );
}
}
void ODevice::init ( )
{
}
/**
* This method initialises the button mapping
*/
void ODevice::initButtons ( )
{
if ( d-> m_buttons )
return;
// Simulation uses iPAQ 3660 device buttons
qDebug ( "init Buttons" );
d-> m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
i_button *ib = ipaq_buttons + i;
ODeviceButton b;
if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
b. setKeycode ( ib-> code );
b. setUserText ( QObject::tr ( "Button", ib-> utext ));
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
d-> m_buttons-> append ( b );
}
}
reloadButtonMapping ( );
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
- connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
+ connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
}
ODevice::~ODevice ( )
{
// we leak m_devicebuttons and m_cpu_frequency
// but it's a singleton and it is not so importantant
// -zecke
delete d;
}
bool ODevice::setSoftSuspend ( bool /*soft*/ )
{
return false;
}
//#include <linux/apm_bios.h>
#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
/**
* This method will try to suspend the device
* It only works if the user is the QWS Server and the apm application
* is installed.
* It tries to suspend and then waits some time cause some distributions
* do have asynchronus apm implementations.
* This method will either fail and return false or it'll suspend the
* device and return once the device got woken up
*
* @return if the device got suspended
*/
bool ODevice::suspend ( )
{
qDebug("ODevice::suspend");
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
return false;
bool res = false;
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync ( ); // flush fs caches
res = ( ::system ( "apm --suspend" ) == 0 );
// This is needed because the iPAQ apm implementation is asynchronous and we
@@ -1067,98 +1067,98 @@ bool Yopy::isYopy ( )
}
void Yopy::init ( )
{
d-> m_vendorstr = "G.Mate";
d-> m_vendor = Vendor_GMate;
d-> m_modelstr = "Yopy3700";
d-> m_model = Model_Yopy_3700;
d-> m_rotation = Rot0;
d-> m_systemstr = "Linupy";
d-> m_system = System_Linupy;
QFile f ( "/etc/issue" );
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
ts.readLine();
d-> m_sysverstr = ts. readLine ( );
f. close ( );
}
}
void Yopy::initButtons ( )
{
if ( d-> m_buttons )
return;
d-> m_buttons = new QValueList <ODeviceButton>;
for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
yopy_button *ib = yopy_buttons + i;
ODeviceButton b;
b. setKeycode ( ib-> code );
b. setUserText ( QObject::tr ( "Button", ib-> utext ));
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
b. setFactoryPresetPressedAction
(OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
b. setFactoryPresetHeldAction
(OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
d-> m_buttons-> append ( b );
}
reloadButtonMapping ( );
QCopChannel *sysch = new QCopChannel("QPE/System", this);
- connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
- this, SLOT(systemMessage(const QCString &, const QByteArray & )));
+ connect(sysch, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(systemMessage(const QCString&,const QByteArray&)));
}
bool Yopy::suspend()
{
/* Opie for Yopy does not implement its own power management at the
moment. The public version runs parallel to X, and relies on the
existing power management features. */
return false;
}
bool Yopy::setDisplayBrightness(int bright)
{
/* The code here works, but is disabled as the current version runs
parallel to X, and relies on the existing backlight demon. */
#if 0
if ( QFile::exists("/proc/sys/pm/light") ) {
int fd = ::open("/proc/sys/pm/light", O_WRONLY);
if (fd >= 0 ) {
if (bright)
::write(fd, "1\n", 2);
else
::write(fd, "0\n", 2);
::close(fd);
return true;
}
}
#endif
return false;
}
int Yopy::displayBrightnessResolution() const
{
return 2;
}
/**************************************************
*
* iPAQ
*
**************************************************/
void iPAQ::init ( )
{
d-> m_vendorstr = "HP";
d-> m_vendor = Vendor_HP;
QFile f ( "/proc/hal/model" );
@@ -1216,97 +1216,97 @@ void iPAQ::init ( )
if ( f. open ( IO_ReadOnly )) {
d-> m_systemstr = "OpenEmbedded/iPaq";
d-> m_system = System_Familiar;
QTextStream ts ( &f );
ts.setDevice ( &f );
d-> m_sysverstr = ts. readLine ( );
f. close ( );
}
}
m_leds [0] = m_leds [1] = Led_Off;
m_power_timer = 0;
}
void iPAQ::initButtons ( )
{
if ( d-> m_buttons )
return;
if ( isQWS( ) )
QWSServer::setKeyboardFilter ( this );
d-> m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
i_button *ib = ipaq_buttons + i;
ODeviceButton b;
if (( ib-> model & d-> m_model ) == d-> m_model ) {
b. setKeycode ( ib-> code );
b. setUserText ( QObject::tr ( "Button", ib-> utext ));
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
d-> m_buttons-> append ( b );
}
}
reloadButtonMapping ( );
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
- connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
+ connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
}
//#include <linux/h3600_ts.h> // including kernel headers is evil ...
typedef struct {
unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
unsigned char TotalTime; /* Units of 5 seconds */
unsigned char OnTime; /* units of 100m/s */
unsigned char OffTime; /* units of 100m/s */
} LED_IN;
typedef struct {
unsigned char mode;
unsigned char pwr;
unsigned char brightness;
} FLITE_IN;
#define LED_ON OD_IOW( 'f', 5, LED_IN )
#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
QValueList <OLed> iPAQ::ledList ( ) const
{
QValueList <OLed> vl;
vl << Led_Power;
if ( d-> m_model == Model_iPAQ_H38xx )
vl << Led_BlueTooth;
return vl;
}
QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
{
QValueList <OLedState> vl;
if ( l == Led_Power )
vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
vl << Led_Off; // << Led_On << ???
return vl;
}
OLedState iPAQ::ledState ( OLed l ) const
{
switch ( l ) {
case Led_Power:
@@ -1702,98 +1702,98 @@ void Zaurus::init ( )
case Model_Zaurus_SLB600:
case Model_Zaurus_SL5500:
case Model_Zaurus_SL5000:
default:
d-> m_rotation = Rot270;
break;
}
m_leds [0] = Led_Off;
}
void Zaurus::initButtons ( )
{
if ( d-> m_buttons )
return;
d-> m_buttons = new QValueList <ODeviceButton>;
struct z_button * pz_buttons;
int buttoncount;
switch ( d-> m_model ) {
case Model_Zaurus_SLC7x0:
pz_buttons = z_buttons_c700;
buttoncount = ARRAY_SIZE(z_buttons_c700);
break;
default:
pz_buttons = z_buttons;
buttoncount = ARRAY_SIZE(z_buttons);
break;
}
for ( int i = 0; i < buttoncount; i++ ) {
struct z_button *zb = pz_buttons + i;
ODeviceButton b;
b. setKeycode ( zb-> code );
b. setUserText ( QObject::tr ( "Button", zb-> utext ));
b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ),
zb-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ),
zb-> fheldaction ));
d-> m_buttons-> append ( b );
}
reloadButtonMapping ( );
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
- connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )),
- this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
+ connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)),
+ this, SLOT( systemMessage(const QCString&,const QByteArray&)));
}
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
//#include <asm/sharp_char.h> // including kernel headers is evil ...
#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
#define SHARP_BUZ_KEYSOUND 2 /* key sound */
#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
/* --- for SHARP_BUZZER device --- */
//#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
//#define SHARP_PDA_APPSTART 9 /* application start */
//#define SHARP_PDA_APPQUIT 10 /* application ends */
//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
//
#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
@@ -2253,97 +2253,97 @@ void SIMpad::init ( )
f. close ( );
} else {
f. setName ( "/etc/oz_version" );
if ( f. open ( IO_ReadOnly )) {
d-> m_systemstr = "OpenEmbedded/SIMpad";
d-> m_system = System_OpenZaurus;
QTextStream ts ( &f );
ts.setDevice ( &f );
d-> m_sysverstr = ts. readLine ( );
f. close ( );
}
}
m_leds [0] = m_leds [1] = Led_Off;
m_power_timer = 0;
}
void SIMpad::initButtons ( )
{
if ( d-> m_buttons )
return;
if ( isQWS( ) )
QWSServer::setKeyboardFilter ( this );
d-> m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
s_button *sb = simpad_buttons + i;
ODeviceButton b;
if (( sb-> model & d-> m_model ) == d-> m_model ) {
b. setKeycode ( sb-> code );
b. setUserText ( QObject::tr ( "Button", sb-> utext ));
b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
d-> m_buttons-> append ( b );
}
}
reloadButtonMapping ( );
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
- connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
+ connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
}
// SIMpad boardcontrol register CS3
#define SIMPAD_BOARDCONTROL "/proc/cs3"
#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
#define SIMPAD_EN1 0x0004 // This is only for EPROM's
#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
#define SIMPAD_DISPLAY_ON 0x0010
#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
#define SIMPAD_MQ_RESET 0x0040
#define SIMPAD_PCMCIA_RESET 0x0080
#define SIMPAD_DECT_POWER_ON 0x0100
#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
#define SIMPAD_RS232_ON 0x0400
#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
#define SIMPAD_LED2_ON 0x1000
#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
#define SIMPAD_RESET_SIMCARD 0x8000
//SIMpad touchscreen backlight strength control
#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
#define SIMPAD_BACKLIGHT_MASK 0x00a10044
QValueList <OLed> SIMpad::ledList ( ) const
{
QValueList <OLed> vl;
vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
//vl << Led_Mail; //TODO find out if LED1 is accessible anyway
return vl;
}
QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
{
QValueList <OLedState> vl;
if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
vl << Led_Off << Led_On;
//else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
//vl << Led_Off;
return vl;
}
OLedState SIMpad::ledState ( OLed l ) const
{
switch ( l ) {
case Led_Power:
@@ -2753,94 +2753,94 @@ bool Jornada::isJornada ( )
void Jornada::init ( )
{
d-> m_vendorstr = "HP";
d-> m_vendor = Vendor_HP;
d-> m_modelstr = "Jornada 56x";
d-> m_model = Model_Jornada_56x;
d-> m_systemstr = "Familiar";
d-> m_system = System_Familiar;
d-> m_rotation = Rot0;
QFile f ( "/etc/familiar-version" );
f. setName ( "/etc/familiar-version" );
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
f. close ( );
}
}
#if 0
void Jornada::initButtons ( )
{
if ( d-> m_buttons )
return;
// Simulation uses iPAQ 3660 device buttons
qDebug ( "init Buttons" );
d-> m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
i_button *ib = ipaq_buttons + i;
ODeviceButton b;
if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
b. setKeycode ( ib-> code );
b. setUserText ( QObject::tr ( "Button", ib-> utext ));
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
d-> m_buttons-> append ( b );
}
}
reloadButtonMapping ( );
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
- connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
+ connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
}
#endif
int Jornada::displayBrightnessResolution ( ) const
{
}
bool Jornada::setDisplayBrightness ( int bright )
{
bool res = false;
int fd;
if ( bright > 255 )
bright = 255;
if ( bright < 0 )
bright = 0;
if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
FLITE_IN bl;
bl. mode = 1;
bl. pwr = bright ? 1 : 0;
bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
::close ( fd );
}
return res;
}
bool Jornada::setSoftSuspend ( bool soft )
{
bool res = false;
int fd;
if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
res = true;
else
::perror ( "write to /proc/sys/ts/suspend_button_mode" );
::close ( fd );
}
else
::perror ( "/proc/sys/ts/suspend_button_mode" );
return res;
}