Example #1
0
        public static RazerReport RazerChromaMiscGetBladeBrightness()
        {
            RazerReport report = GetRazerReport(0x0E, 0x84, 0x02);

            report.arguments[0] = 0x01;
            return(report);
        }
Example #2
0
        public static RazerReport RazerChromaStandardMatrixEffectSpectrum(LED_STORAGE storage, LEDS led_id)
        {
            RazerReport report = GetRazerReport(0x03, 0x0A, 0x01);

            report.arguments[0] = 0x04; // Effect ID
            return(report);
        }
Example #3
0
        public static string RazerAttrReadModeGame(HidDevice usb_dev)
        {
            RazerReport report   = RazerChromaStandardGetLedState(LED_STORAGE.VARSTORE, LEDS.GAME_LED);
            RazerReport response = RazerSendPayload(usb_dev, report);

            return(response.arguments[2].ToString());
        }
Example #4
0
        public static string RazerAttrReadModeMacroEffect(HidDevice device)
        {
            RazerReport report   = RazerChromaStandardGetLedEffect(LED_STORAGE.VARSTORE, LEDS.MACRO_LED);
            RazerReport response = RazerSendPayload(device, report);

            return(response.arguments[2].ToString());
        }
Example #5
0
        static RazerReport RazerSendPayload(HidDevice device, RazerReport request_report)
        {
            request_report.crc = RazerCalculateCrc(request_report);
            RazerReport response = RazerGetReport(device, request_report);

            if (response.remaining_packets != request_report.remaining_packets ||
                response.command_class != request_report.command_class ||
                response.command_id != request_report.command_id)
            {
                Error("response doesn't match request");
            }
            else if (response.status == REPORT_RESPONSE.RAZER_CMD_FAILURE)
            {
                Error("command failed");
            }
            else if (response.status == REPORT_RESPONSE.RAZER_CMD_NOT_SUPPORTED)
            {
                Error("command not supported");
            }
            else if (response.status == REPORT_RESPONSE.RAZER_CMD_TIMEOUT)
            {
                Error("command timed out");
            }

            return(response);
        }
Example #6
0
        public static string RazerAttrReadGetFirmwareVersion(HidDevice device)
        {
            RazerReport report   = RazerChromaStandardGetFirmwareVersion();
            RazerReport response = RazerSendPayload(device, report);

            return(String.Format("v{0}.{1}", response.arguments[0], response.arguments[1]));
        }
Example #7
0
        public static void RazerAttrWriteSetLogo(HidDevice device, byte state)
        {
            RazerReport report =
                RazerChromaStandardSetLedEffect(LED_STORAGE.VARSTORE, LEDS.LOGO_LED, (LED_EFFECT)state);

            RazerSendPayload(device, report);
        }
Example #8
0
        public static string RazerAttrReadSetBrightness(HidDevice device)
        {
            RazerReport report   = RazerChromaMiscGetBladeBrightness();
            RazerReport response = RazerSendPayload(device, report);

            return(response.arguments[1].ToString());
        }
Example #9
0
        public static void RazerAttrWriteModeStarlight(HidDevice device, RazerRgb rgb1, RazerRgb rgb2)
        {
            RazerReport report =
                RazerChromaStandardMatrixEffectStarlightDual(LED_STORAGE.VARSTORE, LEDS.BACKLIGHT_LED, 0x01, rgb1, rgb2);

            RazerSendPayload(device, report);
        }
Example #10
0
        public static void RazerAttrWriteModeReactive(HidDevice device, byte speed, RazerRgb rgb)
        {
            RazerReport report =
                RazerChromaStandardMatrixEffectReactive(LED_STORAGE.VARSTORE, LEDS.BACKLIGHT_LED, speed, rgb);

            RazerSendPayload(device, report);
        }
Example #11
0
        public static void RazerAttrWriteModeWave(HidDevice device, WAVE_DIRECTION direction)
        {
            RazerReport report =
                RazerChromaStandardMatrixEffectWave(LED_STORAGE.VARSTORE, LEDS.BACKLIGHT_LED, direction);

            RazerSendPayload(device, report);
        }
