Debian Codegraph @

src/platforms/gp2x_wiz_canoo.cpp

raw symbols SCIP
1
2 /**
3 *
4 * @file gp2x_wiz_canoo.cpp
5 *
6 * Part of the OpenJazz project
7 *
8 * @par Licence:
9 * Copyright (c) 2015-2026 Carsten Teibes
10 *
11 * OpenJazz is distributed under the terms of
12 * the GNU General Public License, version 2.0
13 *
14 */
15
16
17 #include "gp2x_wiz_canoo.h"
18
19 #if defined(WIZ) || defined(GP2X)
20
21 #include <cstdio>
22 #include <sys/ioctl.h>
23 #include <sys/soundcard.h>
24 #include <fcntl.h>
25 #include <unistd.h>
26
27 #include "io/sound.h"
28
29 void WizPlatform::AdjustVolume(int direction) {
30 if(direction != VOLUME_NOCHG) {
31 if(volume <= 10) {
32 if(direction == VOLUME_UP) volume += VOLUME_CHANGE_RATE/2;
33 if(direction == VOLUME_DOWN) volume -= VOLUME_CHANGE_RATE/2;
34 } else {
35 if(direction == VOLUME_UP) volume += VOLUME_CHANGE_RATE;
36 if(direction == VOLUME_DOWN) volume -= VOLUME_CHANGE_RATE;
37 }
38
39 if(volume < VOLUME_MIN) volume = VOLUME_MIN;
40 if(volume > VOLUME_MAX) volume = VOLUME_MAX;
41
42 printf( "Volume Change: %i\n", volume );
43 }
44
45 unsigned long soundDev = open("/dev/mixer", O_RDWR);
46 if(soundDev) {
47 int vol = ((volume << 8) | volume);
48 ioctl(soundDev, SOUND_MIXER_WRITE_PCM, &vol);
49 close(soundDev);
50 }
51 }
52
53 #endif