Thu, 29 Sep 2016 16:52:48 -0700Fixed bug 3426 - Fixes for joystick related issues
Sam Lantinga [Thu, 29 Sep 2016 16:52:48 -0700] rev 10384
Fixed bug 3426 - Fixes for joystick related issues

ny00

This report is going to cover three issues, with a suggestion for fixes. For reference, tests were done using an installation of android-x86-5.1-rc1.iso within a VirtualBox session. I've actually used an adapter that accepts up to two Playstation 1/2 controllers.

A ZIP file should be attached, with the following contents:
- The patch file itself.
- Outputs of joysticks lists from testjoystick with different orders (before fixing bug).
- Game controllers database entries (for reference).
--- Different outputs for different platforms may stem from different tools being used; The Android mapping was manually constructed using a previously available mapping as a base.
--- Note that it turns out the Linux mapping is already out there in some form: https://github.com/gabomdq/SDL_GameControllerDB/blob/master/gamecontrollerdb.txt

And so, let's begin listing the issues:

1. While changeset https://hg.libsdl.org/SDL/rev/f6567f77f663 has good intentions, it appears to make various input devices being mistakenly detected as SDL joysticks. I got lists of the devices from joysticktest, given in the ZIP file. "badordering.txt" is what I get if the device has been plugged since a reboot of the virtual machine, while I've gotten "goodordering.txt" after hot-plugging the USB adapter. As expected, only in the latter case I could use the controller in the test program (assuming it isn't modified).

To take care of this, I updated pollInputDevices and added the function SDLActivity.isDeviceSDLJoystick, in order to have a better filter. Note that it also checks that the device id is non-negative, since VIRTUAL_KEYBOARD appears to include a SOURCE_DPAD, and I should probably keep accepting it as an SDL_joystick (good if you want, say, to support multiple independent d-pad devices).

I hope the device id filter does not break support for the virtual remote (mentioned in the changeset above).

2. So there's a weird glitch here, where the game controller is reported to have SOURCE_KEYBOARD and SOURCE_JOYSTICK, while each controller button press/release emits a KeyEvent with SOURCE_KEYBOARD only. So obviously any test going over the event's own sources is expected to fail.

It is possible to try and filter by the key code, but then there are the dpad key codes, which can also be emitted by actual PC keyboard's key presses/releases (the arrow keys).

So instead, I just call the newly added isDeviceSDLJoystick function again and check if the input device (not the event) has any source considered to be a joystick/gamepad for us.

3. Finally, if SDL2 properly detects an SDL_Joystick being connected, but it is not opened, then whenever a KeyEvent is received after a button press/release from the same controller, SDLActivity.onNativePadDown/onNativePadUp returns a negative value. In such a case, the onKey handler continues to check for SOURCE_KEYBOARD (and possibly also SOURCE_MOUSE), which is clearly not desired.

And so, in the given patch, the return values of onNativePadDown and onNativePadUp are ignored and "true" is returned either way.

(Note: Maybe the native functions should be modified to have the return value of "void".)

Finally, as another side-note, I've noticed that the various bitwise tests for sources are wrong. For instance, to check if an InputDevice 'device' has source SOURCE_JOYSTICK, the value (device.getSources() & SOURCE_JOYSTICK) should be compared to SOURCE_JOYSTICK, not 0.
However, I think there's enough that this patch covers. At the least, isDeviceSDLJoystick partially solves this.

Thu, 29 Sep 2016 16:40:34 -0700Fixed bug 3427 - Android accelerometer z-axis incorrect
Sam Lantinga [Thu, 29 Sep 2016 16:40:34 -0700] rev 10383
Fixed bug 3427 - Android accelerometer z-axis incorrect

Alex Szpakowski

As seen here https://bitbucket.org/rude/love/issues/1202/accelerometer-z-axis , the Java code for sending accelerometer data to SDL's C code has an incorrect Z-axis calculation.

Thu, 29 Sep 2016 16:37:08 -0700Fixed bug 3429 - Update AM_PATH_SDL2() to also check for SDL2.framework
Sam Lantinga [Thu, 29 Sep 2016 16:37:08 -0700] rev 10382
Fixed bug 3429 - Update AM_PATH_SDL2() to also check for SDL2.framework

neoaggelos

It is common for Mac OS X to use the SDL2.framework instead of the classic UNIX dynamic lib.

Therefore, it makes sense for AM_PATH_SDL2() to be able to locate it. Attached is a patched sdl2.m4 (updated for that purpose).

Changes:
* look for SDL2.framework ONLY if pkg-config and sdl2-config tests failed (this is to ensure compatibility with the old behaviour)

* adds option ('--disable-sdlframework') to retreat to the old behaviour

* adds variable 'SDL2_FRAMEWORK' for the user to specify the exact path to SDL2.framework (e.g. if it is installed in a non-standard location)

Open to suggestions for further improvements

Thu, 29 Sep 2016 16:10:08 -0700Added debug output for new window events
Sam Lantinga [Thu, 29 Sep 2016 16:10:08 -0700] rev 10381
Added debug output for new window events

Thu, 29 Sep 2016 16:05:29 -0700Implemented SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH on X11
Sam Lantinga [Thu, 29 Sep 2016 16:05:29 -0700] rev 10380
Implemented SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH on X11

Thu, 29 Sep 2016 14:48:33 -0700Added Windows support for SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH
Sam Lantinga [Thu, 29 Sep 2016 14:48:33 -0700] rev 10379
Added Windows support for SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH

Thu, 29 Sep 2016 13:34:49 -0700Generalized the hint for whether the application gets a mouse event when clicking on the window to activate it, and is now named SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH.
Sam Lantinga [Thu, 29 Sep 2016 13:34:49 -0700] rev 10378
Generalized the hint for whether the application gets a mouse event when clicking on the window to activate it, and is now named SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH.
The behavior is defined to not receive the click event, and this hint allows you to override that.

Thu, 29 Sep 2016 03:59:04 -0700When clicking on a window to give it focus, don't pass the mouse click to the application.
Sam Lantinga [Thu, 29 Sep 2016 03:59:04 -0700] rev 10377
When clicking on a window to give it focus, don't pass the mouse click to the application.

Thu, 29 Sep 2016 12:04:07 -0400Updated Linux notes on building with Mir and Wayland support.
Ryan C. Gordon [Thu, 29 Sep 2016 12:04:07 -0400] rev 10376
Updated Linux notes on building with Mir and Wayland support.

Wed, 28 Sep 2016 22:24:01 -0700Updated version to 2.0.5 in preparation for release
Sam Lantinga [Wed, 28 Sep 2016 22:24:01 -0700] rev 10375
Updated version to 2.0.5 in preparation for release