Example #1
0
/**********************************************************************
 * Function: EventLoop
 * Description: this is the main event loop for the program. It 
 * listens for events for .5 seconds, if none come in, it checks 
 * wheter it should timeout and lock the program. If the unit
 * is scheduled to sleep within the next five seconds, it locks
 * the display. 
 * Note: timeout does not work properly if you overclock you 
 * palm's processor.
 * ********************************************************************/ 
static void 
EventLoop (void) 
{
	EventType event;
	UInt16 error;
	
	do
		
	{
		
			// wait a bit for an event
			EvtGetEvent (&event, 50);

				/* Dont seed with empty events!*/
			if(event.eType != nilEvent)
				random_seed((byte *) &event, sizeof(event)); 
	
			// first the system gets the event, then the Menu event handler, then the application
			// event handler, then finally the form event handler
			if (!SysHandleEvent (&event))
			if (!MenuHandleEvent (0, &event, &error))
				if (!ApplicationHandleEvent (&event))
					FrmDispatchEvent (&event);
	}
	while (event.eType != appStopEvent);
}
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);
}
Example #3
0
void RunCount(UInt32 start_tik)
{
    UInt32 tik,dtik;
    run=1;
    while(run==1) {
	tik = TimGetTicks();
	dtik = tik - start_tik;
	drawCount(dtik);

	// call this periodically to hold off auto off  
	if (stopWatchPrefs.disableAutoOff) EvtResetAutoOffTimer();

	// delay one tenth of a sec (.09 acksherly to be sly)
	SysTaskDelay((90 * SysTicksPerSecond())/1000);
	// within loop call SysHandleEvent to
	//  give system opportunity to break in? 
	// /opt/palmdev/sdk-5/include/Core/UI/Event.h
	{ 
	    UInt16 err;
	    EventType e;
	    EvtGetEvent(&e, 0);
	    if (! SysHandleEvent (&e))
		if (! MenuHandleEvent (NULL, &e, &err))
		    if (! ApplicationHandleEvent (&e))
			FrmDispatchEvent (&e);
	}
    }

}
Example #4
0
static void
EventLoop (void)
{
    EventType	event;
    SDWord	timeout;
    UInt32	timer_next;
    Word	error;

    do
    {
        timeout = evtWaitForever;
        timer_next = 0;
        if (needRedisplay)
            timeout = 0;
        else if (game.timer_running)
        {
            UInt32  now = TimGetTicks ();
            int	    sec = (now - game.timer_start) / sysTicksPerSecond;

            timer_next = ((sec + 1) * sysTicksPerSecond + game.timer_start);
            timeout = timer_next - now;
        }
        EvtGetEvent (&event, timeout);
        DIAG (("Event %d\n", event.eType));
        if (timer_next && TimGetTicks () <= timer_next)
            DamageCount ();
        if (needRedisplay && event.eType == nilEvent)
            FrmUpdateForm (mainForm, frmRedrawUpdateCode);
        if (event.eType == nilEvent)
            continue;

        /* Give the system a chance to handle the event. */
        if (! SysHandleEvent (&event))
        {
            if (!MenuHandleEvent (0, &event, &error))
            {
                /* Give the application a chance to handle the event. */
                if (!ApplicationHandleEvent (&event))
                {
                    /* Let the form object provide default handling of the event. */
                    FrmDispatchEvent (&event);
                }
            }
        }
    }
    while (event.eType != appStopEvent);
    // ** SPECIAL NOTE **
    // In order for the Emulator to exit
    // cleanly when the File|Quit menu option is
    // selected, the running application
    // must exit.  The emulator will generate an
    // ÒappStopEventÓ when Quit is selected.
}
Example #5
0
/* The main event loop */
static void EventLoop(void)
{
    UInt16 err;
    EventType e;

    do {
	EvtGetEvent(&e, evtWaitForever);
	if (! SysHandleEvent (&e))
	    if (! MenuHandleEvent (NULL, &e, &err))
		if (! ApplicationHandleEvent (&e))
		    FrmDispatchEvent (&e);
    } while (e.eType != appStopEvent);
}
Example #6
0
static void EventLoop( void )
{
	EventType event;
	UInt error;

	do {
		EvtGetEvent( &event, evtWaitForever );
		if( !SysHandleEvent( &event ) )
			if( !MenuHandleEvent( 0, &event, &error ) )
				if( !ApplicationHandleEvent( &event ) )
					FrmDispatchEvent( &event );
	} while( event.eType != appStopEvent );
}
Example #7
0
File: gmi.c Project: miellaby/v4p
void Application_ProcessMessages(int ticks)
{
     EventType event;
     UInt32 until=TimGetTicks()+ticks;
     UInt16 error;
     do {
	     EvtGetEvent(&event, 3);
	     if(event.eType == appStopEvent) {
		     StopEvent=1;
		     break;
	     }
	     if (! SysHandleEvent(&event))
	         if (! MenuHandleEvent(0, &event, &error))
	             if (! Application_EventHandler(&event))
	                FrmDispatchEvent(&event);
     } while(TimGetTicks()<until);
}
Example #8
0
/* The main event loop */
static void EventLoop(void)
{
  Word err;
  EventType e;

  do {
    if( EQIsEmpty() ) {
      EvtGetEvent(&e, .66 * SysTicksPerSecond());
    } else {
      EvtGetEvent(&e, .05 * SysTicksPerSecond());
    }
    if (! SysHandleEvent (&e))
      if (! MenuHandleEvent (NULL, &e, &err) )
	if (! ApplicationHandleEvent (&e) )
	  if( ! FrmDispatchEvent (&e) )
            GameEvents();
  } while (e.eType != appStopEvent);
}
Example #9
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);
}
Example #10
0
/* This routine is the event loop */
static void EventLoop( void )
{
    EventType event;
    UInt16    err;

    do {
        EvtGetEvent( &event, evtWaitForever );

        if ( SysHandleEvent( &event ) )
            continue;

        if ( MenuHandleEvent( NULL, &event, &err ) )
            continue;

        if ( event.eType == frmLoadEvent )
            HandleFormLoad( &event );

        FrmDispatchEvent( &event );
    } while ( event.eType != appStopEvent );
}
Example #11
0
int wxEventLoop::Run()
{
    status_t    error;
    EventType    event;

    do {
        wxTheApp && wxTheApp->ProcessIdle();

        EvtGetEvent(&event, evtWaitForever);

        if (SysHandleEvent(&event))
            continue;

        if (MenuHandleEvent(0, &event, &error))
            continue;

        FrmDispatchEvent(&event);

    } while (event.eType != appStopEvent);

    return 0;
}
Example #12
0
File: IntExp.c Project: ysei/palmos
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);
}
Example #13
0
static void
EventLoop (void)
{
    short err;
    int fid;
    FormPtr form;
    EventType event;

    do
    {
	EvtGetEvent(&event, 200);

	// let the system handle it's own events
	if (SysHandleEvent(&event)) continue;

	// same for menu events
	if (MenuHandleEvent((void *)0, &event, &err)) continue;

	// set up our handler when our main form is loaded
	if (event.eType == frmLoadEvent) {
	    fid = event.data.frmLoad.formID;
	    form = FrmInitForm(fid);
	    FrmSetActiveForm(form);

	    switch (fid) {
	    case fid_kartrando:
		FrmSetEventHandler(form, mainEventHandler);
		break;
	    case fid_prefs:
		FrmSetEventHandler(form, prefsEventHandler);
		break;
	    }
	}

	FrmDispatchEvent(&event);

    } while (event.eType != appStopEvent);
}
Example #14
0
/* The main event loop */
static void EventLoop(void)
{
        UInt16 err;
        EventType e;
        static float timeout = .05;

        do {
                if( EQIsEmpty() &&
                    timeout < 600 &&
                    !DrawFlashies() )
                {
                        timeout *= 2;
                } else {
                        timeout = .05;
                }

                EvtGetEvent(&e, timeout * SysTicksPerSecond());
                if (! SysHandleEvent (&e))
                        if (! MenuHandleEvent (NULL, &e, &err) )
                                if (! ApplicationHandleEvent (&e) )
                                        if( ! FrmDispatchEvent (&e) )
                                                GameEvents();
        } while (e.eType != appStopEvent);
}
Example #15
0
int event_loop(void) {
  UInt16 error;
  EventType event;
  FormPtr form;
  int form_id;
  Regiondesc rd;

  do {
    EvtGetEvent(&event, 0); // No timeout - return immediately
    if (!SysHandleEvent(&event))
      if (!MenuHandleEvent(NULL, &event, &error))
	if (event.eType == frmLoadEvent) {
	  // Load and activate form.
	  form_id = event.data.frmLoad.formID;
	  form = FrmInitForm(form_id);
	  FrmSetActiveForm(form);
	  switch (form_id) {
	  case formID_main_ri_sim: FrmSetEventHandler(form, (FormEventHandlerPtr) ri_sim_event); break;
	  case formID_sys_info: FrmSetEventHandler(form, (FormEventHandlerPtr) sys_info_event); break;
	  }
	} else
	    FrmDispatchEvent(&event);
  } while (event.eType != appStopEvent);
}
Example #16
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);

}
Example #17
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;
}