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 …
@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.
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
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.
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?
I apologize for the delayed response. Recently, I have been immersed in my collection of vintage calculators (Ti59/HP 38g/MK-61/WP34S, etc.), learning their ancient programming methods, and staying away from the internet, which is why I only saw this today.
I rarely use game controllers, so I haven’t tested this controller on other iOS games. However, it can connect and communicate normally with iOS. The manufacturer provides a method of use, which is to use a program to map different areas on the screen to the controller’s various buttons, rather than assigning different internal recognition codes for each button as I understood. Therefore, I am a bit skeptical that this device may need to be certified by Apple to achieve the latter method of communication.