how to mapping Controller button?

May 26, 2009 at 7:46 AM


I  wish that if Keyboard A is pushed, game detect Controller's A button is pushed. (same If real Controller's A button is pushed)

I find out KeyboardMouseControlMapping Class , but i don't know how to use this class. Explanation of this class not exist in Tutorial. 



May 27, 2009 at 11:50 AM
Edited May 27, 2009 at 11:51 AM

Hi. Once again sorry about the late reply.

This is documented in the KeyboardMouseControlMapping class, you can simply assign the values within the class:
To make the gamepad 'A' button to the keyboard 'A' key would be:

Microsoft.Xna.Framework.Input.Keys key = Microsoft.Xna.Framework.Input.Keys.A;

state.PlayerInput[0].KeyboardMouseControlMapping.A = new KeyboardMouseControlMap(key);

To make it simpler, there is an implicit conversion operator too:

state.PlayerInput[0].KeyboardMouseControlMapping.A = key;

You can also assign MouseInput states (Windows only).
However, note that analog/digital states cannot always be mixed. Eg, you cannot assign a mouse axis to a gamepad button (because the mouse axis is analog, the button is digital).
The class also has a 'TestForConflicts()' method, which returns true if two or more mappings share the same input.

May 27, 2009 at 12:15 PM


It's work perfectly!

Xen is really Good!


I have another question,

Can I use Xen in Dream Build Play? ( or other Game Contest)
May 27, 2009 at 12:16 PM
Edited May 27, 2009 at 12:17 PM

Thanks, and of course you can!
You can do whatever you want with it! :-)

May 27, 2009 at 12:20 PM



Hope for the future of Xen will be wonderful.