-rw-r--r-- | libopie2/opiecore/oinputsystem.cpp | 15 | ||||
-rw-r--r-- | libopie2/opiecore/oinputsystem.h | 7 |
2 files changed, 19 insertions, 3 deletions
diff --git a/libopie2/opiecore/oinputsystem.cpp b/libopie2/opiecore/oinputsystem.cpp index bfdc31f..fde36c3 100644 --- a/libopie2/opiecore/oinputsystem.cpp +++ b/libopie2/opiecore/oinputsystem.cpp @@ -42,2 +42,7 @@ using namespace Opie::Core; #define BUFSIZE 256 +#define BIT_MASK( name, numbits ) \ + unsigned short name[ ((numbits) - 1) / (sizeof( short ) * 8) + 1 ]; \ + memset( name, 0, sizeof( name ) ) +#define BIT_TEST( bitmask, bit ) \ + ( bitmask[ (bit) / sizeof(short) / 8 ] & (1u << ( (bit) % (sizeof(short) * 8))) ) @@ -142 +147,11 @@ QString OInputDevice::uniq() const +bool OInputDevice::hasFeature( Feature bit ) const +{ + BIT_MASK( features, EV_MAX ); + + if( ioctl( _fd, EVIOCGBIT( 0, EV_MAX ), features) < 0 ) + return false; + else + return BIT_TEST( features, bit ); +} + diff --git a/libopie2/opiecore/oinputsystem.h b/libopie2/opiecore/oinputsystem.h index 350656b..4d913a1 100644 --- a/libopie2/opiecore/oinputsystem.h +++ b/libopie2/opiecore/oinputsystem.h @@ -95,6 +95,6 @@ class OInputDevice : public QObject - enum EventType + enum Feature { Synchronous = EV_SYN, - Keyboard = EV_KEY, + Keys = EV_KEY, Relative = EV_REL, @@ -102,3 +102,3 @@ class OInputDevice : public QObject Miscellaneous = EV_MSC, - Led = EV_LED, + Leds = EV_LED, Sound = EV_SND, @@ -136,2 +136,3 @@ class OInputDevice : public QObject QString uniq() const; + bool hasFeature( Feature ) const; |