diff options
| author | kimi <kimi.h.kuparinen@gmail.com> | 2020-07-09 14:58:12 -0400 |
|---|---|---|
| committer | kimi <kimi.h.kuparinen@gmail.com> | 2020-07-09 14:58:12 -0400 |
| commit | ab71fe85ea80dc912c5f5871b7036e8da6df33b5 (patch) | |
| tree | 71bbacb9f3037e7e9edfd8c634da96fa6d729e53 | |
| parent | 014c79bc4966b40c2b4e18c0a2407b6af53908a1 (diff) | |
| download | hid-tmff2-ab71fe85ea80dc912c5f5871b7036e8da6df33b5.tar.gz hid-tmff2-ab71fe85ea80dc912c5f5871b7036e8da6df33b5.zip | |
I borked the buttons, hopefully fixed
| -rw-r--r-- | hid-tmt300rs.c | 46 | ||||
| -rw-r--r-- | hid-tmt300rs.h | 2 |
2 files changed, 48 insertions, 0 deletions
diff --git a/hid-tmt300rs.c b/hid-tmt300rs.c index 4173601..3d678c8 100644 --- a/hid-tmt300rs.c +++ b/hid-tmt300rs.c @@ -869,6 +869,7 @@ int t300rs_init(struct hid_device *hdev, const signed short *ff_bits){ goto out; } + hrtimer_init(&t300rs->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); t300rs->hrtimer.function = t300rs_timer; @@ -887,6 +888,48 @@ err: } +/* for some reason this specific command must be sent before hid_hw_start. Odd. + * */ +static int t300rs_preinit(struct hid_device *hdev){ + int ret; + u8 *setup_packet; + + /* this is sort of unnecessary, as later on I compile the interfaces etc + * into one struct, but for now this will do + * */ + struct device *dev = &hdev->dev; + struct usb_interface *usbif = to_usb_interface(dev->parent); + struct usb_device *usbdev = interface_to_usbdev(usbif); + struct urb *urb; + + setup_packet = kmalloc(8, GFP_ATOMIC); + + memcpy(setup_packet, t300rs_ctrl_out, ARRAY_SIZE(t300rs_ctrl_out)); + urb = usb_alloc_urb(0, GFP_ATOMIC); + + usb_fill_control_urb(urb, + usbdev, + usb_sndctrlpipe(usbdev, 0), + setup_packet, + NULL, + 0, + /* technically speaking this isn't an interrupt usb, but hey, this + * works. + * */ + t300rs_int_callback, + hdev); + + ret = usb_submit_urb(urb, GFP_ATOMIC); + if(ret != 0){ + hid_err(hdev, "Failed sending ctrl out with ERRNO: %i", ret); + goto error; + } + +error: + kfree(setup_packet); + return ret; +} + static int t300rs_probe(struct hid_device *hdev, const struct hid_device_id *id){ int ret; struct t300rs_data *drv_data; @@ -910,6 +953,9 @@ static int t300rs_probe(struct hid_device *hdev, const struct hid_device_id *id) goto err; } + /* lord have mercy */ + t300rs_preinit(hdev); + ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); if(ret){ hid_err(hdev, "hw start failed\n"); diff --git a/hid-tmt300rs.h b/hid-tmt300rs.h index 3ac4336..bec73eb 100644 --- a/hid-tmt300rs.h +++ b/hid-tmt300rs.h @@ -81,3 +81,5 @@ static u8 spring_values[] = { static u8 damper_values[] = { 0xfc, 0x7f, 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0xfc, 0x7f, 0x07 }; + +static u8 t300rs_ctrl_out[] = { 0x41, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, }; |
