/// <summary> /// Creates a standard mouse pad effect with the specified parameters. /// </summary> /// <param name="effect">The type of effect to create.</param> /// <param name="param">Effect-specific parameter.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> internal static Guid CreateMousepadEffect(Razer.Mousepad.Effects.Effect effect, IntPtr param) { var guid = Guid.Empty; var result = NativeMethods.CreateMousepadEffect(effect, param, ref guid); if (!result) { throw new NativeCallException("CreateMousepadEffect", result); } return(guid); }
/// <summary> /// Helper method for creating mouse pad effects with parameter struct. /// </summary> /// <typeparam name="T">The effect struct type.</typeparam> /// <param name="effect">The type of effect to create.</param> /// <param name="struct">Effect options struct.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> private static Guid CreateMousepadEffect <T>(Razer.Mousepad.Effects.Effect effect, T @struct) where T : struct { var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(@struct)); Marshal.StructureToPtr(@struct, ptr, false); try { return(CreateMousepadEffect(effect, ptr)); } finally { Marshal.FreeHGlobal(ptr); } }
/// <summary> /// Create a mousepad effect without a parameter. /// </summary> /// <param name="effect">The type of effect to create.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> /// <remarks>This is currently only valid for <see cref="Razer.Mousepad.Effects.Effect.None" />.</remarks> internal static Guid CreateMousepadEffect(Razer.Mousepad.Effects.Effect effect) { return(CreateMousepadEffect(effect, IntPtr.Zero)); }