Download link for GameInput API:https://www.dropbox.com/s/1o0frsdrqzhjz57/EXTRAS.zip?dl=0GameInput 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:
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
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.