BASIC

Author Topic: iCade / iControlPad pairing and use  (Read 16476 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
iCade / iControlPad pairing and use
« on: 2011-Sep-19 »
If you have one of these awesome gadgets to enhance your mobile gaming experience, here's how to use them properly.

Step1:
Buy such a device: iCade or iControlPad.

Step2:
Turn iControlPad into "iCade" mode. The iCade has this already, so skip this step if you got the iCade.
-Download the firmware 2.x or higher from http://icontrolpad.com/support/
-Install it as the PDF in the file described.
-For Windows users: Extract the zip to "C:\Temp", because UAC messes with user profile pathes sometimes.

Step2b:
-After flashing to Firmware 2.x, press and hold "A, B, X and START" (in that order) until the device flashes 3x very quickly.
-After that the iControlPad will flash once a second to indicate it's powered on.
 (you can from now on power on/off by holding the start key until the green led flashes or dies)

Step3:
Pairing the device.
-On your iPad/iPhone open "settings/general/bluetooth"
-remove the iCade/iControlPad if it is already there and not connecting
-power on the gadget
-it wil appear int he bluetooth device list.
-tap it once and watch it pair.
-if it doesn't pair, make sure you have the iCade mode (iControlPad) enabled.

Step4:
Test if it works fine
-Start a browser, and tap the search box
-no keybaord should appear.
-tap a few buttons. It should enter some weird characters now.

Step5:
Programming for it.
-Make your game and read GETNUMJOYSTICKS(), which returns "2" on iOS once the iCade is active and a (ONE) button has been pressed at least.
-Then query the GETJOXX(1), GETJOYY(1) and GETJOYBUTTON(1, id) values
-The "name" of the "Joystick" is returned as "iCade".

Step6:
AppStore it
-There was an advice not to add "iCade" in the description and keywords. However, when you search for "iCade" games pop up.
-Submit it also to these sites:
http://www.thinkgeek.com/electronics/retro-gaming/e762/ (There's an email link for devs)
Twitter to Craig (iControlPad) http://twitter.com/#!/Craigix



Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: iCade / iControlPad pairing and use
« Reply #1 on: 2011-Sep-19 »
You forgot step 0:

Step 0

Buy yourself an iPad 1/2

 :'(
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iCade / iControlPad pairing and use
« Reply #2 on: 2011-Sep-19 »
It also pairs with an iPhone.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: iCade / iControlPad pairing and use
« Reply #3 on: 2011-Sep-20 »
Is the iCade supplied with a giant magnifying glass iPhone users?  =D
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iCade / iControlPad pairing and use
« Reply #4 on: 2011-Sep-20 »

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iCade / iControlPad pairing and use
« Reply #5 on: 2011-Oct-20 »
It works properly on the WebOS touchpad - no QUERTZ issues.

Here's how to use it there. Attention - don't use INKEY$ somewhere else then!
Code: GLBasic [Select]
FUNCTION iCadeWebOS%: BYREF x%, BYREF y%, BYREF b1%, BYREF b2%, BYREF b3%, BYREF b4%
STATIC ix%, iy%, ib1%, ib2%, ib3%, ib4%

LOCAL ik$
        WHILE TRUE
                ik$ = INKEY$()
                IF LEN(ik$) = 0 THEN BREAK
                IF     ik$ = "a" ; ix%=-1
                ELSEIF ik$ = "q" ; ix%=0
                ELSEIF ik$ = "d" ; ix%=1  
                ELSEIF ik$ = "c" ; ix%=0
                ELSEIF ik$ = "w" ; iy%=-1
                ELSEIF ik$ = "e" ; iy%=0
                ELSEIF ik$ = "x" ; iy%=1
                ELSEIF ik$ = "z" ; iy%=0
               
                ELSEIF ik$ = "h" ; ib1%=1
                ELSEIF ik$ = "r" ; ib1%=0
                ELSEIF ik$ = "j" ; ib2%=1
                ELSEIF ik$ = "n" ; ib2%=0

                ELSEIF ik$ = "y" ; ib3%=1
                ELSEIF ik$ = "t" ; ib3%=0
                ELSEIF ik$ = "o" ; ib4%=1
                ELSEIF ik$ = "g" ; ib4%=0
                ENDIF
        WEND

        x=ix
        y=iy
        b1=ib1
        b2=ib2

ENDFUNCTION
 

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4144
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: iCade / iControlPad pairing and use
« Reply #6 on: 2011-Oct-20 »
The TouchPad is annoying when it comes to controllers. It's can find a Wii remote, but even though the remote doesn't need pairing, the TP must have a key entered. You can't just press ENTER, you must enter a value. BT keyboards also don;t show correct values (or even values at all for certain keys). Stoopid HP

So iCade is the next best thing. Well done Gernot :)

