AE - Controller

Previous topic - Next topic

MrPlow

Hi Space fractal et all,

Any chance you could tell me what layout you used in Karma Miwa....I think I could get standard controllers to work on Android game if i knew your mapping for the Joypad... The mapping is totally different but handy to know so that others could use the OUYA and XBOX mappings slightly different to make a standard USB OTG controller work out of the box.

Also, I cant get the Gamecontroller to provide any response so not sure what I am doing wrong...




Code (glbasic) Select


GameController("update")
// checkkeys has the mouse and gamecotroller checks
checkkeys()

...
FUNCTION checkkeys()
IF (GameControllers("Left", 0)>600 OR GameControllers("PadL_Left", 0)>600) THEN sdir# = -(2.4*speed*extraspeed)
IF (GameControllers("Right", 0)>0 OR GameControllers("PadL_Right", 0)>0) THEN sdir# = (2.4*speed*extraspeed)

ENDFUNCTION


Do i need to add anything else?
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

#1
you could just have posted in the previous thread, but anyway, dont worry :-D.

For Karma Miwa, remapping is NOT supported for regular Android Devices. So its wont work with generic Android Controllers on that game at all (im have just not shown the required RemapButton string at all), but Genius Greedy Mouse should do. Im do should fix that issue for that game throught.

But anyway, Look in the AndroidSample how the thing works, its all there, include how remapping work. There is a line you should checkout:
Android.GameControllersSetLayout$("Left=Go Left;Up=Go Up;Right=Go Right;Down=Go Down;b1=Button 1;b2=Button 2;b3=Button 3;b4=Button 4")

This must been done somewhere in your init code. Without it, the GameControllers wont work at all. You might want to change the string to suit your game.

Then you need to show Android.ButtonRemapMessage$ to the user, if its have some content.

Also some older AndroidExtras was quite buggy about remapping or diddent work correctly. Sorry about that. That mean you need to update your AE to newest version and using the Android. extension. Here im will simplt not support older AE anymore (im cant keep multiple AE versions).

Howover again, its most suited for uses with Ouya and Gamestick, when im designed it. Remapping generic controllers is not saved yet. This is something im should take a look on. That mean the users need remapping each time the app is started up, but howover the string is shown automatic when its happens.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

#2
Thanks SF,

Do I need to EXTRASSTARTUP() ??

Looks like I may have to try update my AE code....is there a manual way to update to the new version over an old version for 1 app in particular?

(as I am worried the app might not compile with a full AE update or IAP might fail etc...)

BTW - Your Karma Miwa WILL work with standard controllers....but with different mapping so ....

b1 = right, b2 = left and left pad or dir equals Fire / jump

:)

Thats what I am hoping to map to for my app. I have tried with 2 USB controllers so far and both work on Karma Miwa.

Plus remap with Greedy Mouse works also...is that older or newer AE?
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

Its a bug in Karma Miwa, which havent take account to the remapping string. So yes controllers works, but users dont know what input mapping does. Im thinks im should fix that one to show that farmous string (which is all missing to get that working). Greedy Mouse is howover aware of that and show correctly the string required, so user can remap thier controllers.

You should also testing Android Sample with your controllers. Here you see what its happens and how its works.

EXTRASSTARTUP() is changed to Android.Init() for the new AE, which is the only real command renamed change. that command correct the orientation issue.

Also Android. is needed to all AE commands that is called in AndroidExtras.gbas only. But its is NOT needed for AE commands used other gbas files (such as inapp purchases, which uised AE calls in a another gbas file, they was not renamed at all).

Also its would been nice to show the input both of your controls uses, which can been shown in the Android Sample. Then im can add them as a known controllers, so its all remapped directly.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

Hi SF,

How do i get a sample to give the result of the joypad controller back to screen?

Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

#5
not sure what you mean. But for the code thing, that is correct. There is two thing missing.

- Android.GameControllersSetLayout$ is required start of your code.
- Android.ButtonRemapMessage$ need to been shown to the screen, if its have any content.

For the Android Sample, its on this folder:
GLBasic_v12\Compiler\platform\android\Android Extras - API 18
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

