iOS calls for joypads

All,

Does anyone know how to address iOS system calls?

I now have a more recent iPad which is running iOS 17.5. I have added mouse and keyboard control to it but noticed that the latest iOS has also joypad control included. I have a suitable joypad as I linked it in to Bluetooth and used a demo app to check it’s functionality - works great. But …

HOW DO I INTERFACE TO IT WITH CODEA ?

Anyone know how?

Are you trying to asks how to use a joypad with Codea?

@Dinoball901 - in a word - yes. I don’t think Codea has yet built in joystick compatibility. I’m sure it’s in the next release. But, iOS has added a few new Bluetooth features recently which has included joypad compatibility. So, I was wondering if anyone had incorporated them in a C extension for Codea.

Actually Modern Codea already support it natively I made a game using a gamepad.

@Dinoball901 - when you say modern I think you mean beta which has limited access.

Could you post your section of code relevant to joypad control - would appreciate that.

Cheers.

Bri-G

No anyone can use it. if you click on “Do” (Top Right), under there click (“Perferences”). On the left side top you will see something that say “Legacy” and “Modern”. Click on modern and you will be able to use it. Bare in mind that modern has a different style of writing code compare to Legacy (the version you are using) also there are new functionality compare to Legacy like a Entity Component Scene System (I love using this way of making my games), Compute shaders, Gamepad support, and more. I honestly recommend that you learn how to use this style just in case Apple decide not to continue to support opengl (the graphic api Legacy uses modern uses metal which is made by Apple).

So in order to use the gamepad it is something like this.

-- Modern

function setup()
    --Please make sure your controller is connected to your iPad
    
    --Check if a controller is active (current is the main controller)
    if gamepad.current then
        -- Pecentage of the controller
        print("Gamepad Percentage:", gamepad.current.batteryLevel)
    end
end

function draw()

    --Check if a controller is active (current is the main controller)
    if gamepad.current then
        -- Checks if button A is pressed 
        if(gamepad.current.a.pressed) then
            print("Button A was pressed")
        end
        -- Check if button Y was released 
        if(gamepad.current.y.released) then
            print("Button Y was released")
        end
        -- Value basically is 1 when the player is pressing the button
        if(gamepad.current.x.value == 1) then
            print("Pressing button X")
        end
        -- Gets the x and y direction of the right joy stick.
        if(gamepad.current.rightStick.dir ~= vec2(0))then
            print ("Right Stick Direction:", gamepad.current.rightStick.dir)
        end
        
        -- Check if the left stick is in the right direction
        if(gamepad.current.leftStick.right)then
            print ("Left Stick is in the right direction")
        end
        
        -- Check if the left shoulder was pressed
        if(gamepad.current.leftShoulder.pressed) then
            print ("Left Shoulder was pressed")
        end
        -- Check if the right trigger was pressed
        if(gamepad.current.rightTrigger.released) then
            print("Right Trigger was released")
        end
        -- Check the documentation for more info
    end
    
end

Read the Documentation to learn more: input - Codea 4.0 documentation

You can click here to create a modern project directly

Hi @Dinoball901 - thanks for the code. By the description of modern/legacy you are on the beta program testing, V3 doesn’t have the choice it’s all legacy. Fortunately I’m still running on 3.11(396) on this tablet so I can test it out.

Thanks again for the code.

Update: I have an 8BitPro dot 2 which links into my iPad OK. Tested it out and some of the buttons and rotary levers are working OK but not all. But that should keep me amused for a while. Thanks again for the info again.

1 Like

I have a Thunderobot G50 game controller that can connect to the iPad via Bluetooth, but Codea cannot detect it in the code. Do I need a game controller from a specific brand?

Does your game controller work in other parts of iOS? (i.e., navigating the UI, in other games)