Suggestions for Joypad and Android

Got a cool idea that should be in R'n'D? Let's hear it!

Moderators: Flumminator, Zomis

User avatar
ango
Posts: 20
Joined: Sat Jun 10, 2017 9:38 am
Location: Germany

Suggestions for Joypad and Android

Post by ango »

First I like thank you for this great game.
I grew up with the C64 & Amiga. Emerald Mine was one of my favorite game. I still play it on an amiga emulator.

Some suggestion/wishes:

PC:
I´d like to play RnD on PC with my gamepad (XBox Controller) but I can only use the left stick and no buttons are working for "snap" and "drop".
The control is very slippery after calibrating. Would it be possible to remap the gamepad buttons? I also like to use the "dpad" but it is not recognized.

Android:
It would be great to use a Gamepad for the android version of RnD. I´d like to play RnD on my TV with Amazon Fire TV Stick. It would be a great game for the Fire TV Stick.
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Suggestions for Joypad and Android

Post by Holger »

Hello ango, welcome to the forum! :-)

Regarding your suggestion/wishes for better game controller support: Yes, this is indeed something that's still missing for the (already a few years old) SDL2 port of R'n'D. With the old SDL (1.2), there was simple joystick support which worked quite well (and which should theoretically still work with SDL2, and apparently does), but with the SDL2 version, it seems that it only offers very limited support for today's input devices. :-(

Adding support for SDL2's new "GameController" functionality shouldn't be too hard, though, and I will check if this can be done without too much effort. (Adjusting the joystick support in the setup menu may be a different thing, especially when it comes to supporting buttons and "dpad" style input devices for handling directional input. I'll check this too.)

Regarding the Amazon Fire TV stick: Does it run the existing (apk) R'n'D Android version natively (minus decent game input), or would this require building a different package for this device? (That is, can you install "normal" Android apps on the Fire TV stick?) If the game app/apk already runs natively, maybe it would already be playable with SDL2 GameController support added. (Although it would be interesting to know if some of the (few) buttons on the stick's remote could be mapped to "snap" and "drop"...)
User avatar
ango
Posts: 20
Joined: Sat Jun 10, 2017 9:38 am
Location: Germany

Re: Suggestions for Joypad and Android

Post by ango »

Yes, the app is running with the android natively version on my Fire TV Stick, but I could not start a game, because of the controller Problem.
I only could use the menu with "up" and "down" and "right" to join the submenu. The fire buttons have no function at the moment.

By the way , it makes a lot of fun to play this game on a pc. Thank you very much !
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Suggestions for Joypad and Android

Post by Holger »

I've checked the currently implemented joystick handling in R'n'D again, and I think it could easily be improved a little bit.

Currently, the main problem is that only axis 0/1 and buttons 0/1 are recognized; all other axes and buttons are simply ignored. This is no problem for classic C64/Amiga style joysticks (with just two axes (X/Y) and two fire buttons), but provides only very limited support for modern game controllers (like the Xbox 360 controller with lots of axes and buttons). (This seems to be especially true for the buttons part, as it seems that there are no default "left and right fire button" buttons anymore, but a whole lot of different buttons that can be mapped to various functions in various games.)

These observations seem to match your experience with the PC version with the Xbox game controller: Apparently, the left analog joystick is detected as the first two axes, while the other sticks are ignored. This stick being an analog joystick probably also explains why it feels slippery (as games like R'n'D are best played with a digital joystick). This could/should be improved (dead zone for middle position), but the real solution would probably be using the D-pad for R'n'D game controls. As the D-pad buttons are buttons and not axes, this would require some bigger changes in the R'n'D game controller code, but would definitely be worth it. Another obvious improvement would be mapping snap/direction buttons to the A/B/X/Y buttons (just as the TAS snap keys currently work).

Regarding R'n'D on the Fire TV stick: Apparently the direction buttons are already mapped to either cursor keys or joystick axes, so this already works. So there only has to be support for default fire buttons added.
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Suggestions for Joypad and Android

Post by Holger »

Update:
it seems that there are no default "left and right fire button" buttons anymore
As far as I understand from the SDL2 source code, this will always be the A/B game controller buttons. (I have ordered a Xbox 360 game controller to be able to test all this by myself. :-) )
User avatar
ango
Posts: 20
Joined: Sat Jun 10, 2017 9:38 am
Location: Germany

Re: Suggestions for Joypad and Android

Post by ango »

Thanks for your detailed explanation.
You put a lot of work into the game. Many Thanks. :D
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Suggestions for Joypad and Android

Post by Holger »

Another update:
This stick being an analog joystick probably also explains why it feels slippery (as games like R'n'D are best played with a digital joystick). This could/should be improved (dead zone for middle position)
Just had a quick look how it's currently handled in the R'n'D code: It generally uses a 25% dead zone (which means that moving the stick should not trigger unless it was moved at least 25% of the way from the middle position to the maximum outer position). So in theory it should not be slippery (unless very worn). Maybe this threshold should be made configurable somewhere in the setup menu, to increase/decrease sensitivity. (I'm curious to test for myself soon; maybe something different is wrong here.)
You put a lot of work into the game. Many Thanks.
I'm pleased that you like it! It was (and still is) a lot of fun writing and maintaining it. :)
User avatar
ango
Posts: 20
Joined: Sat Jun 10, 2017 9:38 am
Location: Germany

Re: Suggestions for Joypad and Android

Post by ango »

I'm pleased that you like it! It was (and still is) a lot of fun writing and maintaining it.
I'm not alone, my mother was playing it on the Amiga too. She is looking forward to play it on tv with the fire tv stick.
By the way, she is 75 years old :wink:
User avatar
ango
Posts: 20
Joined: Sat Jun 10, 2017 9:38 am
Location: Germany

Re: Suggestions for Joypad and Android

Post by ango »

...maybe I could help as a beta tester (android/fire tv stick or PC) :wink:
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Suggestions for Joypad and Android

Post by Holger »

I'm not alone, my mother was playing it on the Amiga too. She is looking forward to play it on tv with the fire tv stick.
By the way, she is 75 years old :wink:
I am happy to hear this, and I will do my best to make it possible! :-)

