Input: joydev - do not report stale values on first open
authorRaphael Assenat <raph@raphnet.net>
Thu, 29 Dec 2016 18:23:09 +0000 (10:23 -0800)
committerJiri Slaby <jslaby@suse.cz>
Tue, 11 Apr 2017 06:04:38 +0000 (08:04 +0200)
commit57c08434d2cca9edacd1651c4891148e5bc19135
tree9c513d84874d7750660bda05177c5ece44249c21
parentfc0a62426de73859c1892ab2e61857d5bc283d2f
Input: joydev - do not report stale values on first open

commit 45536d373a21d441bd488f618b6e3e9bfae839f3 upstream.

Postpone axis initialization to the first open instead of doing it
in joydev_connect. This is to make sure the generated startup events
are representative of the current joystick state rather than what
it was when joydev_connect() was called, potentially much earlier.
Once the first user is connected to joydev node we'll be updating
joydev->abs[] values and subsequent clients will be getting correct
initial states as well.

This solves issues with joystick driven menus that start scrolling
up each time they are started, until the user moves the joystick to
generate events. In emulator menu setups where the menu program is
restarted every time the game exits, the repeated need to move the
joystick to stop the unintended scrolling gets old rather quickly...

Signed-off-by: Raphael Assenat <raph@raphnet.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Oliver Neukum <ONeukum@suse.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/input/joydev.c