1 /* ===========================================================================
2 * AScd: mixer_handlers.c
3 * mouse events <-> integrated commands with mixer module
4 * ===========================================================================
5 * Copyright (c) 1999 Denis Bourez and Rob Malda. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Denis Bourez & Rob Malda
19 * 4. Neither the name of the author nor the names of any co-contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY DENIS BOUREZ AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL DENIS BOUREZ, ROB MALDA OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 * ===========================================================================
44 if ((fd
= open(mixer_device
,0))) {
52 int getvol(int control
)
58 if ((fd
= open(mixer_device
,0))) {
59 ioctl(fd
, MIXER_READ(control
), &mixer_vol
);
60 mixer_vol
= mixer_vol
>> 8;
68 void setvol(int control
, int setto
, int maximum
)
72 if (setto
> maximum
) setto
= maximum
;
73 if (setto
< 0) setto
= 0;
75 if ((fd
= open(mixer_device
, 0))) {
76 mixer_vol
= ((float)setto
/ (float)maximum
) * 100;
77 mixer_old
= mixer_vol
<< 8;
78 mixer_vol
= mixer_old
| mixer_vol
;
79 ioctl(fd
, MIXER_WRITE(control
), &mixer_vol
);
84 void mixer_event_handle(int event
, XEvent Event
)
88 if (!mixer_ok
) return;
92 if ((thdata
[but_current
].xpm
.attributes
.width
> 0) && (max_volume
> 0)) {
93 if (thdata
[but_current
].type
== FAK_MIXER_BAR
) {
94 value
= (int)((float)(Event
.xbutton
.x
- thdata
[but_current
].x
) / (float)thdata
[but_current
].xpm
.attributes
.width
* 100.0);
95 } else if (thdata
[but_current
].type
== FAK_VMIXER_BAR
) {
96 value
= (int)((float)(Event
.xbutton
.y
- thdata
[but_current
].y
) / (float)thdata
[but_current
].xpm
.attributes
.height
* 100.0);
98 value
= (int)((float)(Event
.xbutton
.y
- thdata
[but_current
].y
) / (float)thdata
[but_current
].xpm
.attributes
.height
* 100.0);
101 setvol(thdata
[but_current
].arg
, value
, 100);
107 setvol(thdata
[but_current
].arg
, 0, 100);
112 setvol(thdata
[but_current
].arg
, 50, 100);
117 setvol(thdata
[but_current
].arg
, 75, 100);
122 setvol(thdata
[but_current
].arg
, 100, 100);
131 fak_singlemask(but_current
);