From cde931654d1966be6989e6c8f3cfacb23e6822a2 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Wed, 31 Aug 2005 10:21:12 +0000 Subject: - add support for the new Switches type in the Linux Input System (coming with 2.6.14) - use the new Switches support to rewrite the hinge sensor handling on Zaurus models w/ 2.6 - add Switches support to SysInfo, OInputSystem, oinputsystemdemo --- (limited to 'libopie2/opiecore/linux/oinputsystem.cpp') 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 @@ -188,6 +188,22 @@ bool OInputDevice::isHeld( Key bit ) const } +bool OInputDevice::isHeld( Switch bit ) const +{ + BIT_MASK( switches, SW_MAX ); + + if( ioctl( _fd, EVIOCGSW( sizeof(switches) ), switches ) < 0 ) + { + perror( "EVIOCGSW" ); + return false; + } + else + { + return BIT_TEST( switches, bit ); + } +} + + QString OInputDevice::globalKeyMask() const { BIT_MASK( keys, KEY_MAX ); @@ -210,6 +226,28 @@ QString OInputDevice::globalKeyMask() const } +QString OInputDevice::globalSwitchMask() const +{ + BIT_MASK( switches, SW_MAX ); + + if( ioctl( _fd, EVIOCGSW( sizeof(switches) ), switches ) < 0 ) + { + perror( "EVIOCGSW" ); + return QString::null; + } + else + { + QString switchmask; + for ( int i = 0; i < SW_MAX; ++i ) + { + if ( BIT_TEST( switches, i ) ) switchmask.append( QString().sprintf( "%0d, ", i ) ); + } + return switchmask; + + } +} + + bool OInputDevice::isValid( const QString& path ) { char buf[BUFSIZE] = ""; -- cgit v0.9.0.2