aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkimi <kimi.h.kuparinen@gmail.com>2020-06-12 07:47:24 -0400
committerkimi <kimi.h.kuparinen@gmail.com>2020-06-12 07:47:24 -0400
commit75560062fc8f188ebd2a9a53568f99556e593355 (patch)
tree4067e5c043910e516ba54ee6a26b2f7e32478723
parent34776ccd2b8575aa911099704e4fffb0df8eb440 (diff)
downloadhid-tmff2-75560062fc8f188ebd2a9a53568f99556e593355.tar.gz
hid-tmff2-75560062fc8f188ebd2a9a53568f99556e593355.zip
Some small steps in the right direction
- Added some more initialisation blobs, they seem to dictate autocentering and wheel rotation among other things
-rw-r--r--hid-tmff2.c104
1 files changed, 103 insertions, 1 deletions
diff --git a/hid-tmff2.c b/hid-tmff2.c
index b9bbacc..86a5da4 100644
--- a/hid-tmff2.c
+++ b/hid-tmff2.c
@@ -150,6 +150,59 @@ static unsigned int t300rs_in_sizes[] = {
ARRAY_SIZE(t300rs_in_3)
};
+static u8 t300rs_fin_0[] = {
+0x60, 0x09, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static u8 t300rs_fin_1[] = {
+0x60, 0x0b, 0x05, 0xbf, 0x03, 0xc3, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static u8 t300rs_fin_2[] = {
+0x60, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static u8 t300rs_fin_3[] = {
+0x60, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static u8 t300rs_fin_4[] = {
+0x60, 0x00, 0x01, 0x6a, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f,
+0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static u8 t300rs_fin_5[] = {
+0x60, 0x00, 0x02, 0x6b, 0xfc, 0x7f, 0xfe, 0xff, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x80, 0x00, 0x00,
+0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x03, 0x4f, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static u8 t300rs_fin_6[] = {
+0x60, 0x00, 0x03, 0x64, 0xfd, 0x3f, 0xfd, 0x3f, 0x31, 0x03, 0xcb, 0xfc, 0xfd, 0x5f, 0xfd, 0x5f,
+0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xdf, 0x58, 0xa6, 0x6a, 0x06, 0x4f, 0xff, 0xff,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static u8 *t300rs_fin_arr[] = {t300rs_fin_0, t300rs_fin_1, t300rs_fin_2, t300rs_fin_3, t300rs_fin_4, t300rs_fin_5, t300rs_fin_6 };
+static unsigned int t300rs_fin_sizes[] = {
+ARRAY_SIZE(t300rs_fin_0),
+ARRAY_SIZE(t300rs_fin_1),
+ARRAY_SIZE(t300rs_fin_2),
+ARRAY_SIZE(t300rs_fin_3),
+ARRAY_SIZE(t300rs_fin_4),
+ARRAY_SIZE(t300rs_fin_5),
+ARRAY_SIZE(t300rs_fin_6)
+};
+
struct tmff_device {
struct hid_report *report;
struct hid_field *ff_field;
@@ -483,6 +536,7 @@ static int tmff_init_t300rs(struct hid_device *hid){
}
}
+
error:
kfree(send_buf);
kfree(rq_buf);
@@ -656,6 +710,46 @@ static inline int tmff_init(struct hid_device *hid, const signed short *ff_bits)
return 0;
}
#endif
+static int tmff_afterthought_t300rs(struct hid_device *hid){
+ int trans, b_ep, bb_ep, i, err;
+ u8 *send_buf, *rq_buf;
+ struct device *dev = &hid->dev;
+ struct usb_interface *usbif = to_usb_interface(dev->parent);
+ struct usb_device *usbdev = interface_to_usbdev(usbif);
+ struct usb_host_endpoint *ep;
+ struct urb *urb;
+
+ ep = &usbif->cur_altsetting->endpoint[0];
+ bb_ep = ep->desc.bEndpointAddress;
+
+ ep = &usbif->cur_altsetting->endpoint[1];
+ b_ep = ep->desc.bEndpointAddress;
+
+ send_buf = kmalloc(256, GFP_ATOMIC); /* overkill but whatever */
+ rq_buf = kmalloc(256, GFP_ATOMIC);
+
+ for(i = 0; i < 7; ++i){
+ memcpy(send_buf, t300rs_fin_arr[i], t300rs_fin_sizes[i]);
+
+ err = usb_interrupt_msg(usbdev,
+ usb_sndintpipe(usbdev, b_ep),
+ send_buf,
+ t300rs_fin_sizes[i],
+ &trans,
+ USB_CTRL_SET_TIMEOUT);
+ hid_info(hid, "sent %i:th message", i);
+ if(err){
+ hid_err(hid, "T300RS setup data at index %i couldn't be sent, ERRNO: %i\n", i, err);
+ goto error;
+ }
+ }
+
+error:
+ kfree(send_buf);
+ kfree(rq_buf);
+ return err;
+}
+
static int tm_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
@@ -684,7 +778,15 @@ static int tm_probe(struct hid_device *hdev, const struct hid_device_id *id)
}
tmff_init(hdev, (void *)id->driver_data);
-
+
+ if(hdev->product == 0xb66e){
+ ret = tmff_afterthought_t300rs(hdev);
+
+ if(ret){
+ hid_err(hdev, "t300rs afterinit failed\n");
+ goto err;
+ }
+ }
return 0;
err:
return ret;