|
| 1 | +/*-----------------------------------------*\ |
| 2 | +| RGBController_RedragonK556.cpp | |
| 3 | +| | |
| 4 | +| Generic RGB Interface for Redragon K556 | |
| 5 | +| Devarajas RGB Keyboard | |
| 6 | +| | |
| 7 | +| Adam Honse (CalcProgrammer1) 3/25/2020 | |
| 8 | +\*-----------------------------------------*/ |
| 9 | + |
| 10 | +#include "RGBController_RedragonK556.h" |
| 11 | + |
| 12 | +RGBController_RedragonK556::RGBController_RedragonK556(RedragonK556Controller* redragon_ptr) |
| 13 | +{ |
| 14 | + redragon = redragon_ptr; |
| 15 | + |
| 16 | + name = "Redragon K556 Devarajas"; |
| 17 | + type = DEVICE_TYPE_KEYBOARD; |
| 18 | + description = "Redragon K556 Device"; |
| 19 | + |
| 20 | + mode Custom; |
| 21 | + Custom.name = "Custom"; |
| 22 | + Custom.value = REDRAGON_K556_MODE_CUSTOM; |
| 23 | + Custom.flags = MODE_FLAG_HAS_PER_LED_COLOR; |
| 24 | + Custom.color_mode = MODE_COLORS_PER_LED; |
| 25 | + modes.push_back(Custom); |
| 26 | + |
| 27 | + SetupZones(); |
| 28 | +} |
| 29 | + |
| 30 | +void RGBController_RedragonK556::SetupZones() |
| 31 | +{ |
| 32 | + zone new_zone; |
| 33 | + |
| 34 | + new_zone.name = "Keyboard"; |
| 35 | + new_zone.type = ZONE_TYPE_MATRIX; |
| 36 | + new_zone.leds_min = 126; |
| 37 | + new_zone.leds_max = 126; |
| 38 | + new_zone.leds_count = 126; |
| 39 | + |
| 40 | + zones.push_back(new_zone); |
| 41 | + |
| 42 | + for(int led_idx = 0; led_idx < 126; led_idx++) |
| 43 | + { |
| 44 | + led new_led; |
| 45 | + |
| 46 | + new_led.name = "Keyboard LED "; |
| 47 | + new_led.name.append(std::to_string(led_idx)); |
| 48 | + |
| 49 | + leds.push_back(new_led); |
| 50 | + } |
| 51 | + |
| 52 | + SetupColors(); |
| 53 | +} |
| 54 | + |
| 55 | +void RGBController_RedragonK556::ResizeZone(int /*zone*/, int /*new_size*/) |
| 56 | +{ |
| 57 | + /*---------------------------------------------------------*\ |
| 58 | + | This device does not support resizing zones | |
| 59 | + \*---------------------------------------------------------*/ |
| 60 | +} |
| 61 | + |
| 62 | +void RGBController_RedragonK556::UpdateLEDs() |
| 63 | +{ |
| 64 | + unsigned char color_data[7*0x36]; |
| 65 | + |
| 66 | + for(int led_idx = 0; led_idx < 126; led_idx++) |
| 67 | + { |
| 68 | + color_data[(3 * led_idx) + 0] = RGBGetRValue(colors[led_idx]); |
| 69 | + color_data[(3 * led_idx) + 1] = RGBGetGValue(colors[led_idx]); |
| 70 | + color_data[(3 * led_idx) + 2] = RGBGetBValue(colors[led_idx]); |
| 71 | + } |
| 72 | + |
| 73 | + redragon->SendKeyboardBegin(); |
| 74 | + redragon->SendKeyboardMode(20); |
| 75 | + |
| 76 | + redragon->SetKeyboardColors |
| 77 | + ( |
| 78 | + color_data, |
| 79 | + 0x36 * 7 |
| 80 | + ); |
| 81 | + |
| 82 | + redragon->SendKeyboardEnd(); |
| 83 | +} |
| 84 | + |
| 85 | +void RGBController_RedragonK556::UpdateZoneLEDs(int /*zone*/) |
| 86 | +{ |
| 87 | + UpdateLEDs(); |
| 88 | +} |
| 89 | + |
| 90 | +void RGBController_RedragonK556::UpdateSingleLED(int /*led*/) |
| 91 | +{ |
| 92 | + UpdateLEDs(); |
| 93 | +} |
| 94 | + |
| 95 | +void RGBController_RedragonK556::SetCustomMode() |
| 96 | +{ |
| 97 | + |
| 98 | +} |
| 99 | + |
| 100 | +void RGBController_RedragonK556::UpdateMode() |
| 101 | +{ |
| 102 | + UpdateLEDs(); |
| 103 | +} |
0 commit comments