From 3a612657de71eb2ae745525683fec3bb13aec1f3 Mon Sep 17 00:00:00 2001 From: Kirili4ik Date: Wed, 15 Sep 2021 19:22:11 +0300 Subject: [PATCH 1/3] add info to readme on how to add a new device --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ae882d7..fdcc592 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,21 @@ cmake . make ``` -# Usage +## Add new bloody devices + +1. Get USB PID of device: +``` +~$ lsusb -d 09da: | cut -d ' ' -f6 | cut -d ':' -f2 +``` + +2. Add that PID to Mouce.h & Mouce.cpp + +Mouse.h: add line with PID and add name to COMPATIBLE_PIDS variable as all the other mouses. + +Mouse.cpp: add 3 lines: case, name and break; as all the other mouses. + + +## Run ``` sudo ./bloody Available devices: From 3b304667a50d80e23b18bece06052119a71a6613 Mon Sep 17 00:00:00 2001 From: Kirili4ik Date: Wed, 15 Sep 2021 19:33:08 +0300 Subject: [PATCH 2/3] add support of RT5, R8, V8M, J95S --- Mouse.cpp | 12 ++++++++++++ Mouse.h | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Mouse.cpp b/Mouse.cpp index 328ddb3..16a8e72 100644 --- a/Mouse.cpp +++ b/Mouse.cpp @@ -166,6 +166,18 @@ void Mouse::listDevices() { case BLOODY_A9_PID: name = "Bloody A9"; break; + case BLOODY_RT5_PID: + name = "Bloody RT5"; + break; + case BLOODY_V8M_PID: + name = "Bloody V8M"; + break; + case BLOODY_R8_PID: + name = "Bloody R8"; + break; + case BLOODY_J95S_PID: + name = "Bloody J95S"; + break; default: name = "Unknown"; } diff --git a/Mouse.h b/Mouse.h index a790658..d4d498d 100644 --- a/Mouse.h +++ b/Mouse.h @@ -9,6 +9,10 @@ static const int A4TECH_VID = 0x09da; +static const int BLOODY_J95S_PID = 0xfee3; +static const int BLOODY_RT5_PID = 0x7f1b; +static const int BLOODY_V8M_PID = 0x1094; +static const int BLOODY_R8_PID = 0x7c10; static const int BLOODY_V5_PID = 0x172A; static const int BLOODY_V7_PID = 0xF613; static const int BLOODY_V8_PID = 0x11F5; @@ -20,7 +24,7 @@ static const int BLOODY_R70_PID = 0xf643; static const int BLOODY_A7_PID = 0x7e36; static const int BLOODY_A9_PID = 0x1003; -static const int COMPATIBLE_PIDS[] = {BLOODY_V5_PID, BLOODY_V7_PID, BLOODY_V8_PID, BLOODY_R7_PID, BLOODY_R8_1_PID, BLOODY_R3_PID, BLOODY_AL9_PID, BLOODY_R70_PID, BLOODY_A7_PID, BLOODY_A9_PID}; +static const int COMPATIBLE_PIDS[] = {BLOODY_J95S_PID, BLOODY_RT5_PID, BLOODY_V8M_PID, BLOODY_R8_PID, BLOODY_V5_PID, BLOODY_V7_PID, BLOODY_V8_PID, BLOODY_R7_PID, BLOODY_R8_1_PID, BLOODY_R3_PID, BLOODY_AL9_PID, BLOODY_R70_PID, BLOODY_A7_PID, BLOODY_A9_PID}; static const size_t COMPATIBLE_PIDS_SIZE = sizeof(COMPATIBLE_PIDS)/sizeof(COMPATIBLE_PIDS[0]); static const int A4TECH_MAGIC = 0x07; From 43f7ff6dc593ff58c89d2872f4717ae1a448fff2 Mon Sep 17 00:00:00 2001 From: Kirili4ik Date: Wed, 15 Sep 2021 19:36:14 +0300 Subject: [PATCH 3/3] add additional logging --- Mouse.cpp | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/Mouse.cpp b/Mouse.cpp index 16a8e72..18e1fa7 100644 --- a/Mouse.cpp +++ b/Mouse.cpp @@ -33,8 +33,22 @@ void Mouse::discoverDevices() { libusb_device_descriptor desc; libusb_get_device_descriptor(devs[i], &desc); if (isCompatibleDevice(desc)) { - if(libusb_open(devs[i], ¤tDevice) != 0) - continue; + switch (int status = libusb_open(devs[i], ¤tDevice)) { + case 0: + break; + case LIBUSB_ERROR_NO_MEM: + cout << "LIBUSB_ERROR_NO_MEM" << endl; + continue; + case LIBUSB_ERROR_ACCESS: + cout << "LIBUSB_ERROR_ACCESS" << endl; + continue; + case LIBUSB_ERROR_NO_DEVICE: + cout << "LIBUSB_ERROR_NO_DEVICE" << endl; + continue; + default: + cout << "Status: " << status << endl; + continue; + } if(libusb_kernel_driver_active(currentDevice, 2) == 1) if(libusb_detach_kernel_driver(currentDevice, 2) != 0) { @@ -90,14 +104,26 @@ int Mouse::setBackLightLevel(uint8_t level) { } int Mouse::writeToMouse(uint8_t data[], size_t size) { - int res = libusb_control_transfer(currentDevice,0x21,9, - 0x0307,2,data,size,10000); - if(res < 0){ - cout<<"Unnable to send command"<