Input Action
Support us as a GitHub Sponsor and get instant access to all our assets, exclusive tools and assets, escalated support and issue tracking and our gratitude.
These articles are made possible by our GitHub Sponsors ... become a sponsor today!
public class InputAction : GameEvent<InputActionData>
Type | Name | Comment |
---|---|---|
InputActionType | type | The type of action (Analog or Digital) |
string | actionName | |
InputAnalogActionHandle_t | AnalogHandle | The native Steam API handle if this is a analog handle and has been resolved. |
InputDigitalActionHandle_t | DigitalHandle | The native Steam API handle if this is a digital handle and has been resolved. |
public InputActionData this[InputHandle_t controller];
This returns the current cashed state for this action and for this controller, this does not update the state with the latest data from Steam it simply returns the last updated state. Typically you would have a behaviour poll all relivent actions at the start of an update and let various behaviours simply read the last known state for the actions they are interested in.
public class PlayerController : MonoBehaviour
{
Steamworks.InputHandle_t controller;
public InputAction someAction;
// ...
private void Start()
{
controller = HeathenEngineering.SteamworksIntegration.API.Input.Client.ConnectedControllers[0];
}
//...
private void Update()
{
SteamSettings.Client.UpdateAllActions(controller);
var actionData = someAction[controller];
if(actionData.active)
Debug.Log("Engaged: " + actionData.state);
}
}
Once you have a script updating the status of your actions other behaviours can simply read that most recent state;
public class SomeOtherBehaviour : MonoBehaviour
{
Steamworks.InputHandle_t controller;
public InputAction otherAction;
// ...
private void Start()
{
controller = HeathenEngineering.SteamworksIntegration.API.Input.Client.ConnectedControllers[0];
}
// ...
private void Update()
{
var actionData = otherAction[controller];
if(actionData.active)
Debug.Log("Engaged: " + actionData.state);
}
}
public void UpdateStatus(InputHandle_t controller);
Call this to update the state of the action for the indicated controller.
var controller = Input.Client.ConnectedControllers[0];
// ...
testAction.UpdateStatus(controller);
You can optionally call this for all actions at once via the Steam Settings object
var controller = Input.Client.ConnectedControllers[0];
// ...
SteamSettings.Client.UpdateAllActions(controller);
public Texture2D[] GetInputGlyphs(InputHandle_t controller, InputActionSet set);
public Texture2D[] GetInputGlyphs(InputHandle_t controller, InputActionSetLayer set);
public Texture2D[] GetInputGlyphs(InputHandle_t controller, InputactionSetHandle_t set);
This returns the set of textures related to the action for the given controller and action set. For example if this action exists on the indicated set and is mapped to the B button and Right Trigger then the B button texture and RT texture will be returned.
The images for these can be configured in your app.
var images = action.GetInputGlyphs(controller, actionSet);
// ...
rawImage.Texture = images[0];
public string[] GetInputNames(InputHandle_t controller, InputActionSet set);
public string[] GetInputNames(InputHandle_t controller, InputActionSetLayer set);
public string[] GetInputNames(InputHandle_t controller, InputactionSetHandle_t set);
This returns the set of names related to the action for the given controller and action set. For example if this action exists on the indicated set and is mapped to B and Right Trigger then the string "B Button" and "Right Trigger" will be returned.
var names = action.GetInputNames(controller, actionSet);
// ...
label.Text = names[0];

Click the AI or DI buttton to change the type
AI represents "Analog Input"
DI represents "Digital Input"

Last modified 1mo ago