Ongoing Project: GameController support for Android

Previous topic - Next topic

spacefractal

Im have wrote a lots of that in the OYUA thread, but im thinkgs im begin to overtake the thread, so im dedicated to doing a new thread about it with the new API im are doing to make.

What is the goal?
To do support with various game controller supports implemented with Java for Android.

What controllers will it support?
- Ouya controllers (of course).
- X-box controllers.
- iCade controllers (which have iCade in the Bluetooth name).

Other Info
- Most other controls can been remapped trought message to the user (except iCade clones without iCade name in the string).
- Multiply controllers will been supported, but not eventuelly all buttons (but is easy to add them).
- All controller code in glbasic will been done in just one java call and in one function (except sending buttons names for remapping).

requirements:
- Glbasic v11.414+ with ANDROIDEXTRAS installed
- SDK with a least 4.x. Its will NOT work with stock 2.2 SDK.

Todo before full release:
- Save remapping.
- Make sure its run with Android v2.2 and/or Android 2.3 (which is impossible right now, due im lost my HTC phone in a washing machine).
- Doing full xbox profile as well the iCade (easy to been done, eventuelly they can both been remapped).

Im thinks the release will been allready in the next week, the project is mostly done.

Beta:
http://www.glbasic.com/forum/index.php?topic=9166.msg79936;boardseen#new

Even the above todo is still valid, im have now implemented it to Android Extras and Five Sprites have updated his post.


Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

here is the glbasic you will going to use, so you have idea how easy its would been when first working:

Code (glbasic) Select

FUNCTION GameControllers: Command$, PlayerID=0
STATIC ANDROIDKEYS$=""

// this require before invoking keys, example after a SHOWSCREEN or in your controller code.
SELECT Command$

CASE "Update"
IF ANDROIDKEYS$="" THEN GameControllers("SetButtonLayout")
ANDROIDKEYS$=CallJava$("JoyUpdateKeys")
// this retrive all inputs from the first PlayerID connected. If you doing a multiplayer game
// you need set a PlayeerID after invoking this (can been done on a "press button for player 1 screen").
ButtonRemapMessage$=""
IF LEFT$(ANDROIDKEYS$, 8)="Message=" THEN ButtonRemapMessage$=RIGHT$(ANDROIDKEYS$, LEN(ANDROIDKEYS$)-8)
DEPRINT("got: "+ANDROIDKEYS$)
CASE "SetButtonLayout"
// Java controller codes supported for remap (MouseX and MouseX cant been remapped):
// {"Left", "Right", "Up", "Down"
// "PadL_Left", "PadL_Right", "PadL_Up", "PadL_Down"
// "PadR_Left", "PadR_Right", "PadR_Up", "PadR_Down"
// "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8"
// "TriggerLeft", "TriggerRight"
LOCAL layout$="Left=Move Left;Right=Move Right;Up=Move Up;Down=Move Down;b1=Look Map;b2=Pause/Menu";
CallJava$("JoySetButtonLayout:"+layout$)
ENDSELECT

// any other command will detect the current button from the current ANDROIDKEYS$ list. All buttons value
// do return value between 0 and 1. Some buttons can analog as well and will return a float.
LOCAL start=INSTR(ANDROIDKEYS$, "Player="+PlayerID)
start=INSTR(ANDROIDKEYS$, Command$+"=", start)
start=start+LEN(Command$)+1
LOCAL finish=INSTR(ANDROIDKEYS$," ", start-1)
LOCAL value$=MID$(ANDROIDKEYS$, start, finish-start)
RETURN value


ButtonRemapMessage$ is a global variable to show which keys that is currectly under remapping, and its can been happens anywhere in the game (but java dont need to send anything back again).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

erico

Really great Space! :nw:
Count me in any help or test you may need.

bigsofty

I agree, it sounds like a controller powerhouse of a library for Android, looking forward to see how you get on! :)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

spicypixel

My iCade doesn't have iCade in the Bluetooth name, but was sold it for normal price from Amazon if I recall ???:o
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

spacefractal

#5
My was also got from Amazon.co.uk, and its have correct names here.

Im guess its called "Virtual" in Android, when you trying to get those keys from Java (its happens here sometimes)? 

- If yes, you need to checkout the Bluetooth name as well before processing the keys. This is what om does.
- If no, which Bluetooth name do you get? Them im can simply add that to the search list for auto remapping (and show me your cabinet, if its not the original one).

The code checks by now for "iCade" as general name and "8-bitty" only for auto remapping it (its key layout was not 100% same placement as the iCade, but its name was included iCade too, even its compatible).

Todo after some work today:
- l saving its manual based settings.
- Adding to the ANDROIDEXTRAS by fivesprites (which is a bit better than mine metoed), do a example.
- Property do a little test example (even the code is pretty much self explained).

As you can see, the code now works nice now, tested on OUYA and Samsung Tab2.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

im have compiled a ANDROIDEXTRAS 1.2, which is just sent to FiveSprites, which im thinks he should have it first to look on as im did anything correctly (if he have time of course).

Howover the release will been a Beta, because its not finished and need some polish, but its fully workable state (fully playable controller system on OUYA) and code, that will work with our game.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

Version 1.4 beta 2 was released few days ago (v1.2 should have been v1.4). Later on look how to supports full qwerty keyboard supports. That will require android v3.0 and up.

Today I'm get a new Android v2.3 phone, so I'm in next week can test backward compatible, so those news functions don't breaks on Android 2.3. Howover om not planning testing on Android 2.2, due the market today is too small.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

erico

Yep 2.1 and 2.2 seems like it is going almost gone, at least according to some articles.

http://www.androidpolice.com/2013/08/02/august-android-distribution-jelly-bean-rises-to-40-5-gingerbread-and-ics-hold-steady/

Seems to be reliable information at least compared to people I know and what they have.
I quite never knew android had such a fragmentation.