Exemplo n.º 1
0
int macgetch(void)
{
    WindowPtr whichWindow;
    EventRecord theEvent;
    char c;                     /* one-byte buffer for read() to use */

    do {
        SystemTask();
        if (!GetNextEvent(everyEvent, &theEvent))
            theEvent.what = nullEvent;
        else {
            switch (theEvent.what) {
            case keyDown:
                c = theEvent.message & charCodeMask;
                break;
            case mouseDown:
                if (FindWindow(theEvent.where, &whichWindow) ==
                    inSysWindow)
                    SystemClick(&theEvent, whichWindow);
                break;
            case updateEvt:
                break;
            }
        }
    } while (theEvent.what != keyDown);

    printf("*");
    fflush(stdout);

    return (int)c;
}
Exemplo n.º 2
0
/* wait for MacTCP to finish whatever it's doing, with user cancel
 */
static short tcp_wait(struct tcpstate *ts, tcpinfo *tcp)
{
	KeyMap mapkeys;
#define keys ((unsigned char *)mapkeys)
	short percent;

	while (!tcp_checkdriver()
		|| (tcp && (tcp->state & TCP_DNSINUSE) && ! (volatile) tcp->dnrdone)
		|| (tcp && (tcp->state & TCP_PBINUSE) && (volatile short) tcp->pb.ioResult == 1)) {
		if (ts) {
			if (!ts->waiticks) return (0);
			percent = ((TickCount() - ts->waitstart) * 100) / ts->waiticks;
			if (percent > 100) percent = 100;
			if (percent != ts->waitpercent) {
				(*ts->tcp_initp)(ts->waitpercent = percent);
			}
			if (percent == 100) return (0);
		}
		SystemTask();
		GetKeys(mapkeys);
		if ((keys[0x37 >> 3] >> (0x37 & 7))
			& (keys[0x2f >> 3] >> (0x2f & 7)) & 1) {
			return (0);
		}
	}
	
	return (1);
}
Exemplo n.º 3
0
void MacIdle(void)
{
  extern logical anywarns;
  static long time = 0;

  EventRecord myEvent;
  WindowPtr whichWindow;
#if TARGET_API_MAC_CARBON
  Rect tempRect;
#endif
  char theChar;

  if (TickCount()<time) return;
  if (mac_quit_now) {
    anywarns = FALSE;  /* kludge so that window doesn't sit around */
    my_exit(1);
  }
#if !TARGET_API_MAC_CARBON
  SystemTask();
#endif
  if (WaitNextEvent(everyEvent, &myEvent, 1, nil)) {

    if (!SIOUXHandleOneEvent(&myEvent)) switch (myEvent.what) {

    case mouseDown:
      switch (FindWindow(myEvent.where,&whichWindow)) {

      case inMenuBar:
	MenuSelect(myEvent.where);
	break;
#if !TARGET_API_MAC_CARBON
      case inSysWindow:
	SystemClick(&myEvent,whichWindow);
	break;
#endif
      case inContent:
	SelectWindow(whichWindow);
	break;
      case inDrag:
#if TARGET_API_MAC_CARBON
	GetRegionBounds(GetGrayRgn(),&tempRect);
	DragWindow(whichWindow,myEvent.where,&tempRect);
#else
	DragWindow(whichWindow,myEvent.where,&qd.screenBits.bounds);
#endif
	break;
      }
      break;
    case keyDown:
      theChar = myEvent.message & charCodeMask;
      break;
    case updateEvt:
      BeginUpdate((WindowPtr) myEvent.message);
      EndUpdate((WindowPtr) myEvent.message);
      break;
    }
  }
  time=TickCount()+20;
}
Exemplo n.º 4
0
/*
 * Do a SystemTask() call and check for abort key sequence.
 */
