| Summary: | [Android] Joystick Button Mappings are strange | ||
|---|---|---|---|
| Product: | SDL | Reporter: | David Brady <dbrady> |
| Component: | joystick | Assignee: | Gabriel Jacobo <gabomdq> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | API change | ||
| Priority: | P2 | CC: | gabomdq, philipp.wiesemann |
| Version: | HG 2.1 | ||
| Hardware: | All | ||
| OS: | Android (All) | ||
| Attachments: |
Patch to re-assign button IDs
Sort Joystick axes Fix for typo in button ID patch Corrected sorting patch |
||
Created attachment 1530 [details]
Sort Joystick axes
Related to this bug... This isn't the best solution to the problem, but joystick axes can come in a semi-random order. This simply sorts them by axis ID, which works well for standard controllers (even more so if #2229 were accepted). It might be better to explicitly reorder the left and right sticks to the first 4 axes, then sort the rest. But I wanted to keep it simple.
Created attachment 1531 [details]
Fix for typo in button ID patch
(In reply to David Brady from comment #1) > Created attachment 1530 [details] > Sort Joystick axes > > Related to this bug... This isn't the best solution to the problem, but > joystick axes can come in a semi-random order. This simply sorts them by > axis ID, which works well for standard controllers (even more so if #2229 > were accepted). It might be better to explicitly reorder the left and right > sticks to the first 4 axes, then sort the rest. But I wanted to keep it > simple. The Comparator's compare() method could be simplified by just subtracting the two values. It does not have to be exactly -1/0/1 just negative/0/positive. [1] [1] http://developer.android.com/reference/java/util/Comparator.html#compare(T, T) Can you update your axis sorting patch with Philipp's recommendation (and fix spacing while you are at it :) ) Also, we don't use tabs, just four spaces, and comments use the old ANSI C style only (playing along with the fantasy that we are ANSI C compatible). The button patch (with tabs fixed ;) ) is here: https://hg.libsdl.org/SDL/rev/7e01e3908f41 Created attachment 1534 [details]
Corrected sorting patch
Thank you Gabriel. My apologies for the style, I forgot to fix it up. I'll be better about that in the future. Here's the corrected patch.
There was a missing "import java.util.List;" :) Fixed in https://hg.libsdl.org/SDL/rev/d7b7ec662687 |
Created attachment 1529 [details] Patch to re-assign button IDs The GameController API is very nice, but it would be great to fall back to the Joystick API if the GameController is not mapped. But sadly, the button IDs for SDL Android do not correspond even slightly to button mappings on other platforms. I would like to re-order the default button IDs to be somewhat reasonable, so that even unsupported controllers can be a little playable. Patch is attached which reorders the basic joystick button IDs to match the GameController API (where applicable).