Gamepad reader

Post screenshots, binaries and projectfiles of the projects you have made with ZGE that you want to share!

Moderator: Moderators

User avatar
Ats
Posts: 716
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Gamepad reader

Post by Ats »

Following that joystick topic, I wrote a simple Gamepad reader in order to know which button is where.

I've tested it flawlessly with 4 different gamepads at the same time: Then I tried to launch it on the Ouya but didn't get any input. I guess It will not be that simple after all... :lol:
Attachments
GamepadReader.zgeproj
Gamepad Reader - v2
(31.59 KiB) Downloaded 898 times
Last edited by Ats on Mon Oct 07, 2013 11:49 am, edited 2 times in total.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Hi Ats, joystick-related functions work fine. FYI joyGetAxis(?,2) can also be sometimes used; on my Logitech WingMan it handles small "analog" slider.

A special external library calling internal Java API should be used for Ouya controller instead of built-in ZGE functions. I could create such a library, but do not have Ouya device to test it. Is there some emulator of Ouya emulating also functionality of its controller?
User avatar
Ats
Posts: 716
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

Cool, I'll add that new axis to the app :)

There is one emulator but it seems that it's not working anymore due to wifi needs... http://ouyaforum.com/showthread.php?813 ... el-x86-x64
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Ats wrote:There is one emulator but it seems that it's not working anymore due to wifi needs... http://ouyaforum.com/showthread.php?813 ... el-x86-x64
I'm afraid this is a standard AVD emulator with special Ouya image which do not allow emulation of the Ouya controller. It has just software buttons displayed on screenshots and mouse used to emulate finger touches.
User avatar
Ats
Posts: 716
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

Too bad... Otherwise, I can test your builds. Or best, I can change your code if needed if you explain me a bit how do you call the JAVA library.

By the way, does someone other than me owns a Ouya?


Edit:
I've edited the first post to add the new version.
In fact, for the case of the Xbox360 controller, there was up to 5 axis :)
User avatar
Ats
Posts: 716
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

Now that I'm back, I'm more than ever interested to learn how to make an external library for ZGE in order to handle the controller API of the Ouya:
https://devs.ouya.tv/developers/docs/controllers

Can someone point me in the right direction ?
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Ats, to build Android library, you should use NDK to compile C/C++ code. Since there is no direct support for OUYA controllers in NDK, you should use JNI whch is quite cumbersome, but works. However, there are some good news:

1. OuyaController class is simple and writing such a wrapper would be relatively simple task,
2. ADT works fine also for OUYA, so looking at logs and debugging is possible,
3. there is available source code for such wrappers to other engines; for instance, for GameMaker, and
4. there are some discussions and hints how to do it available at various developer fora; just put "OUYA controller NDK" to Google.

This might be a good exercise to create external library for ZGE. If you still have some doubts, I could try to do it, but I do not have OUYA at home. So no possibility to test it or event try. This makes development of Android library very difficult; usually, there is a lot of try/fix cycles.
User avatar
Ats
Posts: 716
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

Thanks Rado1. Yes, it seems like a good exercise.
Maybe a bit difficult for a first, I'll surelly have questions :)

(The thing I like in ZGE is that you don't have to setup a SDK in order to make something)
User avatar
Ats
Posts: 716
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

So after a bunch of tries, I managed to compile the hello-jni sample from ndk into an apk that works on the Ouya.

Problem is: I have no idea what I'm doing, or more precisely, where I'm heading... An external library for ZGE should be some kind of DLL, right ?
Maybe it would be simplier if you started making some kind of skeleton that I could complete because I'm quite lost right now...
Thanks for you help !
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Ok Ats. I'll try to implement shared library (.so file) for Ouya controller. This will require some preparation and study of Ouya API, NDK compilation practices for Ouya, possibilities of emulation, etc. I'll start probably next week.
User avatar
Ats
Posts: 716
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

Oh thanks!
I look forward to see how you do it.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

The first success with OUYA controller in ZGE is here! After reworking Java "glue" for compiling ZGE Android applications, KeyPress component can now read buttons from OUYA controller. See the attachment. If you have OUYA, you can also test the compiled application; the app is terminated by double-clicking the MENU button (in the middle of controller). The current solution still does not differentiate between different controllers connected to one OUYA device, because it uses the standard mechanism for processing keyboard events.

Please note, this is just the first step towards the final solution. The idea is to support any gamepad on Android, not only OUYA, in the same way how ZGE handles them on Windows; i.e., by functions joyGetButton() and joyGetAxis().

Technically, the solution will use built-in Android features available from Android 3.1 (API level 12). BTW it's maybe time to update from minimally supported API level 8 to API level 12. (???).

There is no need for external library as I originally thought; everything will be implemented in Java. With help of Ville, who will provide native methods to consume button and joystick events, I hope ZGE can support gamepads on Android soon. Quite a nice feature for creating games. Then, ZGE should be added to the official list of tools for OUYA; nice marketing, isn't it?

I'll keep you informed about further progress.
Attachments
OUYA.ZIP
OUYA application for reading controller buttons
(317.32 KiB) Downloaded 863 times
User avatar
Ats
Posts: 716
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

Awesome!!!

And if you manage to get gamepads directly working on Android, it will be perfect for all future consoles running on this system (Amazon, Google...)

Now if ZGE is added to the official list of tools for OUYA, that would be quite the publicity stunt. A 3D engine that's easy to use and don't need a NASA machine in order to work!? Be prepared to have new users and questions soon on the forum. :lol:
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

ZGE supports OUYA now!!!

With help of Ville, who created native Android interface to the existing ZGE mechanism of processing joysticks, I implemented the Java and ZGELibrary parts of the connector to gamepads/joysticks on Android.

If you have Ouya, you can test the attached application. Just install, run, and press buttons, move joysticks, etc. Select the active controller with touch-pad and tapping on the touch-pad anywhere else than the controller selection strip exits the application.

Unfortunately, I have only one Ouya controller, so I'm not able to test the implementation with several controllers. If you have more than one controller, please help me to test the app for multiple ones. This is the area where the implementation can be improved for future, but without testing I'm not sure whether it is really necessary. If you have also other kinds of gamepads that can be connected to Android devices, please thest them as well. Thanks.

In addition to the testing app, the attachment contains also modified Zge.java and updated libzgeandroid.so from Ville, so you can compile your Ouya applications by yourself. Please note, you need to change all references to Android API level from 8 to 16 in each auto-generated building file.

Have a fun!

For Ville:

Would it be possible to add this stuff to the official ZGE distribution? The testing project contains also ZLibrary of Android gamepad codes, so it can be included to the list of standard libraries available by context menu.

Ouya is working on Android 4.1.2 (API level 16) and standard ZGE is compiled against level 8 now. There can be a selection of API level in Android settings used for pre-generating of Android building files. Option for level 16 could have text like "Level 16 (OUYA)".

P.S. Thank you Ats for support and helping me with hardware! Now, you can make your games running also on Ouya.
Attachments
OUYA.ZIP
Test of OUYA controller - apk, ZGE project and changed ZGE build files.
(562.5 KiB) Downloaded 871 times
screenshot
screenshot
scr.jpg (41.36 KiB) Viewed 29069 times
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

In meantime I tested Ouya and ZGE implementation also with pretty old Logitech WingMan Action gamepad and it works fine (except of different mapping of buttons). Also connection of several gamepads at one once works without problems. BTW I found and fixed one typo in the testing application attached to my previous post; so if you want to use it download it again.

BTW Chrome download reports "OUYA.ZIP is not commonly downloaded and could be dangerous." even if it is not dangerous... just keep it.
Post Reply