void STasks()
{
	SystemTask();
	if (isAbortEvent()) {
		printf("ABORTING...\n");
		ExitToShell();
	}
}
Exemplo n.º 5
0
Arquivo: ugView.c Projeto: rolk/ug
static void ProcessEvent ()
{
  EventRecord myEvent;
  WindowPtr whichWindow;

  /* do system tasks */
  SystemTask();

  /* get event */
  if (GetNextEvent(everyEvent,&myEvent))
  {
    switch (myEvent.what)
    {
    case mouseDown :
      switch (FindWindow(myEvent.where,&whichWindow))
      {
      case inSysWindow :
        SystemClick(&myEvent,whichWindow);
        break;
      case inMenuBar :
        DoCommand(MenuSelect(myEvent.where));
        break;
      case inDrag :
        DragWindow(whichWindow,myEvent.where,&dragRect);
        break;
      case inContent :
        if (whichWindow!=FrontWindow())
          SelectWindow(whichWindow);
        else
        {
          /*DoContentClick(whichWindow,&myEvent);*/
        }
        break;
      case inGrow :
        /*DoGrowWindow(whichWindow,&myEvent);*/
        break;
      case inGoAway :
        /*DoGoAway(whichWindow,&myEvent);*/
        break;
      }
      break;                           /* mouseDown */

    case keyDown :
    case autoKey :
      DoKey(&myEvent);
      break;

    case activateEvt :
      /*DoActivate(&myEvent);*/
      break;

    case updateEvt :
      whichWindow = (WindowPtr) myEvent.message;
      /*DoUpdate(whichWindow,&myEvent);*/
      break;
    }
  }
} /* ProcessEvent */
Exemplo n.º 6
0
int pause( void )
{
	while ( !Button() )
	{
		SystemTask();
	}
	
	return 1;
}
Exemplo n.º 7
0
static void CallSystemTask()
  {
   static unsigned long int lastCall;

   if (TickCount() < (lastCall + 10)) return;
   SystemTask();
   lastCall = TickCount();
   return;
  }
