/// <summary> /// Creates a standard headset effect with the specified parameters. /// </summary> /// <param name="effectType">The type of effect to create.</param> /// <param name="param">Effect-specific parameter.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> private Guid CreateHeadsetEffect(Effects.Headset.HeadsetEffectType effectType, IntPtr param) { var guid = Guid.Empty; var result = _nativeSdkMethods.CreateHeadsetEffect(effectType, param, ref guid); if (!result) { throw new NativeCallException("CreateHeadsetEffect", result); } return(guid); }
/// <inheritdoc /> /// <summary> /// Helper method for creating headset effects with parameter struct. /// </summary> /// <typeparam name="T">The effect struct type.</typeparam> /// <param name="effectType">The type of effect to create.</param> /// <param name="data">Effect options struct.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> public Task <Guid> CreateHeadsetEffectAsync <T>(Effects.Headset.HeadsetEffectType effectType, T data) where T : struct { var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(data)); Marshal.StructureToPtr(data, ptr, false); try { return(Task.FromResult(CreateHeadsetEffect(effectType, ptr))); } finally { Marshal.FreeHGlobal(ptr); } }
/// <inheritdoc /> /// <summary> /// Creates a new headset effect with the specified effect data by sending a POST request to the headset API. /// </summary> /// <typeparam name="T">The effect struct type.</typeparam> /// <param name="effectType">The type of effect to create.</param> /// <param name="data">Effect options struct.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> public async Task <Guid> CreateHeadsetEffectAsync <T>(Effects.Headset.HeadsetEffectType effectType, T data) where T : struct { return(await CreateEffectAsync("/headset", data).ConfigureAwait(false)); }
/// <inheritdoc /> /// <summary> /// Creates a new headset effect without any effect data by sending a POST request to the headset API. /// </summary> /// <param name="effectType">The type of effect to create.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> public async Task <Guid> CreateHeadsetEffectAsync(Effects.Headset.HeadsetEffectType effectType) { return(await CreateEffectAsync("/headset", new EffectData(effectType)).ConfigureAwait(false)); }
/// <inheritdoc /> /// <summary> /// Creates a new headset effect without any effect data. /// </summary> /// <param name="effectType">The type of effect to create.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> public Task <Guid> CreateHeadsetEffectAsync(Effects.Headset.HeadsetEffectType effectType) { return(Task.FromResult(CreateHeadsetEffect(effectType, IntPtr.Zero))); }