From f60a01cc2d42e834e483d71bbc3893bc5fc07aff Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 27 Jun 2020 21:08:27 +0300 Subject: somewhat successfully played DiRT Rally with my T300RS wheel for the first time --- Module.symvers | 0 hid-tmff2.c | 28 ++++++++++++++------------ hid-tmff2.ko | Bin 0 -> 463480 bytes hid-tmff2.mod | 2 ++ hid-tmff2.mod.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hid-tmff2.mod.o | Bin 0 -> 143104 bytes hid-tmff2.o | Bin 0 -> 321864 bytes modules.order | 1 + 8 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 Module.symvers create mode 100644 hid-tmff2.ko create mode 100644 hid-tmff2.mod create mode 100644 hid-tmff2.mod.c create mode 100644 hid-tmff2.mod.o create mode 100644 hid-tmff2.o create mode 100644 modules.order diff --git a/Module.symvers b/Module.symvers new file mode 100644 index 0000000..e69de29 diff --git a/hid-tmff2.c b/hid-tmff2.c index aebfbff..2bfc38f 100644 --- a/hid-tmff2.c +++ b/hid-tmff2.c @@ -49,6 +49,8 @@ static const signed short ff_joystick[] = { /* Usages for thrustmaster devices I know about */ #define THRUSTMASTER_USAGE_FF (HID_UP_GENDESK | 0xbb) +u16 tmff_gain = 0xffff; + static u8 setup_0[] = { 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static u8 setup_1[] = { 0x0a, 0x04, 0x90, 0x03, 0x00, 0x00, 0x00, 0x00 }; static u8 setup_2[] = { 0x0a, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00 }; @@ -358,10 +360,7 @@ static int tmff_play(struct input_dev *dev, void *data, switch (effect->type) { case FF_CONSTANT: - x = tmff_scale_s8(effect->u.ramp.start_level, - ff_field->logical_minimum, - ff_field->logical_maximum); - y = tmff_scale_s8(effect->u.ramp.end_level, + x = tmff_scale_s8((tmff_gain * effect->u.constant.level) / ((u16)0xffff), ff_field->logical_minimum, ff_field->logical_maximum); @@ -369,15 +368,13 @@ static int tmff_play(struct input_dev *dev, void *data, memcpy(send_buf, ff_stop_array, ARRAY_SIZE(ff_stop_array)); } else { - /*if(x < 128){ - x = 128 - x; + if(x < 128){ + x = 128 + x; + } else if(x > 128){ + x = 256 - x; + } - } else if(x > 128){ - x = 256 - (x - 128); - }*/ - - send_buf[4] = x; - send_buf[5] = y; + send_buf[5] = x; } @@ -646,6 +643,9 @@ static int tmff_delete(struct kref *kref){ return 0; }; +static void tmff_set_gain(struct input_dev *dev, u16 gain){ + tmff_gain = gain; +} static int tmff_init(struct hid_device *hid, const signed short *ff_bits) { @@ -656,6 +656,7 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); struct input_dev *input_dev = hidinput->input; + struct ff_device *ff; int error; int i; @@ -730,6 +731,9 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) if (error) goto fail; + ff = input_dev->ff; + ff->set_gain = tmff_set_gain; + hid_info(hid, "force feedback for ThrustMaster devices by Zinx Verituse \n"); return 0; diff --git a/hid-tmff2.ko b/hid-tmff2.ko new file mode 100644 index 0000000..96f6abc Binary files /dev/null and b/hid-tmff2.ko differ diff --git a/hid-tmff2.mod b/hid-tmff2.mod new file mode 100644 index 0000000..587f15d --- /dev/null +++ b/hid-tmff2.mod @@ -0,0 +1,2 @@ +/home/kimi/Documents/Projects/hid-tmff2/hid-tmff2.o + diff --git a/hid-tmff2.mod.c b/hid-tmff2.mod.c new file mode 100644 index 0000000..4cddaf4 --- /dev/null +++ b/hid-tmff2.mod.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include + +BUILD_SALT; + +MODULE_INFO(vermagic, VERMAGIC_STRING); +MODULE_INFO(name, KBUILD_MODNAME); + +__visible struct module __this_module +__section(.gnu.linkonce.this_module) = { + .name = KBUILD_MODNAME, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif + .arch = MODULE_ARCH_INIT, +}; + +#ifdef CONFIG_RETPOLINE +MODULE_INFO(retpoline, "Y"); +#endif + +static const struct modversion_info ____versions[] +__used __section(__versions) = { + { 0xb90cb2c6, "module_layout" }, + { 0xb314bd85, "hid_unregister_driver" }, + { 0x399e83c3, "__hid_register_driver" }, + { 0xdecd0b29, "__stack_chk_fail" }, + { 0x95ba88c, "input_ff_create_memless" }, + { 0x52af4d4b, "_dev_info" }, + { 0x60da7bc0, "hid_hw_start" }, + { 0x484d36ee, "usb_interrupt_msg" }, + { 0xdf872899, "_dev_err" }, + { 0x69acdf38, "memcpy" }, + { 0x443d25f8, "hid_open_report" }, + { 0xe00d2f98, "__dynamic_dev_dbg" }, + { 0x2d9e7e22, "current_task" }, + { 0x162615, "usb_kill_urb" }, + { 0x4d1ff60a, "wait_for_completion_timeout" }, + { 0x7f02188f, "__msecs_to_jiffies" }, + { 0xd9a5ea54, "__init_waitqueue_head" }, + { 0xc5850110, "printk" }, + { 0x37a0cba, "kfree" }, + { 0xf51ed08d, "usb_submit_urb" }, + { 0xec4e6a94, "kmem_cache_alloc_trace" }, + { 0xc4a14306, "kmalloc_caches" }, + { 0xe0d57b51, "usb_alloc_urb" }, + { 0xb43f9365, "ktime_get" }, + { 0xd0d6e733, "usb_free_urb" }, + { 0xf64c8101, "_dev_warn" }, + { 0x3d6a80fd, "hid_hw_stop" }, + { 0xbdfb6dbb, "__fentry__" }, +}; + +MODULE_INFO(depends, "hid,ff-memless,usbcore"); + +MODULE_ALIAS("hid:b0003g*v0000044Fp0000B65D"); +MODULE_ALIAS("hid:b0003g*v0000044Fp0000B66E"); diff --git a/hid-tmff2.mod.o b/hid-tmff2.mod.o new file mode 100644 index 0000000..c15483f Binary files /dev/null and b/hid-tmff2.mod.o differ diff --git a/hid-tmff2.o b/hid-tmff2.o new file mode 100644 index 0000000..0bbcbe9 Binary files /dev/null and b/hid-tmff2.o differ diff --git a/modules.order b/modules.order new file mode 100644 index 0000000..a82dd0e --- /dev/null +++ b/modules.order @@ -0,0 +1 @@ +/home/kimi/Documents/Projects/hid-tmff2/hid-tmff2.ko -- cgit v1.3