Example #12
0
        public static string RazerAttrReadTartarusProfileLedBlue(HidDevice device)
        {
            RazerReport report   = RazerChromaStandardGetLedState(LED_STORAGE.VARSTORE, LEDS.BLUE_PROFILE_LED);
            RazerReport response = RazerSendPayload(device, report);

            return(response.arguments[2].ToString());
        }
Example #13
0
        public static int RazerAttrWriteModePulsate(HidDevice device, string buf, int count)
        {
            RazerReport report = RazerChromaStandardSetLedEffect(LED_STORAGE.VARSTORE, LEDS.BACKLIGHT_LED, LED_EFFECT.LED_PULSATING);

            RazerSendPayload(device, report);
            return(count);
        }
Example #14
0
        /* TODO: something is broken here... */
        public static int RazerAttrWriteModeMacroEffect(HidDevice device, string buf, int count)
        {
            byte        en     = Convert.ToByte(buf, 10);
            RazerReport report = RazerChromaStandardSetLedEffect(LED_STORAGE.VARSTORE, LEDS.MACRO_LED, (LED_EFFECT)en);

            RazerSendPayload(device, report);
            return(count);
        }
Example #15
0
        /* TODO: what do these actually return? */
        public static int RazerAttrWriteModeMacro(HidDevice device, string buf, int count)
        {
            byte        en     = Convert.ToByte(buf, 10);
            RazerReport report = RazerChromaStandardSetLedState(LED_STORAGE.VARSTORE, LEDS.MACRO_LED, (en == 1) ? LED_STATE.ON : LED_STATE.OFF);

            RazerSendPayload(device, report);
            return(count);
        }
Example #16
0
        public static RazerReport RazerChromaStandardMatrixEffectWave(LED_STORAGE storage, LEDS led_id, WAVE_DIRECTION wave_direction)
        {
            RazerReport report = GetRazerReport(0x03, 0x0A, 0x02);

            report.arguments[0] = 0x01; // Effect ID
            report.arguments[1] = clamp_u8((byte)wave_direction, 0x01, 0x02);
            return(report);
        }
Example #17
0
        public static RazerReport RazerChromaMiscSetBladeBrightness(byte brightness)
        {
            RazerReport report = GetRazerReport(0x0E, 0x04, 0x02);

            report.arguments[0] = 0x01;
            report.arguments[1] = brightness;
            return(report);
        }
Example #18
0
        public static RazerReport RazerChromaStandardGetLedEffect(LED_STORAGE storage, LEDS led_id)
        {
            RazerReport report = GetRazerReport(0x03, 0x82, 0x03);

            report.arguments[0] = (byte)storage;
            report.arguments[1] = (byte)led_id;
            return(report);
        }
Example #19
0
        public static RazerReport RazerChromaMiscFnKeyToggle(byte state)
        {
            RazerReport report = GetRazerReport(0x02, 0x06, 0x02);

            report.arguments[0] = 0x00;                        // ?? Variable storage maybe
            report.arguments[1] = clamp_u8(state, 0x00, 0x01); // State
            return(report);
        }
Example #20
0
        public static RazerReport RazerChromaStandardSetLedBrightness(LED_STORAGE storage, LEDS led_id, byte brightness)
        {
            RazerReport report = GetRazerReport(0x03, 0x03, 0x03);

            report.arguments[0] = (byte)storage;
            report.arguments[1] = (byte)led_id;
            report.arguments[2] = brightness;
            return(report);
        }
Example #21
0
        public static RazerReport RazerChromaStandardSetLedEffect(LED_STORAGE storage, LEDS led_id, LED_EFFECT effect)
        {
            RazerReport report = GetRazerReport(0x03, 0x02, 0x03);

            report.arguments[0] = (byte)storage;
            report.arguments[1] = (byte)led_id;
            report.arguments[2] = clamp_u8((byte)effect, 0x00, 0x05);
            return(report);
        }
