Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

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

Can anybody offer any insight?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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.

This is the right idea. Use a abstract action codes instead of actual Key Codes or Button Codes. Not only does this let you support keyboard + gamepad, it also lets you (or the player) remap controls.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.