Exemplo n.º 8
0
void
full_interrupt_poll (int *counter)
{
  SystemTask ();
  if (interrupt_key_down ())
    putc ('\n', stdout);
  /* 200 seems to be a good compromise here between
     interrupt latency and cpu-bound performance */
  *counter = 200;
}
Exemplo n.º 9
0
void SDL_Delay(Uint32 ms)
{
        Uint32 stop, now;

        stop = SDL_GetTicks() + ms;
        do {
                SystemTask();

                now = SDL_GetTicks();

        } while ( stop > now );
}
Exemplo n.º 10
0
void SDL_Delay(Uint32 ms)
{
        Uint32 stop, now;

        stop = SDL_GetTicks() + ms;
        do {
            #if TARGET_API_MAC_CARBON
                MPYield();
            #else
                SystemTask();
            #endif

                now = SDL_GetTicks();

        } while ( stop > now );
}
Exemplo n.º 11
0
/*--> SANRGParseGame: parse a single game sequence from the current file */
static
siT
SANRGParseGame(void)
{
siT flag;

#if (defined(THINK_C))
SystemTask();
#endif

/* set default return value */

flag = 1;

/* prepare for scan */

SANInitGround();
SANTagClearAll();
gst_done = 0;
gsf_mvc = 0;
gsf_fmc = 0;

/* scan */

while (flag && !gst_done)
	flag = SANRGParseForm();

/* check for game termination to make a game */

if (gtc != gtc_norm)
	{
	gsf_gn++;
	if (optnv[optn_verb])
		SANDspStrSINL("Finished translation for game number: ", gsf_gn);
	};

return (flag);
}
Exemplo n.º 12
0
void __PHYSFS_platformTimeslice(void)
{
    SystemTask();
} /* __PHYSFS_platformTimeslice */
static OSStatus OpenTest(void)
{
	OSStatus err;
	OSStatus junk;
	EndpointRef ep1;
	EndpointRef ep2;
	MapperRef map1;
	MapperRef map2;
	ATSvcRef at1;
	ATSvcRef at2;
	InetSvcRef inet1;
	InetSvcRef inet2;
	ProviderRef prov1;
	ProviderRef prov2;

	ep1   = NULL;
	ep2   = NULL;
	map1  = NULL;
	map2  = NULL;
	at1   = NULL;
	at2   = NULL;
	inet1 = NULL;
	inet2 = NULL;
	prov1 = NULL;
	prov2 = NULL;
	
	ep1 = OTOpenEndpointInContext(OTCreateConfiguration("tcp"), 0, NULL, &err, NULL);
	if (err == noErr) {
		err = OTAsyncOpenEndpointInContext(OTCreateConfiguration("tcp"), 0, NULL, DummyNotifier, &ep2, NULL);
		if (err == noErr) {
			while (ep2 == NULL) {
				SystemTask();
			}
			if (ep2 == (void *) -1) {
				err = -1;
			}
		}
	}

	if (err == noErr) {
		map1 = OTOpenMapperInContext(OTCreateConfiguration("nbp"), 0, &err, NULL);
	}
	if (err == noErr) {
		err = OTAsyncOpenMapperInContext(OTCreateConfiguration("nbp"), 0, DummyNotifier, &map2, NULL);
		if (err == noErr) {
			while (map2 == NULL) {
				SystemTask();
			}
			if (map2 == (void *) -1) {
				err = -1;
			}
		}
	}

	if (err == noErr) {
		inet1 = OTOpenInternetServicesInContext(kDefaultInternetServicesPath, 0, &err, NULL);
	}
	if (err == noErr) {
		err = OTAsyncOpenInternetServicesInContext(kDefaultInternetServicesPath, 0, DummyNotifier, &inet2, NULL);
		if (err == noErr) {
			while (inet2 == NULL) {
				SystemTask();
			}
			if (inet2 == (void *) -1) {
				err = -1;
			}
		}
	}

	if (err == noErr) {
		at1 = OTOpenAppleTalkServicesInContext(kDefaultAppleTalkServicesPath, 0, &err, NULL);
	}
	if (err == noErr) {
		err = OTAsyncOpenAppleTalkServicesInContext(kDefaultAppleTalkServicesPath, 0, DummyNotifier, &at2, NULL);
		if (err == noErr) {
			while (at2 == NULL) {
				SystemTask();
			}
			if (at2 == (void *) -1) {
				err = -1;
			}
		}
	}


	if (err == noErr) {
		prov1 = OTOpenProviderInContext(OTCreateConfiguration("enet"), 0, &err, NULL);
	}
	if (err == noErr) {
		err = OTAsyncOpenProviderInContext(OTCreateConfiguration("enet"), 0, DummyNotifier, &prov2, NULL);
		if (err == noErr) {
			while (prov2 == NULL) {
				SystemTask();
			}
			if (prov2 == (void *) -1) {
				err = -1;
			}
		}
	}

	if (ep1 != NULL) {
		junk = OTCloseProvider(ep1);
		assert(junk == noErr);
	}
	if (ep2 != NULL) {
		junk = OTCloseProvider(ep2);
		assert(junk == noErr);
	}
	if (map1 != NULL) {
		junk = OTCloseProvider(map1);
		assert(junk == noErr);
	}
	if (map2 != NULL) {
		junk = OTCloseProvider(map2);
		assert(junk == noErr);
	}
	if (at1 != NULL) {
		junk = OTCloseProvider(at1);
		assert(junk == noErr);
	}
	if (at2 != NULL) {
		junk = OTCloseProvider(at2);
		assert(junk == noErr);
	}
	if (inet1 != NULL) {
		junk = OTCloseProvider(inet1);
		assert(junk == noErr);
	}
	if (inet2 != NULL) {
		junk = OTCloseProvider(inet2);
		assert(junk == noErr);
	}
	if (prov1 != NULL) {
		junk = OTCloseProvider(prov1);
		assert(junk == noErr);
	}
	if (prov2 != NULL) {
		junk = OTCloseProvider(prov2);
		assert(junk == noErr);
	}
	return err;
}
Exemplo n.º 14
0
static void SendFlowControlTest(void)
{
	OSStatus  err;
	OSStatus  junk;
	MPQueueID deathQueue;
	MPTaskID  rcvTask;
	MPTaskID  sndTask;

	gRcvStarted = false;
	gLookerEP = NULL;
	gQuitLooker = false;
	
	deathQueue = kInvalidID;
	err = MPCreateQueue(&deathQueue);
	if (err == noErr) {
		err = MPCreateTask(SFCRcv, NULL, 65536, deathQueue, (void *) 1, (void *) 666, kNilOptions, &rcvTask);
	}
	if (err == noErr) {
		MPLogPrintf("Waiting for receiver to start.\n");
		while ( ! gRcvStarted ) {
			printf(".");
			fflush(stdout);
		}
		MPLogPrintf("\n");
	}
	if (err == noErr) {
		err = MPCreateTask(SFCSnd, NULL, 65536, deathQueue, (void *) 2, (void *) 666, kNilOptions, &sndTask);
	}
	if (err == noErr) {
		err = MPCreateTask(SFCLooker, NULL, 65536, deathQueue, (void *) 3, (void *) 666, kNilOptions, &rcvTask);
	}
	if (err == noErr) {
		UInt32 terminatedTaskCount;
		UInt32 taskNumber;
		OSStatus taskStatus;
		UInt32 lastPrinted;
		
		lastPrinted = 0;
		terminatedTaskCount = 0;
		do {
			err = MPWaitOnQueue(deathQueue, (void **) &taskNumber, NULL, (void **) &taskStatus, kDurationImmediate);
			if (err == noErr) {
				MPLogPrintf("Task number %ld completed with status %ld.\n", taskNumber, taskStatus);
				terminatedTaskCount += 1;
			} else if (err == kMPTimeoutErr) {
				#if !TARGET_API_MAC_CARBON
					SystemTask();
				#endif
				if (TickCount() > (lastPrinted + 60)) {
					printf(".");
					fflush(stdout);
					lastPrinted = TickCount();
				}
				err = noErr;
			}
		} while ( (err == noErr) && (terminatedTaskCount < 3) );
	}
	
	// Clean up.
	
	if (deathQueue != kInvalidID) {
		junk = MPDeleteQueue(deathQueue);
		assert(junk == noErr);
	}

	printf("gLookCounter = %ld\n", gLookCounter);
	gLookCounter = 0;
	
	if (err == noErr) {
		printf("Success!\n");
	} else {
		printf("Failed with error %ld.\n", err);
	}
}
Exemplo n.º 15
0
void RunLoop()
{
	EventRecord    theEvent;
	WindowPtr whichWindow;
	Rect txRect;
	
	txRect = qd.thePort->portRect;
	
	InsetRect(&txRect,4,0);
	textH = TENew(&txRect,&txRect);
	
	while (!quit)
	{
		SystemTask();
		TEIdle(textH);

		if (GetNextEvent(everyEvent, &theEvent))
		{
			switch (theEvent.what)
			{
				case mouseDown:
				{
					switch (FindWindow(theEvent.where, &whichWindow))
					{
						case inSysWindow:
						{
							SystemClick(&theEvent, whichWindow);
							break;
						}
						case inMenuBar:
						{
							DoCommand(MenuSelect(theEvent.where));
							break;
						}
						case inDrag:
						{
							DragWindow(whichWindow, theEvent.where, &qd.screenBits.bounds);
							break;
						}
						case inContent:
						{
							if (whichWindow != FrontWindow())
							{
								SelectWindow(whichWindow);
							}
							else
							{
								GlobalToLocal(&theEvent.where);
								if (theEvent.modifiers&shiftKey)
									isShift = true;
								
								TEClick(theEvent.where, isShift, textH);
							}
							break;
						}

						case inGoAway:
						{
							if (TrackGoAway(whichWindow, theEvent.where)) {
								quit = true;
							}
							break;
						}

						default:
							break;
					}
					break;
				}
				case autoKey:
				case keyDown:
				{
					char theChar = (theEvent.message&charCodeMask);
					
					if (theEvent.modifiers&cmdKey)
					{
						DoCommand(MenuKey(theChar));
						
						if (theChar == 'm')
						{
							quit = true;
						}
					}
					else
					{
						TEKey(theChar, textH);
					}
					
					break;
				}
				case activateEvt:
				{
					if (theEvent.modifiers&activeFlag)
					{
						TEActivate(textH);
					}
					else
					{
						TEDeactivate(textH);
					}
					break;
				}
				case updateEvt:
				{
					BeginUpdate((WindowPtr)theEvent.message);
					EraseRect(&(qd.thePort->portRect));
					TEUpdate(&(qd.thePort->portRect), textH);
					EndUpdate((WindowPtr)theEvent.message);
					break;
				}
				default:
					break;
			}
		}
	}
}
Exemplo n.º 16
0
void StereoObject::SetUpForInputOfPoleOrMatrix()
static OSStatus StreamTest(void)
{
	OSStatus err;
	OSStatus junk;
	StreamRef strm1;
	StreamRef strm2;
	StreamRef strm3;
	StreamRef strm4;
	
	strm1 = NULL;
	strm2 = NULL;
	strm3 = NULL;
	strm4 = NULL;

	err = noErr;
	if (err == noErr) {
		strm1 = OTStreamOpenInContext("sad", 0, &err, NULL);
	}
	if (err == noErr) {
		err = OTAsyncStreamOpenInContext("sad", 0, DummyNotifier, &strm2, NULL);
		if (err == noErr) {
			while (strm2 == NULL) {
				SystemTask();
			}
			if (strm2 == (void *) -1) {
				err = -1;
			}
		}
	}
	if (err == noErr) {
		strm3 = OTCreateStreamInContext(OTCreateConfiguration("tcp"), 0, &err, NULL);
	}
	if (err == noErr) {
		err = OTAsyncCreateStreamInContext(OTCreateConfiguration("tcp"), 0, DummyNotifier, &strm4, NULL);
		if (err == noErr) {
			while (strm4 == NULL) {
				SystemTask();
			}
			if (strm4 == (void *) -1) {
				err = -1;
			}
		}
	}
	
	if (strm1 != NULL) {	
		junk = OTStreamClose(strm1);
		assert(junk == noErr);
	}
	if (strm2 != NULL) {	
		junk = OTStreamClose(strm2);
		assert(junk == noErr);
	}
	if (strm3 != NULL) {	
		junk = OTStreamClose(strm3);
		assert(junk == noErr);
	}
	if (strm4 != NULL) {	
		junk = OTStreamClose(strm4);
		assert(junk == noErr);
	}
	return err;
}