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 @@ namespace SteamNative
#endregion #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 public struct NewUrlLaunchParameters_t : Steamworks.ISteamCallback
{ {
@ -7458,6 +7483,7 @@ namespace SteamNative
new CallbackHandle<GSStatsReceived_t>( steamworks ); new CallbackHandle<GSStatsReceived_t>( steamworks );
new CallbackHandle<GSStatsStored_t>( steamworks ); new CallbackHandle<GSStatsStored_t>( steamworks );
new CallbackHandle<GSStatsUnloaded_t>( steamworks ); new CallbackHandle<GSStatsUnloaded_t>( steamworks );
new CallbackHandle<PlaybackStatusHasChanged_t>( steamworks );
new CallbackHandle<NewUrlLaunchParameters_t>( steamworks ); new CallbackHandle<NewUrlLaunchParameters_t>( steamworks );
new CallbackHandle<ItemInstalled_t>( steamworks ); new CallbackHandle<ItemInstalled_t>( steamworks );
new CallbackHandle<SteamInventoryDefinitionUpdate_t>( steamworks ); new CallbackHandle<SteamInventoryDefinitionUpdate_t>( steamworks );

View File

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

View File

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