BTW: There seem to be quite a number of R'n'D players that I have heard of, that do not fall into the "usual" or "expected" age range for playing computer games, but who are much younger or older than expected. And I'm happy about this. :-)
...maybe I could help as a beta tester (android/fire tv stick or PC) :wink:
Definitely yes, any help is highly appreciated -- especially for tests on systems I do not have direct access to by myself (like the Fire TV stick, although I'm tempted to just order one, to be able to do tests by myself :-) ).

I will then post a link to download/install an APK for testing here!

Currently I'm struggling with the Android version in general... Apparently I am not able to build a stable Android version at the moment for whatever strange reason. I've already checked two backups from December and April (with the complete development environment, including Android SDK) without success (app is stopping randomly without any message in the Android system log file). This has to be sorted out first... :-/

Besides this, I have very different results with different versions of SDL2 (with versions between 2.0.0 and 2.0.5, plus current Mercurial checkout) regarding game controller support. For example, SDL2 2.0.1 does not detect a game controller on Android (not supported in that version yet), but apparently processes D-pad events as cursor keypress events anyway (this is most probably why you can use the Fire TV remote to navigate the menu, although without buttons), while SDL2 2.0.2 detects the controller as a "simple" joystick (but not as a game controller), but completely ignores the D-pad buttons. :-(

I'll do a lot more tests, and write an update as soon as I know more...
User avatar
ango
Posts: 20
Joined: Sat Jun 10, 2017 9:38 am
Location: Germany

Re: Suggestions for Joypad and Android

Post by ango »

Too bad, but my programming skills lie 30 years back. But I'm good at testing programs :D

I am a computer freak since the Sinclair ZX81 :wink: and I would be glad to help you to test it on Android, Raspberry Pi or PC.
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Suggestions for Joypad and Android

Post by Holger »

In the meantime, I have done a lot of tests and programming regarding the use of game controllers and Fire TV.

Fortunately, I have always, since the beginning of R'n'D in 1995, tried hard to make sure that R'n'D is always playable with a joystick with two fire buttons (although many people suggested to extend this to also use various keyboard keys for various extra functions in the game, but I always hesitated to add such extra input methods). So adding support for input devices such as game controllers or even the Fire TV remote control should be easy or at least possible.

To be able to check and develop this "hands on" with different platforms and devices, I've bought two game controllers (an Xbox 360 game controller with USB cable, and a SnakeByte Bluetooth game controller for Android devices with some extra Android buttons) and an Amazon Fire TV stick with remote control.

First on the two game controllers:
PC:
I´d like to play RnD on PC with my gamepad (XBox Controller) but I can only use the left stick and no buttons are working for "snap" and "drop".
The control is very slippery after calibrating. Would it be possible to remap the gamepad buttons? I also like to use the "dpad" but it is not recognized.
This now works all just as it should, out of the box. You even don't have to configure anything in the "setup" menu in R'n'D. Just connect the Xbox game controller and start R'n'D, and everything should instantly work as expected. You can even use the "start" button on the controller as "play/pause" button (from the main menu and/or within the game), and the "back" button to stop a game (or use it for "cancel" in the request dialogs). The "A", "X" and "left shoulder" buttons work as first button ("snap"), while the "B", "Y" and "right shoulder" buttons work as the second button ("drop") in R'n'D. For navigating the menu and the player in the game, either the left stick, the right stick or the DPAD buttons can now all be used.

The "setup->input->joystick" menu is now only needed for playing local multi-player games, to be able to assign different input devices to different players. If no joysticks are assigned to any player in the "input devices" menu, all connected joysticks can be used to control the menu and the player in the game.

This now works fine with both the USB game controller and the Bluetooth game controller (as tested on my Android phone). Some game controllers require mapping files to be fully supported (while the Xbox game controller seems to be supported "out of the box" without any mapping file). Game controllers without mapping files should be supported as ordinary two-axis, two-button joysticks. But I will replace the old "calibrate" screen in the "input devices" menu (which is not really needed anymore, as today's game controllers and joysticks are all calibrated just fine these days) with a new "configuration" screen to be able to map all axes and buttons of "unknown" game controllers to their correct locations.

And now to the Fire TV stick:
Android:
It would be great to use a Gamepad for the android version of RnD. I´d like to play RnD on my TV with Amazon Fire TV Stick. It would be a great game for the Fire TV Stick.
Yesterday, I got my Fire TV stick, and instantly installed R'n'D on it and did some first tests with it. The first observation is that the remote control does not work at all with it anymore (neither up/down/left/right navigation or select button, nor any of the other buttons). This is because the current release version 4.0.0.2 of R'n'D for Android still uses SDL 2.0.0 or 2.0.1, which effectively still does not have game controller support for Android. Because of that, the remote control buttons were still mapped as key events to the application -- that's why you were able to use them to navigate in the menu. Since SDL 2.0.2, there is now full game controller support for Android, and the navigation of the Fire TV remote control is now mapped to joystick / game controller buttons. As there is no mapping for the Fire TV remote control yet, it is not yet fully supported as a game controller, but only as an "unknown" joystick with button mappings that are not yet recognized by R'n'D (because the remote control navigation is not mapped to usual joystick axes, but to DPAD buttons, which are not recognized by the joystick mappings). So all that is missing for full Fire TV remote control support seems to be a came controller mapping file. I will try to create one today... :-)

But what already works great with my current working version of R'n'D is support for the Android Bluetooth game controller! I've connected it to the Fire TV stick in the "settings" menu of the Fire TV, and R'n'D can fully be played with it "out of the box", just like on the PC or on my Android phone! :-)

So it seems that only a few steps are missing now for full game controller support (game controller configuration screen in R'n'D for new/unknown game controllers) and for full Fire TV support (creating a game controller mappings file for the remote control, which then has to be bundled with the R'n'D APK).

I'll keep you updated on further progress, and hopefully release a new R'n'D version with all those new features soon!
User avatar
ango
Posts: 20
Joined: Sat Jun 10, 2017 9:38 am
Location: Germany

Re: Suggestions for Joypad and Android

Post by ango »

WoW! That's a big step forward. I'm looking forward for the next release. :D

I had also thought of a missing mapping file on the android version, because some emulators for the Raspberry Pi using mapping files to onfigure a controller. The mapping file should be accessible for future settings.

I´m very happy about RnD's progress. :wink:
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Suggestions for Joypad and Android

Post by Holger »

I am a computer freak since the Sinclair ZX81
Just had to comment on this one! :-)

Although I did not own/use this classic home computer by myself (I've started with the C64, as many did), a friend in school had this machine. As far as I remember, it had 1 KB RAM, and my school friend extended the RAM memory of his ZX81 by soldering some more RAM to the mainboard, up to something like 4 or 8 KB... :-D
So all that is missing for full Fire TV remote control support seems to be a came controller mapping file.
I had to adjust the game controller calibration program for the Fire TV, to be able to skip unused game controller buttons in the calibration process (as the Fire TV's remote control obviously does not have all those axes and buttons that is available on a standard Xbox style game controller). (Skipping unused axes and buttons is done via keyboard keys or touch screen input, which are both not available on the Fire TV remote, so I had to add the Android "menu" key/button for this purpose, which is also available on the Fire TV remote control.)

So the R'n'D APK now ships with a mappings file that finally also contains the mappings for the Fire TV remote control!

To make everything work conveniently, I also had to patch the SDL 2.0.5 code to add support for the "rewind" and "fast-forward" buttons (bottom left and right on the remote control), which are not supported by the current SDL version. This finally gives the following key/button mappings of the Fire TV remote control for R'n'D:

- up/down/left/right: usual navigation in menu and game
- select button inside the "navigation ring": left joystick button ("snap" in the game, "yes" in request dialogs, "return" key in the menu)
- back button: acts like the "escape" key in the PC version ("no" in request dialogs)
- home button (unused; cannot be used inside the app)
- menu button: acts as right joystick button ("drop" in the game, "yes" in request dialogs)
- play/pause button: acts like the "space" key in the PC version (start game in menu, pause/play in the game)
- rewind button: like left joystick button ("snap" in the game, "yes" in request dialogs)
- fast-forward button: like right joystick button ("drop" in the game, "no" in request dialogs)

You may wonder why "back" (on the left side of the remote control) and "menu" (right side) work as "no" and "yes", while "rewind" (left side) and "ffwd" (right side) work as "yes" and "no", which seems a bit confusing, as the "yes" and "no" buttons are placed left and right in the request dialogs. This is mainly because "back" is usually the logical choice for "no", so "menu" acts as "yes". Then, on some Android devices (like on my Samsung Galaxy S4 mini), the "back" key is on the bottom right and the "menu" key on the left side of the device.

I've also added an input device detection for the overlay virtual buttons, which are useless on the Fire TV (but not on a phone or tablet): If input from keyboards or game controllers is detected, the virtual button overlay is automatically faded out, while it is automatically faded in when input on touch devices is detected.

Finally, with all these additions and changes, it is not only technically possible to fully play R'n'D on the Fire TV, but it actually works very well and is a lot of fun to play R'n'D games with the remote control (which is surprisingly precise to control the player in the game, using "snap" and "drop" buttons just like it should be)! I was surprised how good it works, and played quite a number of the tutorial levels on the Fire TV!
Too bad, but my programming skills lie 30 years back. But I'm good at testing programs :D
You might want to try by yourself -- here's an APK for testing:

http://www.artsoft.org/RELEASES/rocksnd ... 0712-1.apk

Please let me know if it works for you!

If you also want a Windows (?) binary with the latest game controller code for testing, let me know! So far I've only tested the new game controller support on Linux and Android.

If all works well, I may be able to release a new version soon... :-)
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Suggestions for Joypad and Android

Post by Holger »

Some more thoughts in addition to my last post:
The mapping file should be accessible for future settings.
In "desktop" R'n'D (WIndows/Mac/Linux), it will be stored in a way so that it can easily be updated -- in the installation directory, and also in the personal data directory (for custom mapping files with additional mappings).

In "mobile" R'n'D (Android), it is part of the "assets" directory inside the APK, but there is also support for a custom mapping file in the personal data directory.

I have changed the personal data directory on the Android version from "internal storage" to "external storage" (which is usually also stored on the internal memory and not a potential SD card), which makes it possible to add more level sets. However, I am not sure if adding more level sets is possible on the Fire TV. Adding them to R'n'D on my phone is a bit tricky, but possible (for details, please see the thread "How to add levels to android version" in this forum), but I don't know if this is also possible on the FIre TV, as it does not have a file manager than runs with "system rights" (to be able to write to app data folders like that of R'n'D).

As you were able to run the current release R'n'D APK on your Fire TV, you might also have some knowledge (or might even just try) how to add a level set like "BD2K3" to the Android version on the Fire TV. The data folder should be something like "/.../Android/data/org.artsoft.rocksndiamonds/files/levels" or something like this, but I'm not sure if it is possible to write to this folder without rooting the device. (On my Samsung phone, a third-party file manager installed from the Google Play Store does not have the access rights to write there, but the internal Samsung file manager does. However, I think there is no internal file manager on the Fire TV. :-/ )
Post Reply