Full Screen Key Capture Issues

Moderator
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.

Code:
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);
    
    NSLog(@"Loaded");
}

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
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Member
Posts: 111
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
http://www.meandmark.com
Quote this message in a reply
Moderator
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
DragonForged.com
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 7,962 Feb 19, 2009 02:39 PM
Last Post: backslash
  OpenGL full screen mode leaves garbage on screen when exiting app Malarkey 5 5,367 Nov 19, 2008 12:51 PM
Last Post: Malarkey
  Changing resolution while already in full-screen mode? Malarkey 1 2,704 Jun 10, 2008 07:49 PM
Last Post: AnotherJake
  Full Screen Switching Blacktiger 3 3,671 Feb 9, 2008 03:05 PM
Last Post: Blacktiger
  Dealing with Battery Low Warning During Full Screen AnotherJake 8 5,817 Feb 8, 2008 12:26 PM
Last Post: OneSadCookie