Ejemplo n.º 1
0
void sub_music_handle_input(unsigned int button)
{
    switch (button)
    {
    case GP2X_BUTTON_L:
        if (music_stage == MUS_FULLSCREEN)
        {
            if (LIST_up())
            {
                mus_stop();
                while (!mus_ready());
                sub_music_playsel();
            }
        }
        break;

    case GP2X_BUTTON_R:
        if (music_stage == MUS_FULLSCREEN)
        {
            if (LIST_down())
            {
                mus_stop();
                while (!mus_ready());
                sub_music_playsel();
            }
        }
        break;

    case GP2X_BUTTON_B:
        if (music_stage == MUS_FULLSCREEN && sub_music_playing)
        {
            sub_music_playing = 0;
            mus_stop();
            music_stage = 0;
            xmb_deactivateFlag(XMB_APPFULLSCREEN);

            while (!mus_ready());

            if (Mix_OpenAudio
                (AUDIO_RATE, AUDIO_FORMAT, AUDIO_CHANNELS, AUDIO_BUFFERS))
            {
                printf("Unable to open audio!\n");
            }
            break;
        }
    case GP2X_BUTTON_LEFT:
        {
            if (music_stage == MUS_FULLSCREEN && sub_music_playing)
            {
                mus_bwd();
                break;
            }

            if (!music_stage && music_stage < 5)
            {
                sfx_play(SFXBACK);
                LIST_setEmptyMsg(NULL);
                if (LIST_out())
                    music_stage = 4;
                else
                    music_stage = 2;
                music_levels--;
                music_animtimer_b = music_animtimer = SDL_GetTicks();
            }
            break;
        }
    case GP2X_BUTTON_RIGHT:
        if (music_stage == MUS_FULLSCREEN && sub_music_playing)
        {
            mus_fwd();
            break;
        }
        break;
    case GP2X_BUTTON_UP:
        {
            if (music_stage == MUS_FULLSCREEN && sub_music_playing)
            {
                break;
            }

            if (LIST_up())
                sfx_play(SFXMOVE);
            break;
        }
    case GP2X_BUTTON_DOWN:
        {
            if (music_stage == MUS_FULLSCREEN && sub_music_playing)
            {
                break;
            }

            if (LIST_down())
                sfx_play(SFXMOVE);
            break;
        }
    case GP2X_BUTTON_Y:
        {
            break;
        }
    case GP2X_BUTTON_X:
        {
            if (!music_stage && LIST_getSelected())
            {
                if (music_stage == MUS_FULLSCREEN && sub_music_playing)
                {
                    break;
                }

                if (li_create_new)
                    break;

                LIST_setEmptyMsg(NULL);

                sub_music_playsel();
            }
            break;
        }
    default:
        break;
    }
}
Ejemplo n.º 2
0
void sub_shc_handle_input(unsigned int button)
{
    switch (button)
    {
    case GP2X_BUTTON_B:
        {
            sfx_play(SFXBACK);
            if(shc_showpopup)
            {
            	POPUP_empty();
            	xmb_deactivateFlag(XMB_NOBATT | XMB_FOCUS);
				shc_showpopup = 0;
            }
            else
            {
            	shc_init_stage = 10;
            	shc_timer = 0;
           	}
            break;
        }
    case GP2X_BUTTON_LEFT:
        {
        	if(shc_showpopup)
        		break;

            sfx_play(SFXBACK);
            shc_init_stage = 10;
            shc_timer = 0;
            break;
        }
    case GP2X_BUTTON_UP:
        {
        	if(shc_showpopup)
        	{
        		if(POPUP_up())
        			sfx_play(SFXMOVE);

        		break;
        	}

            if (shc_selection > 0)
            {
                shc_movereq += 1;
                shc_selection--;
            }
            break;
        }
    case GP2X_BUTTON_DOWN:
        {
        	if(shc_showpopup)
        	{
				if(POPUP_down())
					sfx_play(SFXMOVE);

				break;
        	}

            if (shc_selection + 1 < shc_menucount)
            {
                shc_movereq -= 1;
                shc_selection++;
            }
            break;
        }
	case GP2X_BUTTON_Y:
        {
        	shc_node *curr = shc_root;
            unsigned int i = 0;

            for (i = 0; curr != NULL && i < shc_selection;
                 curr = curr->next, i++);

            if (!shc_init_stage && curr && !shc_showpopup)
            {
                struct stat statbuf;

                stat(curr->path, &statbuf);

                if (S_ISREG(statbuf.st_mode))
                {
                    xmb_activateFlag(XMB_NOBATT | XMB_FOCUS);

                    POPUP_setrevert(NULL, 0);

                    POPUP_add(NULL, "Delete Shortcut", sub_shc_popexec, 0);

                    POPUP_setselected(0);

		            shc_showpopup = 1;
                }
            }
            break;
        }
    case GP2X_BUTTON_X:
        {
            shc_node *curr = shc_root;
            unsigned int i = 0;

            if (shc_showpopup)
            {
                POPUP_execsel();
                sub_shc_destroy();         /* Empty list */
                sub_shc_init(shc_self);    /* Reload */
                xmb_deactivateFlag(XMB_NOBATT | XMB_FOCUS);
                POPUP_empty();
                shc_showpopup = 0;
                break;
            }

            for (i = 0; curr != NULL && i < shc_selection;
                 curr = curr->next, i++);

            if (curr)
            {
                char *dir_name = (char *) calloc(1, 1024);

                if (config_lookup_bool(&CONFIG, "outro"))
                    gfx_draw_outro(SDL_GetVideoSurface());

                gp2xmb_deinit();

                if (dir_name)
                {
                    strncpy(dir_name, curr->path, 1023);
                    chdir(dirname(dir_name));
                    free(dir_name);
                }

                gp2x_setclock(200);

                if (execl(curr->path, curr->path, NULL))
                {
                    gp2xmb_init();      /* start everything up again */
                    while (!xmb_getFlagState(XMB_LOADED))
                    {
                        bg_draw(SDL_GetVideoSurface());
                        progress_draw(SDL_GetVideoSurface(), 1);
                        SDL_Flip(SDL_GetVideoSurface());
                    }
                    msgbox(SDL_GetVideoSurface(),NULL, "System Error",
                           "Failed to execute program.", OK);
                    msgbox_retval();
                    return;
                }
            }

            break;
        }
    default:
        break;
    }
}