Compare commits

...
12 changed files with 1488 additions and 48 deletions
@@ -137,7 +137,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
red_color_data red_color_data
); );
Sleep(2); Sleep(5);
SendDirect SendDirect
( (
@@ -145,7 +145,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
grn_color_data grn_color_data
); );
Sleep(2); Sleep(5);
SendDirect SendDirect
( (
@@ -153,7 +153,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
blu_color_data blu_color_data
); );
Sleep(2); Sleep(5);
SendDirectExtended SendDirectExtended
( (
@@ -189,6 +189,8 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
red_color_data red_color_data
); );
Sleep(5);
SendColor SendColor
( (
0x01, 0x01,
@@ -196,6 +198,8 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
grn_color_data grn_color_data
); );
Sleep(5);
SendColor SendColor
( (
0x01, 0x01,
@@ -203,6 +207,8 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
blu_color_data blu_color_data
); );
Sleep(5);
SendExtendedColor SendExtendedColor
( (
0x01, 0x01,
@@ -104,6 +104,9 @@ void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
| Send packets | | Send packets |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
hid_send_feature_report(dev, red_grn_buf, 264); hid_send_feature_report(dev, red_grn_buf, 264);
Sleep(5);
hid_send_feature_report(dev, blu_buf, 264); hid_send_feature_report(dev, blu_buf, 264);
} }
+3 -13
View File
@@ -234,6 +234,7 @@ win32:INCLUDEPATH += \
win32:SOURCES += \ win32:SOURCES += \
dependencies/NVFC/nvapi.cpp \ dependencies/NVFC/nvapi.cpp \
dependencies/hidapi/hid_win.c \
i2c_smbus/i2c_smbus_i801.cpp \ i2c_smbus/i2c_smbus_i801.cpp \
i2c_smbus/i2c_smbus_nct6775.cpp \ i2c_smbus/i2c_smbus_nct6775.cpp \
i2c_smbus/i2c_smbus_nvapi.cpp \ i2c_smbus/i2c_smbus_nvapi.cpp \
@@ -258,7 +259,6 @@ win32:contains(QMAKE_TARGET.arch, x86_64) {
-lws2_32 \ -lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/x64/" -linpoutx64 \ -L"$$PWD/dependencies/inpout32_1501/x64/" -linpoutx64 \
-L"$$PWD/dependencies/libusb-1.0.22/MS64/dll" -llibusb-1.0 \ -L"$$PWD/dependencies/libusb-1.0.22/MS64/dll" -llibusb-1.0 \
-L"$$PWD/dependencies/hidapi-win/x64/" -lhidapi
} }
win32:contains(QMAKE_TARGET.arch, x86) { win32:contains(QMAKE_TARGET.arch, x86) {
@@ -266,7 +266,6 @@ win32:contains(QMAKE_TARGET.arch, x86) {
-lws2_32 \ -lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \ -L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \ -L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \
-L"$$PWD/dependencies/hidapi-win/x86/" -lhidapi
} }
win32:DEFINES -= \ win32:DEFINES -= \
@@ -300,6 +299,7 @@ win32:contains(QMAKE_TARGET.arch, x86) {
# Linux specific project configuration # Linux specific project configuration
#----------------------------------------------- #-----------------------------------------------
unix:INCLUDEPATH += \ unix:INCLUDEPATH += \
dependencies/hidapi \
unix:HEADERS += \ unix:HEADERS += \
i2c_smbus/i2c_smbus_linux.h \ i2c_smbus/i2c_smbus_linux.h \
@@ -308,19 +308,9 @@ unix:HEADERS += \
unix:LIBS += \ unix:LIBS += \
-lusb-1.0 \ -lusb-1.0 \
-lstdc++fs \ -lstdc++fs \
packagesExist(hidapi-libusb){
unix:LIBS += -lhidapi-libusb
} else {
packagesExist(hidapi) {
unix:LIBS += -lhidapi
} else {
unix:LIBS += -lhidapi-libusb
}
}
unix:SOURCES += \ unix:SOURCES += \
dependencies/hidapi/hid_win.c \
i2c_smbus/i2c_smbus_linux.cpp \ i2c_smbus/i2c_smbus_linux.cpp \
serial_port/find_usb_serial_port_linux.cpp \ serial_port/find_usb_serial_port_linux.cpp \
RGBController/OpenRazerDetect.cpp \ RGBController/OpenRazerDetect.cpp \
@@ -9,6 +9,41 @@
#include "RGBController_HyperXKeyboard.h" #include "RGBController_HyperXKeyboard.h"
//Include thread libraries for Windows or Linux
#ifdef WIN32
#include <process.h>
#else
#include "pthread.h"
#include "unistd.h"
#endif
//Thread functions have different types in Windows and Linux
#ifdef WIN32
#define THREAD static void
#define THREADRETURN
#else
#define THREAD static void*
#define THREADRETURN return(NULL);
#endif
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
THREAD keepalive_thread(void *param)
{
RGBController_HyperXKeyboard* controller = static_cast<RGBController_HyperXKeyboard*>(param);
controller->KeepaliveThread();
THREADRETURN
}
static const char* zone_names[] = static const char* zone_names[] =
{ {
"Keyboard", "Keyboard",
@@ -223,6 +258,19 @@ RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardControl
zones.push_back(new_zone); zones.push_back(new_zone);
} }
/*-----------------------------------------------------*\
| The Corsair Lighting Node Pro requires a packet within|
| 20 seconds of sending the lighting change in order |
| to not revert back into rainbow mode. Start a thread |
| to continuously send a keepalive packet every 5s |
\*-----------------------------------------------------*/
#ifdef WIN32
_beginthread(keepalive_thread, 0, this);
#else
pthread_t thread;
pthread_create(&thread, NULL, &keepalive_thread, this);
#endif
} }
RGBController_HyperXKeyboard::~RGBController_HyperXKeyboard() RGBController_HyperXKeyboard::~RGBController_HyperXKeyboard()
@@ -269,3 +317,15 @@ void RGBController_HyperXKeyboard::UpdateMode()
hyperx->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed, temp_colors); hyperx->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed, temp_colors);
} }
} }
void RGBController_HyperXKeyboard::KeepaliveThread()
{
while(1)
{
if(active_mode == 0)
{
hyperx->SetLEDsDirect(colors);
}
Sleep(200);
}
}
@@ -23,6 +23,8 @@ public:
void SetCustomMode(); void SetCustomMode();
void UpdateMode(); void UpdateMode();
void KeepaliveThread();
private: private:
HyperXKeyboardController* hyperx; HyperXKeyboardController* hyperx;
}; };
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1383
View File
File diff suppressed because it is too large Load Diff
+28 -32
View File
@@ -30,7 +30,7 @@
#include <wchar.h> #include <wchar.h>
#ifdef _WIN32 #ifdef _WIN32
#define HID_API_EXPORT __declspec(dllexport) #define HID_API_EXPORT
#define HID_API_CALL #define HID_API_CALL
#else #else
#define HID_API_EXPORT /**< API export macro */ #define HID_API_EXPORT /**< API export macro */
@@ -69,13 +69,9 @@ extern "C" {
(Windows/Mac only).*/ (Windows/Mac only).*/
unsigned short usage; unsigned short usage;
/** The USB interface which this logical device /** The USB interface which this logical device
represents. represents. Valid on both Linux implementations
in all cases, and valid on the Windows implementation
* Valid on both Linux implementations in all cases. only if the device contains more than one interface. */
* Valid on the Windows implementation only if the device
contains more than one interface.
* Valid on the Mac implementation if and only if the device
is a USB HID device. */
int interface_number; int interface_number;
/** Pointer to the next device */ /** Pointer to the next device */
@@ -129,7 +125,7 @@ extern "C" {
@returns @returns
This function returns a pointer to a linked list of type This function returns a pointer to a linked list of type
struct #hid_device_info, containing information about the HID devices struct #hid_device, containing information about the HID devices
attached to the system, or NULL in the case of failure. Free attached to the system, or NULL in the case of failure. Free
this linked list by calling hid_free_enumeration(). this linked list by calling hid_free_enumeration().
*/ */
@@ -195,7 +191,7 @@ extern "C" {
the Control Endpoint (Endpoint 0). the Control Endpoint (Endpoint 0).
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param data The data to send, including the report number as @param data The data to send, including the report number as
the first byte. the first byte.
@param length The length in bytes of the data to send. @param length The length in bytes of the data to send.
@@ -204,7 +200,7 @@ extern "C" {
This function returns the actual number of bytes written and This function returns the actual number of bytes written and
-1 on error. -1 on error.
*/ */
int HID_API_EXPORT HID_API_CALL hid_write(hid_device *dev, const unsigned char *data, size_t length); int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length);
/** @brief Read an Input report from a HID device with timeout. /** @brief Read an Input report from a HID device with timeout.
@@ -213,7 +209,7 @@ extern "C" {
contain the Report number if the device uses numbered reports. contain the Report number if the device uses numbered reports.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param data A buffer to put the read data into. @param data A buffer to put the read data into.
@param length The number of bytes to read. For devices with @param length The number of bytes to read. For devices with
multiple reports, make sure to read an extra byte for multiple reports, make sure to read an extra byte for
@@ -234,7 +230,7 @@ extern "C" {
contain the Report number if the device uses numbered reports. contain the Report number if the device uses numbered reports.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param data A buffer to put the read data into. @param data A buffer to put the read data into.
@param length The number of bytes to read. For devices with @param length The number of bytes to read. For devices with
multiple reports, make sure to read an extra byte for multiple reports, make sure to read an extra byte for
@@ -245,7 +241,7 @@ extern "C" {
-1 on error. If no packet was available to be read and -1 on error. If no packet was available to be read and
the handle is in non-blocking mode, this function returns 0. the handle is in non-blocking mode, this function returns 0.
*/ */
int HID_API_EXPORT HID_API_CALL hid_read(hid_device *dev, unsigned char *data, size_t length); int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length);
/** @brief Set the device handle to be non-blocking. /** @brief Set the device handle to be non-blocking.
@@ -257,7 +253,7 @@ extern "C" {
Nonblocking can be turned on and off at any time. Nonblocking can be turned on and off at any time.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param nonblock enable or not the nonblocking reads @param nonblock enable or not the nonblocking reads
- 1 to enable nonblocking - 1 to enable nonblocking
- 0 to disable nonblocking. - 0 to disable nonblocking.
@@ -265,7 +261,7 @@ extern "C" {
@returns @returns
This function returns 0 on success and -1 on error. This function returns 0 on success and -1 on error.
*/ */
int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *dev, int nonblock); int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock);
/** @brief Send a Feature report to the device. /** @brief Send a Feature report to the device.
@@ -283,7 +279,7 @@ extern "C" {
in would be 17. in would be 17.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param data The data to send, including the report number as @param data The data to send, including the report number as
the first byte. the first byte.
@param length The length in bytes of the data to send, including @param length The length in bytes of the data to send, including
@@ -293,7 +289,7 @@ extern "C" {
This function returns the actual number of bytes written and This function returns the actual number of bytes written and
-1 on error. -1 on error.
*/ */
int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length); int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length);
/** @brief Get a feature report from a HID device. /** @brief Get a feature report from a HID device.
@@ -304,7 +300,7 @@ extern "C" {
start in data[1]. start in data[1].
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param data A buffer to put the read data into, including @param data A buffer to put the read data into, including
the Report ID. Set the first byte of @p data[] to the the Report ID. Set the first byte of @p data[] to the
Report ID of the report to be read, or set it to zero Report ID of the report to be read, or set it to zero
@@ -318,55 +314,55 @@ extern "C" {
one for the report ID (which is still in the first one for the report ID (which is still in the first
byte), or -1 on error. byte), or -1 on error.
*/ */
int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length); int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length);
/** @brief Close a HID device. /** @brief Close a HID device.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
*/ */
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *dev); void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device);
/** @brief Get The Manufacturer String from a HID device. /** @brief Get The Manufacturer String from a HID device.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param string A wide string buffer to put the data into. @param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t. @param maxlen The length of the buffer in multiples of wchar_t.
@returns @returns
This function returns 0 on success and -1 on error. This function returns 0 on success and -1 on error.
*/ */
int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen); int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen);
/** @brief Get The Product String from a HID device. /** @brief Get The Product String from a HID device.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param string A wide string buffer to put the data into. @param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t. @param maxlen The length of the buffer in multiples of wchar_t.
@returns @returns
This function returns 0 on success and -1 on error. This function returns 0 on success and -1 on error.
*/ */
int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen); int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen);
/** @brief Get The Serial Number String from a HID device. /** @brief Get The Serial Number String from a HID device.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param string A wide string buffer to put the data into. @param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t. @param maxlen The length of the buffer in multiples of wchar_t.
@returns @returns
This function returns 0 on success and -1 on error. This function returns 0 on success and -1 on error.
*/ */
int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen); int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen);
/** @brief Get a string from a HID device, based on its string index. /** @brief Get a string from a HID device, based on its string index.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param string_index The index of the string to get. @param string_index The index of the string to get.
@param string A wide string buffer to put the data into. @param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t. @param maxlen The length of the buffer in multiples of wchar_t.
@@ -374,18 +370,18 @@ extern "C" {
@returns @returns
This function returns 0 on success and -1 on error. This function returns 0 on success and -1 on error.
*/ */
int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen); int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen);
/** @brief Get a string describing the last error which occurred. /** @brief Get a string describing the last error which occurred.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@returns @returns
This function returns a string containing the last error This function returns a string containing the last error
which occurred or NULL if none has occurred. which occurred or NULL if none has occurred.
*/ */
HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *dev); HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device);
#ifdef __cplusplus #ifdef __cplusplus
} }
Binary file not shown.