Joystick/gamepad in android

Joystick/gamepad in android

Did anybody managed to detect & receive events from gamepad (i.e. ps4 gamepad) in android app? If yes, can you share some code, please?

We have some examples in cpp-tests, GameControllerTest.cpp.

I saw these tests, even write some test app to see how EventListenerController works. Unfortunately, it works only on ios, and not catch anything on android, at least on my huawei tablet with android 9.0 with ps4 gamepad (and with uses-feature “android.hardware.gamepad” in manifest), despite “real racing 3” catch and use ps4 controller without any problem. Tomorrow will try to catch gamepad input events directly from android via handmade java stub, and if will managed to catch any, then is something wrong with android gamepad support in cocos2d-x.

Upd: I’m successfully read gamepad buttons via java class and callback readings back to c++ code, so it is obvious that cocos2d-x gamepad implementation not work, or at least, it is some tricks unknown to me. Will be creating handmade android gamepad support :frowning:

Upd2: At last, after deep dive into java language whole day, i figured out how android gamepad support works in original cocos2d-x. My bad (my anroid/java skill is really low) - with some android project tricks, it really works! Unfortunately, i’m already write my own gamepad implementation in java classes, which in many parts is much better than in cocos2-x, less error-prone and able to catch events from attached/paired keyboard too. So, i decide to merge “best of two worlds”, and create solution, compatible with EventListenerController philosophy.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.