-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android-specific keys never trigger keyboard events #1479
Comments
… an active joystick. Fixes liballeg#1479
Correction: Even though the allegro5/android/gradle_project/allegro/src/main/java/org/liballeg/android/Key.java Lines 191 to 195 in 0be7a02
|
It seems weird to me to send duplicate events for a single key press. I would imagine the desired behavior is to either:
And, separately, they joystick API should surface all the relevant keys. I'll have to think about it some more. |
Thank you for your response.
If I may offer feedback, there seems to be a design issue. The Android game
keys are actually gamepad buttons and the dpad keys are unused. As far as I
know, only the Android version of Allegro maps gamepad button presses to
keyboard events. No other version does that, unless I'm mistaken. I can
connect a bluetooth controller and catch keyboard events.
I'm not sure why the Android version was designed in this way. Currently
I'm reading both joystick and keyboard input in order to check the state of
a gamepad.
Among the choices you have mentioned, never triggering the Android game
keys (and instead having to rely on the joystick API) would break backwards
compatibility, but it would be a better design choice (in my opinion),
consistent across platforms. The issue addressed here would not exist had
that been the adopted design. On the other hand, keeping the present design
and extending the button set in the joystick API would maintain backwards
compatibility, but it would not address the inconsistent behavior. Maybe
this behavior could be documented somewhere if it's wanted and kept.
In any case, it would be nice if we could read the buttons of a gamepad
entirely with the joystick API, using pre-defined button numbers for
predictability. See #1483, #1482.
Em dom, 8 de out de 2023 17:31, SiegeLord ***@***.***>
escreveu:
… It seems weird to me to send duplicate events for a single key press. I
would imagine the desired behavior is to either:
- Never send the "Android game keys" events
- Only send them if they joystick is not initialized
And, separately, they joystick API should surface all the relevant keys.
I'll have to think about it some more.
—
Reply to this email directly, view it on GitHub
<#1479 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABWCJLQVVVUTLVTSHSIF2DX6MET7AVCNFSM6AAAAAA5RLPXC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJSGE2TKMBUGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
This is probably the best option at this time (we can add an allegro5.cfg option to disable the old events). If I merge #1483 does this implement this or do we need more buttons? |
By the way, how do you test the gamepads? Does your Android device come with builtin buttons? Are you somehow attaching the gamepad to the device? I've tried it a bit with my phone and a F310 and didn't have any luck. |
There are two more game buttons defined on Android (KeyEvent): #1483 neither changes existing behavior nor adds an allegro5.cfg option. It only adds more joystick buttons. What would be the best course of action at this time? May I be of help?
I test with a bluetooth controller, using ex_joystick_events (I modify it and set the joystick ID to 1). I also do cross-testing with an external app I downloaded from the Play Store. |
I think the goal should be to get the Android joystick to be as good as possible, with all the keys mapped. The keyboard events should be left as is, and I'll add a config option to disable them. |
Okay. I can get BUTTON_Z and BUTTON_C mapped too for completeness. Getting the Android joystick to be as good as possible is a different issue with some design choices. May I give feedback on the matter? In order to make the Android joysticks better, I would change their button numbers so that they match the button numbers defined in Allegro's Windows XInput driver. I would do this to unify things using the Xbox 360 controller as a reference, because it's a very good reference with a known layout. Android game buttons have a known layout too, which is similar to and a superset of the layout of the Xbox 360 controller. It would be handy if the buttons defined in src/win/wjoyxi.c were defined the same way on Android. Out of the first 10 joystick buttons currently defined on Allegro for Android, 4 are defined in the same way as on wjoyxi.c (A, B, X, Y) and 6 are defined differently (L1, R1, DPAD_LEFT, DPAD_RIGHT, DPAD_UP, DPAD_DOWN). In order to get consistent input on XInput and on Android, an Allegro user has to remap these 6 buttons, when in principle there would be no need. Also, newly defined buttons will need remapping as well because of this mismatch. The Android joystick would certainly be better if we had a consistent mapping. Conceptually, it is already similar to the Xbox 360 controller. Would this be a worthwhile change? |
Whoops, forgot to respond. There's two things. First, is consistent cross-platform mapping, which should be fixed, but out of scope here. I just meant that the Android joystick has all the buttons/axes mapped.
I tried that with a USB controller, but it doesn't seem to see it, perhaps I need to edit the requested permissions. |
Would you like it fixed at this time? A consistent mapping already exists for controllers designed to be used with Android.
Have you tried it with a third-party app or with a different controller? Is your controller switch in XID mode?
Okay. I'm going to add Here is another design issue of the Android joystick of Allegro: the menu button, recognized as a joystick button by Allegro, is not strictly a gamepad button on Android. It used to be present on older phones, next to the back and to the home buttons. It's long gone from the phones, but you can still see it in remotes of Smart TVs. START, SELECT and MODE are gamepad buttons. Menu is not, but some manufacturers do implement it in their gamepads. Those who do often implement the Back button as well. In spite of this, the Back button is not recognized as a joystick button by Allegro. Back is also not strictly a gamepad button. I find it more common to see start & select instead of menu & back. In order to make the Android joystick better, we could design it in a more principled way, based on the Android documentation. Was the present design based on a specific controller? |
Now #1483 adds all gamepad buttons and improves the design of the Android joystick. |
Allegro defines a set of "Android game keys" in keycodes.h. Of the 18 defined keys, 10 never trigger keyboard events on Android after a successful call to
al_install_joystick()
:ALLEGRO_KEY_BUTTON_A
,ALLEGRO_KEY_BUTTON_B
,ALLEGRO_KEY_BUTTON_X
,ALLEGRO_KEY_BUTTON_Y
,ALLEGRO_KEY_BUTTON_L1
,ALLEGRO_KEY_BUTTON_R1
,ALLEGRO_KEY_DPAD_UP
,ALLEGRO_KEY_DPAD_DOWN
,ALLEGRO_KEY_DPAD_LEFT
,ALLEGRO_KEY_DPAD_RIGHT
.ALLEGRO_KEY_START
,ALLEGRO_KEY_SELECT
,ALLEGRO_KEY_BUTTON_L2
,ALLEGRO_KEY_BUTTON_R2
,ALLEGRO_KEY_THUMBL
,ALLEGRO_KEY_THUMBR
,ALLEGRO_KEY_DPAD_CENTER
,ALLEGRO_KEY_SEARCH
.ALLEGRO_KEY_MENU
, although not defined side-by-side with the Android game keys, also never triggers a keyboard event.The keys that never trigger keyboard events are instead mapped to joystick input. Conversely, the keys that are not mapped to joystick input trigger keyboard events.
The present state of things leads to inconsistent behavior: in order to detect if the START button has been pressed, I have to listen to keyboard input. On the other hand, if I want to detect A, B, X, Y, I have to listen to joystick input. Other buttons behave in the same way: L1/R1 are detected as joystick input only, whereas L2/R2 are detected as keyboard input only.
Since Allegro defines 18 "Android game keys", could we have them all trigger keyboard events?
AllegroActivity
to the XInput button numbers defined in src/win/wjoyxi.c for consistency.al_install_joystick()
. Once you do and it succeeds, Allegro blocks 10 keys (in addition to the menu key), leading to inconsistent behavior.The text was updated successfully, but these errors were encountered: