mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-11 17:38:31 -04:00
Get MSI 3-zone keyboard working by pulling in libusb version of hidapi
This commit is contained in:
@@ -9,11 +9,11 @@
|
||||
|
||||
#include "MSI3ZoneController.h"
|
||||
|
||||
MSI3ZoneController::MSI3ZoneController(libusb_device_handle* dev_handle)
|
||||
MSI3ZoneController::MSI3ZoneController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
strcpy(device_name, "MSI 3-Zone Keyboard");
|
||||
//strcpy(device_name, "MSI 3-Zone Keyboard");
|
||||
}
|
||||
|
||||
MSI3ZoneController::~MSI3ZoneController()
|
||||
@@ -41,38 +41,38 @@ void MSI3ZoneController::SetLEDs(std::vector<RGBColor> colors)
|
||||
buf[6] = RGBGetBValue(colors[0]);
|
||||
buf[7] = 236;
|
||||
|
||||
libusb_control_transfer(dev, LIBUSB_DT_HID, LIBUSB_REQUEST_SET_CONFIGURATION, 0x0300, 0x03, buf, 8, 0);
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 2;
|
||||
buf[4] = RGBGetRValue(colors[1]);
|
||||
buf[5] = RGBGetGValue(colors[1]);
|
||||
buf[6] = RGBGetBValue(colors[1]);
|
||||
|
||||
libusb_control_transfer(dev, LIBUSB_DT_HID, LIBUSB_REQUEST_SET_CONFIGURATION, 0x0300, 0x03, buf, 8, 0);
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 3;
|
||||
buf[4] = RGBGetRValue(colors[2]);
|
||||
buf[5] = RGBGetGValue(colors[2]);
|
||||
buf[6] = RGBGetBValue(colors[2]);
|
||||
|
||||
libusb_control_transfer(dev, LIBUSB_DT_HID, LIBUSB_REQUEST_SET_CONFIGURATION, 0x0300, 0x03, buf, 8, 0);
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 4;
|
||||
buf[4] = RGBGetRValue(colors[3]);
|
||||
buf[5] = RGBGetGValue(colors[3]);
|
||||
buf[6] = RGBGetBValue(colors[3]);
|
||||
|
||||
libusb_control_transfer(dev, LIBUSB_DT_HID, LIBUSB_REQUEST_SET_CONFIGURATION, 0x0300, 0x03, buf, 8, 0);
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 5;
|
||||
|
||||
libusb_control_transfer(dev, LIBUSB_DT_HID, LIBUSB_REQUEST_SET_CONFIGURATION, 0x0300, 0x03, buf, 8, 0);
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 6;
|
||||
|
||||
libusb_control_transfer(dev, LIBUSB_DT_HID, LIBUSB_REQUEST_SET_CONFIGURATION, 0x0300, 0x03, buf, 8, 0);
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 7;
|
||||
|
||||
libusb_control_transfer(dev, LIBUSB_DT_HID, LIBUSB_REQUEST_SET_CONFIGURATION, 0x0300, 0x03, buf, 8, 0);
|
||||
}
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include "hidapi.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
class MSI3ZoneController
|
||||
{
|
||||
public:
|
||||
MSI3ZoneController(libusb_device_handle* dev_handle);
|
||||
MSI3ZoneController(hid_device* dev_handle);
|
||||
~MSI3ZoneController();
|
||||
|
||||
char* GetDeviceName();
|
||||
@@ -26,5 +26,5 @@ public:
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
libusb_device_handle* dev;
|
||||
hid_device* dev;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_MSI3Zone.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include "hidapi.h"
|
||||
|
||||
#define MSI_3_ZONE_KEYBOARD_VID 0x1770
|
||||
#define MSI_3_ZONE_KEYBOARD_PID 0xFF00
|
||||
@@ -18,17 +18,15 @@
|
||||
|
||||
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
hid_device* dev;
|
||||
|
||||
//Look for MSI/Steelseries 3-zone Keyboard
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, MSI_3_ZONE_KEYBOARD_VID, MSI_3_ZONE_KEYBOARD_PID);
|
||||
hid_init();
|
||||
|
||||
dev = hid_open(MSI_3_ZONE_KEYBOARD_VID, MSI_3_ZONE_KEYBOARD_PID, 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 1);
|
||||
libusb_claim_interface(dev, 1);
|
||||
|
||||
MSI3ZoneController* controller = new MSI3ZoneController(dev);
|
||||
|
||||
RGBController_MSI3Zone* rgb_controller = new RGBController_MSI3Zone(controller);
|
||||
|
||||
Reference in New Issue
Block a user