/// <summary> /// Create a mouse 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.Mouse.Effects.Effect.None" />.</remarks> internal static Guid CreateMouseEffect(Razer.Mouse.Effects.Effect effect) { if (effect == Razer.Mouse.Effects.Effect.None) { return(CreateMouseEffect(effect, new Razer.Mouse.Effects.None(Razer.Mouse.Led.All))); } return(CreateMouseEffect(effect, IntPtr.Zero)); }
/// <summary> /// Creates a standard mouse effect with the specified parameters. /// </summary> /// <param name="effect">The type of effect to create.</param> /// <param name="param">Context-sensitive effect parameter.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> /// <seealso cref="Razer.NativeMethods.CreateMouseEffect" /> internal static Guid CreateMouseEffect(Razer.Mouse.Effects.Effect effect, IntPtr param) { var guid = Guid.Empty; var result = NativeMethods.CreateMouseEffect(effect, param, ref guid); if (!result) { throw new NativeCallException("CreateMouseEffect", result); } return(guid); }
/// <summary> /// Helper method for creating mouse 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 CreateMouseEffect <T>(Razer.Mouse.Effects.Effect effect, T @struct) where T : struct { var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(@struct)); Marshal.StructureToPtr(@struct, ptr, false); try { return(CreateMouseEffect(effect, ptr)); } finally { Marshal.FreeHGlobal(ptr); } }
/// <summary> /// Creates a mouse effect without parameter. /// </summary> /// <param name="led">The LED to use.</param> /// <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.Mouse.Effects.Effect.SpectrumCycling" />.</remarks> internal static Guid CreateMouseEffect(Led led, Razer.Mouse.Effects.Effect effect) { return(CreateMouseEffect(led, effect, IntPtr.Zero)); }