diff options
| author | Aaditya Dhruv <[email protected]> | 2025-11-27 16:16:49 -0600 |
|---|---|---|
| committer | Aaditya Dhruv <[email protected]> | 2025-11-27 16:16:49 -0600 |
| commit | 8885b061b083dba7e035b36d3988bd4a42d35d88 (patch) | |
| tree | dcec71ff72567c8eb0d1d94e93a0fdbf1b18f7d3 | |
| parent | 0d0666ceaa9788ac0cb6b810f9055fd5491d9402 (diff) | |
Start basic IR pointer work
| -rw-r--r-- | starbit.c | 39 |
1 files changed, 37 insertions, 2 deletions
@@ -13,11 +13,45 @@ #define IR_SLEEP 150 +struct point { + int x; + int y; + int is_ir; +}; + struct wiimouse_dev { struct hid_device* hdev; struct input_dev* in_dev; + struct point points[4]; }; +static void parse_basic_mode_ir(struct wiimouse_dev* wdev, __u8 data[10]) { + wdev->points[0].x = data[0] << 2 | ((data[2] & 0x30) >> 4); + wdev->points[0].y = data[1] << 2 | ((data[2] & 0xc0) >> 6); + wdev->points[1].x = data[3] << 2 | (data[2] & 0x03); + wdev->points[1].y = data[4] << 2 | ((data[2] & 0x0c) >> 2); + + wdev->points[2].x = data[0 + 5] << 2 | ((data[2 + 5] & 0x30) >> 4); + wdev->points[2].y = data[1 + 5] << 2 | ((data[2 + 5] & 0xc0) >> 6); + wdev->points[3].x = data[3 + 5] << 2 | (data[2 + 5] & 0x03); + wdev->points[3].y = data[4 + 5] << 2 | ((data[2 + 5] & 0x0c) >> 2); +} + +/* + * There can only be 6 combinations of points and one of them is the IR bar + * p1, p2 | p1, p3 | p1, p4 | p2, p3 | p2, p4 | p3, p4 | + * Or (4 * 3) / 2 = 6 + * We need to find a line between 2 points of min distance such that: + * 1. px and py are the only points on the line + * 2. no other points are within some X distance of the line + * + * These points are normalized to rotation of controller + */ +static void get_ir_bar_points(struct wiimouse_dev* wdev) { +} + + + static const struct hid_device_id wiimouse_ids[] = { {HID_BLUETOOTH_DEVICE(NINTENDO_WIIMOTE_VENDOR_ID, NINTENDO_WIIMOTE_PRODUCT_ID)}, @@ -44,7 +78,7 @@ static int wiimote_ir_init(struct hid_device* hdev) { __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 mode[22] = { 0x16, 0x04, 0xb0, 0x00, 0x33, 0x01, 0x01, 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"); @@ -105,7 +139,8 @@ static int wiimote_event(struct hid_device* hdev, struct hid_report* report, u8 struct wiimouse_dev* wdev = hid_get_drvdata(hdev); - + //Parse and save IR data + parse_basic_mode_ir(wdev, data + 6); if (data[2] & 0x08) { printk(KERN_DEBUG "A button was pressed\n"); struct input_dev* in_dev = wdev->in_dev; |