Quote from: spacefractal on 2014-May-16
not sure what you mean. But for the code thing, that is correct. There is two thing missing.

- Android.GameControllersSetLayout$ is required start of your code.
- Android.ButtonRemapMessage$ need to been shown to the screen, if its have any content.

For the Android Sample, its on this folder:
GLBasic_v12\Compiler\platform\android\Android Extras - API 18

Thanks!
Is there an equivalent of Android.GameControllersSetLayout$
for the older version of AE?
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

im do not support older AE, so im cant keep multiply instances of it. So you need to update AE to get the bugfixes.

But howover you dont need to replace AndroidExtras.gbas to the newer version, but more instead, just copy/paste the required funtion to the older AndroidExtras.gbas you have. Here the function is named GameControllersSetLayout$[/b], so just copy/paste it to your old AndroidExtras gbas and uses it there.

No functions in Java Calls did got changed, but added some functions.

Same with Android.init() aka EXTRASSTARTUP(). Its required to correct the wrong screen orientation.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

Hi Guys

This link doesnt seem to work
http://www.spacefractal.com/files/GlBasic-Android-api16.zip

Any other link for the just the small AE gbas file as I need a function from it.

G
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Ian Price

I've attached just the latest AE (I think) bits (including IAP stuffage).
I came. I saw. I played.

MrPlow

Great stuff! Thanks Ian.
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

#11
I'm cheks the issue when home. There is no update yet, I'm removed it, because the most recent ae update required sdk API-18 with a new installer, so I'm created the upgrade installer instead. I'm have not since updated it. That can been why.

EDIT:
Im sometimes rename the link, but when im does, its allways can been checked out in the Android News thread.

Here is the newest version with sdk:
http://www.glbasic.com/forum/index.php?topic=9644.0 (Links & Downloads & News for AndroidExtras)

Im wont do direct link here, because the download link will change sooner or later, so better to do checkout that thread. By now newest version is v2.2 and hopefully im got proguard disabled (due im did have some issues, so its still not configurered correctly yet). You should not see anything relavent to that. But you can eventuelly keep the old AndroidExtras.gbas and copy/paster fom the newer version eventuelly to keep compatible.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

I must be using the controller option wrong somehow ...

While true
GameControllersSetLayout$() // tried this outside and inside loop
Gamecontroller("update")

if Gamecontroler("Left",0)>600 etc...  (note: Is playerid always zero for android?)
    movesomething()  // nothing

endif

Print ButtonRemapMessage$, 100,100 // nothing

showscreen
wend

Any ideas??

Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

GameControllersSetLayout$() cant been empty. This is NOT need to been in main loop, only in the init. Its just send the GameControllers.java, how the remapping should work and in which order to remap.

something like this (please ad the code tag for any code (for AE v2.2, im NOT supporting older versions, sorry for that):
Code (glbasic) Select


// important to add some string, so GameControllers.java can send back user text what to remap, games uses different layouts).
Android.GameControllersSetLayout$("Left=Go Left;Up=Go Up;Right=Go Right;Down=Go Down;b1=Fire;")

While true
Android.Gamecontroller("update")
if Android.Gamecontroller("Left",0)>600 etc...  (note: Is playerid always zero for android?)
    movesomething()  // nothing

endif
Print ButtonRemapMessage$, 100,100 // nothing

showscreen
wend


playerid is zero allways for android (due its only supports one controller), but on Ouya and GameStick, its support 4 controllers. Also im have fighted with the playerid issues (im property relook if there is any issues left in this weekend), which im thinks its got fixed in a quite recent AE version (its was often -1, also a undetected controller).

Also did the v2.2 AndroidSample work with your controller?
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

#14
Hi Space Fractal,

Only reason I left it blank was the defaults looked fine...Are they wrong and need to be changed?

Code (glbasic) Select
FUNCTION GameControllersSetLayout$:layout$=""

IF layout$=""
layout$="Left=Move Left;Right=Move Right;Up=Move Up;Down=Move Down;b1=Button 1";
ENDIF
CallJava$("JoySetButtonLayout:"+layout$)
ENDFUNCTION


Whats the difference with Move Left and Go Left or will they both work?
I am still using my older AE setup and have only added this extra function...
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs