diff --git a/Controllers/GloriousModelOController/GloriousModelOController.cpp b/Controllers/GloriousModelOController/GloriousModelOController.cpp index 234e56e3..5f686bf0 100644 --- a/Controllers/GloriousModelOController/GloriousModelOController.cpp +++ b/Controllers/GloriousModelOController/GloriousModelOController.cpp @@ -16,6 +16,10 @@ GloriousModelOController::GloriousModelOController(libusb_device_handle* dev_han strcpy(device_name, "Glorious Mouse"); led_count = 1; + + current_mode = GLORIOUS_MODE_STATIC; + current_speed = GLORIOUS_SPEED_NORMAL; + current_direction = GLORIOUS_DIRECTION_UP; } GloriousModelOController::~GloriousModelOController() @@ -46,7 +50,7 @@ void GloriousModelOController::SetLEDColor(unsigned char red, unsigned char gree 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x02, 0x41, 0x01, 0x40, 0xff, 0xff, 0xff, //RGB, Brightness, Mode 0x42 - 4 => + 0x00, 0x02, 0x41, 0x01, 0x40, 0xff, 0xff, 0xff, 0x42, 0x07, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x43, @@ -107,21 +111,136 @@ void GloriousModelOController::SetLEDColor(unsigned char red, unsigned char gree 0x00, 0x00, 0x00, 0x00 }; - //usb_buf[0x37] = GLORIOUS_MODE_STATIC; - //usb_buf[0x38] = 0x40; + usb_buf[0x0B] = 0x24; + usb_buf[0x35] = GLORIOUS_MODE_STATIC; + usb_buf[0x38] = 0x40; //max brightness usb_buf[0x39] = red; usb_buf[0x3A] = blue; usb_buf[0x3B] = green; + //DPI Button + /* + usb_buf[0x0B] = 0x44; //third DPI + usb_buf[0x26] = red; + usb_buf[0x27] = blue; + usb_buf[0x28] = green; + */ + libusb_control_transfer(dev, 0x21, 0x09, 0x0304, 0x0001, usb_buf, 520, 0); } -void GloriousModelOController::SetMode(unsigned char /*mode*/) +void GloriousModelOController::SetMode(unsigned char mode, unsigned char speed, unsigned char direction) { - //unsigned char usb_buf[520]; + unsigned char usb_buf[520] = + { + 0x04, 0x11, 0x00, 0x7b, + 0x00, 0x00, 0x00, 0x00, 0x64, 0x06, 0x04, 0x24, + 0xf0, 0x03, 0x07, 0x0f, 0x1f, 0x31, 0x63, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, + 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x41, 0x01, 0x40, 0xff, 0xff, 0xff, + 0x42, 0x07, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, + 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x43, + 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x42, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x42, 0x02, 0xff, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; - //usb_buf[0x37] = mode; + usb_buf[0x35] = mode; + switch (mode) + { + case GLORIOUS_MODE_OFF: + usb_buf[0x81] = 0x00; //mode 0 either 0x00 or 0x03 + break; + case GLORIOUS_MODE_RAINBOW: + usb_buf[0x36] = speed; + usb_buf[0x37] = direction; + break; + case GLORIOUS_MODE_SPECTRUM_BREATING: + //colours not yet researched + break; + case GLORIOUS_MODE_CHASE: + usb_buf[0x53] = speed; //Speed for mode 4 + break; + case GLORIOUS_MODE_SPECTRUM_CYCLE: + usb_buf[0x54] = speed; //Speed for mode 1,2,5 + break; + case GLORIOUS_MODE_FLASHING: + usb_buf[0x74] = speed; //Speed for mode 7 + usb_buf[0x75] = 0xff; //mode 7 red 1 + usb_buf[0x76] = 0x00; //mode 7 blue 1 + usb_buf[0x77] = 0x00; //mode 7 green 1 + usb_buf[0x78] = 0x00; //mode 7 red 2 + usb_buf[0x79] = 0x00; //mode 7 blue 2 + usb_buf[0x7A] = 0xff; //mode 7 green 2 + break; + case GLORIOUS_MODE_SLOW_RAINBOW: + usb_buf[0x7C] = speed; //Speed for mode 9 + break; + case GLORIOUS_MODE_BREATHING: + usb_buf[0x7D] = speed; + usb_buf[0x7E] = 0x00; //mode 0a red + usb_buf[0x7F] = 0x00; //mode 0a blue + usb_buf[0x80] = 0xff; //mode 0a green + default: + break; + } - //libusb_control_transfer(dev, 0x21, 0x09, 0x0304, 0x0001, usb_buf, 520, 0); + libusb_control_transfer(dev, 0x21, 0x09, 0x0304, 0x0001, usb_buf, 520, 0); } diff --git a/Controllers/GloriousModelOController/GloriousModelOController.h b/Controllers/GloriousModelOController/GloriousModelOController.h index f718e979..f86e70c8 100644 --- a/Controllers/GloriousModelOController/GloriousModelOController.h +++ b/Controllers/GloriousModelOController/GloriousModelOController.h @@ -15,7 +15,36 @@ enum { - GLORIOUS_MODE_STATIC = 0x01, + GLORIOUS_MODE_OFF = 0x00, //does nothing + GLORIOUS_MODE_RAINBOW = 0x01, + GLORIOUS_MODE_STATIC = 0x02, + GLORIOUS_MODE_SPECTRUM_BREATING = 0x03, + GLORIOUS_MODE_CHASE = 0x04, + GLORIOUS_MODE_SPECTRUM_CYCLE = 0x05, + GLORIOUS_MODE_FLASHING = 0x07, + GLORIOUS_MODE_EPILEPSY = 0x08, //not in the official software + GLORIOUS_MODE_SLOW_RAINBOW = 0x09, + GLORIOUS_MODE_BREATHING = 0x0a, +}; + +enum +{ + GLORIOUS_SPEED_SLOW = 0x41, + GLORIOUS_SPEED_NORMAL = 0x42, + GLORIOUS_SPEED_FAST = 0x43, +}; + +enum +{ + GLORIOUS_DIRECTION_UP = 0x00, + GLORIOUS_DIRECTION_DOWN = 0x01, +}; + +enum +{ + GLORIOUS_MODE_BREATING_SLOW = 0x01, + GLORIOUS_MODE_BREATING_NORMAL = 0x02, + GLORIOUS_MODE_BREATING_FAST = 0x03, }; class GloriousModelOController @@ -28,10 +57,14 @@ public: unsigned int GetLEDCount(); void SetLEDColor(unsigned char red, unsigned char green, unsigned char blue); - void SetMode(unsigned char mode); + void SetMode(unsigned char mode, unsigned char speed, unsigned char direction); private: libusb_device_handle* dev; char device_name[32]; unsigned int led_count; + + unsigned char current_mode; + unsigned char current_speed; + unsigned char current_direction; }; diff --git a/RGBController/RGBController_GloriousModelO.cpp b/RGBController/RGBController_GloriousModelO.cpp index 4bb1a12a..575a569e 100644 --- a/RGBController/RGBController_GloriousModelO.cpp +++ b/RGBController/RGBController_GloriousModelO.cpp @@ -21,8 +21,93 @@ RGBController_GloriousModelO::RGBController_GloriousModelO(GloriousModelOControl Static.name = "Static"; Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; Static.color_mode = MODE_COLORS_PER_LED; + Static.value = GLORIOUS_MODE_STATIC; modes.push_back(Static); + mode Off; + Off.name = "Off"; + Off.flags = 0; + Off.color_mode = MODE_COLORS_NONE; + Off.value = GLORIOUS_MODE_OFF; + modes.push_back(Off); + + mode Rainbow; + Rainbow.name = "Glorious Mode"; + Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD; + Rainbow.speed_min = GLORIOUS_SPEED_SLOW; + Rainbow.speed = GLORIOUS_SPEED_NORMAL; + Rainbow.speed_max = GLORIOUS_SPEED_FAST; + Rainbow.direction = MODE_DIRECTION_UP; + Rainbow.color_mode = MODE_COLORS_NONE; + Rainbow.value = GLORIOUS_MODE_RAINBOW; + modes.push_back(Rainbow); + + mode SpectrumBreathing; + SpectrumBreathing.name = "Seemless Breathing"; + SpectrumBreathing.flags = MODE_FLAG_HAS_SPEED; + SpectrumBreathing.speed_min = GLORIOUS_SPEED_SLOW; + SpectrumBreathing.speed = GLORIOUS_SPEED_NORMAL; + SpectrumBreathing.speed_max = GLORIOUS_SPEED_FAST; + SpectrumBreathing.value = GLORIOUS_MODE_SPECTRUM_BREATING; + modes.push_back(SpectrumBreathing); + + mode Chase; + Chase.name = "Chase"; + Chase.flags = MODE_FLAG_HAS_SPEED; + Chase.speed_min = GLORIOUS_SPEED_SLOW; + Chase.speed = GLORIOUS_SPEED_NORMAL; + Chase.speed_max = GLORIOUS_SPEED_FAST; + Chase.color_mode = MODE_COLORS_NONE; + Chase.value = GLORIOUS_MODE_CHASE; + modes.push_back(Chase); + + mode SpectrumCycle; + SpectrumCycle.name = "Spectrum Cycle"; + SpectrumCycle.flags = MODE_FLAG_HAS_SPEED; + SpectrumCycle.speed_min = GLORIOUS_SPEED_SLOW; + SpectrumCycle.speed = GLORIOUS_SPEED_NORMAL; + SpectrumCycle.speed_max = GLORIOUS_SPEED_FAST; + SpectrumCycle.color_mode = MODE_COLORS_NONE; + SpectrumCycle.value = GLORIOUS_MODE_SPECTRUM_CYCLE; + modes.push_back(SpectrumCycle); + + mode Flashing; + Flashing.name = "Flashing"; + Flashing.flags = MODE_FLAG_HAS_SPEED; + Flashing.speed_min = GLORIOUS_SPEED_SLOW; + Flashing.speed = GLORIOUS_SPEED_NORMAL; + Flashing.speed_max = GLORIOUS_SPEED_FAST; + Flashing.color_mode = MODE_COLORS_NONE; + Flashing.value = GLORIOUS_MODE_FLASHING; + modes.push_back(Flashing); + + mode Epilepsy; + Epilepsy.name = "Epilepsy"; + Epilepsy.flags = 0; + Epilepsy.color_mode = MODE_COLORS_NONE; + Epilepsy.value = GLORIOUS_MODE_EPILEPSY; + modes.push_back(Epilepsy); + + mode RainbowSlow; + RainbowSlow.name = "Random"; + RainbowSlow.flags = MODE_FLAG_HAS_SPEED; + RainbowSlow.speed_min = GLORIOUS_SPEED_SLOW; + RainbowSlow.speed = GLORIOUS_SPEED_NORMAL; + RainbowSlow.speed_max = GLORIOUS_SPEED_FAST; + RainbowSlow.color_mode = MODE_COLORS_NONE; + RainbowSlow.value = GLORIOUS_MODE_SLOW_RAINBOW; + modes.push_back(RainbowSlow); + + mode Breathing; + Breathing.name = "Breathing"; + Breathing.flags = MODE_FLAG_HAS_SPEED; + Breathing.speed_min = GLORIOUS_MODE_BREATING_SLOW; + Breathing.speed = GLORIOUS_MODE_BREATING_NORMAL; + Breathing.speed_max = GLORIOUS_MODE_BREATING_FAST; + Breathing.color_mode = MODE_COLORS_NONE; + Breathing.value = GLORIOUS_MODE_BREATHING; + modes.push_back(Breathing); + SetupZones(); } @@ -81,12 +166,32 @@ void RGBController_GloriousModelO::UpdateSingleLED(int /*led*/) } void RGBController_GloriousModelO::SetCustomMode() { - active_mode = 0; + //active_mode = 2; } void RGBController_GloriousModelO::UpdateMode() { - gmo->SetMode(modes[active_mode].value); + unsigned int direction; + + if (modes[active_mode].value == GLORIOUS_MODE_STATIC) + { + + } + else + { + if (modes[active_mode].direction == MODE_DIRECTION_UP) + { + direction = GLORIOUS_DIRECTION_UP; + } + else + { + direction = GLORIOUS_DIRECTION_DOWN; + } + + gmo->SetMode(modes[active_mode].value, modes[active_mode].speed, direction); + } + + }