Full Screen Key Capture Issues

Posts: 613
Joined: 2004.09
Post: #1
So over the last few months ive been toying off and on with this code and I cant quite get it to work. Ive narrowed it down a whole bunch but I was hoping for a little guidance since this is my first time really working with OpenGL.

The problem is that my event captures all keys in the window mode just fine. But as soon as I try and go fullscreen it rejects all key input. What I mean by that is any key input I do while in fullscreen I get a system beep.

I checked the code with printf() and it installed the event handler just fine in both modes. In the windowed mode I get an event occured printf, but in full screen it dosnt even call my event handler.

If I call a CGDisplayRelease() and bring up my menu I can capture key strokes while I have a menu bar pulled down but if I dont have a menu bar selected I still get a system beep.

void InitMyEventHandler(void)
    EventTypeSpec    events[3] = {
                                kEventClassKeyboard, kEventRawKeyDown,
                                kEventClassKeyboard, kEventRawKeyUp,
                                kEventClassKeyboard, kEventRawKeyModifiersChanged,

            /* CREATE EVENT HANDLER */

    gMyEventHandlerUPP = NewEventHandlerUPP(MyEventHandler);
    InstallEventHandler(GetApplicationEventTarget(), gMyEventHandlerUPP, 3, events, nil, &gMyEventHandlerRef);
    //InstallEventHandler(GetUserFocusEventTarget(), gMyEventHandlerUPP, 3, events, nil, &gMyEventHandlerRef);

I hope this is enough info, If anyone wants to take a look at my full source let me know I would be happy to email it to you.

Thanks in advance for the help, and thanks for your time

Kyle Richter
Twitter: @kylerichter
Quote this message in a reply
Posts: 112
Joined: 2002.06
Post: #2
I couldn't find anything wrong with the code you posted. I wrote an article on reading the keyboard with Carbon events. You can find the article using the link in my signature. The article includes a small sample program that reads key presses in fullscreen mode.

Mark Szymczyk
Quote this message in a reply
Posts: 613
Joined: 2004.09
Post: #3
I figured out what my issue was, I was missing a RunApplicationMainLoop(); in my switch to full screen code. Thanks for the help Mark, your article lead me down the right path.

Kyle Richter
Twitter: @kylerichter
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Full Screen OpenGL Crashes Blacktiger 13 12,861 Feb 19, 2009 02:39 PM
Last Post: backslash
  OpenGL full screen mode leaves garbage on screen when exiting app Malarkey 5 7,960 Nov 19, 2008 12:51 PM
Last Post: Malarkey
  Changing resolution while already in full-screen mode? Malarkey 1 3,934 Jun 10, 2008 07:49 PM
Last Post: AnotherJake
  Full Screen Switching Blacktiger 3 5,239 Feb 9, 2008 03:05 PM
Last Post: Blacktiger
  Dealing with Battery Low Warning During Full Screen AnotherJake 8 8,840 Feb 8, 2008 12:26 PM
Last Post: OneSadCookie