Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Facepunch.Steamworks/Generated/Interfaces/ISteamInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ internal int GetDigitalActionOrigins( InputHandle_t inputHandle, InputActionSetH
var returnValue = _GetDigitalActionOrigins( Self, inputHandle, actionSetHandle, digitalActionHandle, ref originsOut );
return returnValue;
}

#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamInput_GetStringForDigitalActionName", CallingConvention = Platform.CC)]
private static extern Utf8StringPointer _GetStringForDigitalActionName( IntPtr self, InputDigitalActionHandle_t eActionHandle );
Expand Down
4 changes: 2 additions & 2 deletions Facepunch.Steamworks/Generated/SteamEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ public enum InputSourceMode : int
//
// EInputActionOrigin
//
internal enum InputActionOrigin : int
public enum InputActionOrigin : int
{
None = 0,
SteamController_A = 1,
Expand Down Expand Up @@ -1996,7 +1996,7 @@ internal enum ControllerActionOrigin : int
Count = 386,
MaximumPossibleValue = 32767,
}

//
// ESteamControllerLEDFlag
//
Expand Down
182 changes: 171 additions & 11 deletions Facepunch.Steamworks/SteamInput.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using Steamworks.Data;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace Steamworks
{
Expand All @@ -11,6 +14,8 @@ public class SteamInput : SteamClientClass<SteamInput>
{
internal static ISteamInput Internal => Interface as ISteamInput;

internal static int STEAM_INPUT_MAX_ORIGINS = 16;

internal override bool InitializeInterface( bool server )
{
SetInterface( server, new ISteamInput( server ) );
Expand All @@ -21,6 +26,14 @@ internal override bool InitializeInterface( bool server )

internal const int STEAM_CONTROLLER_MAX_COUNT = 16;

/// <summary>
/// Must be called when starting use of the ISteamInput interface.
/// </summary>
public static void Init( bool explicitlyCallRunFrame = false )
{
Internal.Init( explicitlyCallRunFrame );
}


/// <summary>
/// You shouldn't really need to call this because it gets called by <see cref="SteamClient.RunCallbacks"/>
Expand Down Expand Up @@ -51,29 +64,125 @@ public static IEnumerable<Controller> Controllers
}


/// <summary>
/// Return an absolute path to the PNG image glyph for the provided digital action name. The current
/// action set in use for the controller will be used for the lookup. You should cache the result and
/// maintain your own list of loaded PNG assets.
/// </summary>
/// <param name="controller"></param>
/// <param name="action"></param>
/// <returns></returns>
public static string GetDigitalActionGlyph( Controller controller, string action )
/// <summary>
/// Return an absolute path to the PNG image glyph for the provided analog action name. The current
/// action set in use for the controller will be used for the lookup. You should cache the result and
/// maintain your own list of loaded PNG assets.
/// </summary>
/// <param name="controller"></param>
/// <param name="action"></param>
/// <returns></returns>
public static string GetAnalogActionGlyph( Controller controller, string action )
{
InputActionOrigin origin = InputActionOrigin.None;

Internal.GetAnalogActionOrigins(
controller.Handle,
Internal.GetCurrentActionSet( controller.Handle ),
GetAnalogActionHandle( action ),
ref origin
);

return Internal.GetGlyphForActionOrigin_Legacy( origin );
}


/// <summary>
/// Return an array of all origins mapped to the provided analog action in the current action set
/// </summary>
/// <returns></returns>
public static InputActionOrigin[] GetAnalogActionOrigins( Controller controller, string action )
{
InputActionOrigin[] origins = new InputActionOrigin[STEAM_INPUT_MAX_ORIGINS];

Internal.GetAnalogActionOrigins(
controller.Handle,
Internal.GetCurrentActionSet( controller.Handle ),
GetAnalogActionHandle( action ),
ref origins[0]
);
return origins;
}


/// <summary>
/// Return an array of all origins mapped to the provided analog action in the specified action set
/// </summary>
/// <returns></returns>
public static InputActionOrigin[] GetAnalogActionOrigins( Controller controller, string actionSet, string action )
{
InputActionOrigin[] origins = new InputActionOrigin[STEAM_INPUT_MAX_ORIGINS];

Internal.GetAnalogActionOrigins(
controller.Handle,
Internal.GetActionSetHandle(actionSet),
GetAnalogActionHandle( action ),
ref origins[0]
);
return origins;
}


/// <summary>
/// Return an absolute path to the PNG image glyph for the provided digital action name. The current
/// action set in use for the controller will be used for the lookup. You should cache the result and
/// maintain your own list of loaded PNG assets.
/// </summary>
/// <param name="controller"></param>
/// <param name="action"></param>
/// <returns></returns>
public static string GetDigitalActionGlyph( Controller controller, string action )
{
InputActionOrigin origin = InputActionOrigin.None;
InputActionOrigin[] origins = new InputActionOrigin[16];

Internal.GetDigitalActionOrigins(
int originCount = Internal.GetDigitalActionOrigins(
controller.Handle,
Internal.GetCurrentActionSet(controller.Handle),
GetDigitalActionHandle(action),
ref origin
);

return Internal.GetGlyphForActionOrigin_Legacy(origin);
return Internal.GetGlyphForActionOrigin_Legacy(origin);
}


/// <summary>
/// Return an array of all origins mapped to the provided digital action in the current action set
/// </summary>
/// <returns></returns>
public static InputActionOrigin[] GetDigitalActionOrigins( Controller controller, string action )
{
InputActionOrigin[] origins = new InputActionOrigin[STEAM_INPUT_MAX_ORIGINS];

Internal.GetDigitalActionOrigins(
controller.Handle,
Internal.GetCurrentActionSet( controller.Handle ),
GetDigitalActionHandle( action ),
ref origins[0]
);
return origins;
}


/// <summary>
/// Return an array of all origins mapped to the provided action set and digital action
/// </summary>
/// <returns></returns>
public static InputActionOrigin[] GetDigitalActionOrigins( Controller controller, string actionSet, string action )
{
InputActionOrigin[] origins = new InputActionOrigin[STEAM_INPUT_MAX_ORIGINS];

Internal.GetDigitalActionOrigins(
controller.Handle,
Internal.GetActionSetHandle( actionSet ),
GetDigitalActionHandle( action ),
ref origins[0]
);
return origins;
}


/// <summary>
/// Return an absolute path to the PNG image glyph for the provided digital action name. The current
/// action set in use for the controller will be used for the lookup. You should cache the result and
Expand All @@ -88,6 +197,14 @@ public static string GetPngActionGlyph( Controller controller, string action, Gl
return Internal.GetGlyphPNGForActionOrigin( origin, size, 0 );
}

/// <summary>
/// Return an absolute path to the PNG image glyph for the provided action origin
/// </summary>
public static string GetPngActionGlyphForOrigin( InputActionOrigin origin, GlyphSize size )
{
return Internal.GetGlyphPNGForActionOrigin( origin, size, 0 );
}

/// <summary>
/// Return an absolute path to the SVF image glyph for the provided digital action name. The current
/// action set in use for the controller will be used for the lookup. You should cache the result and
Expand All @@ -102,6 +219,49 @@ public static string GetSvgActionGlyph( Controller controller, string action )
return Internal.GetGlyphSVGForActionOrigin( origin, 0 );
}

/// <summary>
/// Show the binding panel for the specified controller.
/// If the player is using Big Picture Mode the configuration will open in the overlay.
/// In desktop mode a popup window version of Big Picture will be created and open the configuration.
/// </summary>
/// <returns>true for success; false if overlay is disabled or unavailable.</returns>
public static bool ShowBindingPanel(Controller controller)
{
return Internal.ShowBindingPanel(controller.Handle);
}

/// <summary>
/// Get the localized description of the button assigned to the specified digital action
/// </summary>
public static string GetDigitalActionDescription(Controller controller, string action)
{
InputActionOrigin origin = InputActionOrigin.None;

Internal.GetDigitalActionOrigins(
controller.Handle,
Internal.GetCurrentActionSet( controller.Handle ),
GetDigitalActionHandle( action ),
ref origin
);
return Internal.GetStringForActionOrigin( origin );
}

/// <summary>
/// Get the localized description of the joystick or gamepad assigned to the specified analog action
/// </summary>
public static string GetAnalogActionDescription( Controller controller, string action )
{
InputActionOrigin origin = InputActionOrigin.None;

Internal.GetAnalogActionOrigins(
controller.Handle,
Internal.GetCurrentActionSet( controller.Handle ),
GetAnalogActionHandle( action ),
ref origin
);
return Internal.GetStringForActionOrigin( origin );
}

internal static Dictionary<string, InputDigitalActionHandle_t> DigitalHandles = new Dictionary<string, InputDigitalActionHandle_t>();
internal static InputDigitalActionHandle_t GetDigitalActionHandle( string name )
{
Expand Down
19 changes: 14 additions & 5 deletions Facepunch.Steamworks/SteamUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ internal static void InstallEvents( bool server )
Dispatch.Install<LowBatteryPower_t>( x => OnLowBatteryPower?.Invoke( x.MinutesBatteryLeft ), server );
Dispatch.Install<SteamShutdown_t>( x => SteamClosed(), server );
Dispatch.Install<GamepadTextInputDismissed_t>( x => OnGamepadTextInputDismissed?.Invoke( x.Submitted ), server );
Dispatch.Install<FloatingGamepadTextInputDismissed_t>( x => OnFloatingGamepadTextInputDismissed?.Invoke(), server );
}

private static void SteamClosed()
Expand Down Expand Up @@ -60,6 +61,11 @@ private static void SteamClosed()
/// </summary>
public static event Action<bool> OnGamepadTextInputDismissed;

/// <summary>
/// Invoked when floating keyboard invoked from ShowFloatingGamepadTextInput has been closed.
/// </summary>
public static event Action OnFloatingGamepadTextInputDismissed;

/// <summary>
/// Returns the number of seconds since the application was active.
/// </summary>
Expand Down Expand Up @@ -191,6 +197,14 @@ public static bool ShowGamepadTextInput( GamepadTextInputMode inputMode, Gamepad
return Internal.ShowGamepadTextInput( inputMode, lineInputMode, description, (uint)maxChars, existingText );
}

/// <summary>
/// Opens a floating keyboard over the game content and sends OS keyboard keys directly to the game
/// </summary>
public static bool ShowFloatingGamepadTextInput( TextInputMode mode, int left, int top, int width, int height )
{
return Internal.ShowFloatingGamepadTextInput( mode, left, top, width, height );
}

/// <summary>
/// Returns previously entered text.
/// </summary>
Expand Down Expand Up @@ -295,10 +309,5 @@ public static string FilterText( TextFilteringContext context, SteamId sourceSte
/// Steam Input translate the controller input into mouse/kb to navigate the launcher
/// </summary>
public static void SetGameLauncherMode( bool mode ) => Internal.SetGameLauncherMode( mode );

//public void ShowFloatingGamepadTextInput( TextInputMode mode, int left, int top, int width, int height )
//{
// Internal.ShowFloatingGamepadTextInput( mode, left, top, width, height );
//}
}
}
Binary file added UnityPlugin/Facepunch.Steamworks.Posix.dll
Binary file not shown.
Binary file added UnityPlugin/Facepunch.Steamworks.Win32.dll
Binary file not shown.
Binary file added UnityPlugin/Facepunch.Steamworks.Win64.dll
Binary file not shown.