mirror of
https://github.com/MatMoul/g810-led.git
synced 2024-12-23 01:06:11 +00:00
Code formating
This commit is contained in:
parent
c475fc46fd
commit
7c96ec51bc
@ -31,7 +31,7 @@ vector<LedKeyboard::DeviceInfo> LedKeyboard::listKeyboards() {
|
||||
devs = hid_enumerate(0x0, 0x0);
|
||||
dev = devs;
|
||||
while (dev) {
|
||||
for (size_t i=0; i<SupportedKeyboards.size(); i++) {
|
||||
for (size_t i = 0; i < SupportedKeyboards.size(); i++) {
|
||||
if (dev->vendor_id == SupportedKeyboards[i][0]) {
|
||||
if (dev->product_id == SupportedKeyboards[i][1]) {
|
||||
DeviceInfo deviceInfo;
|
||||
@ -40,21 +40,21 @@ vector<LedKeyboard::DeviceInfo> LedKeyboard::listKeyboards() {
|
||||
|
||||
if (dev->serial_number != NULL) {
|
||||
char buf[256];
|
||||
wcstombs(buf,dev->serial_number,256);
|
||||
wcstombs(buf, dev->serial_number, 256);
|
||||
deviceInfo.serialNumber = string(buf);
|
||||
}
|
||||
|
||||
if (dev->manufacturer_string != NULL)
|
||||
{
|
||||
char buf[256];
|
||||
wcstombs(buf,dev->manufacturer_string,256);
|
||||
wcstombs(buf, dev->manufacturer_string, 256);
|
||||
deviceInfo.manufacturer = string(buf);
|
||||
}
|
||||
|
||||
if (dev->product_string != NULL)
|
||||
{
|
||||
char buf[256];
|
||||
wcstombs(buf,dev->product_string,256);
|
||||
wcstombs(buf, dev->product_string, 256);
|
||||
deviceInfo.product = string(buf);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ bool LedKeyboard::isOpen() {
|
||||
bool LedKeyboard::open() {
|
||||
if (m_isOpen) return true;
|
||||
|
||||
return open(0x0,0x0,"");
|
||||
return open(0x0, 0x0, "");
|
||||
}
|
||||
|
||||
bool LedKeyboard::open(uint16_t vendorID, uint16_t productID, string serial) {
|
||||
@ -146,8 +146,7 @@ bool LedKeyboard::open(uint16_t vendorID, uint16_t productID, string serial) {
|
||||
|
||||
while (dev) {
|
||||
for (int i=0; i<(int)SupportedKeyboards.size(); i++) {
|
||||
if (dev->vendor_id == SupportedKeyboards[i][0]) {
|
||||
if (dev->product_id == SupportedKeyboards[i][1]) {
|
||||
if (dev->vendor_id == SupportedKeyboards[i][0] && dev->product_id == SupportedKeyboards[i][1]) {
|
||||
if (!serial.empty() && dev->serial_number != NULL && wideSerial.compare(dev->serial_number) != 0) break; //Serial didn't match
|
||||
|
||||
if (dev->serial_number != NULL) {
|
||||
@ -176,7 +175,6 @@ bool LedKeyboard::open(uint16_t vendorID, uint16_t productID, string serial) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentDevice.model != KeyboardModel::unknown) break;
|
||||
dev = dev->next;
|
||||
}
|
||||
@ -318,8 +316,7 @@ bool LedKeyboard::open(uint16_t vendorID, uint16_t productID, string serial) {
|
||||
return false; //In case neither is defined
|
||||
}
|
||||
|
||||
LedKeyboard::DeviceInfo LedKeyboard::getCurrentDevice()
|
||||
{
|
||||
LedKeyboard::DeviceInfo LedKeyboard::getCurrentDevice() {
|
||||
return currentDevice;
|
||||
}
|
||||
|
||||
@ -332,7 +329,6 @@ bool LedKeyboard::close() {
|
||||
m_hidHandle = NULL;
|
||||
hid_exit();
|
||||
return true;
|
||||
|
||||
#elif defined(libusb)
|
||||
if (m_hidHandle == NULL) return true;
|
||||
if(libusb_release_interface(m_hidHandle, 1) != 0) return false;
|
||||
|
@ -224,4 +224,5 @@ namespace utils {
|
||||
uint16 = std::stoul("0x" + val, nullptr, 16);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
12
src/main.cpp
12
src/main.cpp
@ -15,8 +15,7 @@ int commit(LedKeyboard &kbd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void printDeviceInfo(LedKeyboard::DeviceInfo device)
|
||||
{
|
||||
void printDeviceInfo(LedKeyboard::DeviceInfo device) {
|
||||
std::cout<<"Device: "<<device.manufacturer<<" - "<<device.product<<std::endl;
|
||||
std::cout<<"\tVendor ID: "<<std::hex<<std::setw(4)<<std::setfill('0')<<device.vendorID<<std::endl;
|
||||
std::cout<<"\tProduct ID: "<<std::hex<<std::setw(4)<<std::setfill('0')<<device.productID<<std::endl;
|
||||
@ -302,14 +301,17 @@ int main(int argc, char **argv) {
|
||||
else if (argc > (argIndex + 1) && arg == "-mr") return setMRKey(kbd, argv[argIndex + 1]);
|
||||
else if (argc > (argIndex + 1) && arg == "-mn") return setMNKey(kbd, argv[argIndex + 1]);
|
||||
else if (argc > (argIndex + 1) && arg == "-an") return setAllKeys(kbd, argv[argIndex + 1], false);
|
||||
else if (argc > (argIndex + 2) && arg == "-gn") return setGroupKeys(kbd, argv[argIndex + 1], argv[argIndex + 2], false);
|
||||
else if (argc > (argIndex + 2) && arg == "-gn")
|
||||
return setGroupKeys(kbd, argv[argIndex + 1], argv[argIndex + 2], false);
|
||||
else if (argc > (argIndex + 2) && arg == "-kn") return setKey(kbd, argv[argIndex + 1], argv[argIndex + 2], false);
|
||||
else if (argc > (argIndex + 2) && arg == "-r") return setRegion(kbd, argv[argIndex + 1], argv[argIndex + 2]);
|
||||
else if (argc > (argIndex + 1) && arg == "-gkm") return setGKeysMode(kbd, argv[argIndex + 1]);
|
||||
else if (argc > (argIndex + 1) && arg == "-p") return loadProfile(kbd, argv[argIndex + 1]);
|
||||
else if (arg == "-pp") return pipeProfile(kbd);
|
||||
else if (argc > (argIndex + 4) && arg == "-fx") return setFX(kbd, argv[argIndex + 1], argv[argIndex + 2], argv[argIndex + 3], argv[argIndex + 4]);
|
||||
else if (argc > (argIndex + 3) && arg == "-fx") return setFX(kbd, argv[argIndex + 1], argv[argIndex + 2], argv[argIndex + 3]);
|
||||
else if (argc > (argIndex + 4) && arg == "-fx")
|
||||
return setFX(kbd, argv[argIndex + 1], argv[argIndex + 2], argv[argIndex + 3], argv[argIndex + 4]);
|
||||
else if (argc > (argIndex + 3) && arg == "-fx")
|
||||
return setFX(kbd, argv[argIndex + 1], argv[argIndex + 2], argv[argIndex + 3]);
|
||||
else if (argc > (argIndex + 1) && arg == "--startup-mode") return setStartupMode(kbd, argv[argIndex + 1]);
|
||||
else { help::usage(argv[0]); return 1; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user