summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oinputsystem.cpp17
-rw-r--r--libopie2/opiecore/oinputsystem.h7
2 files changed, 20 insertions, 4 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
@@ -36,13 +36,18 @@ using namespace Opie::Core;
#include <errno.h>
#include <string.h>
#include <linux/input.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
-#define BUFSIZE 256
+#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))) )
/*======================================================================================
* OInputSystem
*======================================================================================*/
OInputSystem* OInputSystem::_instance = 0;
@@ -137,6 +142,16 @@ QString OInputDevice::uniq() const
{
char buf[BUFSIZE] = "<unknown>";
::ioctl( _fd, EVIOCGUNIQ(sizeof buf), buf );
return buf;
}
+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
@@ -90,20 +90,20 @@ class OInputSystem : public QObject
class OInputDevice : public QObject
{
public:
- enum EventType
+ enum Feature
{
Synchronous = EV_SYN,
- Keyboard = EV_KEY,
+ Keys = EV_KEY,
Relative = EV_REL,
Absolute = EV_ABS,
Miscellaneous = EV_MSC,
- Led = EV_LED,
+ Leds = EV_LED,
Sound = EV_SND,
AutoRepeat = EV_REP,
ForceFeedback = EV_FF,
PowerManagement = EV_PWR,
ForceFeedbackStatus = EV_FF_STATUS,
};
@@ -131,12 +131,13 @@ class OInputDevice : public QObject
~OInputDevice();
public:
QString identity() const;
QString path() const;
QString uniq() const;
+ bool hasFeature( Feature ) const;
private:
int _fd;
input_id _id;
};