Diffstat (limited to 'libopie2/opiecore/linux/oinputsystem.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/linux/oinputsystem.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libopie2/opiecore/linux/oinputsystem.cpp b/libopie2/opiecore/linux/oinputsystem.cpp index bad27ed..ebc417f 100644 --- a/libopie2/opiecore/linux/oinputsystem.cpp +++ b/libopie2/opiecore/linux/oinputsystem.cpp | |||
@@ -185,12 +185,28 @@ bool OInputDevice::isHeld( Key bit ) const | |||
185 | { | 185 | { |
186 | return BIT_TEST( keys, bit ); | 186 | return BIT_TEST( keys, bit ); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | bool OInputDevice::isHeld( Switch bit ) const | ||
192 | { | ||
193 | BIT_MASK( switches, SW_MAX ); | ||
194 | |||
195 | if( ioctl( _fd, EVIOCGSW( sizeof(switches) ), switches ) < 0 ) | ||
196 | { | ||
197 | perror( "EVIOCGSW" ); | ||
198 | return false; | ||
199 | } | ||
200 | else | ||
201 | { | ||
202 | return BIT_TEST( switches, bit ); | ||
203 | } | ||
204 | } | ||
205 | |||
206 | |||
191 | QString OInputDevice::globalKeyMask() const | 207 | QString OInputDevice::globalKeyMask() const |
192 | { | 208 | { |
193 | BIT_MASK( keys, KEY_MAX ); | 209 | BIT_MASK( keys, KEY_MAX ); |
194 | 210 | ||
195 | if( ioctl( _fd, EVIOCGKEY( sizeof(keys) ), keys ) < 0 ) | 211 | if( ioctl( _fd, EVIOCGKEY( sizeof(keys) ), keys ) < 0 ) |
196 | { | 212 | { |
@@ -207,12 +223,34 @@ QString OInputDevice::globalKeyMask() const | |||
207 | return keymask; | 223 | return keymask; |
208 | 224 | ||
209 | } | 225 | } |
210 | } | 226 | } |
211 | 227 | ||
212 | 228 | ||
229 | QString OInputDevice::globalSwitchMask() const | ||
230 | { | ||
231 | BIT_MASK( switches, SW_MAX ); | ||
232 | |||
233 | if( ioctl( _fd, EVIOCGSW( sizeof(switches) ), switches ) < 0 ) | ||
234 | { | ||
235 | perror( "EVIOCGSW" ); | ||
236 | return QString::null; | ||
237 | } | ||
238 | else | ||
239 | { | ||
240 | QString switchmask; | ||
241 | for ( int i = 0; i < SW_MAX; ++i ) | ||
242 | { | ||
243 | if ( BIT_TEST( switches, i ) ) switchmask.append( QString().sprintf( "%0d, ", i ) ); | ||
244 | } | ||
245 | return switchmask; | ||
246 | |||
247 | } | ||
248 | } | ||
249 | |||
250 | |||
213 | bool OInputDevice::isValid( const QString& path ) | 251 | bool OInputDevice::isValid( const QString& path ) |
214 | { | 252 | { |
215 | char buf[BUFSIZE] = "<unknown>"; | 253 | char buf[BUFSIZE] = "<unknown>"; |
216 | int fd = ::open( (const char*) path, O_RDONLY ); | 254 | int fd = ::open( (const char*) path, O_RDONLY ); |
217 | if ( fd < 0 ) return false; | 255 | if ( fd < 0 ) return false; |
218 | int res = ::ioctl( fd, EVIOCGNAME(sizeof buf), buf ); | 256 | int res = ::ioctl( fd, EVIOCGNAME(sizeof buf), buf ); |