diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-10-04 21:29:17 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-10-04 21:29:17 +0300 |
| commit | 28c4fc4c82cf3539f4e49a558db014f0f3f711b5 (patch) | |
| tree | 22babbcf036c3d3f0a79b1533550cde419b303e1 | |
| parent | dd575faa00717cf2c3be28ee55a3cb609be6e32c (diff) | |
| download | hid-tminit-28c4fc4c82cf3539f4e49a558db014f0f3f711b5.tar.gz hid-tminit-28c4fc4c82cf3539f4e49a558db014f0f3f711b5.zip | |
Initialize with base info, not attachment
| -rw-r--r-- | hid-tminit.c | 10 | ||||
| -rw-r--r-- | hid-tminit.h | 22 |
2 files changed, 18 insertions, 14 deletions
diff --git a/hid-tminit.c b/hid-tminit.c index 71cc0ab..b64d1f0 100644 --- a/hid-tminit.c +++ b/hid-tminit.c @@ -83,7 +83,7 @@ static void tminit_model_handler(struct urb *urb) { struct hid_device *hdev = urb->context; struct tm_wheel *tm_wheel = hid_get_drvdata(hdev); - uint16_t model = 0; + uint8_t model = 0; int i, ret; const struct tm_wheel_info *twi = 0; @@ -93,20 +93,20 @@ static void tminit_model_handler(struct urb *urb) } if (tm_wheel->response->type == cpu_to_le16(0x49)) - model = le16_to_cpu(tm_wheel->response->data.a.model); + model = tm_wheel->response->data.a.model; else if (tm_wheel->response->type == cpu_to_le16(0x47)) - model = le16_to_cpu(tm_wheel->response->data.b.model); + model = tm_wheel->response->data.b.model; else { hid_err(hdev, "Unknown packet type 0x%x, unable to proceed further with wheel init\n", tm_wheel->response->type); return; } for (i = 0; i < tm_wheels_infos_length && !twi; i++) - if (tm_wheels_infos[i].wheel_type == model) + if (tm_wheels_infos[i].model == model) twi = tm_wheels_infos + i; if (twi) - hid_info(hdev, "Wheel with model id 0x%x is a %s\n", model, twi->wheel_name); + hid_info(hdev, "Wheel with model 0x%x is a %s\n", model, twi->wheel_name); else { hid_err(hdev, "Unknown wheel's model id 0x%x, unable to proceed further with wheel init\n", model); return; diff --git a/hid-tminit.h b/hid-tminit.h index 04d55df..286fe3d 100644 --- a/hid-tminit.h +++ b/hid-tminit.h @@ -27,7 +27,8 @@ static const unsigned int setup_arr_sizes[] = { * and vice-versa */ struct tm_wheel_info { - uint16_t wheel_type; + uint8_t model; + uint8_t attachment; /** * See when the USB control out packet is prepared... @@ -43,14 +44,15 @@ struct tm_wheel_info { * Note: TMX does not work as it requires 2 control packets */ static const struct tm_wheel_info tm_wheels_infos[] = { - {0x0306, 0x0006, "Thrustmaster T150RS"}, - {0x0206, 0x0005, "Thrustmaster T300RS"}, - {0x0204, 0x0005, "Thrustmaster T300 Ferrari Alcantara Edition"}, - {0x0002, 0x0002, "Thrustmaster T500RS"}, - {0x0407, 0x0001, "Thrustmaster TMX"} + {0x03, 0x06, 0x0006, "Thrustmaster T150RS"}, + {0x02, 0x06, 0x0005, "Thrustmaster T300RS"}, + {0x02, 0x03, 0x0005, "Thrustmaster T300RS (F1 attachment)"}, + {0x02, 0x04, 0x0005, "Thrustmaster T300 Ferrari Alcantara Edition"}, + {0x00, 0x02, 0x0002, "Thrustmaster T500RS"}, + {0x04, 0x07, 0x0001, "Thrustmaster TMX"} }; -static const uint8_t tm_wheels_infos_length = 5; +static const uint8_t tm_wheels_infos_length = 6; /** * This structs contains (in little endian) the response data @@ -77,7 +79,8 @@ struct __packed tm_wheel_response * Seems to be the model code of the wheel * Read table thrustmaster_wheels to values */ - uint16_t model; + uint8_t attachment; + uint8_t model; uint16_t field2; uint16_t field3; @@ -87,7 +90,8 @@ struct __packed tm_wheel_response struct __packed { uint16_t field0; uint16_t field1; - uint16_t model; + uint8_t attachment; + uint8_t model; } b; } data; }; |
