General Reference

To assign a control, use the method:

Input.AssignControl(PlayerIndex player, String name, InputMethod method);


There are several overloads for this method, including:

//Assign an analog game pad part, with the same game pad player index as player
public void AssignControl(PlayerIndex player, string name, Pad.Generator gen)

//Assign an anolog game pad part, with a different game pad player index than player
public void AssignControl(PlayerIndex player, string name, PlayerIndex padPlayer, Pad.Generator gen)

//Assign a game pad button. The control will return 1.0f if the button is pressed, and 0.0f otherwise.
public void AssignControl(PlayerIndex player, string name, Buttons button)

//Assign two game pad buttons, one as returning 1.0f when pressed, the other -1.0f. If both or neither are pressed, the control will return 0.0f.
public void AssignControl(PlayerIndex player, string name, Buttons high, Buttons low)

//Assign a keyboard key to the control. it will return 1.0f when the key is pressed, and 0.0f otherwise.
public void AssignControl(PlayerIndex player, string name, Keys key)

//Assign two keyboard keys to a control. One returns 1.0f when pressed, the other -1.0f. If both or neither are pressed, the control will return 0.0f.
public void AssignControl(PlayerIndex player, string name, Keys high, Keys low)


You can also assign one control to all four player indices at the same time, by using the relevant AssignControl method without the player index.

We have two new control assignment methods that take strings as input, instead of a key or delegate. This is great if you want to use the input system with an xml settings document.

public void AssignContol(PlayerIndex player, string name, string source)
public void AssignControl(PlayerIndex player, string name, string high, string low)


The strings are formed by starting with the device name "Mouse", "Keyboard", "Pad" and then concatenating with dots the name of the item. Here are some examples:

Mouse.X
Pad.ThumbSticks.Left.Y
Pad.Up.A
Keyboard.JustPressed.Home


For buttons you need to include what kind of action to look for, such as Up, Down, JustPressed or JustReleased. Analog inputs are just named directly.

To get the state of a control, just call

float Input.ControlState(PlayerIndex player, String name);

Last edited Mar 23, 2009 at 4:00 AM by Shader, version 4

Comments

No comments yet.