From 301f7fa87fa2bafbd9ed3436aa7eb865b341563c Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 24 Mar 2021 20:48:04 +0200 Subject: Merge branch 'minalloc' --- hid-tmt300rs.h | 154 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 104 insertions(+), 50 deletions(-) (limited to 'hid-tmt300rs.h') diff --git a/hid-tmt300rs.h b/hid-tmt300rs.h index 2eef09d..28b44ab 100644 --- a/hid-tmt300rs.h +++ b/hid-tmt300rs.h @@ -1,10 +1,14 @@ -#include "hid-tm.h" -#include "usbhid.h" +#include +#include +#include +#include #include #include #include #include +#define USB_VENDOR_ID_THRUSTMASTER 0x044f + #define T300RS_MAX_EFFECTS 16 #define T300RS_BUFFER_LENGTH 63 @@ -33,69 +37,119 @@ spinlock_t data_lock; unsigned long data_flags; static const signed short t300rs_ff_effects[] = { - FF_CONSTANT, - FF_RAMP, - FF_SPRING, - FF_DAMPER, - FF_FRICTION, - FF_INERTIA, - FF_PERIODIC, - FF_SINE, - FF_TRIANGLE, - FF_SQUARE, - FF_SAW_UP, - FF_SAW_DOWN, - FF_AUTOCENTER, - FF_GAIN, - -1 + FF_CONSTANT, + FF_RAMP, + FF_SPRING, + FF_DAMPER, + FF_FRICTION, + FF_INERTIA, + FF_PERIODIC, + FF_SINE, + FF_TRIANGLE, + FF_SQUARE, + FF_SAW_UP, + FF_SAW_DOWN, + FF_AUTOCENTER, + FF_GAIN, + -1 }; struct t300rs_effect_state { - struct ff_effect effect; - struct ff_effect old; - bool old_set; - unsigned long flags; - unsigned long start_time; - unsigned long count; + struct ff_effect effect; + struct ff_effect old; + bool old_set; + unsigned long flags; + unsigned long start_time; + unsigned long count; +}; + +struct __packed t300rs_firmware_response { + uint8_t unknown0; + uint8_t unknown1; + uint8_t firmware_version; + uint8_t unknown2; +}; + + +struct usb_ctrlrequest t300rs_firmware_request = { + .bRequestType = 0xc1, + .bRequest = 86, + .wValue = 0, + .wIndex = 0, + .wLength = 8 }; + struct t300rs_device_entry { - struct hid_device *hdev; - struct input_dev *input_dev; - struct hid_report *report; - struct hid_field *ff_field; - struct usb_device *usbdev; - struct usb_interface *usbif; - struct t300rs_effect_state *states; - struct hrtimer hrtimer; - - int (*open)(struct input_dev *dev); - void (*close)(struct input_dev *dev); - - spinlock_t lock; - unsigned long lock_flags; - - int open_count; - - int max_id; - u16 range; - u8 effects_used; + struct hid_device *hdev; + struct input_dev *input_dev; + struct hid_report *report; + struct hid_field *ff_field; + struct usb_device *usbdev; + struct usb_interface *usbif; + struct t300rs_effect_state *states; + struct t300rs_firmware_response *firmware_response; + struct hrtimer hrtimer; + + int (*open)(struct input_dev *dev); + void (*close)(struct input_dev *dev); + + spinlock_t lock; + unsigned long lock_flags; + + u8 *send_buffer; + + u16 range; + u8 effects_used; }; struct t300rs_data{ - unsigned long quirks; - void *device_props; + unsigned long quirks; + void *device_props; }; -static __u8 t300rs_rdesc_fixed[] = {0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x85, 0x07, 0x09, 0x30, 0x15, 0x00, 0x27, 0xff, 0xff, 0x00, 0x00, 0x35, 0x00, 0x47, 0xff, 0xff, 0x00, 0x00, 0x75, 0x10, 0x95, 0x01, 0x81, 0x02, 0x09, 0x35, 0x26, 0xff, 0x03, 0x46, 0xff, 0x03, 0x81, 0x02, 0x09, 0x32, 0x81, 0x02, 0x09, 0x31, 0x81, 0x02, 0x81, 0x03, 0x05, 0x09, 0x19, 0x01, 0x29, 0x0d, 0x25, 0x01, 0x45, 0x01, 0x75, 0x01, 0x95, 0x0d, 0x81, 0x02, 0x75, 0x0b, 0x95, 0x01, 0x81, 0x03, 0x05, 0x01, 0x09, 0x39, 0x25, 0x07, 0x46, 0x3b, 0x01, 0x55, 0x00, 0x65, 0x14, 0x75, 0x04, 0x81, 0x42, 0x65, 0x00, 0x81, 0x03, 0x85, 0x60, // here 0x0a - 0x06, 0x00, 0xff, 0x09, 0x60, // here 0x0a - 0x75, 0x08, 0x95, 0x3f, 0x26, 0xff, 0x7f, 0x15, 0x00, 0x46, 0xff, 0x7f, 0x36, 0x00, 0x80, 0x91, 0x02, 0x85, 0x02, 0x09, 0x02, 0x81, 0x02, 0x09, 0x14, 0x85, 0x14, 0x81, 0x02, 0xc0, 0xc0,}; +static __u8 t300rs_rdesc_fixed[] = { + 0x05, 0x01, 0x09, 0x04, 0xa1, + 0x01, 0x09, 0x01, 0xa1, 0x00, + 0x85, 0x07, 0x09, 0x30, 0x15, + 0x00, 0x27, 0xff, 0xff, 0x00, + 0x00, 0x35, 0x00, 0x47, 0xff, + 0xff, 0x00, 0x00, 0x75, 0x10, + 0x95, 0x01, 0x81, 0x02, 0x09, + 0x35, 0x26, 0xff, 0x03, 0x46, + 0xff, 0x03, 0x81, 0x02, 0x09, + 0x32, 0x81, 0x02, 0x09, 0x31, + 0x81, 0x02, 0x81, 0x03, 0x05, + 0x09, 0x19, 0x01, 0x29, 0x0d, + 0x25, 0x01, 0x45, 0x01, 0x75, + 0x01, 0x95, 0x0d, 0x81, 0x02, + 0x75, 0x0b, 0x95, 0x01, 0x81, + 0x03, 0x05, 0x01, 0x09, 0x39, + 0x25, 0x07, 0x46, 0x3b, 0x01, + 0x55, 0x00, 0x65, 0x14, 0x75, + 0x04, 0x81, 0x42, 0x65, 0x00, + 0x81, 0x03, 0x85, 0x60, // here 0x0a + 0x06, 0x00, 0xff, 0x09, 0x60, // here 0x0a + 0x75, 0x08, 0x95, 0x3f, 0x26, + 0xff, 0x7f, 0x15, 0x00, 0x46, + 0xff, 0x7f, 0x36, 0x00, 0x80, + 0x91, 0x02, 0x85, 0x02, 0x09, + 0x02, 0x81, 0x02, 0x09, 0x14, + 0x85, 0x14, 0x81, 0x02, 0xc0, + 0xc0, +}; static u8 spring_values[] = { - 0xa6, 0x6a, 0xa6, 0x6a, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xdf, 0x58, 0xa6, 0x6a, 0x06 + 0xa6, 0x6a, 0xa6, 0x6a, 0xfe, + 0xff, 0xfe, 0xff, 0xfe, 0xff, + 0xfe, 0xff, 0xdf, 0x58, 0xa6, + 0x6a, 0x06 }; static u8 damper_values[] = { - 0xfc, 0x7f, 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0xfc, 0x7f, 0x07 + 0xfc, 0x7f, 0xfc, 0x7f, 0xfe, + 0xff, 0xfe, 0xff, 0xfe, 0xff, + 0xfe, 0xff, 0xfc, 0x7f, 0xfc, + 0x7f, 0x07 }; -- cgit v1.3