Add bindings for retrieving InputActionOrigins for a Controller.

This commit is contained in:
Herman Groenenboom 2023-04-07 10:54:45 +02:00
parent 7c62042af2
commit d19f420a24

View File

@ -1,5 +1,6 @@
using Steamworks.Data;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
namespace Steamworks
@ -30,6 +31,40 @@ namespace Steamworks
public void ActivateLayer( string layer ) => SteamInput.Internal.ActivateActionSetLayer( Handle, SteamInput.Internal.GetActionSetHandle( layer ) );
public void ClearLayers() => SteamInput.Internal.DeactivateAllActionSetLayers( Handle );
#region Action Origins
internal const int STEAM_INPUT_MAX_ORIGINS = 8;
internal InputActionSetHandle_t ActionSetHandle => SteamInput.Internal.GetCurrentActionSet( Handle );
/// <summary>
/// Get the origin(s) for an analog action within an action set.
/// Use this to display the appropriate on-screen prompt for the action.
/// <para>
/// This is cheap, and Valve recommends you re-gather the origins each frame to update your ingame prompts in case they have changed.
/// </para>
/// </summary>
public IEnumerable<InputActionOrigin> GetAnalogActionOrigins( string actionName )
{
InputActionOrigin[] actionOrigins = new InputActionOrigin[STEAM_INPUT_MAX_ORIGINS];
int numOrigins = SteamInput.Internal.GetAnalogActionOrigins( Handle, ActionSetHandle, SteamInput.Internal.GetAnalogActionHandle( actionName ), ref actionOrigins[0] );
return actionOrigins.Take( numOrigins );
}
/// <summary>
/// Get the origin(s) for a digital action within an action set.
/// Use this to display the appropriate on-screen prompt for the action.
/// <para>
/// This is cheap, and Valve recommends you re-gather the origins each frame to update your ingame prompts in case they have changed.
/// </para>
/// </summary>
public IEnumerable<InputActionOrigin> GetDigitalActionOrigins( string actionName )
{
InputActionOrigin[] actionOrigins = new InputActionOrigin[STEAM_INPUT_MAX_ORIGINS];
int numOrigins = SteamInput.Internal.GetDigitalActionOrigins( Handle, ActionSetHandle, SteamInput.Internal.GetDigitalActionHandle( actionName ), ref actionOrigins[0] );
return actionOrigins.Take( numOrigins );
}
#endregion Action Origins
/// <summary>
/// Returns the current state of the supplied digital game action