diff --git a/README.md b/README.md index 62e3e75..6ba826f 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,4 @@ do make udev rule write a nixos module that also sets udev rules +install udev rule that automatically runs driver when you plug in the device?? \ No newline at end of file diff --git a/hexdump_analysis/hexdump_analysis.txt b/hexdump_analysis/hexdump_analysis.txt index 1946be5..65c9cec 100644 --- a/hexdump_analysis/hexdump_analysis.txt +++ b/hexdump_analysis/hexdump_analysis.txt @@ -51,16 +51,16 @@ First Part 0x0d-0x16 jeweils 2 byte most significant byte last, * 50 -> annäherung an dpi -50 0x17-0x44 ??? 0x45 Lighting Mode, 02 Steady, 01 Colorful Streaming, 03 Breathing -0x46 0-4 Brightness und 0-4 Speed bei breathing 0x(br)(sp) +0x46 0-4 Brightness und 0-4 Speed bei colorful 0x(br)(sp) 0x47 ? -0x48 Brightness bei colorful 00-40 +0x48 Brightness und colnr bei steady 0x(br)(colnr) 0x49-0x4b ? -0x4c 0-4 Brightness und 0-4 Speed bei steady 0x(br)(sp) +0x4c 0-4 Brightness und 0-4 Speed bei breathing 0x(br)(sp) 0x4d ??? 0x4e-0x62 Bei Breathing RGB * 7 0x63-0x66 ?? 0x67-0x7a Bei Steady RGB * 7 -0x7b-ende ???? +0x7b-end ???? bei einem modus wechsel ändert sich brightness und speed nicht auser man ändert sie nochmal explizit @@ -73,6 +73,8 @@ And the rest of the settings on advanced page are system settings Part two + 0 1 2 3 4 5 6 7 8 9 a b c d e f + 0000 08 22 00 50 00 00 00 00 11 01 00 00 11 02 00 00 0010 11 04 00 00 11 08 00 00 11 10 00 00 21 00 61 00 0020 41 00 00 00 50 06 00 00 41 02 00 00 41 00 00 00 @@ -117,8 +119,10 @@ Part two 0x18-0x1b 4 Byte für taste 12, Forward Taste, über taste 2,4 0x1c-0x1f 4 Byte für taste 14, 1. über mausrad 0x20-0x23 4 Byte für taste 15, 2. über mausrad ---was machen die 4 Byte die hier leer sind ?-- +0x24-0x27 ?--was machen die 4 Byte die hier leer sind ?-- 0x28-0x47 Jeweils 4 Byte (3 Sicher) für die Belegung der Tasten 1-8 an der Seite +0x48-0x58 ?? +0x58-end zeros Tastenbelegung Leftclick -> 0x11 0x01 0x00, restliche 2 Byte egal? -> schätze nicht werden mit null geschrieben wenn was anderes drinnen stand diff --git a/src/main.cpp b/src/main.cpp index f26849e..acac161 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,31 +46,58 @@ struct col_7 struct conf_1 { - uint8_t __u1; // 0x00 0x08 - uint8_t con; // wired 21 22 wireless 11 12 - uint8_t __u2; // 0x02 zero - uint8_t req_type; // 0x92, 0x50 maybe for if write or read 0x00 - uint8_t __u3[0x8-0x4]; // 0x04-0x07 zeroes - uint8_t __64; // 0x08 - uint8_t profile; // 0x17 profile 1, 0x01 profile 2 - uint8_t polling_rate; // 0x0a, 0x01-0x04->[125,250,500,1000] - uint8_t dpi_modes; // 0x0b, 0x11-0x15 erste 4 welches ist aktiv? dann welhce für conf?? - uint8_t __u4; // 0x0c zero - dpi hdpi; // 0x0 0x0d-0x16 jeweils 2 byte most significant byte last, * 50 -> annäherung an dpi -50 - uint8_t __u5[0x44-0x17]; // 0x17 - 0x44 ????? zeros - uint8_t light_mode; // 0x45 Lighting Mode, 02 Steady, 01 Colorful Streaming, 03 Breathing - uint8_t br_brightness_speed; // 0x46 0-4 Brightness und 0-4 Speed bei breathing 0x(br)(sp) - uint8_t __u8; // 0x47 ??? - uint8_t col_brightness; // 0x48 Brightness bei colorful 00-40 - uint8_t __u9; // 0x49-0x4b ??? + uint8_t __u1; // 0x00 0x08 + uint8_t con; // wireless 21 wired 11 + uint8_t __u2; // 0x02 zero + uint8_t req_type; // 0x92, 0x50 maybe for if write or read 0x00 + uint8_t __u3[0x8 - 0x4]; // 0x04-0x07 zeroes + uint8_t __64; // 0x08 + uint8_t profile; // 0x17 profile 1, 0x01 profile 2 + uint8_t polling_rate; // 0x0a, 0x01-0x04->[125,250,500,1000] + uint8_t dpi_modes; // 0x0b, 0x11-0x15 erste 4 welches ist aktiv? dann welhce für conf?? + uint8_t __u4; // 0x0c zero + dpi hdpi; // 0x0 0x0d-0x16 jeweils 2 byte most significant byte last, * 50 -> annäherung an dpi -50 + uint8_t __u5[0x44 - 0x17]; // 0x17 - 0x44 ????? zeros + uint8_t light_mode; // 0x45 Lighting Mode, 02 Steady, 01 Colorful Streaming, 03 Breathing + uint8_t col_brightness_speed; // 0x46 0-4 Brightness und 0-4 Speed bei colorful 0x(br)(sp) + uint8_t __u8; // 0x47 ??? + uint8_t st_brightness_colnr; // 0x48 Brightness und colnr bei steady 0x(br)(colnr) + uint8_t __u9; // 0x49-0x4b ??? uint8_t __u10; uint8_t __u11; - uint8_t st_brightness_speed; // 0x4c 0-4 Brightness und 0-4 Speed bei steady 0x(br)(sp) + uint8_t br_brightness_speed; // 0x4c 0-4 Brightness und 0-4 Speed bei breathing 0x(br)(sp) uint8_t __u12; // 0x4d ?? col_7 col_breathing; // 0x4e-0x62Bei Breathing RGB * 7 uint32_t __u13; // 0x63-066 ?? col_7 col_steady; // 0x67-0x7a Bei Steady RGB * 7 - uint8_t __rest[397]; //???? + uint8_t __rest[397]; // ???? +}; + +struct key_conf +{ + uint8_t pref; + uint8_t mod; + uint8_t keycode; + uint8_t __u1; +}; + +struct conf_2 +{ + uint8_t __u1; // 0x00 0x08 + uint8_t con; // wireless 22 wired 12 + uint8_t __u2; // 0x02 zero + uint8_t req_type; // 0x92, 0x50 maybe for if write or read 0x00 + uint8_t __u3[0x8 - 0x4]; // 0x04-0x07 zeroes + key_conf l_mouse; // 0x08-0x0b 4 Byte für linke Maustaste + key_conf r_mouse; // 0x0c-0x0f 4 Byte für rechte Maustaste + key_conf m_mouse; // 0x10-0x13 4 Byte für Mausrad taste + key_conf b_mouse; // 0x14-0x17 4 Byte für taste 13, Zurück Taste, über taste 5,6 + key_conf f_mouse; // 0x18-0x1b 4 Byte für taste 12, Forward Taste, über taste 2,4 + key_conf m_mouse_1; // 0x1c-0x1f 4 Byte für taste 14, 1. über mausrad + key_conf m_mouse_2; // 0x20-0x23 4 Byte für taste 15, 2. über mausrad + uint32_t __u4; // 0x24-0x27 zeros + key_conf side[8]; // Jeweils 4 Byte (3 Sicher) für die Belegung der Tasten 1-8 an der Seite + uint8_t __u5[0x207 - 0x47]; // 0x48-0x58 ?? 0x58-end zeros }; int main(int argc, char *argv[]) @@ -79,92 +106,6 @@ int main(int argc, char *argv[]) unsigned char data2[520]; unsigned char deviceData[520]; memset(deviceData, 0, 520 * sizeof(unsigned char)); - std::string data01 = - "082100920000000064170445000c000f" - "00130017001b00000000000000000000" - "00000000000000000000000000000000" - "0000ff00ffffff00ffff9b0000ff00ff" - "ffffff460001430036ff00003207ffff" - "ff000000ffffff000000ffffff000000" - "ffffff020200ff000000ff000000ff00" - "000000ffffff4600ff00ffffffffff00" - "00ff000001020304050607424202ff00" - "0027400102ff0000a500000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "0000000000000000"; - std::string data02 = - "08220050000000001101000011020000" - "11040000110800001110000021006100" - "41000000500600001102000021005a00" - "21005b0021005c0021005d0021005e00" - "21005f00210060005001000050010000" - "50010000500100000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "00000000000000000000000000000000" - "0000000000000000"; - for (int i = 0; i < 1040; i += 2) - { - data[i / 2] = std::stoi(data01.substr(i, 2), (std::size_t *)0, 16); - data2[i / 2] = std::stoi(data02.substr(i, 2), (std::size_t *)0, 16); - } - const char *asd = (char *)data; - conf_1 *bsd = (conf_1 *)asd; - const char *asd2 = (char *)data2; - conf_1 *bsd2 = (conf_1 *)asd2; - std::cout << std::hex << (int)(data[0x45]) << std::endl; - std::cout << std::hex << (int)(bsd->light_mode) << std::endl; - bsd->light_mode = 0x3; - std::cout << std::hex << (int)(data[0x45]) << std::endl; - std::cout << std::hex << (int)(bsd->light_mode) << std::endl; - - bsd->col_breathing.a.r = 0xff; - bsd->col_breathing.a.g = 0x00; - bsd->col_breathing.a.b = 0x00; KIconTheme::initTheme(); // this is not available in nixpkgs version of // KiconTheme @@ -226,16 +167,6 @@ int main(int argc, char *argv[]) if ((r = libusb_open(found, &handle)) < 0) std::cout << "libusb_open: " << libusb_error_name(r) << std::endl; - /* - self.set_report(0x0305, [5, 0x80, 0, 0, 0, 0, 0, 0]) - self.get_report(0x0305, 8) - self.set_report(0x0305, [5, 0x21, 0, 0, 0, 0, 0, 0]) - odata = self.get_report(0x0308, 520) - - self.set_report(0x0308, data) - self.set_report(0x0308, data2) - */ - if ((r = libusb_detach_kernel_driver(handle, 1)) < 0) std::cout << "libusb_detach_kernel_driver: " << libusb_error_name(r) << std::endl; if ((r = libusb_claim_interface(handle, 1)) < 0) @@ -252,10 +183,13 @@ int main(int argc, char *argv[]) std::cout << "libusb_control_transfer1: " << libusb_error_name(r) << std::endl; if ((r = libusb_control_transfer(handle, 0xa1, 0x01, 0x0308, 1, deviceData, 520, 5000)) < 0) std::cout << "libusb_control_transfer2: " << libusb_error_name(r) << std::endl; - for (int i = 0; i < 520; ++i) - { - // std::cout << std::hex << (int)deviceData[i] << "|" << (int)data[i] << "\t"; - } + + // edit data + memcpy(data, deviceData, 520); + conf_1 *_data = (conf_1 *)data; + _data->light_mode = 0x2; + _data->req_type = 0x92; + _data->st_brightness_colnr = {0x16}; std::cout << std::endl; std::cout << std::endl; @@ -269,16 +203,13 @@ int main(int argc, char *argv[]) std::cout << "libusb_control_transfer3: " << libusb_error_name(r) << std::endl; if ((r = libusb_control_transfer(handle, 0xa1, 0x01, 0x0308, 1, deviceData, 520, 5000)) < 0) std::cout << "libusb_control_transfer4: " << libusb_error_name(r) << std::endl; - for (int i = 0; i < 520; ++i) - { - // std::cout << std::hex << (int)deviceData[i] << "|" << (int)data2[i] << "\t"; - } - std::cout << std::endl; - std::cout << std::endl; + // edit data + memcpy(data2, deviceData, 520); + conf_2 *_data2 = (conf_2 *)data2; + _data2->side[3] = {0x21, 0x1, 0x6, 0x0 }; + _data2->req_type = 0x50; - bsd->light_mode = 0x3; - bsd->st_brightness_speed = 0x44; // write new conf // conf_1 if ((r = libusb_control_transfer(handle, 0x21, 0x09, 0x0308, 1, data, 520, 5000)) < 0) @@ -297,14 +228,8 @@ int main(int argc, char *argv[]) std::cout << "libusb_control_transfer1: " << libusb_error_name(r) << std::endl; if ((r = libusb_control_transfer(handle, 0xa1, 0x01, 0x0308, 1, deviceData, 520, 5000)) < 0) std::cout << "libusb_control_transfer2: " << libusb_error_name(r) << std::endl; - // compare written and read - for (int i = 0; i < 520; ++i) - { - // std::cout << std::hex << (int)deviceData[i] << "|" << "\t"; - } - std::cout << std::endl; - std::cout << std::dec << deviceData[0x45] << "|" << bsd->light_mode << std::endl; + if ((r = libusb_release_interface(handle, 1)) < 0) std::cout << "libusb_release_interface: " << libusb_error_name(r) << std::endl; if ((r = libusb_attach_kernel_driver(handle, 1)) < 0)