mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-14 07:38:06 +03:00
Cleanup, crash fixes
This commit is contained in:
parent
fa48a1ce33
commit
bddac0ccc9
@ -21,7 +21,8 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
Console.Write( $"Controller: {controller}" );
|
Console.Write( $"Controller: {controller}" );
|
||||||
|
|
||||||
var state = controller.GetDigitalState( "fire" );
|
var dstate = controller.GetDigitalState( "fire" );
|
||||||
|
var astate = controller.GetAnalogState( "Move" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,17 @@ namespace Steamworks
|
|||||||
_GetActiveActionSetLayers = Marshal.GetDelegateForFunctionPointer<FGetActiveActionSetLayers>( Marshal.ReadIntPtr( VTable, 80) );
|
_GetActiveActionSetLayers = Marshal.GetDelegateForFunctionPointer<FGetActiveActionSetLayers>( Marshal.ReadIntPtr( VTable, 80) );
|
||||||
_GetDigitalActionHandle = Marshal.GetDelegateForFunctionPointer<FGetDigitalActionHandle>( Marshal.ReadIntPtr( VTable, 88) );
|
_GetDigitalActionHandle = Marshal.GetDelegateForFunctionPointer<FGetDigitalActionHandle>( Marshal.ReadIntPtr( VTable, 88) );
|
||||||
_GetDigitalActionData = Marshal.GetDelegateForFunctionPointer<FGetDigitalActionData>( Marshal.ReadIntPtr( VTable, 96) );
|
_GetDigitalActionData = Marshal.GetDelegateForFunctionPointer<FGetDigitalActionData>( Marshal.ReadIntPtr( VTable, 96) );
|
||||||
|
_GetDigitalActionData_Windows = Marshal.GetDelegateForFunctionPointer<FGetDigitalActionData_Windows>( Marshal.ReadIntPtr( VTable, 96) );
|
||||||
_GetDigitalActionOrigins = Marshal.GetDelegateForFunctionPointer<FGetDigitalActionOrigins>( Marshal.ReadIntPtr( VTable, 104) );
|
_GetDigitalActionOrigins = Marshal.GetDelegateForFunctionPointer<FGetDigitalActionOrigins>( Marshal.ReadIntPtr( VTable, 104) );
|
||||||
_GetAnalogActionHandle = Marshal.GetDelegateForFunctionPointer<FGetAnalogActionHandle>( Marshal.ReadIntPtr( VTable, 112) );
|
_GetAnalogActionHandle = Marshal.GetDelegateForFunctionPointer<FGetAnalogActionHandle>( Marshal.ReadIntPtr( VTable, 112) );
|
||||||
_GetAnalogActionData = Marshal.GetDelegateForFunctionPointer<FGetAnalogActionData>( Marshal.ReadIntPtr( VTable, 120) );
|
_GetAnalogActionData = Marshal.GetDelegateForFunctionPointer<FGetAnalogActionData>( Marshal.ReadIntPtr( VTable, 120) );
|
||||||
|
_GetAnalogActionData_Windows = Marshal.GetDelegateForFunctionPointer<FGetAnalogActionData_Windows>( Marshal.ReadIntPtr( VTable, 120) );
|
||||||
_GetAnalogActionOrigins = Marshal.GetDelegateForFunctionPointer<FGetAnalogActionOrigins>( Marshal.ReadIntPtr( VTable, 128) );
|
_GetAnalogActionOrigins = Marshal.GetDelegateForFunctionPointer<FGetAnalogActionOrigins>( Marshal.ReadIntPtr( VTable, 128) );
|
||||||
_GetGlyphForActionOrigin = Marshal.GetDelegateForFunctionPointer<FGetGlyphForActionOrigin>( Marshal.ReadIntPtr( VTable, 136) );
|
_GetGlyphForActionOrigin = Marshal.GetDelegateForFunctionPointer<FGetGlyphForActionOrigin>( Marshal.ReadIntPtr( VTable, 136) );
|
||||||
_GetStringForActionOrigin = Marshal.GetDelegateForFunctionPointer<FGetStringForActionOrigin>( Marshal.ReadIntPtr( VTable, 144) );
|
_GetStringForActionOrigin = Marshal.GetDelegateForFunctionPointer<FGetStringForActionOrigin>( Marshal.ReadIntPtr( VTable, 144) );
|
||||||
_StopAnalogActionMomentum = Marshal.GetDelegateForFunctionPointer<FStopAnalogActionMomentum>( Marshal.ReadIntPtr( VTable, 152) );
|
_StopAnalogActionMomentum = Marshal.GetDelegateForFunctionPointer<FStopAnalogActionMomentum>( Marshal.ReadIntPtr( VTable, 152) );
|
||||||
_GetMotionData = Marshal.GetDelegateForFunctionPointer<FGetMotionData>( Marshal.ReadIntPtr( VTable, 160) );
|
_GetMotionData = Marshal.GetDelegateForFunctionPointer<FGetMotionData>( Marshal.ReadIntPtr( VTable, 160) );
|
||||||
|
_GetMotionData_Windows = Marshal.GetDelegateForFunctionPointer<FGetMotionData_Windows>( Marshal.ReadIntPtr( VTable, 160) );
|
||||||
_TriggerVibration = Marshal.GetDelegateForFunctionPointer<FTriggerVibration>( Marshal.ReadIntPtr( VTable, 168) );
|
_TriggerVibration = Marshal.GetDelegateForFunctionPointer<FTriggerVibration>( Marshal.ReadIntPtr( VTable, 168) );
|
||||||
_SetLEDColor = Marshal.GetDelegateForFunctionPointer<FSetLEDColor>( Marshal.ReadIntPtr( VTable, 176) );
|
_SetLEDColor = Marshal.GetDelegateForFunctionPointer<FSetLEDColor>( Marshal.ReadIntPtr( VTable, 176) );
|
||||||
_TriggerHapticPulse = Marshal.GetDelegateForFunctionPointer<FTriggerHapticPulse>( Marshal.ReadIntPtr( VTable, 184) );
|
_TriggerHapticPulse = Marshal.GetDelegateForFunctionPointer<FTriggerHapticPulse>( Marshal.ReadIntPtr( VTable, 184) );
|
||||||
@ -64,14 +67,17 @@ namespace Steamworks
|
|||||||
_GetActiveActionSetLayers = null;
|
_GetActiveActionSetLayers = null;
|
||||||
_GetDigitalActionHandle = null;
|
_GetDigitalActionHandle = null;
|
||||||
_GetDigitalActionData = null;
|
_GetDigitalActionData = null;
|
||||||
|
_GetDigitalActionData_Windows = null;
|
||||||
_GetDigitalActionOrigins = null;
|
_GetDigitalActionOrigins = null;
|
||||||
_GetAnalogActionHandle = null;
|
_GetAnalogActionHandle = null;
|
||||||
_GetAnalogActionData = null;
|
_GetAnalogActionData = null;
|
||||||
|
_GetAnalogActionData_Windows = null;
|
||||||
_GetAnalogActionOrigins = null;
|
_GetAnalogActionOrigins = null;
|
||||||
_GetGlyphForActionOrigin = null;
|
_GetGlyphForActionOrigin = null;
|
||||||
_GetStringForActionOrigin = null;
|
_GetStringForActionOrigin = null;
|
||||||
_StopAnalogActionMomentum = null;
|
_StopAnalogActionMomentum = null;
|
||||||
_GetMotionData = null;
|
_GetMotionData = null;
|
||||||
|
_GetMotionData_Windows = null;
|
||||||
_TriggerVibration = null;
|
_TriggerVibration = null;
|
||||||
_SetLEDColor = null;
|
_SetLEDColor = null;
|
||||||
_TriggerHapticPulse = null;
|
_TriggerHapticPulse = null;
|
||||||
@ -224,10 +230,20 @@ namespace Steamworks
|
|||||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
private delegate DigitalState FGetDigitalActionData( IntPtr self, InputHandle_t inputHandle, InputDigitalActionHandle_t digitalActionHandle );
|
private delegate DigitalState FGetDigitalActionData( IntPtr self, InputHandle_t inputHandle, InputDigitalActionHandle_t digitalActionHandle );
|
||||||
private FGetDigitalActionData _GetDigitalActionData;
|
private FGetDigitalActionData _GetDigitalActionData;
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
private delegate void FGetDigitalActionData_Windows( IntPtr self, ref DigitalState retVal, InputHandle_t inputHandle, InputDigitalActionHandle_t digitalActionHandle );
|
||||||
|
private FGetDigitalActionData_Windows _GetDigitalActionData_Windows;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
internal DigitalState GetDigitalActionData( InputHandle_t inputHandle, InputDigitalActionHandle_t digitalActionHandle )
|
internal DigitalState GetDigitalActionData( InputHandle_t inputHandle, InputDigitalActionHandle_t digitalActionHandle )
|
||||||
{
|
{
|
||||||
|
if ( Config.Os == OsType.Windows )
|
||||||
|
{
|
||||||
|
var retVal = default( DigitalState );
|
||||||
|
_GetDigitalActionData_Windows( Self, ref retVal, inputHandle, digitalActionHandle );
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
return _GetDigitalActionData( Self, inputHandle, digitalActionHandle );
|
return _GetDigitalActionData( Self, inputHandle, digitalActionHandle );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,10 +273,20 @@ namespace Steamworks
|
|||||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
private delegate AnalogState FGetAnalogActionData( IntPtr self, InputHandle_t inputHandle, InputAnalogActionHandle_t analogActionHandle );
|
private delegate AnalogState FGetAnalogActionData( IntPtr self, InputHandle_t inputHandle, InputAnalogActionHandle_t analogActionHandle );
|
||||||
private FGetAnalogActionData _GetAnalogActionData;
|
private FGetAnalogActionData _GetAnalogActionData;
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
private delegate void FGetAnalogActionData_Windows( IntPtr self, ref AnalogState retVal, InputHandle_t inputHandle, InputAnalogActionHandle_t analogActionHandle );
|
||||||
|
private FGetAnalogActionData_Windows _GetAnalogActionData_Windows;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
internal AnalogState GetAnalogActionData( InputHandle_t inputHandle, InputAnalogActionHandle_t analogActionHandle )
|
internal AnalogState GetAnalogActionData( InputHandle_t inputHandle, InputAnalogActionHandle_t analogActionHandle )
|
||||||
{
|
{
|
||||||
|
if ( Config.Os == OsType.Windows )
|
||||||
|
{
|
||||||
|
var retVal = default( AnalogState );
|
||||||
|
_GetAnalogActionData_Windows( Self, ref retVal, inputHandle, analogActionHandle );
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
return _GetAnalogActionData( Self, inputHandle, analogActionHandle );
|
return _GetAnalogActionData( Self, inputHandle, analogActionHandle );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,10 +338,20 @@ namespace Steamworks
|
|||||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
private delegate MotionState FGetMotionData( IntPtr self, InputHandle_t inputHandle );
|
private delegate MotionState FGetMotionData( IntPtr self, InputHandle_t inputHandle );
|
||||||
private FGetMotionData _GetMotionData;
|
private FGetMotionData _GetMotionData;
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
private delegate void FGetMotionData_Windows( IntPtr self, ref MotionState retVal, InputHandle_t inputHandle );
|
||||||
|
private FGetMotionData_Windows _GetMotionData_Windows;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
internal MotionState GetMotionData( InputHandle_t inputHandle )
|
internal MotionState GetMotionData( InputHandle_t inputHandle )
|
||||||
{
|
{
|
||||||
|
if ( Config.Os == OsType.Windows )
|
||||||
|
{
|
||||||
|
var retVal = default( MotionState );
|
||||||
|
_GetMotionData_Windows( Self, ref retVal, inputHandle );
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
return _GetMotionData( Self, inputHandle );
|
return _GetMotionData( Self, inputHandle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,13 +86,15 @@ namespace Steamworks
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
internal static Dictionary<string, InputActionSetHandle_t> ActionSets = new Dictionary<string, InputActionSetHandle_t>();
|
||||||
/// Lookup the handle for an Action Set. Best to do this once on startup, and store the handles for all future API calls.
|
internal static InputActionSetHandle_t GetActionSetHandle( string name )
|
||||||
/// </summary>
|
|
||||||
public static ActionSet GetActionSet( string name )
|
|
||||||
{
|
{
|
||||||
return new ActionSet( Internal.GetActionSetHandle( name ) );
|
if ( ActionSets.TryGetValue( name, out var val ) )
|
||||||
}
|
return val;
|
||||||
|
|
||||||
|
val = Internal.GetActionSetHandle( name );
|
||||||
|
ActionSets.Add( name, val );
|
||||||
|
return val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +0,0 @@
|
|||||||
using Steamworks.Data;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Steamworks
|
|
||||||
{
|
|
||||||
public struct ActionSet
|
|
||||||
{
|
|
||||||
internal InputActionSetHandle_t Handle;
|
|
||||||
|
|
||||||
internal ActionSet( InputActionSetHandle_t handle )
|
|
||||||
{
|
|
||||||
this.Handle = handle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,15 +21,14 @@ namespace Steamworks
|
|||||||
/// This is cheap, and can be safely called repeatedly. It's often easier to repeatedly call it in
|
/// This is cheap, and can be safely called repeatedly. It's often easier to repeatedly call it in
|
||||||
/// our state loops, instead of trying to place it in all of your state transitions.
|
/// our state loops, instead of trying to place it in all of your state transitions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ActionSet ActionSet
|
public string ActionSet
|
||||||
{
|
{
|
||||||
get => new ActionSet( SteamInput.Internal.GetCurrentActionSet( Handle ) );
|
set => SteamInput.Internal.ActivateActionSet( Handle, SteamInput.Internal.GetActionSetHandle( value ) );
|
||||||
set => SteamInput.Internal.ActivateActionSet( Handle, value.Handle );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeactivateLayer( ActionSet layer ) => SteamInput.Internal.DeactivateActionSetLayer( Handle, layer.Handle );
|
public void DeactivateLayer( string layer ) => SteamInput.Internal.DeactivateActionSetLayer( Handle, SteamInput.Internal.GetActionSetHandle( layer ) );
|
||||||
public void ActivateLayer( ActionSet layer ) => SteamInput.Internal.ActivateActionSetLayer( Handle, layer.Handle );
|
public void ActivateLayer( string layer ) => SteamInput.Internal.ActivateActionSetLayer( Handle, SteamInput.Internal.GetActionSetHandle( layer ) );
|
||||||
public void ClearLayers( ActionSet layer ) => SteamInput.Internal.DeactivateAllActionSetLayers( Handle );
|
public void ClearLayers() => SteamInput.Internal.DeactivateAllActionSetLayers( Handle );
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -87,7 +86,9 @@ namespace Steamworks
|
|||||||
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
|
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
|
||||||
public struct DigitalState
|
public struct DigitalState
|
||||||
{
|
{
|
||||||
|
[MarshalAs( UnmanagedType.I1 )]
|
||||||
internal byte BState; // bState byte
|
internal byte BState; // bState byte
|
||||||
|
[MarshalAs( UnmanagedType.I1 )]
|
||||||
internal byte BActive; // bActive byte
|
internal byte BActive; // bActive byte
|
||||||
|
|
||||||
public bool Pressed => BState != 0;
|
public bool Pressed => BState != 0;
|
||||||
|
@ -57,6 +57,9 @@ internal class BaseType
|
|||||||
if ( basicType == "NetIdentity" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
if ( basicType == "NetIdentity" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
if ( basicType == "NetAddress" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
if ( basicType == "NetAddress" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
if ( basicType == "ConnectionInfo" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
if ( basicType == "ConnectionInfo" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
|
if ( basicType == "DigitalState" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
|
if ( basicType == "AnalogState" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
|
if ( basicType == "MotionState" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
if ( basicType.StartsWith( "E" ) && char.IsUpper( basicType[1] ) ) return new EnumType { NativeType = type.Substring( 1 ), VarName = varname };
|
if ( basicType.StartsWith( "E" ) && char.IsUpper( basicType[1] ) ) return new EnumType { NativeType = type.Substring( 1 ), VarName = varname };
|
||||||
|
|
||||||
return new BaseType { NativeType = type, VarName = varname };
|
return new BaseType { NativeType = type, VarName = varname };
|
||||||
@ -164,9 +167,10 @@ internal class StructType : BaseType
|
|||||||
{
|
{
|
||||||
"DigitalState",
|
"DigitalState",
|
||||||
"AnalogState",
|
"AnalogState",
|
||||||
|
"MotionState",
|
||||||
};
|
};
|
||||||
|
|
||||||
public override bool IsReturnedWeird => SpecialTypes.Contains( TypeName );
|
public override bool IsReturnedWeird => SpecialTypes.Contains( StructName );
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class SteamApiCallType : BaseType
|
internal class SteamApiCallType : BaseType
|
||||||
|
Loading…
x
Reference in New Issue
Block a user