Closed pcnimdock closed 5 years ago
Cool! I don't have the Guncon 3 with me at the moment, but it seems like this change would be sufficient without the need to mask the LSB in the result.
diff --git a/guncon3.c b/guncon3.c
index e845930..744aa3b 100644
--- a/guncon3.c
+++ b/guncon3.c
@@ -104,7 +104,9 @@ MODULE_DEVICE_TABLE(usb, usb_guncon3_id_table);
static int guncon3_decode(unsigned char *data, const unsigned char *key) {
int x, y, key_index;
- unsigned char bkey, keyr, a_sum, b_sum, key_offset, byte;
+ unsigned char bkey, keyr, byte;
+ char a_sum, b_sum, key_offset;
+
b_sum = ((data[13] ^ data[12]) + data[11] + data[10] - data[9] - data[8]) ^ data[7];
a_sum = (((data[6] ^ b_sum) - data[5] - data[4]) ^ data[3]) + data[2] + data[1] - data[0];
if (a_sum != key[7]) {
If you are able to test these changes I would gladly accept a pull request :)
I tested the patch with Ubuntu 17.04 with kernel Linux 4.10.0-42-generic. It 's working well now
Thanks for the tip, I made the change in dd7ad767233b2404fca54886c5d4c9af432a4108.
I have corrected the error of the random numbers when the stick is placed in certain positions. I signed the variables, a_sum,b_sum and key_offset