shauleiz / vJoy

Virtual Joystick
http://vjoystick.sourceforge.net
MIT License
616 stars 170 forks source link

Fast FFB Packets Out of Order #46

Open Sirius902 opened 4 years ago

Sirius902 commented 4 years ago

I was writing a vJoy feeder (v2.1.9) and noticed if FFB packets come in too quickly (<1ms) they have a tendency to be received out of order. A game I was testing sends a ConstantReport, Start effect, and then Stop effect in <1ms to stop the rumble on the controller, which works fine with other controllers such as an Xbox controller, but vJoy is sending the packets to me as a Stop effect, ConstantReport, and Start effect, causing the controller to vibrate infinitely any time the game tries to clear the rumble on a controller.

Here you can see for the first two sets of FFB packets it's fine, but the last ones are out of order.

ConstantReport
BlockFreeReport: FFBEffOp { effect_block_index: 1, effect_op: Start, loop_count: 1 }
BlockFreeReport: FFBEffOp { effect_block_index: 1, effect_op: Stop, loop_count: 0 }
ConstantReport
BlockFreeReport: FFBEffOp { effect_block_index: 1, effect_op: Start, loop_count: 1 }
BlockFreeReport: FFBEffOp { effect_block_index: 1, effect_op: Stop, loop_count: 0 } 
BlockFreeReport: FFBEffOp { effect_block_index: 1, effect_op: Stop, loop_count: 0 }
ConstantReport
BlockFreeReport: FFBEffOp { effect_block_index: 1, effect_op: Start, loop_count: 1 }
njz3 commented 2 years ago

The issue appears because vJoy 2.1.9 does not handle correctly effect block index. It overwrites everything and use always the same first block (index 1), which mix up everything in the ffb queue.