Don't include _Linux files in MacOS build, add support for _MacOS files
This commit is contained in:
parent
698ae9debc
commit
d834b18a16
7 changed files with 295 additions and 20 deletions
|
|
@ -0,0 +1,91 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| HYTEMousematControllerDetect_MacOS.cpp |
|
||||
| |
|
||||
| Detector for HYTE mousemat (libusb implementation for |
|
||||
| MacOS) |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com) 05 Aug 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <vector>
|
||||
#include <libusb.h>
|
||||
#include "Detector.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_HYTEMousemat.h"
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| HYTE vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define HYTE_VID 0x3402
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| HYTE CNVS product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define HYTE_CNVS_HW_VER_1_PID 0x0B00
|
||||
#define HYTE_CNVS_HW_VER_2_PID 0x0B01
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
unsigned char usb_interface;
|
||||
const char * name;
|
||||
} hyte_mousemat_device;
|
||||
|
||||
#define HYTE_MOUSEMAT_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const hyte_mousemat_device device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mousemats |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ HYTE_VID, HYTE_CNVS_HW_VER_1_PID, 0, "HYTE CNVS" },
|
||||
{ HYTE_VID, HYTE_CNVS_HW_VER_2_PID, 0, "HYTE CNVS" },
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHYTEMousematControllers *
|
||||
* *
|
||||
* Detect devices supported by the HyteMousemat driver *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHYTEMousematControllers()
|
||||
{
|
||||
libusb_init(NULL);
|
||||
|
||||
#ifdef _WIN32
|
||||
libusb_set_option(NULL, LIBUSB_OPTION_USE_USBDK);
|
||||
#endif
|
||||
|
||||
for(std::size_t device_idx = 0; device_idx < HYTE_MOUSEMAT_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(NULL, device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for HYTE CNVS
|
||||
if(dev)
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
HYTEMousematController * controller = new HYTEMousematController(dev);
|
||||
RGBController_HYTEMousemat * rgb_controller = new RGBController_HYTEMousemat(controller);
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectHYTEMousematControllers() */
|
||||
|
||||
REGISTER_DETECTOR("HYTE Mousemat", DetectHYTEMousematControllers);
|
||||
/*---------------------------------------------------------------------------------------------------------*\
|
||||
| Entries for dynamic UDEV rules |
|
||||
| |
|
||||
| DUMMY_DEVICE_DETECTOR("HYTE Mousemat", DetectHYTEMousematControllers, 0x3402, 0x0B00 ) |
|
||||
| DUMMY_DEVICE_DETECTOR("HYTE Mousemat", DetectHYTEMousematControllers, 0x3402, 0x0B01 ) |
|
||||
\*---------------------------------------------------------------------------------------------------------*/
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| HYTEMousematController_MacOS.cpp |
|
||||
| |
|
||||
| Driver for HYTE mousemat (libusb implementation for |
|
||||
| MacOS) |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com) 05 Aug 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include "HYTEMousematController_MacOS.h"
|
||||
|
||||
HYTEMousematController::HYTEMousematController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in location string with USB ID |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_device_descriptor descriptor;
|
||||
libusb_get_device_descriptor(libusb_get_device(dev_handle), &descriptor);
|
||||
|
||||
std::stringstream location_stream;
|
||||
location_stream << std::hex << std::setfill('0') << std::setw(4) << descriptor.idVendor << ":" << std::hex << std::setfill('0') << std::setw(4) << descriptor.idProduct;
|
||||
location = location_stream.str();
|
||||
}
|
||||
|
||||
HYTEMousematController::~HYTEMousematController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string HYTEMousematController::GetLocation()
|
||||
{
|
||||
return(location);
|
||||
}
|
||||
|
||||
void HYTEMousematController::FirmwareAnimationControl(bool enabled)
|
||||
{
|
||||
unsigned char serial_buf[4];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(serial_buf, 0, sizeof(serial_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Firmware Animation Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0] = 0xFF;
|
||||
serial_buf[1] = 0xDC;
|
||||
serial_buf[2] = 0x05;
|
||||
serial_buf[3] = enabled;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_bulk_transfer(dev, HYTE_CNVS_EP_OUT, serial_buf, sizeof(serial_buf), NULL, 1000);
|
||||
}
|
||||
|
||||
void HYTEMousematController::StreamingCommand(RGBColor* colors)
|
||||
{
|
||||
unsigned char serial_buf[157];
|
||||
unsigned int max_brightness = 72;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(serial_buf, 0, sizeof(serial_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Streaming packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0] = 0xFF;
|
||||
serial_buf[1] = 0xEE;
|
||||
serial_buf[2] = 0x02;
|
||||
serial_buf[3] = 0x01;
|
||||
serial_buf[4] = 0x00;
|
||||
serial_buf[5] = 0x32;
|
||||
serial_buf[6] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in colors |
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned int color_idx = 0; color_idx < 50; color_idx++)
|
||||
{
|
||||
serial_buf[7 + (color_idx * 3)] = ( max_brightness * RGBGetGValue(colors[color_idx]) ) / 100;
|
||||
serial_buf[8 + (color_idx * 3)] = ( max_brightness * RGBGetRValue(colors[color_idx]) ) / 100;
|
||||
serial_buf[9 + (color_idx * 3)] = ( max_brightness * RGBGetBValue(colors[color_idx]) ) / 100;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_bulk_transfer(dev, HYTE_CNVS_EP_OUT, serial_buf, sizeof(serial_buf), NULL, 1000);
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| HYTEMousematController_MacOS.h |
|
||||
| |
|
||||
| Driver for HYTE mousemat (libusb implementation for |
|
||||
| MacOS) |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com) 05 Aug 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <libusb.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| HYTE CNVS endpoint values |
|
||||
\*---------------------------------------------------------*/
|
||||
#define HYTE_CNVS_EP_IN 0x81
|
||||
#define HYTE_CNVS_EP_OUT 0x01
|
||||
|
||||
class HYTEMousematController
|
||||
{
|
||||
public:
|
||||
HYTEMousematController(libusb_device_handle* dev_handle);
|
||||
~HYTEMousematController();
|
||||
|
||||
std::string GetLocation();
|
||||
|
||||
void FirmwareAnimationControl(bool enabled);
|
||||
void StreamingCommand(RGBColor* colors);
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
std::string location;
|
||||
};
|
||||
34
OpenRGB.pro
34
OpenRGB.pro
|
|
@ -72,10 +72,12 @@ for(iter, $$list($$CONTROLLER_H)) {
|
|||
}
|
||||
CONTROLLER_INCLUDES = $$unique(CONTROLLER_INCLUDES)
|
||||
|
||||
CONTROLLER_H_WIN = $$files("Controllers/*_Windows.h", true)
|
||||
CONTROLLER_CPP_WIN = $$files("Controllers/*_Windows.cpp", true)
|
||||
CONTROLLER_H_LNX = $$files("Controllers/*_Linux.h", true)
|
||||
CONTROLLER_CPP_LNX = $$files("Controllers/*_Linux.cpp", true)
|
||||
CONTROLLER_H_WINDOWS = $$files("Controllers/*_Windows.h", true)
|
||||
CONTROLLER_CPP_WINDOWS = $$files("Controllers/*_Windows.cpp", true)
|
||||
CONTROLLER_H_LINUX = $$files("Controllers/*_Linux.h", true)
|
||||
CONTROLLER_CPP_LINUX = $$files("Controllers/*_Linux.cpp", true)
|
||||
CONTROLLER_H_MACOS = $$files("Controllers/*_MacOS.cpp", true)
|
||||
CONTROLLER_CPP_MACOS = $$files("Controllers/*_MacOS.cpp", true)
|
||||
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
# OpenRGB Common #
|
||||
|
|
@ -244,7 +246,8 @@ win32:INCLUDEPATH +=
|
|||
dependencies/NVFC \
|
||||
wmi/ \
|
||||
|
||||
win32:SOURCES -= $$CONTROLLER_CPP_LNX
|
||||
win32:SOURCES -= $$CONTROLLER_CPP_LINUX
|
||||
win32:SOURCES -= $$CONTROLLER_CPP_MACOS
|
||||
|
||||
win32:SOURCES += \
|
||||
dependencies/hueplusplus-1.1.0/src/WinHttpHandler.cpp \
|
||||
|
|
@ -355,7 +358,8 @@ win32:SOURCES +=
|
|||
wmi/wmi.cpp \
|
||||
AutoStart/AutoStart-Windows.cpp \
|
||||
|
||||
win32:HEADERS -= $$CONTROLLER_H_LNX
|
||||
win32:HEADERS -= $$CONTROLLER_H_LINUX
|
||||
win32:HEADERS -= $$CONTROLLER_H_MACOS
|
||||
|
||||
win32:HEADERS += \
|
||||
dependencies/display-library/include/adl_defines.h \
|
||||
|
|
@ -457,7 +461,8 @@ contains(QMAKE_PLATFORM, linux) {
|
|||
|
||||
TARGET = $$lower($$TARGET)
|
||||
|
||||
HEADERS -= $$CONTROLLER_H_WIN
|
||||
HEADERS -= $$CONTROLLER_H_WINDOWS
|
||||
HEADERS -= $$CONTROLLER_H_MACOS
|
||||
|
||||
HEADERS += \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
|
|
@ -498,7 +503,8 @@ contains(QMAKE_PLATFORM, linux) {
|
|||
}
|
||||
}
|
||||
|
||||
SOURCES -= $$CONTROLLER_CPP_WIN
|
||||
SOURCES -= $$CONTROLLER_CPP_WINDOWS
|
||||
SOURCES -= $$CONTROLLER_CPP_MACOS
|
||||
|
||||
SOURCES += \
|
||||
dependencies/hueplusplus-1.1.0/src/LinHttpHandler.cpp \
|
||||
|
|
@ -575,7 +581,7 @@ contains(QMAKE_PLATFORM, freebsd) {
|
|||
Controllers/SeagateController/RGBController_Seagate.h \
|
||||
Controllers/SeagateController/SeagateController.h \
|
||||
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_ROGArion.h \
|
||||
$$CONTROLLER_H_WIN \
|
||||
$$CONTROLLER_H_WINDOWS \
|
||||
|
||||
LIBS += \
|
||||
-lmbedx509 \
|
||||
|
|
@ -620,7 +626,7 @@ contains(QMAKE_PLATFORM, freebsd) {
|
|||
Controllers/SeagateController/SeagateControllerDetect.cpp \
|
||||
Controllers/ENESMBusController/ROGArionDetect.cpp \
|
||||
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_ROGArion.cpp \
|
||||
$$CONTROLLER_CPP_WIN \
|
||||
$$CONTROLLER_CPP_WINDOWS \
|
||||
|
||||
#-------------------------------------------------------------------------------------------#
|
||||
# Set up install paths #
|
||||
|
|
@ -674,15 +680,17 @@ macx {
|
|||
AutoStart/AutoStart-MacOS.h \
|
||||
qt/macutils.h \
|
||||
|
||||
HEADERS -= $$CONTROLLER_H_WIN
|
||||
HEADERS -= $$CONTROLLER_H_WINDOWS
|
||||
HEADERS -= $$CONTROLLER_H_LINUX
|
||||
|
||||
SOURCES += \
|
||||
dependencies/hueplusplus-1.1.0/src/LinHttpHandler.cpp \
|
||||
serial_port/find_usb_serial_port_linux.cpp \
|
||||
serial_port/find_usb_serial_port_macos.cpp \
|
||||
AutoStart/AutoStart-MacOS.cpp \
|
||||
qt/macutils.mm \
|
||||
|
||||
SOURCES -= $$CONTROLLER_CPP_WIN
|
||||
SOURCES -= $$CONTROLLER_CPP_WINDOWS
|
||||
SOURCES -= $$CONTROLLER_CPP_LINUX
|
||||
|
||||
# Use mbedtls v2 instead of latest
|
||||
MBEDTLS_PREFIX = $$system(brew --prefix mbedtls@2)
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@
|
|||
@@ -443,8 +443,6 @@ contains(QMAKE_PLATFORM, linux) {
|
||||
PKGCONFIG += \
|
||||
libusb-1.0
|
||||
|
||||
|
||||
- TARGET = $$lower($$TARGET)
|
||||
-
|
||||
HEADERS -= $$CONTROLLER_H_WIN
|
||||
|
||||
HEADERS -= $$CONTROLLER_H_WINDOWS
|
||||
HEADERS -= $$CONTROLLER_H_MACOS
|
||||
|
||||
HEADERS += \
|
||||
--- a/qt/org.openrgb.OpenRGB.desktop
|
||||
+++ b/qt/org.openrgb.OpenRGB.desktop
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ extern "C" {
|
|||
| Functions |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
void scsi_close(struct scsi_device * dev)
|
||||
void scsi_close(struct scsi_device * /*dev*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
struct scsi_device_info * scsi_enumerate(const char * vendor, const char * product)
|
||||
struct scsi_device_info * scsi_enumerate(const char * /*vendor*/, const char * /*product*/)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
|
@ -54,12 +54,12 @@ void scsi_free_enumeration(struct scsi_device_info * devs)
|
|||
}
|
||||
}
|
||||
|
||||
struct scsi_device * scsi_open_path(const char *path)
|
||||
struct scsi_device * scsi_open_path(const char * /*path*/)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t data_length, const unsigned char * cdb, size_t cdb_length, unsigned char * sense, size_t sense_length)
|
||||
int scsi_write(struct scsi_device * /*dev*/, const unsigned char * /*data*/, size_t /*data_length*/, const unsigned char * /*cdb*/, size_t /*cdb_length*/, unsigned char * /*sense*/, size_t /*sense_length*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
35
serial_port/find_usb_serial_port_macos.cpp
Normal file
35
serial_port/find_usb_serial_port_macos.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| find_usb_serial_port_macos.cpp |
|
||||
| |
|
||||
| Finds the serial port path(s) of USB serial port devices|
|
||||
| given the USB VID and PID of the device |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "find_usb_serial_port.h"
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| |
|
||||
| find_usb_serial_port |
|
||||
| |
|
||||
| This function returns the name of the first USB serial port matching|
|
||||
| the given USB product and vendor ID. |
|
||||
| |
|
||||
| vid: Vendor ID code |
|
||||
| pid: Product ID code |
|
||||
| |
|
||||
| returns: std::string containing port name "COMx" or "/dev/ttyX" |
|
||||
| |
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
std::vector<std::string *> find_usb_serial_port(unsigned short /*vid*/, unsigned short /*pid*/)
|
||||
{
|
||||
std::vector<std::string *> ret_vector;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| TODO: Implement for MacOS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
return(ret_vector);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue