Re: Cocoa and full-screen GL
Re: Cocoa and full-screen GL
- Subject: Re: Cocoa and full-screen GL
- From: Guy English <email@hidden>
- Date: Mon, 31 Jan 2005 22:05:33 -0500
On Mon, 31 Jan 2005 18:19:01 -0800, John Stiles <email@hidden> wrote:
> So, hmm... is there any way I could override "sendEvent," catch all the
> events, and then route them to an NSView of my choice?
Yeah ... one of the things I had a hard time with was the different
'modes' of input a game expects. You'll need raw key up / down stuff
but you'd also like the 'cooked' input stuff for doing text entry and
the higher level AppKit stuff.
>From my reading of the docs the run loop inside NSApp calls sendEvent
to do the actual dispatch and you'll be able to catch them all there.
You can examine [[NSApp keyWindow] firstResponder] and dispatch as you
please. The trouble is you want to control the run loop - otherwise
you're stuck only updating as fast as you can fire off timers. The one
thing you've got going for you is that you know what input mode you're
interested in given the game state. I'd set a flag when the user is
focused on one of your text fields and set the key windows first
responder to a hidden NSTextField and grab the contents out of that
and stick it back into your text field after each sendEvent. I'm not
sure how feasible this is for you guys. It would depend on how much
interaction with the Lua context running the UI you've got down at the
platform level I suppose.
So, roughly:
while ( running )
{
event = next_event();
if ( mode == raw )
dispatch_to_lowlevel_input( event )
else
[NSApp sendEvent: event];
}
set_mode( the_new_mode )
{
if ( the_new_mode == raw )
{
[[[NSApp keyWindow] makeFirstResponder: openGLView];
}
else
{
[[NSApp keyWindow] makeFirstResponder: hiddenTextField];
}
mode = the_new_mode;
}
When I rewrote the stuff off the standard app kit run loop I started
with Tim Woods Game Developer code as reference, but he kind of
side-steps this issue. I can't remember off hand but I think the Quake
code that was GPL'd also punts. I do remember having trouble getting
the run-loop to do what I wanted originally which is why I switched
over to the event polling model. But that was ages ago, 10.0, possibly
public beta, so things may have improved now.
Take care,
Guy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden