Key reading questions.

Member
Posts: 129
Joined: 2009.03
Post: #1
Almost finished the port of my game..

My default key definitions are using 'control' (player 1) and 'shift' (player 2) to fire (i.e. throw an egg).

I figure the mac can't seem to distinguish between left and right shift (same with control etc). That's correct yes?

Anyhoo, the problem I'm having is with control, if the player presses control in combination with the arrow (cursor) keys, the OS activates 'spaces' (the desktop switching thingy). This happens in windowed mode, I'm not sure if it happens in full-screen, maybe not; but in any case, I'd like to block this behaviour.

Is it possible to stop this?

Thank you.
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #2
Jamie W Wrote:Anyhoo, the problem I'm having is with control, if the player presses control in combination with the arrow (cursor) keys, the OS activates 'spaces' (the desktop switching thingy). This happens in windowed mode, I'm not sure if it happens in full-screen, maybe not; but in any case, I'd like to block this behaviour.

Is it possible to stop this?

This depends on the user's system settings for Spaces. I have mine set to control+command+arrows because control+arrows conflicted with the keyboard setup in an application I use. In any case, this isn't something you should be attempting to block; you'll create a bad user experience if you disable system functions that are expected to work while your game is running. A more friendly solution would be to allow users to change their key bindings so that they don't conflict with system functions they have set up, and adjust your defaults so that they don't conflict with system defaults. If you try to instead disable Space switching shortcuts, you'll be fighting the system and your users the entire way.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #3
Left and right shift have different key codes, and you can check the event modifier flags for the left/right key as well.
Quote this message in a reply
Member
Posts: 129
Joined: 2009.03
Post: #4
ThemsAllTook Wrote:A more friendly solution would be to allow users to change their key bindings so that they don't conflict with system functions they have set up, and adjust your defaults so that they don't conflict with system defaults. If you try to instead disable Space switching shortcuts, you'll be fighting the system and your users the entire way.

Sure, I can apprecieate that. The key bindings in my game are configurable by the user, so perhaps I shouldn't use control key as the the default fire button (not if it's going to trigger 'spaces' on most systems).

Which key do most mac games default to for 'fire', assuming they're using the cursors to move? (am a bit of a mac newbie).
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #5
Jamie W Wrote:Which key do most mac games default to for 'fire', assuming they're using the cursors to move? (am a bit of a mac newbie).

Space bar is usually a pretty good choice. For me, at least, the first keys I try in a game where I don't know the controls are the arrow keys, space, and the return key. I expect arrow keys to move, space to jump or fire (whichever is appropriate in the game), and return to confirm menu choices. If I can't find any keys that do what I want, I'll try modifier keys, then the letter keys near the modifiers (Z, X, A, S), then start trying letter keys at random until I find one that does something.
Quote this message in a reply
Member
Posts: 129
Joined: 2009.03
Post: #6
DoG Wrote:Left and right shift have different key codes, and you can check the event modifier flags for the left/right key as well.

That wasn't the case on my setup, I did the getModifierKeys (or something like that) function, and the controlKeyBit worked if you pressed left or right control, and the rightControlKeyBit didn't come on at all, no matter what I pressed.

Maybe it's just my setup (non apple keyboard etc)?

I've coded my game in such a way that it shouldn't be an issue, if the system detects the differences between left and right, or not.
Quote this message in a reply
Post Reply