Diffstat (limited to 'libopie2/opiecore/device/odevice_yopy.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_yopy.cpp | 107 |
1 files changed, 29 insertions, 78 deletions
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp index 9d0cdeb..a76f90b 100644 --- a/libopie2/opiecore/device/odevice_yopy.cpp +++ b/libopie2/opiecore/device/odevice_yopy.cpp | |||
@@ -1,26 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
@@ -28,5 +28,5 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice.h" | 30 | #include "odevice_yopy.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
@@ -54,44 +54,7 @@ | |||
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef ARRAY_SIZE | ||
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | ||
63 | |||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | ||
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | ||
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | ||
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | ||
68 | |||
69 | using namespace Opie; | 56 | using namespace Opie; |
70 | 57 | ||
71 | class Yopy : public ODevice | 58 | struct yopy_button yopy_buttons [] = { |
72 | { | ||
73 | protected: | ||
74 | |||
75 | virtual void init(); | ||
76 | virtual void initButtons(); | ||
77 | |||
78 | public: | ||
79 | virtual bool suspend(); | ||
80 | |||
81 | virtual bool setDisplayBrightness ( int b ); | ||
82 | virtual int displayBrightnessResolution() const; | ||
83 | |||
84 | static bool isYopy(); | ||
85 | }; | ||
86 | |||
87 | struct yopy_button { | ||
88 | Qt::Key code; | ||
89 | char *utext; | ||
90 | char *pix; | ||
91 | char *fpressedservice; | ||
92 | char *fpressedaction; | ||
93 | char *fheldservice; | ||
94 | char *fheldaction; | ||
95 | } yopy_buttons [] = { | ||
96 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), | 59 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), |
97 | "devicebuttons/yopy_action", | 60 | "devicebuttons/yopy_action", |
@@ -108,24 +71,4 @@ struct yopy_button { | |||
108 | }; | 71 | }; |
109 | 72 | ||
110 | bool Yopy::isYopy() | ||
111 | { | ||
112 | QFile f( "/proc/cpuinfo" ); | ||
113 | if ( f. open ( IO_ReadOnly ) ) { | ||
114 | QTextStream ts ( &f ); | ||
115 | QString line; | ||
116 | while( line = ts. readLine() ) { | ||
117 | if ( line. left ( 8 ) == "Hardware" ) { | ||
118 | int loc = line. find ( ":" ); | ||
119 | if ( loc != -1 ) { | ||
120 | QString model = | ||
121 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | ||
122 | return ( model == "Yopy" ); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | return false; | ||
128 | } | ||
129 | |||
130 | void Yopy::init() | 73 | void Yopy::init() |
131 | { | 74 | { |
@@ -140,5 +83,6 @@ d->m_system = System_Linupy; | |||
140 | 83 | ||
141 | QFile f ( "/etc/issue" ); | 84 | QFile f ( "/etc/issue" ); |
142 | if ( f. open ( IO_ReadOnly )) { | 85 | if ( f. open ( IO_ReadOnly ) ) |
86 | { | ||
143 | QTextStream ts ( &f ); | 87 | QTextStream ts ( &f ); |
144 | ts.readLine(); | 88 | ts.readLine(); |
@@ -148,4 +92,5 @@ if ( f. open ( IO_ReadOnly )) { | |||
148 | } | 92 | } |
149 | 93 | ||
94 | |||
150 | void Yopy::initButtons() | 95 | void Yopy::initButtons() |
151 | { | 96 | { |
@@ -155,5 +100,6 @@ if ( d->m_buttons ) | |||
155 | d->m_buttons = new QValueList <ODeviceButton>; | 100 | d->m_buttons = new QValueList <ODeviceButton>; |
156 | 101 | ||
157 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { | 102 | for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) |
103 | { | ||
158 | 104 | ||
159 | yopy_button *ib = yopy_buttons + i; | 105 | yopy_button *ib = yopy_buttons + i; |
@@ -178,4 +124,5 @@ connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), | |||
178 | } | 124 | } |
179 | 125 | ||
126 | |||
180 | bool Yopy::suspend() | 127 | bool Yopy::suspend() |
181 | { | 128 | { |
@@ -186,4 +133,5 @@ return false; | |||
186 | } | 133 | } |
187 | 134 | ||
135 | |||
188 | bool Yopy::setDisplayBrightness(int bright) | 136 | bool Yopy::setDisplayBrightness(int bright) |
189 | { | 137 | { |
@@ -191,7 +139,9 @@ bool Yopy::setDisplayBrightness(int bright) | |||
191 | parallel to X, and relies on the existing backlight demon. */ | 139 | parallel to X, and relies on the existing backlight demon. */ |
192 | #if 0 | 140 | #if 0 |
193 | if ( QFile::exists("/proc/sys/pm/light") ) { | 141 | if ( QFile::exists( "/proc/sys/pm/light" ) ) |
142 | { | ||
194 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); | 143 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); |
195 | if (fd >= 0 ) { | 144 | if ( fd >= 0 ) |
145 | { | ||
196 | if (bright) | 146 | if (bright) |
197 | ::write(fd, "1\n", 2); | 147 | ::write(fd, "1\n", 2); |
@@ -206,4 +156,5 @@ return false; | |||
206 | } | 156 | } |
207 | 157 | ||
158 | |||
208 | int Yopy::displayBrightnessResolution() const | 159 | int Yopy::displayBrightnessResolution() const |
209 | { | 160 | { |