App not Frontmost
So here is my issue, Im using GetKeys for the first time. This works great and everything no sign of the missing GetKeys bug yet. Anyways everything works fine in Windowed and Full Screen till the user switches to another app. The game continues to accept inputs from any other app which is understandable normal behavior for get keys.
My question is, is there a way i can check to see if the game app is the front most app? This would allow me to either pause or ignore key inputs if it is not. I know there is something in com.apple.HIToolbox.menuBarShownNotification I just cant seem to be able to get it working correctly.
By the way i would REALLY like to avoid polling =D.
Thanks for the help in Advance guys.
My question is, is there a way i can check to see if the game app is the front most app? This would allow me to either pause or ignore key inputs if it is not. I know there is something in com.apple.HIToolbox.menuBarShownNotification I just cant seem to be able to get it working correctly.
By the way i would REALLY like to avoid polling =D.
Thanks for the help in Advance guys.
You can register for Carbon events that notify you when your application is activated/deactivated. Take a look a kEventClassApplication/kEventAppActivated and kEventClassApplication/kEventAppDeactivated. When you receive a deactivate event, it's a good idea to pause your event loop timer and stop accepting input until you receive an activate event.
- Alex Diener
- Alex Diener
Don't use GetKeys. It's old and it doesn't work and it's not the right way to do things anymore. You should definitely be receiving keyboard events through a registered event handler instead.
You can easly build a event handler that basicly is the same as GetKeys....
You just "log" a key when you get a key down event and "un-log" a key when you get a key up.
(no GetKeys... no 72% of your time in GetKeys...
)
You just "log" a key when you get a key down event and "un-log" a key when you get a key up.
(no GetKeys... no 72% of your time in GetKeys...
)
Global warming is caused by hobos and mooses
72% of the time =p. I have heard more like 1 out of 900 times.

