summaryrefslogtreecommitdiff
path: root/libopie
authorschurig <schurig>2003-06-02 11:12:03 (UTC)
committer schurig <schurig>2003-06-02 11:12:03 (UTC)
commit2d6bec942d8b9b8b50639cb4ffe58cf24d5a255b (patch) (unidiff)
tree5b917d74d600715ad1223f174a9b672d822caf47 /libopie
parent68a88060627137e8cb424c758c1339f1ed5c6eac (diff)
downloadopie-2d6bec942d8b9b8b50639cb4ffe58cf24d5a255b.zip
opie-2d6bec942d8b9b8b50639cb4ffe58cf24d5a255b.tar.gz
opie-2d6bec942d8b9b8b50639cb4ffe58cf24d5a255b.tar.bz2
new Ramses target
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp197
-rw-r--r--libopie/odevice.h6
2 files changed, 203 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index f0429d4..d86654e 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -162,4 +162,23 @@ protected:
162}; 162};
163 163
164class Ramses : public ODevice, public QWSServer::KeyboardFilter {
165protected:
166 virtual void init ( );
167 virtual void initButtons ( );
168
169public:
170 virtual bool setSoftSuspend ( bool soft );
171
172 virtual bool setDisplayStatus( bool on );
173 virtual bool setDisplayBrightness ( int b );
174 virtual int displayBrightnessResolution ( ) const;
175
176protected:
177 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
178 virtual void timerEvent ( QTimerEvent *te );
179
180 int m_power_timer;
181};
182
164struct i_button { 183struct i_button {
165 uint model; 184 uint model;
@@ -323,4 +342,26 @@ struct s_button {
323}; 342};
324 343
344struct r_button {
345 uint model;
346 Qt::Key code;
347 char *utext;
348 char *pix;
349 char *fpressedservice;
350 char *fpressedaction;
351 char *fheldservice;
352 char *fheldaction;
353} ramses_buttons [] = {
354 { Model_Ramses_MNCI,
355 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
356 "devicebuttons/simpad_menu",
357 "QPE/TaskBar", "toggleMenu()",
358 "QPE/TaskBar", "toggleStartMenu()" },
359 { Model_Ramses_MNCI,
360 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
361 "devicebuttons/ipaq_home",
362 "QPE/Launcher", "home()",
363 "buttonsettings", "raise()" },
364};
365
325static QCString makeChannel ( const char *str ) 366static QCString makeChannel ( const char *str )
326{ 367{
@@ -347,4 +388,6 @@ ODevice *ODevice::inst ( )
347 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 388 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
348 dev = new SIMpad ( ); 389 dev = new SIMpad ( );
390 else if ( QFile::exists ( "/proc/sys/board/name" ))
391 dev = new Ramses ( );
349 else 392 else
350 dev = new ODevice ( ); 393 dev = new ODevice ( );
@@ -1845,2 +1888,156 @@ int SIMpad::displayBrightnessResolution ( ) const
1845} 1888}
1846 1889
1890/**************************************************
1891 *
1892 * Ramses
1893 *
1894 **************************************************/
1895
1896void Ramses::init ( )
1897{
1898 d->m_vendorstr = "M und N";
1899 d->m_vendor = Vendor_MundN;
1900
1901 QFile f( "/proc/sys/board/ramses" );
1902
1903 d->m_modelstr = "Ramses";
1904 d->m_model = Model_Ramses_MNCI;
1905
1906 d->m_rotation = Rot180;
1907 d->m_direction = CCW;
1908 d->m_holdtime = 1000;
1909
1910 f.setName( "/etc/oz_version" );
1911
1912 if ( f.open( IO_ReadOnly )) {
1913 d->m_systemstr = "OpenEmbedded/Ramses";
1914 d->m_system = System_OpenZaurus;
1915
1916 QTextStream ts ( &f );
1917 ts.setDevice ( &f );
1918 d->m_sysverstr = ts.readLine ( );
1919 f.close ( );
1920 }
1921
1922 m_power_timer = 0;
1923
1924}
1925
1926void Ramses::initButtons ( )
1927{
1928 if ( d->m_buttons )
1929 return;
1930
1931 if ( isQWS( ) )
1932 QWSServer::setKeyboardFilter ( this );
1933
1934 d->m_buttons = new QValueList <ODeviceButton>;
1935
1936 for ( uint i = 0; i < ( sizeof( ramses_buttons ) / sizeof( s_button )); i++ ) {
1937 r_button *rb = ramses_buttons + i;
1938 ODeviceButton b;
1939
1940 if (( rb->model & d->m_model ) == d->m_model ) {
1941 b.setKeycode( rb->code );
1942 b.setUserText( QObject::tr ( "Button", rb->utext ));
1943 b.setPixmap( Resource::loadPixmap ( rb->pix ));
1944 b.setFactoryPresetPressedAction( OQCopMessage ( makeChannel ( rb->fpressedservice ), rb->fpressedaction ));
1945 b.setFactoryPresetHeldAction( OQCopMessage ( makeChannel ( rb->fheldservice ), rb->fheldaction ));
1946
1947 d->m_buttons->append( b );
1948 }
1949 }
1950 reloadButtonMapping();
1951
1952 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1953 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1954}
1955
1956bool Ramses::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1957{
1958 //TODO
1959 return false;
1960}
1961
1962void Ramses::timerEvent ( QTimerEvent * )
1963{
1964 killTimer ( m_power_timer );
1965 m_power_timer = 0;
1966 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1967 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1968}
1969
1970
1971bool Ramses::setSoftSuspend ( bool soft )
1972{
1973 bool res = false;
1974 int fd;
1975
1976 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1977 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1978
1979 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1980
1981 if ( sources >= 0 ) {
1982 if ( soft )
1983 sources &= ~APM_EVT_POWER_BUTTON;
1984 else
1985 sources |= APM_EVT_POWER_BUTTON;
1986
1987 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1988 res = true;
1989 else
1990 perror ( "APM_IOCGEVTSRC" );
1991 }
1992 else
1993 perror ( "APM_IOCGEVTSRC" );
1994
1995 ::close ( fd );
1996 }
1997 else
1998 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1999
2000 return res;
2001}
2002
2003/**
2004 * This sets the display on or off
2005 */
2006bool Ramses::setDisplayStatus ( bool on )
2007{
2008 bool res = false;
2009 int fd;
2010
2011 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
2012 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
2013 ::close ( fd );
2014 }
2015 return res;
2016}
2017
2018
2019bool Ramses::setDisplayBrightness ( int bright )
2020{
2021 qDebug( "ODevice for Ramses: setDisplayBrightness( %d )", bright );
2022 bool res = false;
2023 int fd;
2024
2025 if ( bright > 255 )
2026 bright = 100;
2027 if ( bright < 0 )
2028 bright = 0;
2029
2030 if (( fd = ::open ( "/proc/sys/board/pwm0", O_WRONLY )) >= 0 ) {
2031 char writeCommand[100];
2032 const int count = sprintf( writeCommand, "%d\n", bright);
2033 res = ( ::write ( fd, writeCommand, count ) != -1 );
2034 ::close ( fd );
2035 }
2036 return res;
2037}
2038
2039
2040int Ramses::displayBrightnessResolution ( ) const
2041{
2042 return 100;
2043}
diff --git a/libopie/odevice.h b/libopie/odevice.h
index dcdd4a8..5829440 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -65,4 +65,9 @@ enum OModel {
65 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 65 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
66 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 66 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
67
68 Model_Ramses = ( 4 << 24 ),
69
70 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
71 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
67}; 72};
68 73
@@ -76,4 +81,5 @@ enum OVendor {
76 Vendor_Sharp, 81 Vendor_Sharp,
77 Vendor_SIEMENS, 82 Vendor_SIEMENS,
83 Vendor_MundN,
78}; 84};
79 85