Example #22
0
        public static RazerReport RazerChromaStandardSetLedState(LED_STORAGE storage, LEDS led_id, LED_STATE led_state)
        {
            RazerReport report = GetRazerReport(0x03, 0x00, 0x03);

            report.arguments[0] = (byte)storage;
            report.arguments[1] = (byte)led_id;
            report.arguments[2] = clamp_u8((byte)led_state, 0x00, 0x01);
            return(report);
        }
Example #23
0
        public static RazerReport RazerChromaStandardMatrixEffectBreathingRandom(LED_STORAGE storage, LEDS led_id)
        {
            RazerReport report = GetRazerReport(0x03, 0x0A, 0x08);

            report.arguments[0] = 0x03; // Effect ID
            report.arguments[1] = 0x03; // Breathing type

            return(report);
        }
Example #24
0
        public static RazerReport RazerChromaStandardSetLedBlinking(LED_STORAGE storage, LEDS led_id)
        {
            RazerReport report = GetRazerReport(0x03, 0x04, 0x04);

            report.arguments[0] = (byte)storage;
            report.arguments[1] = (byte)led_id;
            report.arguments[2] = 0x05;
            report.arguments[3] = 0x05;
            return(report);
        }
Example #25
0
        public static RazerReport RazerChromaStandardMatrixEffectCustomFrame(LED_STORAGE storage)
        {
            RazerReport report = GetRazerReport(0x03, 0x0A, 0x02);

            report.arguments[0] = 0x05;          // Effect ID
            report.arguments[1] = (byte)storage; // Data frame ID
                                                 // report.arguments[1] = 0x01; // Data frame ID

            return(report);
        }
Example #26
0
        public static RazerReport RazerChromaStandardSetLedRgb(LED_STORAGE storage, LEDS led_id, RazerRgb rgb)
        {
            RazerReport report = GetRazerReport(0x03, 0x01, 0x05);

            report.arguments[0] = (byte)storage;
            report.arguments[1] = (byte)led_id;
            report.arguments[2] = rgb.r;
            report.arguments[3] = rgb.g;
            report.arguments[4] = rgb.b;
            return(report);
        }
        private static RazerReport BytesToReport(byte[] data, int offset)
        {
            RazerReport ret = new RazerReport();
            int         sz  = Marshal.SizeOf(ret);
            IntPtr      ptr = Marshal.AllocHGlobal(sz);

            Marshal.Copy(data, offset, ptr, sz);
            ret = (RazerReport)Marshal.PtrToStructure(ptr, typeof(RazerReport));
            Marshal.FreeHGlobal(ptr);
            return(ret);
        }
Example #28
0
        public static RazerReport RazerChromaStandardMatrixEffectStatic(LED_STORAGE storage, LEDS led_id, RazerRgb rgb1)
        {
            RazerReport report = GetRazerReport(0x03, 0x0A, 0x04);

            report.arguments[0] = 0x06;   // Effect ID
            report.arguments[1] = rgb1.r; /*rgb color definition*/
            report.arguments[2] = rgb1.g;
            report.arguments[3] = rgb1.b;

            return(report);
        }
        /* calculates crc - xor all bytes */
        public static byte RazerCalculateCrc(RazerReport data)
        {
            byte crc = 0;

            byte[] raw = ReportToBytes(data);
            for (int i = 2; i < 88; i++)
            {
                crc ^= raw[i];
            }
            return(crc);
        }
Example #30
0
        public static RazerReport RazerChromaStandardMatrixEffectBreathingSingle(LED_STORAGE storage, LEDS led_id, RazerRgb rgb1)
        {
            RazerReport report = GetRazerReport(0x03, 0x0A, 0x08);

            report.arguments[0] = 0x03; // Effect ID
            report.arguments[1] = 0x01; // Breathing type
            report.arguments[2] = rgb1.r;
            report.arguments[3] = rgb1.g;
            report.arguments[4] = rgb1.b;

            return(report);
        }