-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 | |||
@@ -36,13 +36,18 @@ using namespace Opie::Core; | |||
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; |
@@ -137,6 +142,16 @@ 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 | |||
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 | |||
90 | 90 | ||
91 | 91 | ||
92 | class OInputDevice : public QObject | 92 | class OInputDevice : public QObject |
93 | { | 93 | { |
94 | public: | 94 | public: |
95 | 95 | ||
96 | enum EventType | 96 | enum Feature |
97 | { | 97 | { |
98 | Synchronous = EV_SYN, | 98 | Synchronous = EV_SYN, |
99 | Keyboard = EV_KEY, | 99 | Keys = EV_KEY, |
100 | Relative = EV_REL, | 100 | Relative = EV_REL, |
101 | Absolute = EV_ABS, | 101 | Absolute = EV_ABS, |
102 | Miscellaneous = EV_MSC, | 102 | Miscellaneous = EV_MSC, |
103 | Led = EV_LED, | 103 | Leds = EV_LED, |
104 | Sound = EV_SND, | 104 | Sound = EV_SND, |
105 | AutoRepeat = EV_REP, | 105 | AutoRepeat = EV_REP, |
106 | ForceFeedback = EV_FF, | 106 | ForceFeedback = EV_FF, |
107 | PowerManagement = EV_PWR, | 107 | PowerManagement = EV_PWR, |
108 | ForceFeedbackStatus = EV_FF_STATUS, | 108 | ForceFeedbackStatus = EV_FF_STATUS, |
109 | }; | 109 | }; |
@@ -131,12 +131,13 @@ class OInputDevice : public QObject | |||
131 | ~OInputDevice(); | 131 | ~OInputDevice(); |
132 | 132 | ||
133 | public: | 133 | public: |
134 | QString identity() const; | 134 | QString identity() const; |
135 | QString path() const; | 135 | QString path() const; |
136 | QString uniq() const; | 136 | QString uniq() const; |
137 | bool hasFeature( Feature ) const; | ||
137 | 138 | ||
138 | private: | 139 | private: |
139 | int _fd; | 140 | int _fd; |
140 | input_id _id; | 141 | input_id _id; |
141 | 142 | ||
142 | }; | 143 | }; |