Jump to content
  • Advertisement
Sign in to follow this  
TheBroodian

How to support multiple input devices

This topic is 2262 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

I'm currently developing a PC game with the assistance of XNA and I'm integrating keyboard and gamepad control support. Up until now I've only supported gamepad control, and finding an elegant way to allow the player to choose one or the other is posing a complicated task to resolve.

I was thinking of creating a class that would sort of convert either input into a universal sort of data that the game could then use for the player's character and the rest of the game to interpret- but I don't exactly know what that might look like, and I don't know where to start?

Then, I thought maybe it would be simpler to create a duplicate of my main character's class, except adjust it to respond to keyboard input instead of gamepad input.

Can anybody offer any insight?

Share this post


Link to post
Share on other sites
Advertisement
You can just write your input handling code however you want. Gather your keyboard input, then gather your gamepad input. They can each call your character's movement methods if you are using direct control or they can each issue their own commands (in a scripting system) or in a command pattern. Another way is to have each input device output game-effect structs and define their addition in order to resolve conflicts or differences, this can be all done in the struct, which sounds like your idea of having a universal data representing your game commands.

You can have an interpreting class as you thought as well, I've done that before and just passed my mouse/keyboard data into it where it can be made sense of in game terms. I'd say use a method that you are comfortable with and just try to make it work as best you can. Edited by Gavin Williams

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!