Diffstat (limited to 'libopie2/opiecore/linux/oinputsystem.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/linux/oinputsystem.h | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/libopie2/opiecore/linux/oinputsystem.h b/libopie2/opiecore/linux/oinputsystem.h new file mode 100644 index 0000000..9676e73 --- a/dev/null +++ b/libopie2/opiecore/linux/oinputsystem.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | ||
4 | .=l. | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This program is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; version 2 of the License. | ||
11 | ._= =} : | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This program is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
18 | ..}^=.= = ; Library General Public License for more | ||
19 | ++= -. .` .: details. | ||
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | */ | ||
28 | |||
29 | #ifndef OINPUTSYSTEM_H | ||
30 | #define OINPUTSYSTEM_H | ||
31 | |||
32 | #include "linux_input.h" | ||
33 | |||
34 | /* QT */ | ||
35 | #include <qobject.h> | ||
36 | #include <qdict.h> | ||
37 | |||
38 | namespace Opie { | ||
39 | namespace Core { | ||
40 | |||
41 | class OInputDevice; | ||
42 | |||
43 | /** | ||
44 | * @brief A container class for the Linux input device subsystem | ||
45 | * | ||
46 | * This class provides access to all available input system devices of your device. | ||
47 | * | ||
48 | * @author Michael 'Mickey' Lauer <mickey@Vanille.de> | ||
49 | */ | ||
50 | class OInputSystem : public QObject | ||
51 | { | ||
52 | public: | ||
53 | typedef QDict<OInputDevice> DeviceMap; | ||
54 | typedef QDictIterator<OInputDevice> DeviceIterator; | ||
55 | |||
56 | /** | ||
57 | * @returns the number of available input devices | ||
58 | */ | ||
59 | int count() const; | ||
60 | /** | ||
61 | * @returns a pointer to the (one and only) @ref OInputSystem instance. | ||
62 | */ | ||
63 | static OInputSystem* instance(); | ||
64 | /** | ||
65 | * @returns an iterator usable for iterating through all network interfaces. | ||
66 | */ | ||
67 | DeviceIterator iterator() const; | ||
68 | /** | ||
69 | * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found | ||
70 | * @see OAudioInterface | ||
71 | */ | ||
72 | OInputDevice* device( const QString& interface ) const; | ||
73 | /** | ||
74 | * @internal Rebuild the internal interface database | ||
75 | * @note Sometimes it might be useful to call this from client code, | ||
76 | */ | ||
77 | void synchronize(); | ||
78 | /** | ||
79 | * @internal destructor | ||
80 | */ | ||
81 | ~OInputSystem(); | ||
82 | |||
83 | protected: | ||
84 | OInputSystem(); | ||
85 | |||
86 | static OInputSystem* _instance; | ||
87 | DeviceMap _devices; | ||
88 | }; | ||
89 | |||
90 | |||
91 | class OInputDevice : public QObject | ||
92 | { | ||
93 | public: | ||
94 | OInputDevice( QObject* parent, const char* name = 0 ); | ||
95 | ~OInputDevice(); | ||
96 | |||
97 | #include "oinputsystemenums.h" | ||
98 | |||
99 | public: | ||
100 | /** | ||
101 | * @returns the identity string of this input device | ||
102 | */ | ||
103 | QString identity() const; | ||
104 | /** | ||
105 | * @returns the path of this input device | ||
106 | */ | ||
107 | QString path() const; | ||
108 | /** | ||
109 | * @returns a unique identifier for this input device | ||
110 | * @note Only a few devices support this | ||
111 | */ | ||
112 | QString uniq() const; | ||
113 | /** | ||
114 | * @returns whether a certain @a Feature is being supported by this device | ||
115 | */ | ||
116 | bool hasFeature( Feature ) const; | ||
117 | /** | ||
118 | * @returns whether a given @a Key or Button is being held at the moment | ||
119 | */ | ||
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; | ||
126 | /** | ||
127 | * @internal | ||
128 | * @returns whether a certain @a path corresponds to an input device | ||
129 | */ | ||
130 | static bool isValid( const QString& path ); | ||
131 | |||
132 | private: | ||
133 | int _fd; | ||
134 | input_id _id; | ||
135 | |||
136 | }; | ||
137 | |||
138 | } | ||
139 | } | ||
140 | |||
141 | #endif // OINPUTSYSTEM_H | ||
142 | |||