Fix various issues with SDL mouse scrolling and add a test. Fixes #2643.