-rw-r--r-- | libopie/odevice.cpp | 77 |
1 files changed, 26 insertions, 51 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 993aedf..62dc9d4 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -908,33 +908,34 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | |||
908 | if ( button >= (int) d-> m_buttons-> count ( )) | 908 | if ( button >= (int) d-> m_buttons-> count ( )) |
909 | return; | 909 | return; |
910 | 910 | ||
911 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 911 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
912 | b. setHeldAction ( action ); | 912 | b. setHeldAction ( action ); |
913 | 913 | ||
914 | Config buttonFile ( "ButtonSettings" ); | 914 | Config buttonFile ( "ButtonSettings" ); |
915 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 915 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
918 | 918 | ||
919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
920 | 920 | ||
921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
922 | } | 922 | } |
923 | void ODevice::virtual_hook( int id, void* data ) { | 923 | void ODevice::virtual_hook( int id, void* data ) { |
924 | 924 | Q_UNUSED(id); | |
925 | Q_UNUSED(data); | ||
925 | } | 926 | } |
926 | 927 | ||
927 | 928 | ||
928 | 929 | ||
929 | /************************************************** | 930 | /************************************************** |
930 | * | 931 | * |
931 | * iPAQ | 932 | * iPAQ |
932 | * | 933 | * |
933 | **************************************************/ | 934 | **************************************************/ |
934 | 935 | ||
935 | void iPAQ::init ( ) | 936 | void iPAQ::init ( ) |
936 | { | 937 | { |
937 | d-> m_vendorstr = "HP"; | 938 | d-> m_vendorstr = "HP"; |
938 | d-> m_vendor = Vendor_HP; | 939 | d-> m_vendor = Vendor_HP; |
939 | 940 | ||
940 | QFile f ( "/proc/hal/model" ); | 941 | QFile f ( "/proc/hal/model" ); |
@@ -1960,33 +1961,34 @@ int SIMpad::displayBrightnessResolution ( ) const | |||
1960 | /************************************************** | 1961 | /************************************************** |
1961 | * | 1962 | * |
1962 | * Ramses | 1963 | * Ramses |
1963 | * | 1964 | * |
1964 | **************************************************/ | 1965 | **************************************************/ |
1965 | 1966 | ||
1966 | void Ramses::init() | 1967 | void Ramses::init() |
1967 | { | 1968 | { |
1968 | d->m_vendorstr = "M und N"; | 1969 | d->m_vendorstr = "M und N"; |
1969 | d->m_vendor = Vendor_MundN; | 1970 | d->m_vendor = Vendor_MundN; |
1970 | 1971 | ||
1971 | QFile f("/proc/sys/board/ramses"); | 1972 | QFile f("/proc/sys/board/ramses"); |
1972 | 1973 | ||
1973 | d->m_modelstr = "Ramses"; | 1974 | d->m_modelstr = "Ramses"; |
1974 | d->m_model = Model_Ramses_MNCI; | 1975 | d->m_model = Model_Ramses_MNCI; |
1975 | 1976 | ||
1976 | d->m_rotation = Rot0; | 1977 | d->m_rotation = Rot180; |
1978 | d->m_direction = CW; | ||
1977 | d->m_holdtime = 1000; | 1979 | d->m_holdtime = 1000; |
1978 | 1980 | ||
1979 | f.setName("/etc/oz_version"); | 1981 | f.setName("/etc/oz_version"); |
1980 | 1982 | ||
1981 | if (f.open(IO_ReadOnly)) { | 1983 | if (f.open(IO_ReadOnly)) { |
1982 | d->m_systemstr = "OpenEmbedded/Ramses"; | 1984 | d->m_systemstr = "OpenEmbedded/Ramses"; |
1983 | d->m_system = System_OpenZaurus; | 1985 | d->m_system = System_OpenZaurus; |
1984 | 1986 | ||
1985 | QTextStream ts(&f); | 1987 | QTextStream ts(&f); |
1986 | ts.setDevice(&f); | 1988 | ts.setDevice(&f); |
1987 | d->m_sysverstr = ts.readLine(); | 1989 | d->m_sysverstr = ts.readLine(); |
1988 | f.close(); | 1990 | f.close(); |
1989 | } | 1991 | } |
1990 | 1992 | ||
1991 | m_power_timer = 0; | 1993 | m_power_timer = 0; |
1992 | 1994 | ||
@@ -2019,150 +2021,123 @@ bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, b | |||
2019 | Q_UNUSED( isPress ); | 2021 | Q_UNUSED( isPress ); |
2020 | Q_UNUSED( autoRepeat ); | 2022 | Q_UNUSED( autoRepeat ); |
2021 | return false; | 2023 | return false; |
2022 | } | 2024 | } |
2023 | 2025 | ||
2024 | void Ramses::timerEvent(QTimerEvent *) | 2026 | void Ramses::timerEvent(QTimerEvent *) |
2025 | { | 2027 | { |
2026 | killTimer(m_power_timer); | 2028 | killTimer(m_power_timer); |
2027 | m_power_timer = 0; | 2029 | m_power_timer = 0; |
2028 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 2030 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
2029 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 2031 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
2030 | } | 2032 | } |
2031 | 2033 | ||
2032 | 2034 | ||
2033 | bool Ramses::setSoftSuspend(bool soft) | 2035 | bool Ramses::setSoftSuspend(bool soft) |
2034 | { | 2036 | { |
2035 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 2037 | Q_UNUSED(soft); |
2036 | #if 0 | ||
2037 | bool res = false; | ||
2038 | int fd; | ||
2039 | |||
2040 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | ||
2041 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | ||
2042 | |||
2043 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | ||
2044 | |||
2045 | if (sources >= 0) { | ||
2046 | if (soft) | ||
2047 | sources &= ~APM_EVT_POWER_BUTTON; | ||
2048 | else | ||
2049 | sources |= APM_EVT_POWER_BUTTON; | ||
2050 | |||
2051 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | ||
2052 | res = true; | ||
2053 | else | ||
2054 | perror("APM_IOCGEVTSRC"); | ||
2055 | } | ||
2056 | else | ||
2057 | perror("APM_IOCGEVTSRC"); | ||
2058 | |||
2059 | ::close(fd); | ||
2060 | } | ||
2061 | else | ||
2062 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | ||
2063 | |||
2064 | return res; | ||
2065 | #else | ||
2066 | return true; | 2038 | return true; |
2067 | #endif | ||
2068 | } | 2039 | } |
2069 | 2040 | ||
2070 | bool Ramses::suspend ( ) | 2041 | bool Ramses::suspend ( ) |
2071 | { | 2042 | { |
2072 | qDebug("Ramses::suspend"); | 2043 | //qDebug("Ramses::suspend()"); |
2044 | if ( !isQWS() ) // only qwsserver is allowed to suspend | ||
2073 | return false; | 2045 | return false; |
2046 | |||
2047 | bool res = false; | ||
2048 | int fd; | ||
2049 | |||
2050 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { | ||
2051 | res = ( ::write ( fd, "1", 1 ) != -1 ); | ||
2052 | ::close(fd); | ||
2053 | } | ||
2054 | return res; | ||
2074 | } | 2055 | } |
2075 | 2056 | ||
2076 | /** | 2057 | /** |
2077 | * This sets the display on or off | 2058 | * This sets the display on or off |
2078 | */ | 2059 | */ |
2079 | bool Ramses::setDisplayStatus(bool on) | 2060 | bool Ramses::setDisplayStatus(bool on) |
2080 | { | 2061 | { |
2081 | qDebug("Ramses::setDisplayStatus(%d)", on); | 2062 | //qDebug("Ramses::setDisplayStatus(%d)", on); |
2082 | #if 0 | ||
2083 | bool res = false; | 2063 | bool res = false; |
2084 | int fd; | 2064 | int fd; |
2085 | 2065 | ||
2086 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { | 2066 | if ((fd = ::open ("/dev/fb/1", O_RDWR)) >= 0) { |
2087 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2067 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2088 | ::close(fd); | 2068 | ::close(fd); |
2089 | } | 2069 | } |
2090 | return res; | 2070 | return res; |
2091 | #else | ||
2092 | return true; | ||
2093 | #endif | ||
2094 | } | 2071 | } |
2095 | 2072 | ||
2096 | 2073 | ||
2097 | /* | 2074 | /* |
2098 | * We get something between 0..255 into us | 2075 | * We get something between 0..255 into us |
2099 | */ | 2076 | */ |
2100 | bool Ramses::setDisplayBrightness(int bright) | 2077 | bool Ramses::setDisplayBrightness(int bright) |
2101 | { | 2078 | { |
2102 | qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2079 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2103 | bool res = false; | 2080 | bool res = false; |
2104 | int fd; | 2081 | int fd; |
2105 | 2082 | ||
2106 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2083 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2107 | 2084 | ||
2108 | if (bright > 255 ) | 2085 | if (bright > 255 ) |
2109 | bright = 255; | 2086 | bright = 255; |
2110 | if (bright < 0) | 2087 | if (bright < 0) |
2111 | bright = 0; | 2088 | bright = 0; |
2112 | 2089 | ||
2113 | // Turn backlight completely off | 2090 | // Turn backlight completely off |
2114 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 2091 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
2115 | char writeCommand[10]; | 2092 | char writeCommand[10]; |
2116 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 2093 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
2117 | res = (::write(fd, writeCommand, count) != -1); | 2094 | res = (::write(fd, writeCommand, count) != -1); |
2118 | ::close(fd); | 2095 | ::close(fd); |
2119 | } | 2096 | } |
2120 | 2097 | ||
2121 | // scale backlight brightness to hardware | 2098 | // scale backlight brightness to hardware |
2122 | bright = 500-(bright * 500 / 255); | 2099 | if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { |
2123 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2100 | //qDebug(" %d -> pwm1", bright); |
2124 | qDebug(" %d -> pwm1", bright); | ||
2125 | char writeCommand[100]; | 2101 | char writeCommand[100]; |
2126 | const int count = sprintf(writeCommand, "%d\n", bright); | 2102 | const int count = sprintf(writeCommand, "%d\n", bright); |
2127 | res = (::write(fd, writeCommand, count) != -1); | 2103 | res = (::write(fd, writeCommand, count) != -1); |
2128 | ::close(fd); | 2104 | ::close(fd); |
2129 | } | 2105 | } |
2130 | return res; | 2106 | return res; |
2131 | } | 2107 | } |
2132 | 2108 | ||
2133 | 2109 | ||
2134 | int Ramses::displayBrightnessResolution() const | 2110 | int Ramses::displayBrightnessResolution() const |
2135 | { | 2111 | { |
2136 | return 32; | 2112 | return 256; |
2137 | } | 2113 | } |
2138 | 2114 | ||
2139 | bool Ramses::setDisplayContrast(int contr) | 2115 | bool Ramses::setDisplayContrast(int contr) |
2140 | { | 2116 | { |
2141 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2117 | //qDebug("Ramses::setDisplayContrast(%d)", contr); |
2142 | bool res = false; | 2118 | bool res = false; |
2143 | int fd; | 2119 | int fd; |
2144 | 2120 | ||
2145 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2121 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2146 | 2122 | ||
2147 | if (contr > 255 ) | 2123 | if (contr > 255 ) |
2148 | contr = 255; | 2124 | contr = 255; |
2149 | if (contr < 0) | 2125 | if (contr < 0) |
2150 | contr = 0; | 2126 | contr = 0; |
2151 | contr = 90 - (contr * 20 / 255); | ||
2152 | 2127 | ||
2153 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2128 | if ((fd = ::open("/proc/sys/board/lcd_contrast", O_WRONLY)) >= 0) { |
2154 | qDebug(" %d -> pwm0", contr); | 2129 | //qDebug(" %d -> pwm0", contr); |
2155 | char writeCommand[100]; | 2130 | char writeCommand[100]; |
2156 | const int count = sprintf(writeCommand, "%d\n", contr); | 2131 | const int count = sprintf(writeCommand, "%d\n", contr); |
2157 | res = (::write(fd, writeCommand, count) != -1); | 2132 | res = (::write(fd, writeCommand, count) != -1); |
2158 | res = true; | 2133 | res = true; |
2159 | ::close(fd); | 2134 | ::close(fd); |
2160 | } | 2135 | } |
2161 | return res; | 2136 | return res; |
2162 | } | 2137 | } |
2163 | 2138 | ||
2164 | 2139 | ||
2165 | int Ramses::displayContrastResolution() const | 2140 | int Ramses::displayContrastResolution() const |
2166 | { | 2141 | { |
2167 | return 20; | 2142 | return 256; |
2168 | } | 2143 | } |