Example #1
0
int EventUpdate(void *data)
{
    while (running) {
                SDL_SemWait(event_sem);
                                sceHprmPeekCurrentKey(&hprm);
                SDL_SemPost(event_sem);
                /* Delay 1/60th of a second */
                sceKernelDelayThread(1000000 / 60);
        }
        return 0;
}
Example #2
0
static void playmedia(char *rootpath, char *modname)
{
    char filename[200];
    u32 buttonsold;
    SceCtrlData pad;
    u32 remoteButtons, remoteButtonsOld = 0;
    int codec;
    int finished = 0;

    filename[0] = 0;
    strcat2(filename, rootpath);
    strcat2(filename, modname);

    pspDebugScreenClear();
    printf("%s\n\n", banner);
    printf("loading media File : %s\n", modname);

    //determine codec of the file
    for (codec = 0; codec <= codecnum; codec++) {
	char *ptr = &(stubs[codec].extension[0]);
	while (*ptr != 0) {
	    if (strncasecmp(&modname[strlen(modname) - 3], ptr, 3) == 0) {
		decoder = &stubs[codec];
		break;
	    }
	    ptr += 4;
	}
    }

    decoder->init(0);
    if (decoder->load(filename)) {
	decoder->play();

	pspDebugScreenSetXY(0, 32);
	printf("X = Pause/Resume.  START = Tune Select\n");
	pspDebugScreenSetXY(0, 26);
	printf("Playing\n\n");

	forceskip = 0;

	sceCtrlReadBufferPositive(&pad, 1);
	sceHprmPeekCurrentKey(&remoteButtons);

	buttonsold = pad.Buttons;
	remoteButtonsOld = remoteButtons;
	while (finished == 0) {
	    sceDisplayWaitVblankStart();
	    sceCtrlReadBufferPositive(&pad, 1);
	    sceHprmPeekCurrentKey(&remoteButtons);

	    // Check if we have hit the end of tune
	    if (loopmode != 0) {
		if (decoder->eos != 0) {
		    if (decoder->eos() == 1) {	// End of file, advance in playlist
			pad.Buttons = PSP_CTRL_RTRIGGER;
		    }
		}
	    }

	    if (pad.Buttons != buttonsold) {
		if (pad.Buttons & PSP_CTRL_LTRIGGER) {	// Previous tune
		    forceskip = 1;
		    finished = 1;
		}
		if (pad.Buttons & PSP_CTRL_RTRIGGER) {	// Next tune
		    forceskip = 2;
		    finished = 1;
		}
		if (pad.Buttons & PSP_CTRL_TRIANGLE)
		    loopmode = !loopmode;
		if (pad.Buttons & PSP_CTRL_CIRCLE)
		    decoder->stop();
		if (pad.Buttons & PSP_CTRL_CROSS)
		    decoder->pause();
		if (pad.Buttons & PSP_CTRL_START)
		    finished = 1;
		buttonsold = pad.Buttons;
	    }
	    if (remoteButtons != remoteButtonsOld && !(remoteButtons & PSP_HPRM_HOLD)) {
		if (remoteButtons & PSP_HPRM_PLAYPAUSE)
		    decoder->pause();
		if (remoteButtons & PSP_HPRM_BACK) {
		    forceskip = 1;
		    finished = 1;
		}
		if (remoteButtons & PSP_HPRM_FORWARD) {
		    forceskip = 2;
		    finished = 1;
		}
		remoteButtonsOld = remoteButtons;
	    }
	    //  Show loop status
	    pspDebugScreenSetXY(58, 1);
	    if (loopmode == 0) {
		printf(" LOOP  ");
	    } else {
		printf("ADVANCE");
	    }
	    //  Show the time
	    if (decoder->time != NULL) {
		char time[200];
		decoder->time(time);
		pspDebugScreenSetXY(58, 0);
		printf("%s", time);
		pspDebugScreenSetXY(0, 32);
	    }
	}
	decoder->stop();
	decoder->end();
    }
}