diff options
| author | Aaditya Dhruv <[email protected]> | 2025-11-27 02:09:57 -0600 |
|---|---|---|
| committer | Aaditya Dhruv <[email protected]> | 2025-11-27 02:09:57 -0600 |
| commit | 0d0666ceaa9788ac0cb6b810f9055fd5491d9402 (patch) | |
| tree | 2a5bad25f9915e18cc9cf114120647720f9ce86f | |
| parent | 06d6d8ddf8e76992383e925410b2adc55406e83b (diff) | |
Fix incorrect write to 0xb00030 for enabling IR
| -rw-r--r-- | starbit.c | 25 |
1 files changed, 14 insertions, 11 deletions
@@ -11,7 +11,7 @@ #include <linux/hid.h> #include "startbit.h" -#define IR_SLEEP 80 +#define IR_SLEEP 150 struct wiimouse_dev { struct hid_device* hdev; @@ -28,24 +28,25 @@ static const struct hid_device_id wiimouse_ids[] = { static int wiimote_ir_init(struct hid_device* hdev) { int ret = 0; - __u8 enable_ir1[2] = { HID_REPORT_ID_WIIMOTE_IR1_ENABLE, HID_REPORT_DATA_WIIMOTE_IR1_ENABLE }; + __u8 enable_ir1[2] = { 0x13, 0x04}; if ((ret = hid_hw_output_report(hdev, (__u8*)enable_ir1, 2)) < 0) { printk(KERN_DEBUG "enable ir 1"); return ret; } msleep(IR_SLEEP); - __u8 enable_ir2[2] = { HID_REPORT_ID_WIIMOTE_IR2_ENABLE, HID_REPORT_DATA_WIIMOTE_IR2_ENABLE }; + __u8 enable_ir2[2] = { 0x1a, 0x04}; if ((ret = hid_hw_output_report(hdev, (__u8*)enable_ir2, 2)) < 0) { printk(KERN_DEBUG "enable ir 2"); return ret; } msleep(IR_SLEEP); - __u8 eeprom_set_data[22] = { 0x16, 0x04, 0xb0, 0x00, 0x30, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - __u8 sensitive_1[22] = { 0x16, 0x04, 0xb0, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - __u8 sensitive_2[22] = { 0x16, 0x04, 0xb0, 0x00, 0x1a, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - __u8 mode[22] = { 0x16, 0x04, 0xb0, 0x00, 0x33, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - if ((ret = hid_hw_output_report(hdev, (__u8*)eeprom_set_data, 22)) < 0) { + __u8 enable[22] = { 0x16, 0x04, 0xb0, 0x00, 0x30, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + __u8 sensitive_1[22] = { 0x16, 0x04, 0xb0, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + __u8 sensitive_2[22] = { 0x16, 0x04, 0xb0, 0x00, 0x1a, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + __u8 mode[22] = { 0x16, 0x04, 0xb0, 0x00, 0x33, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + __u8 final[22] = { 0x16, 0x04, 0xb0, 0x00, 0x30, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + if ((ret = hid_hw_output_report(hdev, (__u8*)enable, 22)) < 0) { printk(KERN_DEBUG "eeprom 1"); return ret; } @@ -65,7 +66,7 @@ static int wiimote_ir_init(struct hid_device* hdev) { return ret; } msleep(IR_SLEEP); - if ((ret = hid_hw_output_report(hdev, (__u8*)eeprom_set_data, 22)) < 0) { + if ((ret = hid_hw_output_report(hdev, (__u8*)final, 22)) < 0) { printk(KERN_DEBUG "eeprom 2"); return ret; } @@ -90,7 +91,7 @@ static int wiimote_init(struct hid_device* hdev) { if ((ret = hid_hw_output_report(hdev, (__u8*)rumble, 2)) < 0) return ret; __u8 led_p1[2] = { HID_REPORT_ID_WIIMOTE_LED_ENABLE, HID_REPORT_DATA_WIIMOTE_LED_ENABLE_P1 }; if ((ret = hid_hw_output_report(hdev, (__u8*)led_p1, 2)) < 0) return ret; - __u8 report_mode[3] = { 0x12, 0x00, 0x33 }; + __u8 report_mode[3] = { 0x12, 0x04, 0x33 }; if ((ret = hid_hw_output_report(hdev, (__u8*)report_mode, 3)) < 0) return ret; return ret; @@ -98,7 +99,9 @@ static int wiimote_init(struct hid_device* hdev) { static int wiimote_event(struct hid_device* hdev, struct hid_report* report, u8 *data, int size) { - printk(KERN_DEBUG "Report ID: %02x | Buttons: %02x %02x %02x\n", report->id, data[0], data[1], data[2]); + printk(KERN_DEBUG "Report ID: %02x, Size: %d", report->id, size); + printk(KERN_DEBUG "Button Data: %02x, %02x", data[1], data[2]); + printk(KERN_DEBUG "IR Data: %02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x", data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15]); struct wiimouse_dev* wdev = hid_get_drvdata(hdev); |
