Rockbox Development > Starting Development and Compiling
volume control for xobox on Sansa ClipV2
(1/1)
adw:
Hi,
I'm trying to add volume control (for music playing) to the "xobox" game. Currently the volume keys are non functional. I have tried to add
#include "misc.h"
#include "settings.h"
...
switch (button) {
...
case BUTTON_VOL_UP:
global_settings.volume++;
setvol();
break;
case BUTTON_VOL_DOWN:
global_settings.volume--;
setvol();
break;
but I get
/home/user/rockbox/build/apps/plugins/xobox.o: In function `plugin_start':
xobox.c:(.text+0xcd8): undefined reference to `setvol'
xobox.c:(.text+0xcf0): undefined reference to `setvol'
xobox.c:(.text+0x152c): undefined reference to `global_settings'
Can anyone help me?
saratoga:
Theres no setvol function in plugins.h. Just looking around at what other plugins do, I believe you want:
rb->sound_set(SOUND_VOLUME, vol);
mpegplayer controls all kinds of playback options, so its probably worth looking at as well.
adw:
Thanks a lot, that worked well.
I have decided to make the volume keys change volume when the game is active, or change track when the game is paused:
--- Code: --- switch (button) {
...
case BUTTON_VOL_UP:
if (!pause) {
limit = rb->sound_max(SOUND_VOLUME);
if (++rb->global_settings->volume > limit)
rb->global_settings->volume = limit;
rb->sound_set(SOUND_VOLUME, rb->global_settings->volume);
} else {
rb->audio_next();
}
break;
case BUTTON_VOL_UP|BUTTON_REPEAT:
if (!pause) {
limit = rb->sound_max(SOUND_VOLUME);
if (++rb->global_settings->volume > limit)
rb->global_settings->volume = limit;
rb->sound_set(SOUND_VOLUME, rb->global_settings->volume);
}
break;
case BUTTON_VOL_DOWN:
if (!pause) {
limit = rb->sound_min(SOUND_VOLUME);
if (--rb->global_settings->volume < limit)
rb->global_settings->volume = limit;
rb->sound_set(SOUND_VOLUME, rb->global_settings->volume);
} else {
rb->audio_prev();
}
break;
case BUTTON_VOL_DOWN|BUTTON_REPEAT:
if (!pause) {
limit = rb->sound_min(SOUND_VOLUME);
if (--rb->global_settings->volume < limit)
rb->global_settings->volume = limit;
rb->sound_set(SOUND_VOLUME, rb->global_settings->volume);
}
break;
--- End code ---
Navigation
[0] Message Index
Go to full version