On May 14, 2009, at 10:45 AM, Christopher Hansen wrote:

I'm writing a game and I need to set the key and key repeat thresholds in my Cocoa application. The functions needed to do to this under Carbon (Events.h) are:

LMGetKeyThresh
LMSetKeyThresh
LMGetKeyRepThresh
LMSetKeyRepThresh

I'm looking for the Cocoa equivalents.

Unlike the other responses, I'm going to take a different tack:

Since you're writing a game, you probably don't want to worry about key repeat thresholds, either getting or setting. Instead, you should care about key/button down and key/button up events, and map those to state in your game engine.

The reason is that your game probably has its own internal concept of "repeating" that may not map at all to the typing concept of "repeating." An example would be a first-person shooter that supplies an automatic weapon: Different weapons will have different rates of fire. You may even have an energy weapon that fires as long as the user is (conceptually) pulling the trigger.

This is a game-engine level concept, not something you should try to map to input handling necessarily. Just use your input handling to supply your game engine with the necessary information. For the most flexibility in doing this take a look at the HID Manager APIs, especially the new HID APIs introduced in Mac OS X 10.5 Leopard.

  -- Chris

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to