UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) {
	EventType event;
	Err err = 0;

	switch (cmd) {
	case sysAppLaunchCmdNormalLaunch:
		if(isTheDeviceSupported() == false) {
			FrmAlert(OldAlert);
			break;
		}
		
		FrmGotoForm(MainForm);
		do {
			UInt16 MenuError;
			EvtGetEvent(&event, evtWaitForever);
			if (! SysHandleEvent(&event))
				if (! MenuHandleEvent(0, &event, &MenuError))
					if (! AppHandleEvent(&event))
						FrmDispatchEvent(&event);
		} while (event.eType != appStopEvent);
		break;
	case sysAppLaunchCmdNotify:
		if(((SysNotifyParamType*) cmdPBP)->notifyType==sysNotifyDisplayResizedEvent) {
			EventType resizedEvent;
			MemSet(&resizedEvent,sizeof(EventType),0);
			resizedEvent.eType=winDisplayChangedEvent;
			EvtAddUniqueEventToQueue(&resizedEvent,0,true);
		}
		break;
	default:
		break;
	}    
	return(err);
}
/***********************************************************************
 *
 * FUNCTION:    AppEventLoop
 *
 * DESCRIPTION: This routine is the event loop for the application.  
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/
static void AppEventLoop(void)
{
	UInt16 error;
	EventType event;

	do {
		EvtGetEvent(&event, evtWaitForever);

		if (! SysHandleEvent(&event))
			if (! MenuHandleEvent(0, &event, &error))
				if (! AppHandleEvent(&event))
					FrmDispatchEvent(&event);

	} while (event.eType != appStopEvent);
}
Beispiel #3
0
static void AppEventLoop(void)
{
    UInt16 error;
    EventType event;

    do {
        /* change timeout if you need periodic nilEvents */
        EvtGetEvent(&event, SysTicksPerSecond() / 5);

        if (!SysHandleEvent(&event)) {
            if (!MenuHandleEvent(0, &event, &error)) {
                if (!AppHandleEvent(&event)) {
                    FrmDispatchEvent(&event);
                }
            }
        }
    } while (event.eType != appStopEvent);
}
Beispiel #4
0
static void AppEventLoop(void){
  EventType event;
  short error;
  UInt16 nilEvents;
  do {
    EvtGetEvent(&event, 25);
    if (MenuHandleEvent(NULL, &event, &error)) { nilEvents=0; continue; }
    if (AppHandleEvent(&event)){ if(event.eType!=nilEvent){nilEvents=0;} continue; }
    if (SysHandleEvent(&event)) { nilEvents=0; continue; }
    if (event.eType == nilEvent){
      nilEvents++;
      if(nilEvents++ > 40 * 60){
        nilEvents = 0;
        if(FrmGetActiveFormID()!=HelpForm){
          FrmGotoForm(HelpForm);
        }
        continue;
      }
    }
    FrmDispatchEvent(&event);
  } while (event.eType != appStopEvent);
}
Beispiel #5
0
/***********************************************************************
 * main event loop; loops until appStopEvent is caught or
 * QuitApp is set
 ***********************************************************************/
static void
AppEventLoop(void)
{
  UInt16 error;
  EventType event;


  do {
    EvtGetEvent(&event, evtWaitForever);


    if (! SysHandleEvent(&event))
      if (! MenuHandleEvent(0, &event, &error))
	if (! AppHandleEvent(&event))
	  FrmDispatchEvent(&event);

    // Check the heaps after each event
#if EMULATION_LEVEL != EMULATION_NONE
    MemHeapCheck(0);
    MemHeapCheck(1);
#endif
  } while (event.eType != appStopEvent);

}
Beispiel #6
0
static void AppEventLoop(void)
{
    Err error;
    EventType event;

    do 
    {
	/* we should wait for 100ms only so we can server the audio */
	EvtGetEvent(&event, evtWaitForever);
    
	if (SysHandleEvent(&event)) continue;
	if (MenuHandleEvent(0, &event, &error)) continue;
	if (AppHandleEvent(&event)) continue;

	FrmDispatchEvent(&event);

    	/* Serve playing */
	if (FlopPlay == true)
	{
	    if (!flite->samples)
	    {   /* Got stuff to play and we're not currently playing */
		flite->type = FlopOutputType; /* words, phones, wave, stream */
		flite->text = input;               /* text to be synthesized */
		flite_synth_text(flite);                 /* do the synthesis */
		flite->WavePosition = flite->start;
		flite->start += flite->utt_length;        /* update position */
		
		/* highlight the area being spoken */

		if (flite->type != FliteOutputTypeWave)
		    FlopPlay = false;  /* we don't do async play on words/ph */

	    }

	    if (playdata.samples && !playdata.active)
		/* stop and tidy up anything that's finished playing */
		StopPlayStream();
	    else if (flite->samples && !playdata.active)
	    {   /* create a new stream and start it playing */
		flite->PlayPosition = flite->WavePosition;
		SetupPlayStream(flite);
		SndStreamStart(playstream);
	    }
	    else if (!playdata.active)
		/* go into stop mode as there is nothing more to play */
		FlopPlay = false;   /* nothing more to play */
	}
	else
	{
	    if (flite && flite->output)
		StrPrintF(flite->output,"stopped %d",flite->PlayPosition);
	    StopPlayStream();
	    /* flush any other waveform waiting to play */
	    if (flite->samples)
	    {
	    	MemPtrFree(flite->samples);
		flite->num_samples = 0;
		flite->samples = 0;
	    }
	}
	if (flite && flite->output)
	{   /* should be within if above, but for debugging ... */
	    /* Update the output field with any new information */
	    SetField(FlopForm, FlopOutput, flite->output);
	    FrmDrawForm(FrmGetFormPtr(FlopForm));
	}
    } 
    while ((FlopStop==false) && (event.eType != appStopEvent));

    return;
}