Add SteamInput Get(Analog|Digital)ActionOrigin; SteamUtils ShowFloatingKeyboardTextInput

This commit is contained in:
David Tootill 2024-02-26 17:08:42 -08:00
parent a6677dbe04
commit 0c3f4ec5fc
4 changed files with 68 additions and 10 deletions

View File

@ -216,7 +216,7 @@ namespace Steamworks
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 );

View File

@ -1048,7 +1048,7 @@ namespace Steamworks
//
// EInputActionOrigin
//
internal enum InputActionOrigin : int
public enum InputActionOrigin : int
{
None = 0,
SteamController_A = 1,
@ -1996,7 +1996,7 @@ namespace Steamworks
Count = 386,
MaximumPossibleValue = 32767,
}
//
// ESteamControllerLEDFlag
//

View File

@ -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
{
@ -11,6 +14,8 @@ namespace Steamworks
{
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 ) );
@ -82,6 +87,24 @@ namespace Steamworks
}
/// <summary>
/// Return an array of all origins mapped to the provided analog action
/// </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 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
@ -93,18 +116,37 @@ namespace Steamworks
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
/// </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 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
@ -119,6 +161,14 @@ namespace Steamworks
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

View File

@ -30,6 +30,7 @@ namespace Steamworks
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()
@ -60,6 +61,10 @@ namespace Steamworks
/// </summary>
public static event Action<bool> OnGamepadTextInputDismissed;
/// <summary>
/// Invoked when floating keyboard invoked from ShowFloatingGamepadTextInput has been closed.
public static event Action OnFloatingGamepadTextInputDismissed;
/// <summary>
/// Returns the number of seconds since the application was active.
/// </summary>
@ -191,6 +196,14 @@ namespace Steamworks
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>
@ -295,10 +308,5 @@ namespace Steamworks
/// 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 );
//}
}
}