Joystick Balls on linux never recenter

Hi all,

I’m trying to do some multikeyboard / multimouse action with Mame and linux.

I figured out a workaround where I can write a small c program that will open a keyboard in exclusive mode with EVIOCGRAB and take those EV_KEY events and translate them into button presses like BTN_1, BTN_2 etc.

If I open a virtual input device with uinput and tell it that it will get BTN_UP BTN_DOWN BTN_LEFT BTN_RIGHT, the system thinks that it’s a joystick and I can use it in mame.

So keyboards events work fine, but the relative movements of a mouse don’t work properly.

I can open a mouse in exclusive mode and translate the EV_REL movements from a mouse into a EV_REL movement for REL_X and REL_Y and that gets mapped to a “Joystick Ball”.

Which pretty much works very well except for one big issue: The EV_REL events stop, but the ball never stops moving because it basically continues the last movement that was done. I can even send EV_REL events with a zero value and that doesn’t have any effect.

I’ve also tried converting MIDI input into a joystick device relative ball (with an ION DJ turntable controller) and have run into the same issue of non-centering balls.

Some sample programs and tests: