Skip to main content
gamedev.net
🔒 Locked

Key Bindings!

Started by golgoth13 Mar 3, 2009 at 1:00 PM 1 replies 1k views
Original Post
golgoth13
golgoth13
Greetings everyone, I do have ideas but I wonder if there is there is an elegant solution for User Key Binding. As an example on what I want to achieve is to reproduce 3D package navigation, like XSI and Maya. Both require a user key like L-Alt and a mouse click to Orbit, Zoom and Pan. Any ideas on how to switch between them would appreciated. Let say: XSI User key: L-Alt Mouse LC = Orbit Mouse MC = Pan Mouse RC = Zoom Maya User key: L-CTRL Mouse LC = Pan Mouse MC = Zoom Mouse RC = Orbit thx
DantarionX
DantarionX
Are you asking about key binding, or are you asking how to do the 3D transforms for the camera movements?
~Dantar
Zakwayda
Zakwayda
I think he's asking about how to store and use different sets of key bindings (control preferences).

@The OP: Here's a brief outline of one approach you could take:

1. First, abstract the mouse buttons so that mouse buttons and keyboard keys can be treated uniformly.

2. You'll need some way to convert between key IDs (enums, integers, or whatever) and their text representations (e.g. KEY_LALT to "L-Alt").

3. Store the key bindings for a particular configuration in a text file (it would probably look a lot like the examples you posted).

4. Read the configuration file corresponding to the set of bindings that you want, and build a map that associates key IDs with commands (e.g. zoom, pan, etc.).

5. When a key is pressed or released, look for the corresponding ID in the map. If the ID is found, take the appropriate action (start or stop the specified behavior, depending on whether it was a key up event or a key down event).

6. If you want to change the configuration while the app is running, just load and read the new configuration file and rebuild the map.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.