Ejemplo n.º 1
0
        /// <summary>
        /// Creates a standard keypad effect with the specified parameters.
        /// </summary>
        /// <param name="effect">The type of effect to create.</param>
        /// <param name="param">Effect-specific parameters.</param>
        /// <returns>A <see cref="Guid" /> for the created effect.</returns>
        internal static Guid CreateKeypadEffect(Razer.Keypad.Effects.Effect effect, IntPtr param)
        {
            var guid   = Guid.Empty;
            var result = NativeMethods.CreateKeypadEffect(effect, param, ref guid);

            if (!result)
            {
                throw new NativeCallException("CreateKeypadEffect", result);
            }
            return(guid);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Helper method for creating keypad 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 CreateKeypadEffect <T>(Razer.Keypad.Effects.Effect effect, T @struct) where T : struct
        {
            var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(@struct));

            Marshal.StructureToPtr(@struct, ptr, false);

            try
            {
                return(CreateKeypadEffect(effect, ptr));
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a keypad 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.Keypad.Effects.Effect.None" />.</remarks>
 internal static Guid CreateKeypadEffect(Razer.Keypad.Effects.Effect effect)
 {
     return(CreateKeypadEffect(effect, IntPtr.Zero));
 }