BASIC

Author Topic: iCade Support?  (Read 10369 times)

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Re: iCade Support?
« Reply #30 on: 2011-Sep-17 »

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Re: iCade Support?
« Reply #31 on: 2011-Sep-18 »
Taito rips off the Icade and introduces... the Invadercade..

http://toucharcade.com/2011/09/15/taito-set-to-release-its-own-arcade-cabinet-peripheral/#comments

1 button and it only supports portrait by the look of the cabinet. Ubbish :)
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.

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Re: iCade Support?
« Reply #32 on: 2011-Sep-18 »
Couldn't agree more!

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10689
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iCade Support?
« Reply #33 on: 2011-Sep-19 »
please press the "trash button" before you recompile. If getnumjoysticks() returns 0, the device is not paired, or you did not press a button, yet. (1st button press "plugs the stick in").

I tested to auto-detect the keyboard layouts and I think it's pretty possible to do so:

Code: GLBasic [Select]
        There are three main latin keyboard layouts: QWERTY, QWERTZ and AZERTY – keyboard layouts.
                The QWERTZ layout switches Y - Z
                The AZERTY layout switches A - Q and Z - W


        // iCade events:
          WE    YT UF IM OG
        AQ  DC
          XZ    HR JN KP LV

        QUERTZ/AZERTY: W w/o Z (UP,   pressed w/o DOWN, released)
        AZERTY:        Q w/o A (LEFT, release w/o LEFT, pressed)
                       Z w/o X (DOWN, release w/o DOWN, pressed)
 
« Last Edit: 2011-Sep-19 by Kitty Hello »

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Re: iCade Support?
« Reply #34 on: 2011-Sep-19 »
Amazing!!

I've been compiling test programs for ages - the key to it working was pressing the Trash Icon like you said before recompiling..

I can't figure out why this would matter - I suppose part of my compilation was using precompiled routines from a previous version?

Anyway the GREAT news to report is SUCCESS!!

Here I am paired and pressing a joystick and a button at same time..

Ohh - the important screenshot..

http://www.pictureviewerpro.com/storage/gen/icade.png (on my font - lower case letters show up as inverted colours)

Bear in mind my code is still being rather naughty so ignore the phantom 3rd device shown... Its the second one that matters of course!!

Now I will go and fix my code up.

I compiled this on iOS 4.2 and iOS 5.- (Beta 7) as I initially thought that might be the problem at my end and can report it works fine on both anyway.

Take a bow, Kitty Hello!

This is awesome!!   :good: :good: :good: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw:
« Last Edit: 2011-Sep-19 by mrplant »

Offline Gary

  • Dr. Type
  • ****
  • Posts: 313
    • View Profile
Re: iCade Support?
« Reply #35 on: 2011-Sep-19 »
could you not have a calibrate joystick option in your software? if you ask the user to move the joystick or press a button that uses Y or Z and it returns the wrong keypress then set a flag in GLB to switch to the reversed keys being looked for?

Nice to see another option being added though

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10689
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iCade Support?
« Reply #36 on: 2011-Sep-19 »
Nah, don't make it complicated to users. I'll up an update tonight where the keyboard layout is taken care properly (once you pressed up/down). iControlPad is an awesome addition to the iDevices.
Get one and spread the word.


Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Re: iCade Support?
« Reply #37 on: 2011-Sep-19 »
I think transparent use is the way to go - it keeps Apple happy who don't want the iCade devices mentioned in your app - for fear it would confuse other users without one...

Jeff Minters new game Goat Up has the right idea - just detect the device on the fly and start using it when game in launched - with no fanfare - it just works..

The way this is being implemented in GLBasic will enable us to do the exact same thing in our apps.

This is great news.

I will pass word around as much as I am able to!!

Offline doimus

  • Dr. Type
  • ****
  • Posts: 284
    • View Profile
Re: iCade Support?
« Reply #38 on: 2011-Sep-19 »
iControlPad is an awesome addition to the iDevices.
Get one and spread the word.

Yeah, I bet they will earn much more money on IControlPad than on Pandora. It's the same guy(s) developing it.

That thing would rock with iPad2 and big screen TV.
It's a shame we can't have emulators on non-jailbroken devices.

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 232
    • View Profile
Re: iCade Support?
« Reply #39 on: 2011-Sep-20 »
As my last report back on this subject, I thought I would post some code I came up with.
It's not amazingly crafted or anything but it does the job I wanted done and may be useful to someone.

In my game - I am only interested in Up, Down, Left Or Right. The Fire Button stops the game - its a puzzle style tiled game!
You therefore may have to adapt the code below. I ignore diagonals on purpose as they would not suit my gameplay well.
This code therefore is "as is" so please adapt to your own usage. You will see it is pretty easy to do.
It is mulit-platform which is what i wanted - Windows, Mac and iOS and is well tested now.
I read digital and analogue input on the PC (Windows), analogue on the Mac and iCade input on IOS devices.
The Function JoyDevInput$() returns an empty or one character text string which can be acted upon in your game.
"" for no input. "U" for up. "D" for down. "L" for left, "R" for right and "F" for fire. Fire always gets priority, as in my game, it stops play!

I hope it is of use to someone. V2.0:

Code: GLBasic [Select]
///////////////////////////////////////
//      Joystick Device Input Reading
///////////////////////////////////////


