author | mickeyl <mickeyl> | 2005-02-02 15:23:01 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-02-02 15:23:01 (UTC) |
commit | 227d06128b74ef78b8268e18dabe454469b65cc8 (patch) (unidiff) | |
tree | 64632ebff3bb6df1ba81ce1e70638cbce15de33c /libopie2 | |
parent | 1a5dc271114432e0e598af499c076bfbf69ff972 (diff) | |
download | opie-227d06128b74ef78b8268e18dabe454469b65cc8.zip opie-227d06128b74ef78b8268e18dabe454469b65cc8.tar.gz opie-227d06128b74ef78b8268e18dabe454469b65cc8.tar.bz2 |
first work on input system abstractions
-rw-r--r-- | libopie2/opiecore/oinputsystem.cpp | 113 | ||||
-rw-r--r-- | libopie2/opiecore/oinputsystem.h | 108 | ||||
-rw-r--r-- | libopie2/opiemm/osoundsystem.h | 4 |
3 files changed, 218 insertions, 7 deletions
diff --git a/libopie2/opiecore/oinputsystem.cpp b/libopie2/opiecore/oinputsystem.cpp index c33d5c8..bfdc31f 100644 --- a/libopie2/opiecore/oinputsystem.cpp +++ b/libopie2/opiecore/oinputsystem.cpp | |||
@@ -1,31 +1,142 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "oinputsystem.h" | 29 | #include "oinputsystem.h" |
30 | |||
31 | using namespace Opie::Core; | 30 | using namespace Opie::Core; |
31 | |||
32 | /* QT */ | ||
33 | #include <qfile.h> | ||
34 | |||
35 | /* STD */ | ||
36 | #include <errno.h> | ||
37 | #include <string.h> | ||
38 | #include <linux/input.h> | ||
39 | #include <sys/fcntl.h> | ||
40 | #include <sys/ioctl.h> | ||
41 | |||
42 | #define BUFSIZE 256 | ||
43 | |||
44 | /*====================================================================================== | ||
45 | * OInputSystem | ||
46 | *======================================================================================*/ | ||
47 | |||
48 | OInputSystem* OInputSystem::_instance = 0; | ||
49 | |||
50 | OInputSystem::OInputSystem() : QObject() | ||
51 | { | ||
52 | qDebug( "OInputSystem::OInputSystem()" ); | ||
53 | synchronize(); | ||
54 | } | ||
55 | |||
56 | |||
57 | void OInputSystem::synchronize() | ||
58 | { | ||
59 | qDebug( "OInputSystem::synchronize()" ); | ||
60 | if ( QFile::exists( "/dev/input/event0" ) ) _devices.insert( "0", new OInputDevice( this, "/dev/input/event0" ) ); | ||
61 | if ( QFile::exists( "/dev/input/event1" ) ) _devices.insert( "1", new OInputDevice( this, "/dev/input/event1" ) ); | ||
62 | if ( QFile::exists( "/dev/input/event2" ) ) _devices.insert( "2", new OInputDevice( this, "/dev/input/event2" ) ); | ||
63 | if ( QFile::exists( "/dev/input/event3" ) ) _devices.insert( "3", new OInputDevice( this, "/dev/input/event3" ) ); | ||
64 | qDebug( "OInputSystem::synchronize() done" ); | ||
65 | } | ||
66 | |||
67 | |||
68 | OInputSystem::~OInputSystem() | ||
69 | { | ||
70 | qDebug( "OInputSystem::~OInputSystem()" ); | ||
71 | } | ||
72 | |||
73 | |||
74 | int OInputSystem::count() const | ||
75 | { | ||
76 | return _devices.count(); | ||
77 | } | ||
78 | |||
79 | |||
80 | OInputDevice* OInputSystem::device( const QString& device ) const | ||
81 | { | ||
82 | return _devices[device]; | ||
83 | } | ||
84 | |||
85 | |||
86 | OInputSystem* OInputSystem::instance() | ||
87 | { | ||
88 | if ( !_instance ) _instance = new OInputSystem(); | ||
89 | return _instance; | ||
90 | } | ||
91 | |||
92 | |||
93 | OInputSystem::DeviceIterator OInputSystem::iterator() const | ||
94 | { | ||
95 | return OInputSystem::DeviceIterator( _devices ); | ||
96 | } | ||
97 | |||
98 | /*====================================================================================== | ||
99 | * OInputDevice | ||
100 | *======================================================================================*/ | ||
101 | |||
102 | OInputDevice::OInputDevice( QObject* parent, const char* name ) : QObject( parent, name ) | ||
103 | { | ||
104 | qDebug( "OInputDevice::OInputDevice( '%s' )", name ); | ||
105 | |||
106 | _fd = ::open( name, O_RDONLY ); | ||
107 | if ( _fd == -1 ) | ||
108 | { | ||
109 | qDebug( "OInputDevice::OInputDevice() - Warning: couldn't open %s (%s)", name, strerror( errno ) ); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | |||
114 | OInputDevice::~OInputDevice() | ||
115 | { | ||
116 | qDebug( "OInputDevice::~OInputDevice()" ); | ||
117 | } | ||
118 | |||
119 | |||
120 | QString OInputDevice::identity() const | ||
121 | { | ||
122 | char buf[BUFSIZE] = "<unknown>"; | ||
123 | ::ioctl( _fd, EVIOCGNAME(sizeof buf), buf ); | ||
124 | return buf; | ||
125 | } | ||
126 | |||
127 | |||
128 | QString OInputDevice::path() const | ||
129 | { | ||
130 | char buf[BUFSIZE] = "<unknown>"; | ||
131 | ::ioctl( _fd, EVIOCGPHYS(sizeof buf), buf ); | ||
132 | return buf; | ||
133 | } | ||
134 | |||
135 | |||
136 | QString OInputDevice::uniq() const | ||
137 | { | ||
138 | char buf[BUFSIZE] = "<unknown>"; | ||
139 | ::ioctl( _fd, EVIOCGUNIQ(sizeof buf), buf ); | ||
140 | return buf; | ||
141 | } | ||
142 | |||
diff --git a/libopie2/opiecore/oinputsystem.h b/libopie2/opiecore/oinputsystem.h index 2bcdc3a..350656b 100644 --- a/libopie2/opiecore/oinputsystem.h +++ b/libopie2/opiecore/oinputsystem.h | |||
@@ -1,48 +1,148 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef OINPUTSYSTEM_H | 29 | #ifndef OINPUTSYSTEM_H |
30 | #define OINPUTSYSTEM_H | 30 | #define OINPUTSYSTEM_H |
31 | 31 | ||
32 | /* QT */ | ||
32 | #include <qobject.h> | 33 | #include <qobject.h> |
34 | #include <qdict.h> | ||
35 | |||
36 | /* STD */ | ||
37 | #include <linux/input.h> | ||
33 | 38 | ||
34 | namespace Opie { | 39 | namespace Opie { |
35 | namespace Core { | 40 | namespace Core { |
36 | 41 | ||
37 | /** | 42 | class OInputDevice; |
38 | * ... | ||
39 | * | ||
40 | */ | ||
41 | 43 | ||
44 | /** | ||
45 | * @brief A container class for all input devices | ||
46 | * | ||
47 | * This class provides access to all available input system devices of your computer. | ||
48 | * | ||
49 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
50 | */ | ||
42 | class OInputSystem : public QObject | 51 | class OInputSystem : public QObject |
43 | { | 52 | { |
53 | public: | ||
54 | typedef QDict<OInputDevice> DeviceMap; | ||
55 | typedef QDictIterator<OInputDevice> DeviceIterator; | ||
56 | |||
57 | /** | ||
58 | * @returns the number of available input devices | ||
59 | */ | ||
60 | int count() const; | ||
61 | /** | ||
62 | * @returns a pointer to the (one and only) @ref OInputSystem instance. | ||
63 | */ | ||
64 | static OInputSystem* instance(); | ||
65 | /** | ||
66 | * @returns an iterator usable for iterating through all network interfaces. | ||
67 | */ | ||
68 | DeviceIterator iterator() const; | ||
69 | /** | ||
70 | * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found | ||
71 | * @see OAudioInterface | ||
72 | */ | ||
73 | OInputDevice* device( const QString& interface ) const; | ||
74 | /** | ||
75 | * @internal Rebuild the internal interface database | ||
76 | * @note Sometimes it might be useful to call this from client code, | ||
77 | */ | ||
78 | void synchronize(); | ||
79 | /** | ||
80 | * @internal desctructor | ||
81 | */ | ||
82 | ~OInputSystem(); | ||
83 | |||
84 | protected: | ||
85 | OInputSystem(); | ||
86 | |||
87 | static OInputSystem* _instance; | ||
88 | DeviceMap _devices; | ||
89 | }; | ||
90 | |||
91 | |||
92 | class OInputDevice : public QObject | ||
93 | { | ||
94 | public: | ||
95 | |||
96 | enum EventType | ||
97 | { | ||
98 | Synchronous = EV_SYN, | ||
99 | Keyboard = EV_KEY, | ||
100 | Relative = EV_REL, | ||
101 | Absolute = EV_ABS, | ||
102 | Miscellaneous = EV_MSC, | ||
103 | Led = EV_LED, | ||
104 | Sound = EV_SND, | ||
105 | AutoRepeat = EV_REP, | ||
106 | ForceFeedback = EV_FF, | ||
107 | PowerManagement = EV_PWR, | ||
108 | ForceFeedbackStatus = EV_FF_STATUS, | ||
109 | }; | ||
110 | |||
111 | enum Bus | ||
112 | { | ||
113 | PCI = BUS_PCI, | ||
114 | ISAPNP = BUS_ISAPNP, | ||
115 | HIL = BUS_HIL, | ||
116 | BLUETOOTH = BUS_BLUETOOTH, | ||
117 | ISA = BUS_ISA, | ||
118 | I8042 = BUS_I8042, | ||
119 | XTKBD = BUS_XTKBD, | ||
120 | RS232 = BUS_RS232, | ||
121 | GAMEPORT = BUS_GAMEPORT, | ||
122 | PARPORT = BUS_PARPORT, | ||
123 | AMIGA = BUS_AMIGA, | ||
124 | ADB = BUS_ADB, | ||
125 | I2C = BUS_I2C, | ||
126 | HOST = BUS_HOST, | ||
127 | }; | ||
128 | |||
129 | public: | ||
130 | OInputDevice( QObject* parent, const char* name = 0 ); | ||
131 | ~OInputDevice(); | ||
132 | |||
133 | public: | ||
134 | QString identity() const; | ||
135 | QString path() const; | ||
136 | QString uniq() const; | ||
137 | |||
138 | private: | ||
139 | int _fd; | ||
140 | input_id _id; | ||
141 | |||
44 | }; | 142 | }; |
143 | |||
45 | } | 144 | } |
46 | } | 145 | } |
47 | 146 | ||
48 | #endif // OINPUTSYSTEM_H | 147 | #endif // OINPUTSYSTEM_H |
148 | |||
diff --git a/libopie2/opiemm/osoundsystem.h b/libopie2/opiemm/osoundsystem.h index cce90c0..5f6fb7a 100644 --- a/libopie2/opiemm/osoundsystem.h +++ b/libopie2/opiemm/osoundsystem.h | |||
@@ -1,245 +1,245 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef OSOUNDSYSTEM_H | 31 | #ifndef OSOUNDSYSTEM_H |
32 | #define OSOUNDSYSTEM_H | 32 | #define OSOUNDSYSTEM_H |
33 | 33 | ||
34 | #include <qobject.h> | 34 | #include <qobject.h> |
35 | #include <qdict.h> | 35 | #include <qdict.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | namespace Opie { | 38 | namespace Opie { |
39 | namespace MM { | 39 | namespace MM { |
40 | 40 | ||
41 | class OAudioInterface; | 41 | class OAudioInterface; |
42 | class OMixerInterface; | 42 | class OMixerInterface; |
43 | class OSoundCard; | 43 | class OSoundCard; |
44 | 44 | ||
45 | /*====================================================================================== | 45 | /*====================================================================================== |
46 | * OSoundSystem | 46 | * OSoundSystem |
47 | *======================================================================================*/ | 47 | *======================================================================================*/ |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * @brief A container class for all audio interfaces | 50 | * @brief A container class for all audio interfaces |
51 | * | 51 | * |
52 | * This class provides access to all available audio/midi/sequencer interfaces of your computer. | 52 | * This class provides access to all available audio/midi/sequencer interfaces of your computer. |
53 | * | 53 | * |
54 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 54 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
55 | */ | 55 | */ |
56 | class OSoundSystem : public QObject | 56 | class OSoundSystem : public QObject |
57 | { | 57 | { |
58 | Q_OBJECT | 58 | Q_OBJECT |
59 | 59 | ||
60 | public: | 60 | public: |
61 | typedef QDict<OSoundCard> CardMap; | 61 | typedef QDict<OSoundCard> CardMap; |
62 | typedef QDictIterator<OSoundCard> CardIterator; | 62 | typedef QDictIterator<OSoundCard> CardIterator; |
63 | 63 | ||
64 | public: | 64 | public: |
65 | /** | 65 | /** |
66 | * @returns the number of available interfaces | 66 | * @returns the number of available interfaces |
67 | */ | 67 | */ |
68 | int count() const; | 68 | int count() const; |
69 | /** | 69 | /** |
70 | * @returns a pointer to the (one and only) @ref ONetwork instance. | 70 | * @returns a pointer to the (one and only) @ref OSystem instance. |
71 | */ | 71 | */ |
72 | static OSoundSystem* instance(); | 72 | static OSoundSystem* instance(); |
73 | /** | 73 | /** |
74 | * @returns an iterator usable for iterating through all network interfaces. | 74 | * @returns an iterator usable for iterating through all sound cards. |
75 | */ | 75 | */ |
76 | CardIterator iterator() const; | 76 | CardIterator iterator() const; |
77 | /** | 77 | /** |
78 | * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found | 78 | * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found |
79 | * @see OAudioInterface | 79 | * @see OAudioInterface |
80 | */ | 80 | */ |
81 | OSoundCard* card( const QString& interface ) const; | 81 | OSoundCard* card( const QString& interface ) const; |
82 | /** | 82 | /** |
83 | * @internal Rebuild the internal interface database | 83 | * @internal Rebuild the internal interface database |
84 | * @note Sometimes it might be useful to call this from client code, | 84 | * @note Sometimes it might be useful to call this from client code, |
85 | * e.g. after issuing a cardctl insert | 85 | * e.g. after issuing a cardctl insert |
86 | */ | 86 | */ |
87 | void synchronize(); | 87 | void synchronize(); |
88 | 88 | ||
89 | protected: | 89 | protected: |
90 | OSoundSystem(); | 90 | OSoundSystem(); |
91 | 91 | ||
92 | private: | 92 | private: |
93 | static OSoundSystem* _instance; | 93 | static OSoundSystem* _instance; |
94 | CardMap _interfaces; | 94 | CardMap _interfaces; |
95 | class Private; | 95 | class Private; |
96 | Private *d; | 96 | Private *d; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | /*====================================================================================== | 100 | /*====================================================================================== |
101 | * OSoundCard | 101 | * OSoundCard |
102 | *======================================================================================*/ | 102 | *======================================================================================*/ |
103 | 103 | ||
104 | class OSoundCard : public QObject | 104 | class OSoundCard : public QObject |
105 | { | 105 | { |
106 | Q_OBJECT | 106 | Q_OBJECT |
107 | 107 | ||
108 | public: | 108 | public: |
109 | /** | 109 | /** |
110 | * Constructor. Normally you don't create @ref OSoundCard objects yourself, | 110 | * Constructor. Normally you don't create @ref OSoundCard objects yourself, |
111 | * but access them via @ref OSoundSystem::card(). | 111 | * but access them via @ref OSoundSystem::card(). |
112 | */ | 112 | */ |
113 | OSoundCard( QObject* parent, const char* name ); | 113 | OSoundCard( QObject* parent, const char* name ); |
114 | /** | 114 | /** |
115 | * Destructor. | 115 | * Destructor. |
116 | */ | 116 | */ |
117 | virtual ~OSoundCard(); | 117 | virtual ~OSoundCard(); |
118 | 118 | ||
119 | bool hasMixer() const { return _audio; }; | 119 | bool hasMixer() const { return _audio; }; |
120 | bool hasAudio() const { return _mixer; }; | 120 | bool hasAudio() const { return _mixer; }; |
121 | 121 | ||
122 | OAudioInterface* audio() const { return _audio; }; | 122 | OAudioInterface* audio() const { return _audio; }; |
123 | OMixerInterface* mixer() const { return _mixer; }; | 123 | OMixerInterface* mixer() const { return _mixer; }; |
124 | 124 | ||
125 | protected: | 125 | protected: |
126 | OAudioInterface* _audio; | 126 | OAudioInterface* _audio; |
127 | OMixerInterface* _mixer; | 127 | OMixerInterface* _mixer; |
128 | 128 | ||
129 | private: | 129 | private: |
130 | void init(); | 130 | void init(); |
131 | private: | 131 | private: |
132 | class Private; | 132 | class Private; |
133 | Private *d; | 133 | Private *d; |
134 | }; | 134 | }; |
135 | 135 | ||
136 | /*====================================================================================== | 136 | /*====================================================================================== |
137 | * OAudioInterface | 137 | * OAudioInterface |
138 | *======================================================================================*/ | 138 | *======================================================================================*/ |
139 | 139 | ||
140 | class OAudioInterface : public QObject | 140 | class OAudioInterface : public QObject |
141 | { | 141 | { |
142 | Q_OBJECT | 142 | Q_OBJECT |
143 | 143 | ||
144 | public: | 144 | public: |
145 | /** | 145 | /** |
146 | * Constructor. Normally you don't create @ref OAudioInterface objects yourself, | 146 | * Constructor. Normally you don't create @ref OAudioInterface objects yourself, |
147 | * but access them via the @ref OSoundCard interface. | 147 | * but access them via the @ref OSoundCard interface. |
148 | */ | 148 | */ |
149 | OAudioInterface( QObject* parent, const char* name ); | 149 | OAudioInterface( QObject* parent, const char* name ); |
150 | /** | 150 | /** |
151 | * Destructor. | 151 | * Destructor. |
152 | */ | 152 | */ |
153 | virtual ~OAudioInterface(); | 153 | virtual ~OAudioInterface(); |
154 | 154 | ||
155 | protected: | 155 | protected: |
156 | const int _sfd; | 156 | const int _sfd; |
157 | 157 | ||
158 | private: | 158 | private: |
159 | void init(); | 159 | void init(); |
160 | private: | 160 | private: |
161 | class Private; | 161 | class Private; |
162 | Private *d; | 162 | Private *d; |
163 | }; | 163 | }; |
164 | 164 | ||
165 | 165 | ||
166 | /*====================================================================================== | 166 | /*====================================================================================== |
167 | * OMixerInterface | 167 | * OMixerInterface |
168 | *======================================================================================*/ | 168 | *======================================================================================*/ |
169 | 169 | ||
170 | class OMixerInterface : public QObject | 170 | class OMixerInterface : public QObject |
171 | { | 171 | { |
172 | Q_OBJECT | 172 | Q_OBJECT |
173 | 173 | ||
174 | public: | 174 | public: |
175 | 175 | ||
176 | typedef QMap<QString,int>::ConstIterator ChannelIterator; | 176 | typedef QMap<QString,int>::ConstIterator ChannelIterator; |
177 | 177 | ||
178 | /** | 178 | /** |
179 | * Constructor. Normally you don't create @ref OMixerInterface objects yourself, | 179 | * Constructor. Normally you don't create @ref OMixerInterface objects yourself, |
180 | * but access them via the @ref OSoundCard interface. | 180 | * but access them via the @ref OSoundCard interface. |
181 | */ | 181 | */ |
182 | OMixerInterface( QObject* parent, const char* name ); | 182 | OMixerInterface( QObject* parent, const char* name ); |
183 | /** | 183 | /** |
184 | * Destructor. | 184 | * Destructor. |
185 | */ | 185 | */ |
186 | virtual ~OMixerInterface(); | 186 | virtual ~OMixerInterface(); |
187 | 187 | ||
188 | /** | 188 | /** |
189 | * @returns all available channels. | 189 | * @returns all available channels. |
190 | */ | 190 | */ |
191 | QStringList allChannels() const; | 191 | QStringList allChannels() const; |
192 | /** | 192 | /** |
193 | * @returns recordable channels. | 193 | * @returns recordable channels. |
194 | */ | 194 | */ |
195 | QStringList recChannels() const; | 195 | QStringList recChannels() const; |
196 | /** | 196 | /** |
197 | * @returns playable channels. | 197 | * @returns playable channels. |
198 | */ | 198 | */ |
199 | QStringList playChannels() const; | 199 | QStringList playChannels() const; |
200 | /** | 200 | /** |
201 | * @returns true, if the device features multiple recording sources. | 201 | * @returns true, if the device features multiple recording sources. |
202 | */ | 202 | */ |
203 | bool hasMultipleRecording() const; | 203 | bool hasMultipleRecording() const; |
204 | /** | 204 | /** |
205 | * @returns true, if @a channel exists. | 205 | * @returns true, if @a channel exists. |
206 | */ | 206 | */ |
207 | bool hasChannel( const QString& channel ) const; | 207 | bool hasChannel( const QString& channel ) const; |
208 | /** | 208 | /** |
209 | * @returns true, if @a channel is stereo. | 209 | * @returns true, if @a channel is stereo. |
210 | */ | 210 | */ |
211 | bool isStereo( const QString& channel ) const; | 211 | bool isStereo( const QString& channel ) const; |
212 | /** | 212 | /** |
213 | * @returns tru, if @a channel is a possible recording source. | 213 | * @returns tru, if @a channel is a possible recording source. |
214 | */ | 214 | */ |
215 | bool isRecordable( const QString& channel ) const; | 215 | bool isRecordable( const QString& channel ) const; |
216 | /** | 216 | /** |
217 | * Set the @a left and @a right volumes for @a channel. | 217 | * Set the @a left and @a right volumes for @a channel. |
218 | * If no value for right is given, the value for left is taken for that. | 218 | * If no value for right is given, the value for left is taken for that. |
219 | */ | 219 | */ |
220 | void setVolume( const QString& channel, int left, int right = -1 ); | 220 | void setVolume( const QString& channel, int left, int right = -1 ); |
221 | /** | 221 | /** |
222 | * @returns the volume of @a channel or -1, if the channel doesn't exist. | 222 | * @returns the volume of @a channel or -1, if the channel doesn't exist. |
223 | * @note You might want to use @ref hasChannel() to check if a channel exists. | 223 | * @note You might want to use @ref hasChannel() to check if a channel exists. |
224 | */ | 224 | */ |
225 | int volume( const QString& channel ) const; | 225 | int volume( const QString& channel ) const; |
226 | 226 | ||
227 | protected: | 227 | protected: |
228 | int _fd; | 228 | int _fd; |
229 | int _capmask; | 229 | int _capmask; |
230 | int _devmask; | 230 | int _devmask; |
231 | int _recmask; | 231 | int _recmask; |
232 | int _stmask; | 232 | int _stmask; |
233 | QMap<QString,int> _channels; | 233 | QMap<QString,int> _channels; |
234 | 234 | ||
235 | private: | 235 | private: |
236 | void init(); | 236 | void init(); |
237 | private: | 237 | private: |
238 | class Private; | 238 | class Private; |
239 | Private *d; | 239 | Private *d; |
240 | }; | 240 | }; |
241 | 241 | ||
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | #endif // OSOUNDSYSTEM_H | 245 | #endif // OSOUNDSYSTEM_H |