author | mickeyl <mickeyl> | 2005-02-02 16:37:12 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-02-02 16:37:12 (UTC) |
commit | 8ea35f618c5811b59f4460d0f2198b9818db281e (patch) (unidiff) | |
tree | 0ef5a73e14c9b236dde77cb866401ab0ad3a103f /libopie2/opiecore/oinputsystem.cpp | |
parent | 896b1f8f0855feec3bb6cb9944c5f7a7b2d6cd1f (diff) | |
download | opie-8ea35f618c5811b59f4460d0f2198b9818db281e.zip opie-8ea35f618c5811b59f4460d0f2198b9818db281e.tar.gz opie-8ea35f618c5811b59f4460d0f2198b9818db281e.tar.bz2 |
more input system stuff
Diffstat (limited to 'libopie2/opiecore/oinputsystem.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/oinputsystem.cpp | 15 |
1 files changed, 15 insertions, 0 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 | |||
@@ -31,24 +31,29 @@ using namespace Opie::Core; | |||
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | 34 | ||
35 | /* STD */ | 35 | /* STD */ |
36 | #include <errno.h> | 36 | #include <errno.h> |
37 | #include <string.h> | 37 | #include <string.h> |
38 | #include <linux/input.h> | 38 | #include <linux/input.h> |
39 | #include <sys/fcntl.h> | 39 | #include <sys/fcntl.h> |
40 | #include <sys/ioctl.h> | 40 | #include <sys/ioctl.h> |
41 | 41 | ||
42 | #define BUFSIZE 256 | 42 | #define BUFSIZE 256 |
43 | #define BIT_MASK( name, numbits ) \ | ||
44 | unsigned short name[ ((numbits) - 1) / (sizeof( short ) * 8) + 1 ]; \ | ||
45 | memset( name, 0, sizeof( name ) ) | ||
46 | #define BIT_TEST( bitmask, bit ) \ | ||
47 | ( bitmask[ (bit) / sizeof(short) / 8 ] & (1u << ( (bit) % (sizeof(short) * 8))) ) | ||
43 | 48 | ||
44 | /*====================================================================================== | 49 | /*====================================================================================== |
45 | * OInputSystem | 50 | * OInputSystem |
46 | *======================================================================================*/ | 51 | *======================================================================================*/ |
47 | 52 | ||
48 | OInputSystem* OInputSystem::_instance = 0; | 53 | OInputSystem* OInputSystem::_instance = 0; |
49 | 54 | ||
50 | OInputSystem::OInputSystem() : QObject() | 55 | OInputSystem::OInputSystem() : QObject() |
51 | { | 56 | { |
52 | qDebug( "OInputSystem::OInputSystem()" ); | 57 | qDebug( "OInputSystem::OInputSystem()" ); |
53 | synchronize(); | 58 | synchronize(); |
54 | } | 59 | } |
@@ -131,12 +136,22 @@ QString OInputDevice::path() const | |||
131 | ::ioctl( _fd, EVIOCGPHYS(sizeof buf), buf ); | 136 | ::ioctl( _fd, EVIOCGPHYS(sizeof buf), buf ); |
132 | return buf; | 137 | return buf; |
133 | } | 138 | } |
134 | 139 | ||
135 | 140 | ||
136 | QString OInputDevice::uniq() const | 141 | QString OInputDevice::uniq() const |
137 | { | 142 | { |
138 | char buf[BUFSIZE] = "<unknown>"; | 143 | char buf[BUFSIZE] = "<unknown>"; |
139 | ::ioctl( _fd, EVIOCGUNIQ(sizeof buf), buf ); | 144 | ::ioctl( _fd, EVIOCGUNIQ(sizeof buf), buf ); |
140 | return buf; | 145 | return buf; |
141 | } | 146 | } |
142 | 147 | ||
148 | bool OInputDevice::hasFeature( Feature bit ) const | ||
149 | { | ||
150 | BIT_MASK( features, EV_MAX ); | ||
151 | |||
152 | if( ioctl( _fd, EVIOCGBIT( 0, EV_MAX ), features) < 0 ) | ||
153 | return false; | ||
154 | else | ||
155 | return BIT_TEST( features, bit ); | ||
156 | } | ||
157 | |||