mirror of
https://github.com/MatMoul/g810-led.git
synced 2026-01-06 12:56:58 +00:00
Add support for opening a specific device
Allow filtration and matching of specified Device ID, Product ID, Serial Number Fix an issue in listKeyboards (hidapi) with an out of bounds search when using serial number Fix possible null reference problem in listKeyboards (hidapi) that caused rare segfaults when traversing the device enumeration in increments of two Fix handling of output of listKeyboards (hidapi) where it was incrementing the dev list pointer, then accessing the node to look for device serial number (potential security risk) Fix handling of serial number output of listKeyboards (hidapi) to handle wchar_t instead of outputting the memory address Fix issue in listKeyboards (libusb) failure to finish cleaning up USB contexts, leading to a segfault if calling a separate function after listing keyboards. Fix issue in close (libusb) segfaulting if m_hidHandle was null, so added a check. Modify listKeyboards to provide a vector of DeviceInfo objects that can be used by calling applications instead of outputting to stdout directly. Implement a struct to hold information regarding device information and ability for a library caller to query this information to make decisions about the currently targeted device. Signed-off-by: Kevin Pearson <pearson.kevin.m@gmail.com>
This commit is contained in:
committed by
Kevin Pearson
parent
ca1ecadf98
commit
4b2a1002e8
@@ -109,7 +109,15 @@ class LedKeyboard {
|
||||
ctrl_right, shift_right, alt_right, win_right
|
||||
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t vendorID = 0x0;
|
||||
uint16_t productID = 0x0;
|
||||
std::string manufacturer = "";
|
||||
std::string product = "";
|
||||
std::string serialNumber = "";
|
||||
KeyboardModel model;
|
||||
} DeviceInfo;
|
||||
|
||||
struct Color {
|
||||
uint8_t red;
|
||||
@@ -127,10 +135,12 @@ class LedKeyboard {
|
||||
~LedKeyboard();
|
||||
|
||||
|
||||
bool listKeyboards();
|
||||
std::vector<DeviceInfo> listKeyboards();
|
||||
|
||||
bool isOpen();
|
||||
bool open();
|
||||
bool open(uint16_t vendorID, uint16_t productID, std::string serial);
|
||||
DeviceInfo getCurrentDevice();
|
||||
bool close();
|
||||
|
||||
KeyboardModel getKeyboardModel();
|
||||
@@ -152,7 +162,6 @@ class LedKeyboard {
|
||||
bool setNativeEffect(NativeEffect effect, NativeEffectPart part, uint8_t speed, Color color);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
typedef std::vector<unsigned char> byte_buffer_t;
|
||||
@@ -191,9 +200,7 @@ class LedKeyboard {
|
||||
};
|
||||
|
||||
bool m_isOpen = false;
|
||||
uint16_t m_vendorID = 0;
|
||||
uint16_t m_productID = 0;
|
||||
KeyboardModel m_keyboardModel = KeyboardModel::unknown;
|
||||
DeviceInfo currentDevice;
|
||||
|
||||
#if defined(hidapi)
|
||||
hid_device *m_hidHandle;
|
||||
|
||||
Reference in New Issue
Block a user