Publish LumaOps source
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| InstantMouseController.cpp |
|
||||
| |
|
||||
| Driver for Instant mouse |
|
||||
| |
|
||||
| Morgan Guimard (morg) 19 Jan 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <string.h>
|
||||
#include "InstantMouseController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
InstantMouseController::InstantMouseController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = info.path;
|
||||
pid = info.product_id;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
InstantMouseController::~InstantMouseController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string InstantMouseController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string InstantMouseController::GetNameString()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string InstantMouseController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
uint16_t InstantMouseController::GetPID()
|
||||
{
|
||||
return pid;
|
||||
}
|
||||
|
||||
void InstantMouseController::SendColor(RGBColor color)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Packet details |
|
||||
| 07 14 XG RB 00 00 00 00 |
|
||||
| where X is the DPI slot |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
uint8_t red = 0xF - RGBGetRValue(color) / 16;
|
||||
uint8_t grn = 0xF - RGBGetGValue(color) / 16;
|
||||
uint8_t blu = 0xF - RGBGetBValue(color) / 16;
|
||||
|
||||
uint8_t pkt[INSTANT_MOUSE_REPORT_SIZE];
|
||||
memset(pkt, 0 , INSTANT_MOUSE_REPORT_SIZE);
|
||||
|
||||
pkt[0] = INSTANT_MOUSE_REPORT_ID;
|
||||
pkt[1] = INSTANT_MOUSE_SET_COLOR;
|
||||
pkt[3] = (red << 4) | (blu & 0xF);
|
||||
|
||||
for(unsigned int i = 0; i <= 0xA; i+= 2)
|
||||
{
|
||||
pkt[2] = (i << 4) | (grn & 0xF);
|
||||
hid_send_feature_report(dev, pkt, INSTANT_MOUSE_REPORT_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
void InstantMouseController::SetMode(uint8_t mode_value, uint8_t speed, uint8_t brightness, uint8_t direction)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Packet details: |
|
||||
| 07 13 FF MS DN -B M- -- |
|
||||
| |
|
||||
| 07 = report id |
|
||||
| 13 = set mode function |
|
||||
| FF = constant |
|
||||
| - = still undiscovered/useless |
|
||||
| M = mode |
|
||||
| S = speed 0 -> 5 (6 and above makes the effect static) |
|
||||
| N = number of leds |
|
||||
| D = direction (0/1) |
|
||||
| B = brightness (0 full, 7 off) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
uint8_t led_mask = 0xB;
|
||||
|
||||
uint8_t pkt[INSTANT_MOUSE_REPORT_SIZE];
|
||||
|
||||
pkt[0] = INSTANT_MOUSE_REPORT_ID;
|
||||
pkt[1] = INSTANT_MOUSE_SET_MODE;
|
||||
pkt[2] = 0xFF;
|
||||
|
||||
pkt[3] = (mode_value << 4) | (speed & 0xF);
|
||||
pkt[4] = (direction << 4) | led_mask;
|
||||
pkt[5] = 0xF - (brightness & 0xF);
|
||||
|
||||
pkt[6] = mode_value & 0xF0;
|
||||
pkt[7] = 0x00;
|
||||
|
||||
hid_send_feature_report(dev, pkt, INSTANT_MOUSE_REPORT_SIZE);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| InstantMouseController.h |
|
||||
| |
|
||||
| Driver for Instant mouse |
|
||||
| |
|
||||
| Morgan Guimard (morg) 19 Jan 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
#define INSTANT_MOUSE_REPORT_ID 0x07
|
||||
#define INSTANT_MOUSE_REPORT_SIZE 8
|
||||
#define INSTANT_MOUSE_SET_MODE 0x13
|
||||
#define INSTANT_MOUSE_SET_COLOR 0x14
|
||||
|
||||
enum
|
||||
{
|
||||
INSTANT_MOUSE_DIRECT_MODE = 0x0A,
|
||||
INSTANT_MOUSE_OFF_MODE = 0xFF,
|
||||
INSTANT_MOUSE_MULTICOLOR_BREATHING_MODE = 0x01,
|
||||
INSTANT_MOUSE_FILL_DRAIN_MODE = 0x03,
|
||||
INSTANT_MOUSE_LOOP_MODE = 0x04,
|
||||
INSTANT_MOUSE_SPECTRUM_CYCLE_MODE = 0x06,
|
||||
INSTANT_MOUSE_RAINBOW_WAVE_MODE = 0x07,
|
||||
INSTANT_MOUSE_BREATHING_MODE = 0x08,
|
||||
ANT_MOUSE_BREATHING_MODE = 0x09,
|
||||
INSTANT_MOUSE_ENRAPTURED_MODE = 0xBB,
|
||||
INSTANT_MOUSE_FLICKER_MODE = 0xB8,
|
||||
INSTANT_MOUSE_RIPPLE_MODE = 0xBA,
|
||||
INSTANT_MOUSE_STARTRECK_MODE = 0xB9,
|
||||
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
INSTANT_MOUSE_SPEED_MIN = 0x00,
|
||||
INSTANT_MOUSE_SPEED_MAX = 0x05,
|
||||
INSTANT_MOUSE_BRIGHTNESS_MIN = 0x00,
|
||||
INSTANT_MOUSE_BRIGHTNESS_MAX = 0x07
|
||||
};
|
||||
|
||||
class InstantMouseController
|
||||
{
|
||||
public:
|
||||
InstantMouseController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
|
||||
~InstantMouseController();
|
||||
|
||||
std::string GetNameString();
|
||||
std::string GetSerialString();
|
||||
std::string GetDeviceLocation();
|
||||
uint16_t GetPID();
|
||||
|
||||
void SetMode(uint8_t mode_value, uint8_t speed, uint8_t brightness, uint8_t direction);
|
||||
void SendColor(RGBColor color);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
uint16_t pid;
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| InstantMouseControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Instant mouse |
|
||||
| |
|
||||
| Morgan Guimard (morg) 19 Jan 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "InstantMouseController.h"
|
||||
#include "RGBController_InstantMouse.h"
|
||||
#include "InstantMouseDevices.h"
|
||||
|
||||
|
||||
void DetectInstantMouseControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
InstantMouseController* controller = new InstantMouseController(dev, *info, name);
|
||||
RGBController_InstantMouse* rgb_controller = new RGBController_InstantMouse(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("Advanced GTA 250 USB Gaming Mouse", DetectInstantMouseControllers, INSTANT_MICROELECTRONICS_VID, ADVANCED_GTA_250_PID, 1, 0xFF01, 0x01);
|
||||
REGISTER_HID_DETECTOR_IPU("Anko KM43243952 USB Gaming Mouse", DetectInstantMouseControllers, INSTANT_MICROELECTRONICS_VID, ANKO_KM43243952_VID, 1, 0xFF01, 0x01);
|
||||
REGISTER_HID_DETECTOR_IPU("Anko KM43277483 USB Gaming Mouse", DetectInstantMouseControllers, INSTANT_MICROELECTRONICS_VID, ANKO_KM43277483_VID, 1, 0xFF01, 0x01);
|
||||
REGISTER_HID_DETECTOR_IPU("AntEsports GM600 USB Gaming Mouse", DetectInstantMouseControllers, INSTANT_MICROELECTRONICS_VID, ANTESPORTS_GM600_PID, 1, 0xFF01, 0001);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| InstantMouseController.h |
|
||||
| |
|
||||
| Driver for Instant mouse |
|
||||
| |
|
||||
| shafiahaz2478 29 Aug 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
#define INSTANTMOUSEDEVICES_H
|
||||
|
||||
#define INSTANT_MICROELECTRONICS_VID 0x30FA
|
||||
#define ADVANCED_GTA_250_PID 0x1030
|
||||
#define ANKO_KM43243952_VID 0x1440
|
||||
#define ANKO_KM43277483_VID 0x1540
|
||||
#define ANTESPORTS_GM600_PID 0x1040
|
||||
@@ -0,0 +1,223 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_InstantMouse.cpp |
|
||||
| |
|
||||
| RGBController for Instant mouse |
|
||||
| |
|
||||
| Morgan Guimard (morg) 19 Jan 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_InstantMouse.h"
|
||||
#include "InstantMouseDevices.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Instant mouse
|
||||
@category Mouse
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectInstantMouseControllers
|
||||
@comment This controller should work with all mouse with this chip.
|
||||
Identified devices that work with this controller: Advance Gaming
|
||||
GTA 250 (GX72-A725), Anko KM43243952 (GM8-A825), Anko KM43277483,
|
||||
Ant Esports GM600
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_InstantMouse::RGBController_InstantMouse(InstantMouseController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
vendor = controller->GetNameString();
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Instant USB Gaming Mouse";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode direct;
|
||||
direct.name = "Direct";
|
||||
direct.value = INSTANT_MOUSE_DIRECT_MODE;
|
||||
direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
direct.color_mode = MODE_COLORS_PER_LED;
|
||||
direct.brightness = INSTANT_MOUSE_BRIGHTNESS_MAX;
|
||||
direct.brightness_min = INSTANT_MOUSE_BRIGHTNESS_MIN;
|
||||
direct.brightness_max = INSTANT_MOUSE_BRIGHTNESS_MAX;
|
||||
modes.push_back(direct);
|
||||
|
||||
mode rainbow;
|
||||
rainbow.name = "Rainbow wave";
|
||||
rainbow.value = INSTANT_MOUSE_RAINBOW_WAVE_MODE;
|
||||
rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
rainbow.color_mode = MODE_COLORS_NONE;
|
||||
rainbow.speed_min = INSTANT_MOUSE_SPEED_MIN;
|
||||
rainbow.speed_max = INSTANT_MOUSE_SPEED_MAX;
|
||||
rainbow.speed = INSTANT_MOUSE_SPEED_MAX/2;
|
||||
modes.push_back(rainbow);
|
||||
|
||||
mode spectrum;
|
||||
spectrum.name = "Spectrum cycle";
|
||||
spectrum.value = INSTANT_MOUSE_SPECTRUM_CYCLE_MODE;
|
||||
spectrum.flags = MODE_FLAG_HAS_SPEED;
|
||||
spectrum.color_mode = MODE_COLORS_NONE;
|
||||
spectrum.speed_min = INSTANT_MOUSE_SPEED_MIN;
|
||||
spectrum.speed_max = INSTANT_MOUSE_SPEED_MAX;
|
||||
spectrum.speed = INSTANT_MOUSE_SPEED_MAX/2;
|
||||
modes.push_back(spectrum);
|
||||
|
||||
mode breathing;
|
||||
breathing.name = "Breathing";
|
||||
/*------------------------------------------------------------------*\
|
||||
| ANT ESPORTS GM600 has different mode id for breathing mode. |
|
||||
\*------------------------------------------------------------------*/
|
||||
breathing.value = (controller->GetPID() == ANTESPORTS_GM600_PID ) ? ANT_MOUSE_BREATHING_MODE : INSTANT_MOUSE_BREATHING_MODE;
|
||||
breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
breathing.colors.resize(1);
|
||||
breathing.colors_min = 1;
|
||||
breathing.colors_max = 1;
|
||||
breathing.speed_min = INSTANT_MOUSE_SPEED_MIN;
|
||||
breathing.speed_max = INSTANT_MOUSE_SPEED_MAX;
|
||||
breathing.speed = INSTANT_MOUSE_SPEED_MAX/2;
|
||||
modes.push_back(breathing);
|
||||
|
||||
mode fill;
|
||||
fill.name = "Fill";
|
||||
fill.value = INSTANT_MOUSE_FILL_DRAIN_MODE;
|
||||
fill.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
fill.color_mode = MODE_COLORS_NONE;
|
||||
fill.speed_min = INSTANT_MOUSE_SPEED_MIN;
|
||||
fill.speed_max = INSTANT_MOUSE_SPEED_MAX;
|
||||
fill.speed = INSTANT_MOUSE_SPEED_MAX/2;
|
||||
fill.brightness = INSTANT_MOUSE_BRIGHTNESS_MAX;
|
||||
fill.brightness_min = INSTANT_MOUSE_BRIGHTNESS_MIN;
|
||||
fill.brightness_max = INSTANT_MOUSE_BRIGHTNESS_MAX;
|
||||
modes.push_back(fill);
|
||||
|
||||
mode loop;
|
||||
loop.name = "Loop";
|
||||
loop.value = INSTANT_MOUSE_LOOP_MODE;
|
||||
loop.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
loop.color_mode = MODE_COLORS_NONE;
|
||||
loop.speed_min = INSTANT_MOUSE_SPEED_MIN;
|
||||
loop.speed_max = INSTANT_MOUSE_SPEED_MAX;
|
||||
loop.speed = INSTANT_MOUSE_SPEED_MAX/2;
|
||||
loop.brightness = INSTANT_MOUSE_BRIGHTNESS_MAX;
|
||||
loop.brightness_min = INSTANT_MOUSE_BRIGHTNESS_MIN;
|
||||
loop.brightness_max = INSTANT_MOUSE_BRIGHTNESS_MAX;
|
||||
modes.push_back(loop);
|
||||
/*------------------------------------------------------------------*\
|
||||
| Extra modes for Ant Esports GM600. |
|
||||
\*------------------------------------------------------------------*/
|
||||
if(controller->GetPID() == ANTESPORTS_GM600_PID )
|
||||
{
|
||||
mode enraptured;
|
||||
enraptured.name = "Enrpatured";
|
||||
enraptured.value = INSTANT_MOUSE_ENRAPTURED_MODE;
|
||||
enraptured.flags = MODE_FLAG_HAS_SPEED;
|
||||
enraptured.color_mode = MODE_COLORS_NONE;
|
||||
enraptured.speed_min = INSTANT_MOUSE_SPEED_MIN;
|
||||
enraptured.speed_max = INSTANT_MOUSE_SPEED_MAX;
|
||||
enraptured.speed = INSTANT_MOUSE_SPEED_MAX/2;
|
||||
modes.push_back(enraptured);
|
||||
|
||||
mode flicker;
|
||||
flicker.name = "Flicker";
|
||||
flicker.value = INSTANT_MOUSE_FLICKER_MODE;
|
||||
flicker.flags = MODE_FLAG_HAS_SPEED;
|
||||
flicker.color_mode = MODE_COLORS_NONE;
|
||||
flicker.speed_min = INSTANT_MOUSE_SPEED_MIN;
|
||||
flicker.speed_max = INSTANT_MOUSE_SPEED_MAX;
|
||||
flicker.speed = INSTANT_MOUSE_SPEED_MAX/2;
|
||||
modes.push_back(flicker);
|
||||
|
||||
mode ripple;
|
||||
ripple.name = "Ripple";
|
||||
ripple.value = INSTANT_MOUSE_RIPPLE_MODE;
|
||||
ripple.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
ripple.color_mode = MODE_COLORS_NONE;
|
||||
ripple.speed_min = INSTANT_MOUSE_SPEED_MIN;
|
||||
ripple.speed_max = INSTANT_MOUSE_SPEED_MAX;
|
||||
ripple.speed = INSTANT_MOUSE_SPEED_MAX/2;
|
||||
modes.push_back(ripple);
|
||||
|
||||
mode startreck;
|
||||
startreck.name = "Star treck";
|
||||
startreck.value = INSTANT_MOUSE_STARTRECK_MODE;
|
||||
|
||||
modes.push_back(startreck);
|
||||
}
|
||||
|
||||
mode off;
|
||||
off.name = "Off";
|
||||
off.value = INSTANT_MOUSE_OFF_MODE;
|
||||
|
||||
modes.push_back(off);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_InstantMouse::~RGBController_InstantMouse()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_InstantMouse::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Mouse";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = 1;
|
||||
new_zone.leds_max = 1;
|
||||
new_zone.leds_count = 1;
|
||||
new_zone.matrix_map = nullptr;
|
||||
|
||||
zones.emplace_back(new_zone);
|
||||
|
||||
leds.resize(1);
|
||||
leds[0].name = "Mouse";
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_InstantMouse::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_InstantMouse::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SendColor(colors[0]);
|
||||
}
|
||||
|
||||
void RGBController_InstantMouse::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_InstantMouse::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_InstantMouse::DeviceUpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == INSTANT_MOUSE_OFF_MODE)
|
||||
{
|
||||
controller->SetMode(INSTANT_MOUSE_DIRECT_MODE, 0, 0, 0);
|
||||
controller->SendColor(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, modes[active_mode].direction);
|
||||
|
||||
if(modes[active_mode].colors.size() == 1)
|
||||
{
|
||||
controller->SendColor(modes[active_mode].colors[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_InstantMouse.h |
|
||||
| |
|
||||
| RGBController for Instant mouse |
|
||||
| |
|
||||
| Morgan Guimard (morg) 19 Jan 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "InstantMouseController.h"
|
||||
|
||||
class RGBController_InstantMouse : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_InstantMouse(InstantMouseController* controller_ptr);
|
||||
~RGBController_InstantMouse();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
InstantMouseController* controller;
|
||||
};
|
||||
Reference in New Issue
Block a user