summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-02-04 15:00:52 (UTC)
committer mickeyl <mickeyl>2005-02-04 15:00:52 (UTC)
commit41886a2bfe003d715ad8fe48011d054c2ba0a779 (patch) (unidiff)
tree709abfef22d2052574d3517deae3949d1dce37fd
parent93f9fcf5bbcecaf8c7c4070e42676d24caa12d87 (diff)
downloadopie-41886a2bfe003d715ad8fe48011d054c2ba0a779.zip
opie-41886a2bfe003d715ad8fe48011d054c2ba0a779.tar.gz
opie-41886a2bfe003d715ad8fe48011d054c2ba0a779.tar.bz2
show which bits are set in global keymask
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/oinputsystem.cpp25
-rw-r--r--libopie2/opiecore/oinputsystem.h23
2 files changed, 47 insertions, 1 deletions
diff --git a/libopie2/opiecore/oinputsystem.cpp b/libopie2/opiecore/oinputsystem.cpp
index 29de35c..d1a28f5 100644
--- a/libopie2/opiecore/oinputsystem.cpp
+++ b/libopie2/opiecore/oinputsystem.cpp
@@ -141,32 +141,57 @@ QString OInputDevice::uniq() const
141{ 141{
142 char buf[BUFSIZE] = "<unknown>"; 142 char buf[BUFSIZE] = "<unknown>";
143 ::ioctl( _fd, EVIOCGUNIQ(sizeof buf), buf ); 143 ::ioctl( _fd, EVIOCGUNIQ(sizeof buf), buf );
144 return buf; 144 return buf;
145} 145}
146 146
147 147
148bool OInputDevice::hasFeature( Feature bit ) const 148bool OInputDevice::hasFeature( Feature bit ) const
149{ 149{
150 BIT_MASK( features, EV_MAX ); 150 BIT_MASK( features, EV_MAX );
151 151
152 if( ioctl( _fd, EVIOCGBIT( 0, EV_MAX ), features) < 0 ) 152 if( ioctl( _fd, EVIOCGBIT( 0, EV_MAX ), features) < 0 )
153 {
154 perror( "EVIOCGBIT" );
153 return false; 155 return false;
156 }
154 else 157 else
155 return BIT_TEST( features, bit ); 158 return BIT_TEST( features, bit );
156} 159}
157 160
158 161
159bool OInputDevice::isHeld( Key bit ) const 162bool OInputDevice::isHeld( Key bit ) const
160{ 163{
161 BIT_MASK( keys, KEY_MAX ); 164 BIT_MASK( keys, KEY_MAX );
162 165
163 if( ioctl( _fd, EVIOCGKEY( sizeof(keys) ), keys ) < 0 ) 166 if( ioctl( _fd, EVIOCGKEY( sizeof(keys) ), keys ) < 0 )
164 { 167 {
165 perror( "EVIOCGKEY" ); 168 perror( "EVIOCGKEY" );
166 return false; 169 return false;
167 } 170 }
168 else 171 else
169 { 172 {
170 return BIT_TEST( keys, bit ); 173 return BIT_TEST( keys, bit );
171 } 174 }
172} 175}
176
177
178QString OInputDevice::globalKeyMask() const
179{
180 BIT_MASK( keys, KEY_MAX );
181
182 if( ioctl( _fd, EVIOCGKEY( sizeof(keys) ), keys ) < 0 )
183 {
184 perror( "EVIOCGKEY" );
185 }
186 else
187 {
188 QString keymask;
189 for ( int i = 0; i < KEY_MAX; ++i )
190 {
191 if ( BIT_TEST( keys, i ) ) keymask.append( QString().sprintf( "%0d, ", i ) );
192 }
193 return keymask;
194
195 }
196}
197
diff --git a/libopie2/opiecore/oinputsystem.h b/libopie2/opiecore/oinputsystem.h
index 9020bc1..7919610 100644
--- a/libopie2/opiecore/oinputsystem.h
+++ b/libopie2/opiecore/oinputsystem.h
@@ -67,50 +67,71 @@ class OInputSystem : public QObject
67 DeviceIterator iterator() const; 67 DeviceIterator iterator() const;
68 /** 68 /**
69 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found 69 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found
70 * @see OAudioInterface 70 * @see OAudioInterface
71 */ 71 */
72 OInputDevice* device( const QString& interface ) const; 72 OInputDevice* device( const QString& interface ) const;
73 /** 73 /**
74 * @internal Rebuild the internal interface database 74 * @internal Rebuild the internal interface database
75 * @note Sometimes it might be useful to call this from client code, 75 * @note Sometimes it might be useful to call this from client code,
76 */ 76 */
77 void synchronize(); 77 void synchronize();
78 /** 78 /**
79 * @internal desctructor 79 * @internal destructor
80 */ 80 */
81 ~OInputSystem(); 81 ~OInputSystem();
82 82
83 protected: 83 protected:
84 OInputSystem(); 84 OInputSystem();
85 85
86 static OInputSystem* _instance; 86 static OInputSystem* _instance;
87 DeviceMap _devices; 87 DeviceMap _devices;
88}; 88};
89 89
90 90
91class OInputDevice : public QObject 91class OInputDevice : public QObject
92{ 92{
93 public: 93 public:
94 OInputDevice( QObject* parent, const char* name = 0 ); 94 OInputDevice( QObject* parent, const char* name = 0 );
95 ~OInputDevice(); 95 ~OInputDevice();
96 96
97 #include "oinputsystemenums.h" 97 #include "oinputsystemenums.h"
98 98
99 public: 99 public:
100 /**
101 * @returns the identity string of this input device
102 */
100 QString identity() const; 103 QString identity() const;
104 /**
105 * @returns the path of this input device
106 */
101 QString path() const; 107 QString path() const;
108 /**
109 * @returns a unique identifier for this input device
110 * @note Only a few devices support this
111 */
102 QString uniq() const; 112 QString uniq() const;
113 /**
114 * @returns whether a certain @a Feature is being supported by this device
115 */
103 bool hasFeature( Feature ) const; 116 bool hasFeature( Feature ) const;
117 /**
118 * @returns whether a given @a Key or Button is being held at the moment
119 */
104 bool isHeld( Key ) const; 120 bool isHeld( Key ) const;
121 /**
122 * @internal
123 * @returns a string containing a printable form of the global keymask
124 */
125 QString globalKeyMask() const;
105 126
106 private: 127 private:
107 int _fd; 128 int _fd;
108 input_id _id; 129 input_id _id;
109 130
110}; 131};
111 132
112} 133}
113} 134}
114 135
115#endif // OINPUTSYSTEM_H 136#endif // OINPUTSYSTEM_H
116 137