If this is your first time reading this, you probably haven't signed up yet. Do so now by clicking here.

Members Login

Username:
Password:
Remember me ?      

Advertisement

Recommended Books

Partner Links

Forum - iDevApps » Mac, iPhone, iPad & iPod Development » APIs, Frameworks, & SDKs » Do Carbon Idle Event Timers work?

APIs, Frameworks, & SDKs Discussion and reference for Apple & third-party technologies.

Reply
Old 2004.08.11, 03:43 AM   #1
Dardan
Guest
 
Posts: n/a
Default Do Carbon Idle Event Timers work?

Hello everyone,

I'd first like to say that I have long used this forum as a valuable resource, and I just now got around to registering, so this is my first post! YaY!

Anyway, I am trying to set up a Carbon event loop that uses an idle event timer to drive the game loop. My problem is this: Xcode will not compile the callback function that my timer calls.

This is the error I get:
Prototypes.h:36: error: parse error before "EventIdleAction"

That error refers to the third line in this prototype:
Code:
pascal void NextFrame(  EventLoopTimerRef	timer,
			void		        *userData,
			EventIdleAction	        action );
I have no problem compiling a regular event timer callback, so it seems that EventIdleAction is the only thing giving me grief. I have read the Apple online docs, but the very code they supply does not compile. I have searched and searched for an example that uses idle event loop timers, and I have found nothing.

I set my timer up like this (almost exactly like the example in the Apple docs):
Code:
	EventLoopRef			mainLoop;		
	EventLoopIdleTimerUPP           idleTimerUPP;   
	EventLoopTimerRef		theTimer;		

	mainLoop = GetMainEventLoop();				
	idleTimerUPP = NewEventLoopTimerUPP( NextFrame );   
	InstallEventLoopIdleTimer( mainLoop,	
		                   0,	
                                   kEventDurationNoWait,		
		                   idleTimerUPP,			
		                   NULL,
		                   &theTimer );

        RunApplicationEventLoop();
Has anyone had this problem? If not, can someone please post a working example (or a summary of one anyway)?

Thanks a lot!


---
Dard.
  Reply With Quote
Old 2004.08.11, 08:16 AM   #2
ThemsAllTook
Moderator
 
ThemsAllTook's Avatar
 
Join Date: Mar 2005
Posts: 59
Default

Looking in CarbonEventsCore.h, I'm not seeing a typedef for EventIdleAction. What I did find was this:

Code:
typedef CALLBACK_API( void , EventLoopIdleTimerProcPtr )(EventLoopTimerRef inTimer, EventLoopIdleTimerMessage inState, void *inUserData);
Those are probably the function parameters you actually want. I have no idea why the Apple docs would have gotten it wrong, though...

Alex Diener
ThemsAllTook is offline   Reply With Quote
Old 2004.08.11, 08:48 AM   #3
radiance
Guest
 
Posts: n/a
Default

According the the CarbonEventsCore.h file:

Code:
*    Idle timers are
 *    only called when there is no user activity occuring in the
 *    application. This means that the user is not actively
 *    clicking/typing, and is also not in the middle of tracking a
 *    control, menu, or window
I think what you want is:

Code:
EventLoopTimerUPP myFrameUPP = NewEventLoopTimerUPP (NextFrame),
EventLoopTimerRef nextFrameTimer;


	InstallEventLoopTimer(
			GetCurrentEventLoop(),
			kEventDurationNoWait,
			kEventDurationMillisecond,
			myFrameUPP,
			NULL,
			&nextFrameTimer);

	RunApplicationEventLoop();
I use timers a lot to drive my game and it works very well.

Good luck,

::ken::
www.angelfroggames.com
  Reply With Quote
Old 2004.08.11, 12:25 PM   #4
FCCovett
Guest
 
Posts: n/a
Default

There's a fully working example here - with some other goodies: http://webpages.charter.net/utopiapl...rbonStruct.dmg
  Reply With Quote
Old 2004.08.11, 02:24 PM   #5
Dardan
Guest
 
Posts: n/a
Default

Thanks a lot for the help, everyone...

Just so you all don't think I'm crazy, here is a link to the docs that this code came from.

Goto:
http://developer.apple.com/documenta...ger/index.html

Then click "Carbon Event Manager Tasks," in the navigation bar, and then click "Installing Timers."

Thanks for the example and the tip... I'll be using a regular event timer now.
  Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 06:44 AM.