From 34ec011611086be4411db1f4f5383f3a5d78d16e Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 27 Jun 2020 21:17:39 +0300 Subject: Removed unneccessary files --- Module.symvers | 0 hid-tmff2.ko | Bin 463480 -> 0 bytes hid-tmff2.mod | 2 -- hid-tmff2.mod.c | 60 -------------------------------------------------------- hid-tmff2.mod.o | Bin 143104 -> 0 bytes hid-tmff2.o | Bin 321864 -> 0 bytes modules.order | 1 - 7 files changed, 63 deletions(-) delete mode 100644 Module.symvers delete mode 100644 hid-tmff2.ko delete mode 100644 hid-tmff2.mod delete mode 100644 hid-tmff2.mod.c delete mode 100644 hid-tmff2.mod.o delete mode 100644 hid-tmff2.o delete mode 100644 modules.order diff --git a/Module.symvers b/Module.symvers deleted file mode 100644 index e69de29..0000000 diff --git a/hid-tmff2.ko b/hid-tmff2.ko deleted file mode 100644 index 96f6abc..0000000 Binary files a/hid-tmff2.ko and /dev/null differ diff --git a/hid-tmff2.mod b/hid-tmff2.mod deleted file mode 100644 index 587f15d..0000000 --- a/hid-tmff2.mod +++ /dev/null @@ -1,2 +0,0 @@ -/home/kimi/Documents/Projects/hid-tmff2/hid-tmff2.o - diff --git a/hid-tmff2.mod.c b/hid-tmff2.mod.c deleted file mode 100644 index 4cddaf4..0000000 --- a/hid-tmff2.mod.c +++ /dev/null @@ -1,60 +0,0 @@ -#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 deleted file mode 100644 index c15483f..0000000 Binary files a/hid-tmff2.mod.o and /dev/null differ diff --git a/hid-tmff2.o b/hid-tmff2.o deleted file mode 100644 index 0bbcbe9..0000000 Binary files a/hid-tmff2.o and /dev/null differ diff --git a/modules.order b/modules.order deleted file mode 100644 index a82dd0e..0000000 --- a/modules.order +++ /dev/null @@ -1 +0,0 @@ -/home/kimi/Documents/Projects/hid-tmff2/hid-tmff2.ko -- cgit v1.3 From a7891899b46c84e30e93f6e6f29c5676a3aa1dc1 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 5 Jul 2020 19:24:03 +0300 Subject: improved feel of constant force, still no clue why random crashes occur --- compile_commands.json | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++ hid-tmff2.c | 80 ++++++++++++++++++++------------------ 2 files changed, 147 insertions(+), 37 deletions(-) create mode 100644 compile_commands.json diff --git a/compile_commands.json b/compile_commands.json new file mode 100644 index 0000000..0ac6efe --- /dev/null +++ b/compile_commands.json @@ -0,0 +1,104 @@ +[ + { + "arguments": [ + "gcc-9", + "-c", + "-Wp,-MD,/home/kimi/Documents/Projects/hid-tmff2/.hid-tmff2.o.d", + "-nostdinc", + "-isystem", + "/usr/lib/gcc/x86_64-linux-gnu/9/include", + "-I/usr/src/linux-headers-5.7.0-1-common/arch/x86/include", + "-I./arch/x86/include/generated", + "-I/usr/src/linux-headers-5.7.0-1-common/include", + "-I./include", + "-I/usr/src/linux-headers-5.7.0-1-common/arch/x86/include/uapi", + "-I./arch/x86/include/generated/uapi", + "-I/usr/src/linux-headers-5.7.0-1-common/include/uapi", + "-I./include/generated/uapi", + "-include", + "/usr/src/linux-headers-5.7.0-1-common/include/linux/kconfig.h", + "-include", + "/usr/src/linux-headers-5.7.0-1-common/include/linux/compiler_types.h", + "-D__KERNEL__", + "-Wall", + "-Wundef", + "-Werror=strict-prototypes", + "-Wno-trigraphs", + "-fno-strict-aliasing", + "-fno-common", + "-fshort-wchar", + "-fno-PIE", + "-Werror=implicit-function-declaration", + "-Werror=implicit-int", + "-Wno-format-security", + "-std=gnu89", + "-mno-sse", + "-mno-mmx", + "-mno-sse2", + "-mno-3dnow", + "-mno-avx", + "-m64", + "-falign-jumps=1", + "-falign-loops=1", + "-mno-80387", + "-mno-fp-ret-in-387", + "-mpreferred-stack-boundary=3", + "-mskip-rax-setup", + "-mtune=generic", + "-mno-red-zone", + "-mcmodel=kernel", + "-DCONFIG_X86_X32_ABI", + "-Wno-sign-compare", + "-fno-asynchronous-unwind-tables", + "-mindirect-branch=thunk-extern", + "-mindirect-branch-register", + "-fno-jump-tables", + "-fno-delete-null-pointer-checks", + "-Wno-frame-address", + "-Wno-format-truncation", + "-Wno-format-overflow", + "-Wno-address-of-packed-member", + "-O2", + "--param=allow-store-data-races=0", + "-Wframe-larger-than=2048", + "-fstack-protector-strong", + "-Wno-unused-but-set-variable", + "-Wimplicit-fallthrough", + "-Wno-unused-const-variable", + "-fno-var-tracking-assignments", + "-g", + "-pg", + "-mrecord-mcount", + "-mfentry", + "-DCC_USING_FENTRY", + "-flive-patching=inline-clone", + "-Wdeclaration-after-statement", + "-Wvla", + "-Wno-pointer-sign", + "-Wno-stringop-truncation", + "-Wno-array-bounds", + "-Wno-stringop-overflow", + "-Wno-restrict", + "-Wno-maybe-uninitialized", + "-fno-strict-overflow", + "-fno-merge-all-constants", + "-fmerge-constants", + "-fno-stack-check", + "-fconserve-stack", + "-Werror=date-time", + "-Werror=incompatible-pointer-types", + "-Werror=designated-init", + "-fmacro-prefix-map=/usr/src/linux-headers-5.7.0-1-common/=", + "-fcf-protection=none", + "-Wno-packed-not-aligned", + "-DMODULE", + "-DKBUILD_BASENAME=\"hid_tmff2\"", + "-DKBUILD_MODNAME=\"hid_tmff2\"", + "-o", + "/home/kimi/Documents/Projects/hid-tmff2/hid-tmff2.o", + "../../../home/kimi/Documents/Projects/hid-tmff2/hid-tmff2.c" + ], + "directory": "/usr/src/linux-headers-5.7.0-1-amd64", + "file": "../../../home/kimi/Documents/Projects/hid-tmff2/hid-tmff2.c" + } +] \ No newline at end of file diff --git a/hid-tmff2.c b/hid-tmff2.c index 2bfc38f..66c712b 100644 --- a/hid-tmff2.c +++ b/hid-tmff2.c @@ -265,12 +265,13 @@ static inline int tmff_scale_s8(int in, int minimum, int maximum) return maximum; return ret; } - +bool transferred = true; static void tmff_ctrl(struct urb *urb){ if(urb->status){ hid_warn(urb->dev, "urb status %d received\n", urb->status); } usb_free_urb(urb); + transferred = true; } static void tmff_init_ctrl(struct urb *urb){ @@ -326,57 +327,41 @@ out: return retval; } +bool last_stop = false; + static int tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect) { //spin_lock_irqsave(report_lock, flags); struct hid_device *hid = input_get_drvdata(dev); - struct tmff_device *tmff = data; - struct hid_field *ff_field = tmff->ff_field; - int x, y; - int left, right; /* Rumbling */ - int trans, b_ep, err; - unsigned long flags; struct device *d_dev = &hid->dev; struct usb_interface *usbif = to_usb_interface(d_dev->parent); struct usb_device *usbdev = interface_to_usbdev(usbif); struct usb_host_endpoint *ep; - - if((ktime_get_ns() - last) < 4000000){ - return 0; - } - - last = ktime_get_ns(); - + struct tmff_device *tmff = data; + struct hid_field *ff_field = tmff->ff_field; struct urb *urb = usb_alloc_urb(0, GFP_ATOMIC); - u8 *send_buf = kmalloc(1024, GFP_ATOMIC); + __s16 x; + + if(!transferred){ + return 0; + } + + memcpy(send_buf, ff_constant_array, ARRAY_SIZE(ff_constant_array)); ep = &usbif->cur_altsetting->endpoint[1]; - b_ep = ep->desc.bEndpointAddress; - + switch (effect->type) { case FF_CONSTANT: + x = tmff_scale_s8(effect->u.ramp.start_level, + ff_field->logical_minimum, + ff_field->logical_maximum); - x = tmff_scale_s8((tmff_gain * effect->u.constant.level) / ((u16)0xffff), - ff_field->logical_minimum, - ff_field->logical_maximum); - - if(x == 128){ - memcpy(send_buf, ff_stop_array, ARRAY_SIZE(ff_stop_array)); - } else { - - if(x < 128){ - x = 128 + x; - } else if(x > 128){ - x = 256 - x; - } - - send_buf[5] = x; - - } + send_buf[4] = x & 0xff; + send_buf[5] = x >> 8; usb_fill_int_urb( urb, @@ -388,6 +373,7 @@ static int tmff_play(struct input_dev *dev, void *data, hid, ep->desc.bInterval ); + transferred = false; usb_submit_urb(urb, GFP_ATOMIC); @@ -666,7 +652,8 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) tmff = kzalloc(sizeof(struct tmff_device), GFP_KERNEL); if (!tmff) return -ENOMEM; - + + hid_info(hid, "what is going ong here???"); spin_lock_init(&tmff->report_lock); report_lock = &tmff->report_lock; @@ -677,6 +664,7 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) for (fieldnum = 0; fieldnum < report->maxfield; ++fieldnum) { struct hid_field *field = report->field[fieldnum]; + printk("found field at fieldnum %i\n", fieldnum); if (field->maxusage <= 0) continue; @@ -707,7 +695,7 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) tmff->report = report; tmff->ff_field = field; - + for (i = 0; ff_bits[i] >= 0; i++) set_bit(ff_bits[i], input_dev->ffbit); @@ -738,6 +726,7 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) return 0; fail: + hid_err(hid, "We have failed creating a force feedback memless device!!!\n"); kfree(tmff); return error; } @@ -754,7 +743,6 @@ static int tmff_afterthought_t300rs(struct hid_device *hid){ 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; @@ -844,6 +832,23 @@ static void tm_remove(struct hid_device *hdev){ hid_hw_stop(hdev); } +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, 0x31, 0x26, 0xff, 0x03, 0x46, 0xff, 0x03, 0x81, 0x02, 0x09, 0x35, 0x81, 0x02, 0x09, 0x36, 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, 0x0a, 0x06, 0x00, 0xff, 0x09, 0x0a, 0x75, 0x08, 0x95, 0x3f, + 0x26, 0xff, 0x7f, + 0x16, 0x00, 0x80, + 0x46, 0xff, 0x7f, + 0x36, 0x00, 0x80, + 0x91, 0x02, 0x85, 0x02, 0x09, 0x02, 0x81, 0x02, 0x09, 0x14, 0x85, 0x14, 0x81, 0x02, 0xc0, 0xc0,}; + +static __u8 *tmff_t300rs_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize){ + if(hdev->product != 0xb66e){ + return rdesc; + } + printk("wahey"); + rdesc = t300rs_rdesc_fixed; + *rsize = sizeof(t300rs_rdesc_fixed); + return rdesc; +}; + static const struct hid_device_id tm_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65d), .driver_data = (unsigned long)ff_constant }, /* die */ @@ -858,6 +863,7 @@ static struct hid_driver tm_driver = { .id_table = tm_devices, .probe = tm_probe, .remove = tm_remove, + .report_fixup = tmff_t300rs_report_fixup, }; module_hid_driver(tm_driver); -- cgit v1.3 From 237930d9eb6177cb64f2a844b4867ea011dc4f7c Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 6 Jul 2020 14:49:43 +0300 Subject: started creating documentation for the different usb commands --- force-effects.txt | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 force-effects.txt diff --git a/force-effects.txt b/force-effects.txt new file mode 100644 index 0000000..47d5b35 --- /dev/null +++ b/force-effects.txt @@ -0,0 +1,153 @@ +Here I will gather all info I can find out about the different force effects and +their USB commands. All values seem to be little-endian. +Also, general note, it seems like some effects are affected by the direction of +the force, denoted by *** +GENERAL: + + Playing: + 60 00 - standard header + 01 - ID + 89 - playing options + 01 - play + 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + + Stopping/removing: (why are they rolled into one?) + 60 00 - standard header + 01 - ID + 89 - playing options + 00 - stop + 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + +FF_CONSTANT: + Initialization: + 60 00 - standard header + 01 - ID + 6a - new constant effect(?) + fe ff - strength *** + 00 00 - attack_length + 00 00 - attack_level *** + 00 00 - fade_length + 00 00 - fade_level *** + 00 4f - ? + f7 17 - time in milliseconds, unsigned + 00 00 + 07 00 - offset from start(?) + 00 ff ff - end of new effect(?) + 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + + Modifying: (It may be possible to modify the effects all at once, not sure) + Direction: n/a + + Constant force: + 60 00 - standard header + 01 - ID + 0a - modify constant force + 05 16 - constant force + 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + Envelope: + 60 00 - standard header + 01 - ID + 31 - modify envelope + 84 - ID of envelope attribute ( attack_level 82, + attack_length 81, + fade_level 88, + fade_length 84 ) + 63 04 - value attribute should be set to + 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + Duration: + 60 00 - standard header + 01 - ID + 49 00 41 - modify timing? + 6c 20 - length in milliseconds + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + +FF_RAMP: + (Why on earth is it this difficult to figure out how a fucking ramp works?) + Init: + 60 00 - standard header + 01 - ID + 6b - new ramp effect + f6 7f - ? *** (these two have something in common but no idea what yet) + fe ff - ? + 00 00 + f7 17 - time? + 00 80 - some kind of marker + 00 00 - attack_length? + f6 7f - attack_level? *** + 00 00 - fade_length? + f6 7f - fade_level? *** + 04 - invert (going "down", 05, going "up", 04) + 4f + f7 17 - time again? + 00 00 + 00 00 - offset + 00 ff ff - end of init + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + +FF_SPRING: + Init: + 60 00 - standard header + 01 - ID + 64 - new conditional effect + fc 7f - positive coefficient (right?) + fc 7f - negative coefficient (left?) + fe ff - deadband (left?) (deadband + offset) (fe ff means no deadband) + fe ff - deadband (right?) (deadband + offset) + a6 6a a6 6a fe ff fe ff fe ff fe ff df 58 a6 6a 06 4f f7 17 + 00 00 - some weird hard-coded values to do with springs? + 00 00 - offset + 00 ff ff - end of init + 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + +FF_DAMPER + FF_FRICTION + FF_INERTIA: + Init: + 60 00 - standard header + 02 -ID + 64 - new conditional effect + fc 7f - positive coefficient (right?) + fc 7f - negative coefficient (left?) + fe ff - deadband (left?) (deadband + offset) (fe ff means no deadband) + fe ff - deadband (right?) (deadband + offset) + fc 7f fc 7f fe ff fe ff fe ff fe ff fc 7f fc 7f 07 4f f7 17 + 00 00 - some weird hard-coded values to do with friction? + 00 00 - offset + 00 ff ff - end of init 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + +FF_PERIODIC: +FF_SQUARE: + 60 00 - standard header + 01 - ID + 6b - new periodic effect + 00 00 - direction + fe ff - ? + 00 00 - offset + e8 03 00 80 00 00 + 00 00 00 00 00 00 01 4f f7 17 00 00 00 00 00 ff + ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + -- cgit v1.3 From a7d5f982b156aa44d47f1b8abcda8a4db8f59e8f Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 6 Jul 2020 18:02:55 +0300 Subject: added more fields to the forces file --- force-effects.txt | 68 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 12 deletions(-) diff --git a/force-effects.txt b/force-effects.txt index 47d5b35..5850dc8 100644 --- a/force-effects.txt +++ b/force-effects.txt @@ -2,6 +2,10 @@ Here I will gather all info I can find out about the different force effects and their USB commands. All values seem to be little-endian. Also, general note, it seems like some effects are affected by the direction of the force, denoted by *** + +All values are examples of actual commands that I captured on the USB interface, +not the only ones available. + GENERAL: Playing: @@ -46,6 +50,7 @@ FF_CONSTANT: Modifying: (It may be possible to modify the effects all at once, not sure) + (In any case, so far I only investigated the constant modifiers) Direction: n/a Constant force: @@ -89,7 +94,7 @@ FF_RAMP: 60 00 - standard header 01 - ID 6b - new ramp effect - f6 7f - ? *** (these two have something in common but no idea what yet) + f6 7f - ? *** (these two have something in common but no idea what exactly yet) fe ff - ? 00 00 f7 17 - time? @@ -116,8 +121,12 @@ FF_SPRING: fc 7f - negative coefficient (left?) fe ff - deadband (left?) (deadband + offset) (fe ff means no deadband) fe ff - deadband (right?) (deadband + offset) - a6 6a a6 6a fe ff fe ff fe ff fe ff df 58 a6 6a 06 4f f7 17 - 00 00 - some weird hard-coded values to do with springs? + a6 6a a6 6a fe ff fe ff fe ff fe ff df 58 a6 6a 06- some weird hard-coded + values to do with springs? + + 4f + f7 17 - duration + 00 00 00 00 - offset 00 ff ff - end of init 00 00 00 00 00 00 00 00 00 @@ -132,22 +141,57 @@ FF_DAMPER + FF_FRICTION + FF_INERTIA: fc 7f - negative coefficient (left?) fe ff - deadband (left?) (deadband + offset) (fe ff means no deadband) fe ff - deadband (right?) (deadband + offset) - fc 7f fc 7f fe ff fe ff fe ff fe ff fc 7f fc 7f 07 4f f7 17 - 00 00 - some weird hard-coded values to do with friction? + fc 7f fc 7f fe ff fe ff fe ff fe ff fc 7f fc 7f 07 - some weird hard-coded + values to do with friction? + 4f + f7 17 - duration + 00 00 00 00 - offset - 00 ff ff - end of init 00 00 00 00 00 00 00 00 00 + 00 ff ff - end of init + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF_PERIODIC: -FF_SQUARE: 60 00 - standard header 01 - ID 6b - new periodic effect - 00 00 - direction - fe ff - ? + 00 00 - magnitude *** + fe ff - phase (left/right) + 00 00 - offset of effect (forward/backward) + e8 03 - period + 00 80 + 00 00 - attack_length? + 00 00 - attack_level? *** + 00 00 - fade_length? + 00 00 - fade_level? *** + 01 - type of periodic ( square 01, + sine 03, + triangle 02, + sawtooth down 05, + sawtooth up 04 ) + 4f + f7 17 - duration + 00 00 00 00 - offset - e8 03 00 80 00 00 - 00 00 00 00 00 00 01 4f f7 17 00 00 00 00 00 ff - ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 ff ff - end of init + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +FF_AUTOCENTER: + 60 08 - header plus settings? + 03 - set autocenter force + 8f 02 - force (between ff ff and 00 00) + 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + +Rotation angle: + 60 08 - header plus settings? + 11 - set rotation angle + 55 d5 - angle (between ff ff and 7b 09, one degree is roughly 3c) + 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -- cgit v1.3 From 8aefca14c327b9d43ab55697f98b6101b3f36c0d Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 6 Jul 2020 19:51:49 +0300 Subject: more research --- force-effects.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/force-effects.txt b/force-effects.txt index 5850dc8..8181860 100644 --- a/force-effects.txt +++ b/force-effects.txt @@ -94,15 +94,15 @@ FF_RAMP: 60 00 - standard header 01 - ID 6b - new ramp effect - f6 7f - ? *** (these two have something in common but no idea what exactly yet) - fe ff - ? + f6 7f - difference? *** + fe ff - level? ** (possibly starting_level?) 00 00 f7 17 - time? 00 80 - some kind of marker 00 00 - attack_length? - f6 7f - attack_level? *** + f6 7f - attack_level but with difference? *** 00 00 - fade_length? - f6 7f - fade_level? *** + f6 7f - fade_level but with difference? *** 04 - invert (going "down", 05, going "up", 04) 4f f7 17 - time again? @@ -186,6 +186,13 @@ FF_AUTOCENTER: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +FF_GAIN: + 60 02 - header plus gain? + bf - gain (between ff and 00) + 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Rotation angle: 60 08 - header plus settings? -- cgit v1.3 From 716eb9c2ef6ac77600eb9c8c8f7e5a2aa9a42f88 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 8 Jul 2020 12:54:43 +0300 Subject: maybe figured out how ramp works --- force-effects.txt | 60 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/force-effects.txt b/force-effects.txt index 8181860..e8fe6f1 100644 --- a/force-effects.txt +++ b/force-effects.txt @@ -3,6 +3,10 @@ their USB commands. All values seem to be little-endian. Also, general note, it seems like some effects are affected by the direction of the force, denoted by *** +As far as I can tell, fade_level and attack_level values are calculated by +mapping the u16 into s16 and taking the absolute value, and after that +multiplying by the direction. + All values are examples of actual commands that I captured on the USB interface, not the only ones available. @@ -94,15 +98,16 @@ FF_RAMP: 60 00 - standard header 01 - ID 6b - new ramp effect - f6 7f - difference? *** - fe ff - level? ** (possibly starting_level?) + f6 7f - difference *** + fe ff - level? *** (level = (if end_level > start_level, end_level, else + start_level) - difference?) 00 00 - f7 17 - time? + f7 17 - time 00 80 - some kind of marker - 00 00 - attack_length? - f6 7f - attack_level but with difference? *** - 00 00 - fade_length? - f6 7f - fade_level but with difference? *** + 00 00 - attack_length + f6 7f - attack_level *** + 00 00 - fade_length + f6 7f - fade_level*** 04 - invert (going "down", 05, going "up", 04) 4f f7 17 - time again? @@ -121,7 +126,7 @@ FF_SPRING: fc 7f - negative coefficient (left?) fe ff - deadband (left?) (deadband + offset) (fe ff means no deadband) fe ff - deadband (right?) (deadband + offset) - a6 6a a6 6a fe ff fe ff fe ff fe ff df 58 a6 6a 06- some weird hard-coded + a6 6a a6 6a fe ff fe ff fe ff fe ff df 58 a6 6a 06 - some weird hard-coded values to do with springs? 4f @@ -160,10 +165,10 @@ FF_PERIODIC: 00 00 - offset of effect (forward/backward) e8 03 - period 00 80 - 00 00 - attack_length? - 00 00 - attack_level? *** - 00 00 - fade_length? - 00 00 - fade_level? *** + 00 00 - attack_length + 00 00 - attack_level *** + 00 00 - fade_length + 00 00 - fade_level *** 01 - type of periodic ( square 01, sine 03, triangle 02, @@ -202,3 +207,34 @@ Rotation angle: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + +Open: + 60 01 - standard header? + 04 - ? + 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + (this command doesn't appear every time, odd) + 60 12 - ? + bf 04 00 00 03 b7 1e - ? + 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + 60 01 - ? + 05 - ? + 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + +Close: + 60 01 - standard header? + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + -- cgit v1.3 From c7171a1fe795911a925f47af15352deb6609b001 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 8 Jul 2020 13:18:01 +0300 Subject: small changes, nothing on value (I assume) --- force-effects.txt | 4 ++-- hid-tmff2.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/force-effects.txt b/force-effects.txt index e8fe6f1..6c205f7 100644 --- a/force-effects.txt +++ b/force-effects.txt @@ -98,9 +98,9 @@ FF_RAMP: 60 00 - standard header 01 - ID 6b - new ramp effect - f6 7f - difference *** + f6 7f - difference *** fe ff - level? *** (level = (if end_level > start_level, end_level, else - start_level) - difference?) + start_level) - difference?) (signed) 00 00 f7 17 - time 00 80 - some kind of marker diff --git a/hid-tmff2.c b/hid-tmff2.c index 66c712b..b26185f 100644 --- a/hid-tmff2.c +++ b/hid-tmff2.c @@ -354,9 +354,11 @@ static int tmff_play(struct input_dev *dev, void *data, ep = &usbif->cur_altsetting->endpoint[1]; - switch (effect->type) { + switch (effect->type) { case FF_CONSTANT: - x = tmff_scale_s8(effect->u.ramp.start_level, + // this only works with input_ff_create_memless, which clamps + // constant forces to s8 for some reason + x = tmff_scale_s8(effect->u.constant.level, ff_field->logical_minimum, ff_field->logical_maximum); -- cgit v1.3