This commit is contained in:
Garry Newman 2019-04-14 21:57:09 +01:00
parent db1cfde383
commit 9cf553a786
5 changed files with 618 additions and 373 deletions

View File

@ -0,0 +1,129 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using SteamNative;
namespace Steamworks.Internal
{
public class ISteamMusic : BaseSteamInterface
{
public override string InterfaceName => "STEAMMUSIC_INTERFACE_VERSION001";
public override void InitInternals()
{
BIsEnabledDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsEnabledDelegate>( Marshal.ReadIntPtr( VTable, 0) );
BIsPlayingDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsPlayingDelegate>( Marshal.ReadIntPtr( VTable, 8) );
GetPlaybackStatusDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetPlaybackStatusDelegate>( Marshal.ReadIntPtr( VTable, 16) );
PlayDelegatePointer = Marshal.GetDelegateForFunctionPointer<PlayDelegate>( Marshal.ReadIntPtr( VTable, 24) );
PauseDelegatePointer = Marshal.GetDelegateForFunctionPointer<PauseDelegate>( Marshal.ReadIntPtr( VTable, 32) );
PlayPreviousDelegatePointer = Marshal.GetDelegateForFunctionPointer<PlayPreviousDelegate>( Marshal.ReadIntPtr( VTable, 40) );
PlayNextDelegatePointer = Marshal.GetDelegateForFunctionPointer<PlayNextDelegate>( Marshal.ReadIntPtr( VTable, 48) );
SetVolumeDelegatePointer = Marshal.GetDelegateForFunctionPointer<SetVolumeDelegate>( Marshal.ReadIntPtr( VTable, 56) );
GetVolumeDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetVolumeDelegate>( Marshal.ReadIntPtr( VTable, 64) );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
public delegate bool BIsEnabledDelegate( IntPtr self );
private BIsEnabledDelegate BIsEnabledDelegatePointer;
#endregion
public bool BIsEnabled()
{
return BIsEnabledDelegatePointer( Self );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
public delegate bool BIsPlayingDelegate( IntPtr self );
private BIsPlayingDelegate BIsPlayingDelegatePointer;
#endregion
public bool BIsPlaying()
{
return BIsPlayingDelegatePointer( Self );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
public delegate AudioPlayback_Status GetPlaybackStatusDelegate( IntPtr self );
private GetPlaybackStatusDelegate GetPlaybackStatusDelegatePointer;
#endregion
public AudioPlayback_Status GetPlaybackStatus()
{
return GetPlaybackStatusDelegatePointer( Self );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
public delegate void PlayDelegate( IntPtr self );
private PlayDelegate PlayDelegatePointer;
#endregion
public void Play()
{
PlayDelegatePointer( Self );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
public delegate void PauseDelegate( IntPtr self );
private PauseDelegate PauseDelegatePointer;
#endregion
public void Pause()
{
PauseDelegatePointer( Self );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
public delegate void PlayPreviousDelegate( IntPtr self );
private PlayPreviousDelegate PlayPreviousDelegatePointer;
#endregion
public void PlayPrevious()
{
PlayPreviousDelegatePointer( Self );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
public delegate void PlayNextDelegate( IntPtr self );
private PlayNextDelegate PlayNextDelegatePointer;
#endregion
public void PlayNext()
{
PlayNextDelegatePointer( Self );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
public delegate void SetVolumeDelegate( IntPtr self, float flVolume );
private SetVolumeDelegate SetVolumeDelegatePointer;
#endregion
public void SetVolume( float flVolume )
{
SetVolumeDelegatePointer( Self, flVolume );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
public delegate float GetVolumeDelegate( IntPtr self );
private GetVolumeDelegate GetVolumeDelegatePointer;
#endregion
public float GetVolume()
{
return GetVolumeDelegatePointer( Self );
}
}
}

View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using SteamNative;
namespace Steamworks
{
/// <summary>
/// Undocumented Parental Settings
/// </summary>
public static class Music
{
static Internal.ISteamMusic _internal;
internal static Internal.ISteamMusic music
{
get
{
if ( _internal == null )
_internal = new Internal.ISteamMusic();
return _internal;
}
}
internal static void InstallEvents()
{
new Event<PlaybackStatusHasChanged_t>( x => OnPlaybackChanged?.Invoke() );
new Event<VolumeHasChanged_t>( x => OnVolumeChanged?.Invoke( x.NewVolume ) );
}
/// <summary>
/// Playback status changed
/// </summary>
public static event Action OnPlaybackChanged;
/// <summary>
/// Volume changed, parameter is new volume
/// </summary>
public static event Action<float> OnVolumeChanged;
/// <summary>
/// Checks if Steam Music is enabled
/// </summary>
public static bool IsEnabled => music.BIsEnabled();
/// <summary>
/// true if a song is currently playing, paused, or queued up to play; otherwise false.
/// </summary>
public static bool IsPlaying => music.BIsPlaying();
/// <summary>
/// Gets the current status of the Steam Music player
/// </summary>
public static AudioPlayback_Status Status => music.GetPlaybackStatus();
public static void Play() => music.Play();
public static void Pause() => music.Pause();
/// <summary>
/// Have the Steam Music player play the previous song.
/// </summary>
public static void PlayPrevious() => music.PlayPrevious();
/// <summary>
/// Have the Steam Music player skip to the next song
/// </summary>
public static void PlayNext() => music.PlayNext();
/// <summary>
/// Gets/Sets the current volume of the Steam Music player
/// </summary>
public static float Volume
{
get => music.GetVolume();
set => music.SetVolume( value );
}
}
}

View File

@ -6816,6 +6816,31 @@ public struct Pack8
#endregion
}
public struct PlaybackStatusHasChanged_t : Steamworks.ISteamCallback
{
#region ISteamCallback
public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 1;
public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) );
public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((PlaybackStatusHasChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((PlaybackStatusHasChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) ));
#endregion
#region Packed Versions
[StructLayout( LayoutKind.Sequential, Pack = 4 )]
public struct Pack4
{
public static implicit operator PlaybackStatusHasChanged_t ( PlaybackStatusHasChanged_t.Pack4 d ) => new PlaybackStatusHasChanged_t{ };
}
[StructLayout( LayoutKind.Sequential, Pack = 8 )]
public struct Pack8
{
public static implicit operator PlaybackStatusHasChanged_t ( PlaybackStatusHasChanged_t.Pack8 d ) => new PlaybackStatusHasChanged_t{ };
}
#endregion
}
public struct NewUrlLaunchParameters_t : Steamworks.ISteamCallback
{
@ -7458,6 +7483,7 @@ internal static void RegisterCallbacks( Facepunch.Steamworks.BaseSteamworks stea
new CallbackHandle<GSStatsReceived_t>( steamworks );
new CallbackHandle<GSStatsStored_t>( steamworks );
new CallbackHandle<GSStatsUnloaded_t>( steamworks );
new CallbackHandle<PlaybackStatusHasChanged_t>( steamworks );
new CallbackHandle<NewUrlLaunchParameters_t>( steamworks );
new CallbackHandle<ItemInstalled_t>( steamworks );
new CallbackHandle<SteamInventoryDefinitionUpdate_t>( steamworks );

View File

@ -95,6 +95,7 @@ public void ToFolder( string folder )
GenerateVTableClass( "ISteamApps", $"{folder}../Generated/Interfaces/ISteamApps.cs" );
GenerateVTableClass( "ISteamUtils", $"{folder}../Generated/Interfaces/ISteamUtils.cs" );
GenerateVTableClass( "ISteamParentalSettings", $"{folder}../Generated/Interfaces/ISteamParentalSettings.cs" );
GenerateVTableClass( "ISteamMusic", $"{folder}../Generated/Interfaces/ISteamMusic.cs" );
}
}

View File

@ -1,374 +1,381 @@
{
"structs": [
{
"struct": "NewUrlLaunchParameters_t",
"fields": [
]
},
{
"struct": "ItemInstalled_t",
"fields": [
{
"fieldname": "m_unAppID",
"fieldtype": "AppId_t"
},
{
"fieldname": "m_nPublishedFileId",
"fieldtype": "PublishedFileId_t"
}
]
},
{
"struct": "InputAnalogActionData_t",
"fields": [
{
"fieldname": "eMode",
"fieldtype": "EInputSourceMode"
},
{
"fieldname": "x",
"fieldtype": "float"
},
{
"fieldname": "y",
"fieldtype": "float"
},
{
"fieldname": "bActive",
"fieldtype": "bool"
}
]
},
{
"struct": "InputMotionData_t",
"fields": [
{
"fieldname": "rotQuatX",
"fieldtype": "float"
},
{
"fieldname": "rotQuatY",
"fieldtype": "float"
},
{
"fieldname": "rotQuatZ",
"fieldtype": "float"
},
{
"fieldname": "rotQuatW",
"fieldtype": "float"
},
{
"fieldname": "posAccelX",
"fieldtype": "float"
},
{
"fieldname": "posAccelY",
"fieldtype": "float"
},
{
"fieldname": "posAccelZ",
"fieldtype": "float"
},
{
"fieldname": "rotVelX",
"fieldtype": "float"
},
{
"fieldname": "rotVelY",
"fieldtype": "float"
},
{
"fieldname": "rotVelZ",
"fieldtype": "float"
}
]
},
{
"struct": "InputDigitalActionData_t",
"fields": [
{
"fieldname": "bState",
"fieldtype": "bool"
},
{
"fieldname": "bActive",
"fieldtype": "bool"
}
]
},
{
"struct": "SteamInventoryDefinitionUpdate_t"
},
{
"struct": "SteamParentalSettingsChanged_t"
},
{
"struct": "SteamServersConnected_t"
},
{
"struct": "NewLaunchQueryParameters_t"
},
{
"struct": "GCMessageAvailable_t",
"fields": [
{
"fieldname": "m_nMessageSize",
"fieldtype": "uint32"
}
]
},
{
"struct": "GCMessageFailed_t"
},
{
"struct": "ScreenshotRequested_t"
},
{
"struct": "LicensesUpdated_t"
},
{
"struct": "SteamShutdown_t"
},
{
"struct": "IPCountry_t"
},
{
"struct": "IPCFailure_t",
"fields": [
{
"fieldname": "m_eFailureType",
"fieldtype": "uint8"
}
]
}
],
"methods":
[
{
"classname": "SteamApi",
"methodname": "SteamAPI_Init",
"returntype": "bool",
"NeedsSelfPointer": false
},
{
"classname": "SteamApi",
"methodname": "SteamAPI_RunCallbacks",
"returntype": "void",
"NeedsSelfPointer": false
},
{
"classname": "SteamApi",
"methodname": "SteamGameServer_RunCallbacks",
"returntype": "void",
"NeedsSelfPointer": false
},
{
"classname": "SteamApi",
"methodname": "SteamAPI_RegisterCallback",
"returntype": "void",
"NeedsSelfPointer": false,
"params":
[
{
"paramname": "pCallback",
"paramtype": "void *"
},
{
"paramname": "callback",
"paramtype": "int"
}
]
},
{
"classname": "SteamApi",
"methodname": "SteamAPI_UnregisterCallback",
"returntype": "void",
"NeedsSelfPointer": false,
"params":
[
{
"paramname": "pCallback",
"paramtype": "void *"
}
]
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_RegisterCallResult",
"returntype": "void",
"params":
[
{
"paramname": "pCallback",
"paramtype": "void *"
},
{
"paramname": "callback",
"paramtype": "SteamAPICall_t"
}
]
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_UnregisterCallResult",
"returntype": "void",
"params":
[
{
"paramname": "pCallback",
"paramtype": "void *"
},
{
"paramname": "callback",
"paramtype": "SteamAPICall_t"
}
]
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamInternal_GameServer_Init",
"returntype": "bool",
"params":
[
{
"paramname": "unIP",
"paramtype": "uint32"
},
{
"paramname": "usPort",
"paramtype": "uint16"
},
{
"paramname": "usGamePort",
"paramtype": "uint16"
},
{
"paramname": "usQueryPort",
"paramtype": "uint16"
},
{
"paramname": "eServerMode",
"paramtype": "int"
},
{
"paramname": "pchVersionString",
"paramtype": "const char *"
}
]
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_Shutdown",
"returntype": "void"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamGameServer_Shutdown",
"returntype": "void"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_GetHSteamUser",
"returntype": "HSteamUser"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_GetHSteamPipe",
"returntype": "HSteamPipe"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamGameServer_GetHSteamUser",
"returntype": "HSteamUser"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamGameServer_GetHSteamPipe",
"returntype": "HSteamPipe"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamInternal_CreateInterface",
"returntype": "void *",
"params":
[
{
"paramname": "version",
"paramtype": "const char *"
}
]
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_RestartAppIfNecessary",
"returntype": "bool",
"params":
[
{
"paramname": "unOwnAppID",
"paramtype": "uint32"
}
]
}
]
}
"structs": [
{
"struct": "PlaybackStatusHasChanged_t",
"fields": [ ]
},
{
"struct": "NewUrlLaunchParameters_t",
"fields": [ ]
},
{
"struct": "ItemInstalled_t",
"fields": [
{
"fieldname": "m_unAppID",
"fieldtype": "AppId_t"
},
{
"fieldname": "m_nPublishedFileId",
"fieldtype": "PublishedFileId_t"
}
]
},
{
"struct": "InputAnalogActionData_t",
"fields": [
{
"fieldname": "eMode",
"fieldtype": "EInputSourceMode"
},
{
"fieldname": "x",
"fieldtype": "float"
},
{
"fieldname": "y",
"fieldtype": "float"
},
{
"fieldname": "bActive",
"fieldtype": "bool"
}
]
},
{
"struct": "InputMotionData_t",
"fields": [
{
"fieldname": "rotQuatX",
"fieldtype": "float"
},
{
"fieldname": "rotQuatY",
"fieldtype": "float"
},
{
"fieldname": "rotQuatZ",
"fieldtype": "float"
},
{
"fieldname": "rotQuatW",
"fieldtype": "float"
},
{
"fieldname": "posAccelX",
"fieldtype": "float"
},
{
"fieldname": "posAccelY",
"fieldtype": "float"
},
{
"fieldname": "posAccelZ",
"fieldtype": "float"
},
{
"fieldname": "rotVelX",
"fieldtype": "float"
},
{
"fieldname": "rotVelY",
"fieldtype": "float"
},
{
"fieldname": "rotVelZ",
"fieldtype": "float"
}
]
},
{
"struct": "InputDigitalActionData_t",
"fields": [
{
"fieldname": "bState",
"fieldtype": "bool"
},
{
"fieldname": "bActive",
"fieldtype": "bool"
}
]
},
{
"struct": "SteamInventoryDefinitionUpdate_t"
},
{
"struct": "SteamParentalSettingsChanged_t"
},
{
"struct": "SteamServersConnected_t"
},
{
"struct": "NewLaunchQueryParameters_t"
},
{
"struct": "GCMessageAvailable_t",
"fields": [
{
"fieldname": "m_nMessageSize",
"fieldtype": "uint32"
}
]
},
{
"struct": "GCMessageFailed_t"
},
{
"struct": "ScreenshotRequested_t"
},
{
"struct": "LicensesUpdated_t"
},
{
"struct": "SteamShutdown_t"
},
{
"struct": "IPCountry_t"
},
{
"struct": "IPCFailure_t",
"fields": [
{
"fieldname": "m_eFailureType",
"fieldtype": "uint8"
}
]
}
],
"methods":
[
{
"classname": "SteamApi",
"methodname": "SteamAPI_Init",
"returntype": "bool",
"NeedsSelfPointer": false
},
{
"classname": "SteamApi",
"methodname": "SteamAPI_RunCallbacks",
"returntype": "void",
"NeedsSelfPointer": false
},
{
"classname": "SteamApi",
"methodname": "SteamGameServer_RunCallbacks",
"returntype": "void",
"NeedsSelfPointer": false
},
{
"classname": "SteamApi",
"methodname": "SteamAPI_RegisterCallback",
"returntype": "void",
"NeedsSelfPointer": false,
"params":
[
{
"paramname": "pCallback",
"paramtype": "void *"
},
{
"paramname": "callback",
"paramtype": "int"
}
]
},
{
"classname": "SteamApi",
"methodname": "SteamAPI_UnregisterCallback",
"returntype": "void",
"NeedsSelfPointer": false,
"params":
[
{
"paramname": "pCallback",
"paramtype": "void *"
}
]
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_RegisterCallResult",
"returntype": "void",
"params":
[
{
"paramname": "pCallback",
"paramtype": "void *"
},
{
"paramname": "callback",
"paramtype": "SteamAPICall_t"
}
]
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_UnregisterCallResult",
"returntype": "void",
"params":
[
{
"paramname": "pCallback",
"paramtype": "void *"
},
{
"paramname": "callback",
"paramtype": "SteamAPICall_t"
}
]
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamInternal_GameServer_Init",
"returntype": "bool",
"params":
[
{
"paramname": "unIP",
"paramtype": "uint32"
},
{
"paramname": "usPort",
"paramtype": "uint16"
},
{
"paramname": "usGamePort",
"paramtype": "uint16"
},
{
"paramname": "usQueryPort",
"paramtype": "uint16"
},
{
"paramname": "eServerMode",
"paramtype": "int"
},
{
"paramname": "pchVersionString",
"paramtype": "const char *"
}
]
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_Shutdown",
"returntype": "void"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamGameServer_Shutdown",
"returntype": "void"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_GetHSteamUser",
"returntype": "HSteamUser"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_GetHSteamPipe",
"returntype": "HSteamPipe"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamGameServer_GetHSteamUser",
"returntype": "HSteamUser"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamGameServer_GetHSteamPipe",
"returntype": "HSteamPipe"
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamInternal_CreateInterface",
"returntype": "void *",
"params":
[
{
"paramname": "version",
"paramtype": "const char *"
}
]
},
{
"NeedsSelfPointer": false,
"classname": "SteamApi",
"methodname": "SteamAPI_RestartAppIfNecessary",
"returntype": "bool",
"params":
[
{
"paramname": "unOwnAppID",
"paramtype": "uint32"
}
]
}
]
}