Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: adw on October 14, 2011, 02:14:20 PM

Title: volume control for xobox on Sansa ClipV2
Post by: adw on October 14, 2011, 02:14:20 PM
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?
Title: Re: volume control for xobox on Sansa ClipV2
Post by: saratoga on October 14, 2011, 02:25:47 PM
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.
Title: Re: volume control for xobox on Sansa ClipV2
Post by: adw on October 19, 2011, 03:26:07 AM
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: [Select]
        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;