Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

mse61

DI and cooking the input

This topic is 6114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you go about ''cooking'' the keyboard input from DI into a user map of the keyboard, ie allowing the user to select which key they want to use? ~mse61 "It''s a dog eat dog world and I''m wearing Milkbone underwear."

Share this post


Link to post
Share on other sites
Advertisement
I would try something like having a structure that contains all forms of input, like this:

  
struct PlayerInput
{
int JUMP;
int FORWARD;
int BACKWARD;
...
};


Then you can declare an instance of it wherever you want. Let''s say you declared a PlayerInput object called input. When you check your input, you can do:

  
if (KeyDown(input.jump))
...


that way, you can change the user input easily. About actually changing the input, how you want to go about it depends on the number of controls that you have.

Share this post


Link to post
Share on other sites
Ok, clarification of what I want. I can get the input from DI but I have to use DI key codes to refrence it. What I need is a system that allows me to load a key map from and ini or data file and then use the map to cook the input, i.e. asign DI_UP to player_up or whatever.

Share this post


Link to post
Share on other sites
DX8 offers a new feature called "action mapping" for that purpose. take a look at the DInput SDK examples.

Though all this stuff uses pre-defined key sets, it might be useful...

Share this post


Link to post
Share on other sites
just use a struct like above, but instead of ints use DWORDS...i think that is the type you''ll want.

then you could just do something like:

player.jump = DIK_SPACE;
player.moveForward = DIK_W;

and then check like:

if ( directInputSystem->checkKeyPress ( player.jump ) )
// the player pressed jump, process accordingly

if ( directInputSystem->checkKeyPress ( player.moveForward ) )
// player''s moving forward...

// et cetera.

of course ''directInputSystem->checkKeyPress()'' would be some method you would write to check if arbitrary keys have been pressed...



<(o)>

Share this post


Link to post
Share on other sites
Thanx for you help. It let me figure out what I need to finish the key binding function.

~mse61

ICQ: 122419859
AIM: ThePhantomTIE
e-mail: randlem@bgnet.bgsu.edu

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!