FUNCTION JoyDevInput$:

        LOCAL Joy$="" // Used to hold the final return value.
        LOCAL X#, Y#, XD#, YD# // Used to read raw joystick values.
        LOCAL n% = 0 // Used to loop through buttons.
        LOCAL v% = 0 // Used to keep a running count on button values.

        // The following code ia multi platform and can be called anytime to check for working joystick and iCade devices.
        //
        // The function returns a sting which is blank for nothing pressed. It does the same if no device is found.
        //
        // If a device is found, it returns a one character string as follows:
        //
        // "U" for when Up is pressed. "D" for when Down Is pressed.
        // "L" for when Left is pressed. "R" for when right is pressed and "F" for when ANY fire button being pressed.
        //
        // Note: This routine ignores diagonals, even though the device supports them. It also gives priority to fire buttons,
        //               So, if a direction plus fire is pressed - only the fire value will be returned in this case.
        //               The Windows code checks both analogue and digital sticks and again ignores conflicting inputs.
        //               This behaviour is all by design and intended.

        // The following code is compiled for Windows Platform only:
        ?IFDEF WIN32
                IF GETNUMJOYSTICKS()=0
                        Joy$ = "" // Return empty string if no devices found.
                ELSE
                        // Read raw Y value from Device 0
                        Y = GETJOYY(0)
                        YD = GETDIGIY(0) // On the PC, we also look at the digital stick values as well.
                        IF Y = -1 OR YD = -1
                                Joy$ = Joy$ + "U"
                        ELSEIF Y = 1 OR YD = 1
                                Joy$ = Joy$ + "D"
                        ENDIF
                        // If we have a movement on Y and also on Digital stick Y and they are not the same movement, then ignore the input!
                        IF ((Y <> 0) AND (YD<>0)) AND (Y<>YD)
                                Joy$ = Joy$ + "LR" // This invalidates the input as the length of this string must be one for a valid input!
                        ENDIF
                        // Read raw X value from Device 0
                        X = GETJOYX(0)
                        XD = GETDIGIX(0) // On the PC, we also look at the digital stick values as well.
                        IF X = -1 OR XD = -1
                                Joy$ = Joy$ + "L"
                        ELSEIF X = 1 OR XD = 1
                                Joy$ = Joy$ + "R"
                        ENDIF
                        // If we have a movement on X and also on Digital stick X and they are not the same movement, then ignore the input!
                        IF ((X <> 0) AND (XD<>0)) AND (X<>XD)
                                Joy$ = Joy$ + "UD" // This invalidates the input as the length of this string must be one for a valid input!
                        ENDIF
                        // Read status of first 8 buttons from Device 0 and add a running total.
                        FOR n = 0 TO 7
                                v = v + GETJOYBUTTON(0,n)
                        NEXT
                        // All raw values now read - now to process final return value.
                        // Priority to (any) buttons first:
                        IF v
                                Joy$= "F" // Return with "F" if any buttons pressed!
                        ELSE
                                // If more than one direction pressed, return an empty string, otherwise keep value set earlier.
                                IF LEN(Joy$) > 1
                                        Joy$ = ""
                                ENDIF
                        ENDIF
                ENDIF
        ?ENDIF

        // The following code is compiled for Mac OSX Platform only:
        ?IFDEF OSXX86
                IF GETNUMJOYSTICKS()=0
                        Joy$ = "" // Return empty string if no devices found.
                ELSE
                        // Read raw Y value from Device 0
                        Y = GETJOYY(0)
                        IF Y <= -1
                                Joy$ = Joy$ + "U"
                        ELSEIF Y >= 1
                                Joy$ = Joy$ + "D"
                        ENDIF
                        // Read raw X value from Device 0
                        X = GETJOYX(0)
                        IF X <= -1
                                Joy$ = Joy$ + "L"
                        ELSEIF X >= 1
                                Joy$ = Joy$ + "R"
                        ENDIF
                        // Read status of first 8 buttons from Device 0 and add a running total.
                        FOR n = 0 TO 7
                                v = v + GETJOYBUTTON(0,n)
                        NEXT
                        // All raw values now read - now to process final return value.
                        // Priority to (any) buttons first:
                        IF v
                                Joy$= "F" // Return with "F" if any buttons pressed!
                        ELSE
                                // If more than one direction pressed, return an empty string, otherwise keep value set earlier.
                                IF LEN(Joy$) > 1
                                        Joy$ = ""
                                ENDIF
                        ENDIF
                ENDIF
        ?ENDIF


        // The following code is compiled for iOS Platform only:

        ?IFDEF IPHONE
                IF GETNUMJOYSTICKS()<>2 // The first joystick on iOS devices is the Accelerometer.
                        Joy$ = "" // Return empty string if no iCade device detected.
                ELSE
                        // Read raw Y value from Device 1 - The iCade device!
                        Y = GETJOYY(1)
                        IF Y = -1
                                Joy$ = Joy$ + "U"
                        ELSEIF Y = 1
                                Joy$ = Joy$ + "D"
                        ENDIF
                        // Read raw X value from Device 1
                        X = GETJOYX(1)
                        IF X = -1
                                Joy$ = Joy$ + "L"
                        ELSEIF X = 1
                                Joy$ = Joy$ + "R"
                        ENDIF
                        // Read status of first 8 buttons from Device 1 and add a running total.
                        FOR n = 0 TO 7
                                v = v + GETJOYBUTTON(1,n)
                        NEXT
                        // All raw values now read - now to process final return value.
                        // Priority to (any) buttons first:
                        IF v
                                Joy$= "F" // Return with "F" if any buttons pressed!
                        ELSE
                                // If more than one direction pressed, return an empty string, otherwise keep value set earlier.
                                IF LEN(Joy$) > 1
                                        Joy$ = ""
                                ENDIF
                        ENDIF
                ENDIF
        ?ENDIF

        RETURN Joy$ // Return from function with the value detected above.

ENDFUNCTION
 
« Last Edit: 2011-Sep-24 by mrplant »