author | mickeyl <mickeyl> | 2005-02-02 16:37:12 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-02-02 16:37:12 (UTC) |
commit | 8ea35f618c5811b59f4460d0f2198b9818db281e (patch) (side-by-side diff) | |
tree | 0ef5a73e14c9b236dde77cb866401ab0ad3a103f /libopie2 | |
parent | 896b1f8f0855feec3bb6cb9944c5f7a7b2d6cd1f (diff) | |
download | opie-8ea35f618c5811b59f4460d0f2198b9818db281e.zip opie-8ea35f618c5811b59f4460d0f2198b9818db281e.tar.gz opie-8ea35f618c5811b59f4460d0f2198b9818db281e.tar.bz2 |
more input system stuff
-rw-r--r-- | libopie2/opiecore/oinputsystem.cpp | 17 | ||||
-rw-r--r-- | libopie2/opiecore/oinputsystem.h | 7 |
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 @@ -30,25 +30,30 @@ using namespace Opie::Core; /* QT */ #include <qfile.h> /* STD */ #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; OInputSystem::OInputSystem() : QObject() { qDebug( "OInputSystem::OInputSystem()" ); synchronize(); } @@ -131,12 +136,22 @@ QString OInputDevice::path() const ::ioctl( _fd, EVIOCGPHYS(sizeof buf), buf ); return buf; } 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 @@ -84,32 +84,32 @@ class OInputSystem : public QObject protected: OInputSystem(); static OInputSystem* _instance; DeviceMap _devices; }; 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, }; enum Bus { PCI = BUS_PCI, ISAPNP = BUS_ISAPNP, HIL = BUS_HIL, @@ -125,24 +125,25 @@ class OInputDevice : public QObject I2C = BUS_I2C, HOST = BUS_HOST, }; public: OInputDevice( QObject* parent, const char* name = 0 ); ~OInputDevice(); public: QString identity() const; QString path() const; QString uniq() const; + bool hasFeature( Feature ) const; private: int _fd; input_id _id; }; } } #endif // OINPUTSYSTEM_H |