/// <summary> /// Creates a standard mouse pad 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 CreateMousepadEffect(Effects.Mousepad.MousepadEffectType effectType, IntPtr param) { var guid = Guid.Empty; var result = _nativeSdkMethods.CreateMousepadEffect(effectType, param, ref guid); if (!result) { throw new NativeCallException("CreateMousepadEffect", result); } return(guid); }
/// <inheritdoc /> /// <summary> /// Helper method for creating mouse pad 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> CreateMousepadEffectAsync <T>(Effects.Mousepad.MousepadEffectType effectType, T data) where T : struct { var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(data)); Marshal.StructureToPtr(data, ptr, false); try { return(Task.FromResult(CreateMousepadEffect(effectType, ptr))); } finally { Marshal.FreeHGlobal(ptr); } }
/// <inheritdoc /> /// <summary> /// Creates a new mousepad effect with the specified effect data by sending a POST request to the mousepad 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> CreateMousepadEffectAsync <T>(Effects.Mousepad.MousepadEffectType effectType, T data) where T : struct { return(await CreateEffectAsync("/mousepad", data).ConfigureAwait(false)); }
/// <inheritdoc /> /// <summary> /// Creates a new mousepad effect without any effect data by sending a POST request to the mousepad 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> CreateMousepadEffectAsync(Effects.Mousepad.MousepadEffectType effectType) { return(await CreateEffectAsync("/mousepad", new EffectData(effectType)).ConfigureAwait(false)); }
/// <inheritdoc /> /// <summary> /// Creates a new mousepad 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> CreateMousepadEffectAsync(Effects.Mousepad.MousepadEffectType effectType) { return(Task.FromResult(CreateMousepadEffect(effectType, IntPtr.Zero))); }