Main forum > Tutorials

How to uses GameInput API.

(1/2) > >>

spacefractal:
Download link for GameInput API:
https://www.dropbox.com/s/1o0frsdrqzhjz57/EXTRAS.zip?dl=0

GameInput API is a replacement for Android.GameController$() code, except its runs on more platform than just Android. Here its also supports iOS, tvOS, Pandora and Windows as well.

1. A basic uses for GameInput code could been something like this:


--- Code: (glbasic) --- LOCAL Left, Right, Up, Down

GameInput.update()
GameInput.SetPresaure(0) // Analog Presaure is supported on iOS only, include all buttons on that platform.

FOR i=1 to 2
Left=GameInput.LeftStick_Left(i)+GameInput.Left(i); IF Left>1 THEN Left=1
Right=GameInput.LeftStick_Right(i)+GameInput.Right(i); IF Right>1 THEN Right=1
Up=GameInput.LeftStick_Up(i)+GameInput.Up(i); IF Up>1 THEN Up=1
Down=GameInput.LeftStick_Down(i)+GameInput.Down(i); IF Down>1 THEN Down=1


A=GameInput.ActionButton("A", i)
B=GameInput.ActionButton("B", i)
Y=GameInput.ActionButton("Y", i)
X=GameInput.ActionButton("X", i)
NEXT

SHOWSCREEN

--- End code ---

You can also checking other forms for buttons, like these:

1. GameInput.CenterButton() for checking the Center button on Android TV remote.
2. GameInput.Back() for checking the BACK button on the controller.
3. GameInput.isProfileChanged() can been checked, if something have been changed to the controller (required on iOS).

On Android, you can also uses PLATFORMINFO$("DEVICE") as well. Here its auto change to "KEYBOARD" or "TOUCHSCREEN", what the user have changed last time.

4. GameInput.GetButtonName$() can been used to check the name of the button, which might differ from platform to platform. Example, you can checkout a GameInput.GetButtonName$("A"), the main select button.

5. A Platform can also been checked, by using GameInput.GetDeviceName$(). This is mostly used with Android.

6. If you want do your own mapping on Android, you can also uses Android.Scancode() or KEY() commands. KEY() cannot send a float, but Android.Scancode() does. Im mapped to those command, and not JOY, simply because mapping on those GameControllers does NOT suit those commands at all, because they can been quite very different, unlike on Windows. On Android those is treated more as a keyboard.

7. GameInput also supports Remapping, which is required to been do that on Android, if you will use RIGHT STICK or ANALOGE TRIGGERS. None of those buttons follow a standard at all. Im will explain that in a a later post.

8. Open up GameControllers.gbas. Most functions is explained how to use them. helper functions should been used internal.
 

Ian Price:
Cheers SF  :good:  :booze:

erico:
Super nice SF! But to a noob like me, that is all a bit hard to understand, I could do with trying it out, like on PC which is faster.
I will try a go on the avocado.

spacefractal:
im can eventuelly edit, if im got corrections. No problem.

erico:
You are doing great man! Way way up above. :good:
Maybe smoothing it out to noobs is a task for others, donĀ“t worry about it, it is class as it is. :good:

Navigation

[0] Message Index

[#] Next page

Go to full version