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 (limited to '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(-) (limited to 'force-effects.txt') 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(-) (limited to 'force-effects.txt') 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(-) (limited to 'force-effects.txt') 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(-) (limited to 'force-effects.txt') 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