author | schurig <schurig> | 2003-06-02 11:12:03 (UTC) |
---|---|---|
committer | schurig <schurig> | 2003-06-02 11:12:03 (UTC) |
commit | 2d6bec942d8b9b8b50639cb4ffe58cf24d5a255b (patch) (unidiff) | |
tree | 5b917d74d600715ad1223f174a9b672d822caf47 /libopie/odevice.cpp | |
parent | 68a88060627137e8cb424c758c1339f1ed5c6eac (diff) | |
download | opie-2d6bec942d8b9b8b50639cb4ffe58cf24d5a255b.zip opie-2d6bec942d8b9b8b50639cb4ffe58cf24d5a255b.tar.gz opie-2d6bec942d8b9b8b50639cb4ffe58cf24d5a255b.tar.bz2 |
new Ramses target
-rw-r--r-- | libopie/odevice.cpp | 197 |
1 files changed, 197 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 | |||
@@ -152,24 +152,43 @@ public: | |||
152 | virtual OLedState ledState ( OLed led ) const; | 152 | virtual OLedState ledState ( OLed led ) const; |
153 | virtual bool setLedState ( OLed led, OLedState st ); | 153 | virtual bool setLedState ( OLed led, OLedState st ); |
154 | 154 | ||
155 | protected: | 155 | protected: |
156 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 156 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
157 | virtual void timerEvent ( QTimerEvent *te ); | 157 | virtual void timerEvent ( QTimerEvent *te ); |
158 | 158 | ||
159 | int m_power_timer; | 159 | int m_power_timer; |
160 | 160 | ||
161 | OLedState m_leds [1]; //FIXME check if really only one | 161 | OLedState m_leds [1]; //FIXME check if really only one |
162 | }; | 162 | }; |
163 | 163 | ||
164 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { | ||
165 | protected: | ||
166 | virtual void init ( ); | ||
167 | virtual void initButtons ( ); | ||
168 | |||
169 | public: | ||
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 | |||
176 | protected: | ||
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 | |||
164 | struct i_button { | 183 | struct i_button { |
165 | uint model; | 184 | uint model; |
166 | Qt::Key code; | 185 | Qt::Key code; |
167 | char *utext; | 186 | char *utext; |
168 | char *pix; | 187 | char *pix; |
169 | char *fpressedservice; | 188 | char *fpressedservice; |
170 | char *fpressedaction; | 189 | char *fpressedaction; |
171 | char *fheldservice; | 190 | char *fheldservice; |
172 | char *fheldaction; | 191 | char *fheldaction; |
173 | } ipaq_buttons [] = { | 192 | } ipaq_buttons [] = { |
174 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 193 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
175 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 194 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
@@ -313,48 +332,72 @@ struct s_button { | |||
313 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 332 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
314 | "devicebuttons/simpad_lower_upper", | 333 | "devicebuttons/simpad_lower_upper", |
315 | "QPE/Launcher", "home()", | 334 | "QPE/Launcher", "home()", |
316 | "buttonsettings", "raise()" }, | 335 | "buttonsettings", "raise()" }, |
317 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 336 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
318 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 337 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
319 | "devicebuttons/simpad_upper_lower", | 338 | "devicebuttons/simpad_upper_lower", |
320 | "QPE/Launcher", "home()", | 339 | "QPE/Launcher", "home()", |
321 | "buttonsettings", "raise()" }, | 340 | "buttonsettings", "raise()" }, |
322 | */ | 341 | */ |
323 | }; | 342 | }; |
324 | 343 | ||
344 | struct 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 | |||
325 | static QCString makeChannel ( const char *str ) | 366 | static QCString makeChannel ( const char *str ) |
326 | { | 367 | { |
327 | if ( str && !::strchr ( str, '/' )) | 368 | if ( str && !::strchr ( str, '/' )) |
328 | return QCString ( "QPE/Application/" ) + str; | 369 | return QCString ( "QPE/Application/" ) + str; |
329 | else | 370 | else |
330 | return str; | 371 | return str; |
331 | } | 372 | } |
332 | 373 | ||
333 | static inline bool isQWS() | 374 | static inline bool isQWS() |
334 | { | 375 | { |
335 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 376 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
336 | } | 377 | } |
337 | 378 | ||
338 | ODevice *ODevice::inst ( ) | 379 | ODevice *ODevice::inst ( ) |
339 | { | 380 | { |
340 | static ODevice *dev = 0; | 381 | static ODevice *dev = 0; |
341 | 382 | ||
342 | if ( !dev ) { | 383 | if ( !dev ) { |
343 | if ( QFile::exists ( "/proc/hal/model" )) | 384 | if ( QFile::exists ( "/proc/hal/model" )) |
344 | dev = new iPAQ ( ); | 385 | dev = new iPAQ ( ); |
345 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 386 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
346 | dev = new Zaurus ( ); | 387 | dev = new Zaurus ( ); |
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 ( ); |
351 | 394 | ||
352 | dev-> init ( ); | 395 | dev-> init ( ); |
353 | } | 396 | } |
354 | return dev; | 397 | return dev; |
355 | } | 398 | } |
356 | 399 | ||
357 | 400 | ||
358 | /************************************************** | 401 | /************************************************** |
359 | * | 402 | * |
360 | * common | 403 | * common |
@@ -1835,12 +1878,166 @@ int SIMpad::displayBrightnessResolution ( ) const | |||
1835 | switch ( model ( )) { | 1878 | switch ( model ( )) { |
1836 | case Model_SIMpad_CL4: | 1879 | case Model_SIMpad_CL4: |
1837 | case Model_SIMpad_SL4: | 1880 | case Model_SIMpad_SL4: |
1838 | case Model_SIMpad_SLC: | 1881 | case Model_SIMpad_SLC: |
1839 | case Model_SIMpad_TSinus: | 1882 | case Model_SIMpad_TSinus: |
1840 | return 255; //TODO find out if this is save | 1883 | return 255; //TODO find out if this is save |
1841 | 1884 | ||
1842 | default: | 1885 | default: |
1843 | return 2; | 1886 | return 2; |
1844 | } | 1887 | } |
1845 | } | 1888 | } |
1846 | 1889 | ||
1890 | /************************************************** | ||
1891 | * | ||
1892 | * Ramses | ||
1893 | * | ||
1894 | **************************************************/ | ||
1895 | |||
1896 | void 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 | |||
1926 | void 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 | |||
1956 | bool Ramses::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | ||
1957 | { | ||
1958 | //TODO | ||
1959 | return false; | ||
1960 | } | ||
1961 | |||
1962 | void 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 | |||
1971 | bool 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 | */ | ||
2006 | bool 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 | |||
2019 | bool 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 | |||
2040 | int Ramses::displayBrightnessResolution ( ) const | ||
2041 | { | ||
2042 | return 100; | ||
2043 | } | ||