Shame that most TP owners actually HAVE keyboards and Wii remotes, but not iCades.  :(
I came. I saw. I played.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iCade / iControlPad pairing and use
« Reply #7 on: 2011-Oct-21 »
Craig and ED have so many that they even sell them :P

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4144
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: iCade / iControlPad pairing and use
« Reply #8 on: 2011-Oct-21 »
Wow, that's a first!
I came. I saw. I played.

Offline AlienMenace

  • Mr. Polyvector
  • ***
  • Posts: 149
    • View Profile
Re: iCade / iControlPad pairing and use
« Reply #9 on: 2011-Dec-19 »
It works properly on the WebOS touchpad - no QUERTZ issues.

Here's how to use it there. Attention - don't use INKEY$ somewhere else then!
Code: GLBasic [Select]
FUNCTION iCadeWebOS%: BYREF x%, BYREF y%, BYREF b1%, BYREF b2%, BYREF b3%, BYREF b4%
STATIC ix%, iy%, ib1%, ib2%, ib3%, ib4%

LOCAL ik$
        WHILE TRUE
                ik$ = INKEY$()
                IF LEN(ik$) = 0 THEN BREAK
                IF     ik$ = "a" ; ix%=-1
                ELSEIF ik$ = "q" ; ix%=0
                ELSEIF ik$ = "d" ; ix%=1  
                ELSEIF ik$ = "c" ; ix%=0
                ELSEIF ik$ = "w" ; iy%=-1
                ELSEIF ik$ = "e" ; iy%=0
                ELSEIF ik$ = "x" ; iy%=1
                ELSEIF ik$ = "z" ; iy%=0
               
                ELSEIF ik$ = "h" ; ib1%=1
                ELSEIF ik$ = "r" ; ib1%=0
                ELSEIF ik$ = "j" ; ib2%=1
                ELSEIF ik$ = "n" ; ib2%=0

                ELSEIF ik$ = "y" ; ib3%=1
                ELSEIF ik$ = "t" ; ib3%=0
                ELSEIF ik$ = "o" ; ib4%=1
                ELSEIF ik$ = "g" ; ib4%=0
                ENDIF
        WEND

        x=ix
        y=iy
        b1=ib1
        b2=ib2

ENDFUNCTION
 

Wondering how to read the diagonal of the joystick using the inkeys method? On each pass, inkeys will only hold 1 character, right? Is there a joystick read method available to use for WebOS like on iOS?
« Last Edit: 2011-Dec-19 by AlienMenace »
Apps published: 3

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iCade / iControlPad pairing and use
« Reply #10 on: 2011-Dec-19 »
you press down - it sends a key. You releas, it sends another key. Diagonal is working properly as well as multi-buttons.

Offline AlienMenace

  • Mr. Polyvector
  • ***
  • Posts: 149
    • View Profile
Re: iCade / iControlPad pairing and use
« Reply #11 on: 2011-Dec-19 »
I'm not talking about movement, I'm talking about directional firing. My game uses an 8-way firing system, so it needs to know literally in a single pass which direction is being pressed. If pushing the diagonal does not produce an actual keypress then how do I trap this in a single pass? 


Apps published: 3

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
Re: iCade / iControlPad pairing and use
« Reply #12 on: 2011-Dec-19 »
An iCade button is considered 'pushed' when its associated 'down' value is sent, and 'released' when its 'up' value is sent.
So, when a user presses 'left', your program will receive a 'A' code, when you release it, you'll receive a 'Q' code.
A directional input is when both directional keys have been pressed before either has been released.

Using that function as it is wont work for directional input. 
It also wont work to detect two concurrent key presses (like your current problem).
[Edit] I just reread that original function.  I think you can detect a direction by reading the resulting 'x', and 'y' values.
If both aren't zero, then a direction is being pressed.
And the buttons are separate, so you can check for 'x' and 'b1' at once.
I still prefer my following function and TYPE, as it is more clear what is happening.

BTW, here's an iCade DEV reference:
http://www.thinkgeek.com/files/iCADE/iCade_Dev_Resource_v1_3.pdf

You could create a custom iCade input function that handles all states, such as:

Code: GLBasic [Select]
// Updated to use Function in TYPE, and SELECT / CASE
TYPE TiCade
        is_left%
        is_right%
        is_up%
        is_down%
        is_b1%
        is_b2%
        is_b3%
        is_b4%

        FUNCTION Update%:
                LOCAL ik$
                WHILE TRUE
                        ik$ = INKEY$()
                        IF LEN(ik$) = 0 THEN BREAK
                        SELECT ik$
                        // Left
                        CASE "a"; self.is_left = TRUE
                        CASE "q"; self.is_left = FALSE
                        // Right
                        CASE "d"; self.is_right = TRUE
                        CASE "c"; self.is_right = FALSE
                        // Up
                        CASE "w"; self.is_up = TRUE
                        CASE "e"; self.is_up = FALSE
                        // Down
                        CASE "x"; self.is_down = TRUE
                        CASE "z"; self.is_down = FALSE

                        // Button 1
                        CASE "h"; self.is_b1 = TRUE
                        CASE "r"; self.is_b1 = FALSE
                        // Button 2
                        CASE "j"; self.is_b2 = TRUE
                        CASE "n"; self.is_b2 = FALSE
                        // Button 3
                        CASE "y"; self.is_b3 = TRUE
                        CASE "t"; self.is_b3 = FALSE
                        // Button 4
                        CASE "o"; self.is_b4 = TRUE
                        CASE "g"; self.is_b4 = FALSE
                        ENDSELECT
                WEND
        ENDFUNCTION

ENDTYPE
GLOBAL iCade AS TiCade

// Usage
WHILE TRUE
        iCade.Update()
        IF iCade.is_left AND iCade.is_up THEN "move player up and left"
        SHOWSCREEN
WEND

[Edit2] One other difference is mine allows both (left AND right) or (up AND down) at once, which may not be desirable.

BTW, I don't have an iCade (yet? Christmas is coming!), so I've never tested or ran the above.  Let me know of any bugs!
« Last Edit: 2011-Dec-20 by Slydog »
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline AlienMenace

  • Mr. Polyvector
  • ***
  • Posts: 149
    • View Profile
Re: iCade / iControlPad pairing and use
« Reply #13 on: 2011-Dec-20 »
I don't understand how using the inkey$ method can trap more than 1 character in a loop so how can you read a character value for x,y, and buttons at the same time using a single inkey$ statement? Seems like it will only return a single character at a time which makes reading diagonal impossible unless there was a character code assigned to these diagonal presses as well and that would not be a great solution either as you could not press a fire button at the same time.

On the iPad, since it is using joystick method and not an inkey$ method, you can read all the inputs on 1 pass and that works. No problem.
« Last Edit: 2011-Dec-20 by AlienMenace »
Apps published: 3

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
Re: iCade / iControlPad pairing and use
« Reply #14 on: 2011-Dec-20 »
That part confused me too.  That's what I had originally thought, then I reread the original function.
The 'INKEY' command is inside a WHILE loop, so I assume when more than one keyboard / icade event happens, they get queued and you loop through them until there are no more (IF LEN(ik$) = 0).

So in one game loop frame, if the user hits one key and release another (for example), you'll get two INKEY events to cycle through.  Try my TYPE and sample usage, I think it handles this all for you.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]