Defold -> Retro handhelds?

ROCKNIX - 20250118

I’ve hosted it on github.

I was able to get “gamepad action_id connected”.

So “gamepad_unknown” = true.

But I couldn’t get “action Raw” at all.

function on_input(self, action_id, action)
	if action_id == hash("raw") and action.pressed then
		label.set_text("/system#key", action.gamepad_buttons)
	end

	if action_id == hash("connected") then
		if action.gamepad_unknown then
			print("gamepad_unknown")
			label.set_text("/system#gamepad_unknown_label", "gamepad_unknown")
		else
			print("NOT gamepad_unknown")
			label.set_text("/system#gamepad_unknown_label", "NOT gamepad_unknown")
		end
	end
	
end

You need to set the input binding for raw gamepad input in your input bindings file:

I know it might seem strange that you need to define the input binding for raw gamepad data, but we also don’t want the engine to flood scripts with raw gamepad data unless the game actually cares about gamespads.

I was showing that I registered a raw input.

game.input_binding:

gamepad_trigger {
  input: GAMEPAD_RAW
  action: "raw"

Is there anything else I forgot to define?


Actually on other OS you will need to use Westonpack(Portmaster). There the override is with “gptk”.

To be honest, I haven’t quite figured it out yet.

Ah, missed that! Adding a raw binding should be everything you need!

I don’t really know what’s wrong then. We could perhaps add some additional debug logs about gamepads when the engine starts or a gamepad is connected.

I ran the engine on my Anbernic device, and it works well! Plus, it doesn’t require the libdecor workaround, because Rocknix for H700 CPUs uses X11 as a display server.

But, for some reason, Rocknix reports a different name for the gamepad (not “retrogame_joypad”), so add this gamepad description:

driver
{
    device: "H700 Gamepad" # Anbernic handhelds on H700 internal controller name.
    platform: "linux"
    dead_zone: 0.2
    map { input: GAMEPAD_LSTICK_LEFT type: GAMEPAD_TYPE_AXIS index: 0 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_LSTICK_RIGHT type: GAMEPAD_TYPE_AXIS index: 0 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_LSTICK_DOWN type: GAMEPAD_TYPE_AXIS index: 1 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_LSTICK_UP type: GAMEPAD_TYPE_AXIS index: 1 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_LSTICK_CLICK type: GAMEPAD_TYPE_BUTTON index: 11 }
    map { input: GAMEPAD_RSTICK_LEFT type: GAMEPAD_TYPE_AXIS index: 2 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_RSTICK_RIGHT type: GAMEPAD_TYPE_AXIS index: 2 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_RSTICK_DOWN type: GAMEPAD_TYPE_AXIS index: 3 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_RSTICK_UP type: GAMEPAD_TYPE_AXIS index: 3 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
    map { input: GAMEPAD_RSTICK_CLICK type: GAMEPAD_TYPE_BUTTON index: 12 }
    map { input: GAMEPAD_LPAD_LEFT type: GAMEPAD_TYPE_BUTTON index: 15 }
    map { input: GAMEPAD_LPAD_RIGHT type: GAMEPAD_TYPE_BUTTON index: 16 }
    map { input: GAMEPAD_LPAD_DOWN type: GAMEPAD_TYPE_BUTTON index: 14 }
    map { input: GAMEPAD_LPAD_UP type: GAMEPAD_TYPE_BUTTON index: 13 }
    map { input: GAMEPAD_RPAD_LEFT type: GAMEPAD_TYPE_BUTTON index: 2 }
    map { input: GAMEPAD_RPAD_RIGHT type: GAMEPAD_TYPE_BUTTON index: 1 }
    map { input: GAMEPAD_RPAD_DOWN type: GAMEPAD_TYPE_BUTTON index: 0 }
    map { input: GAMEPAD_RPAD_UP type: GAMEPAD_TYPE_BUTTON index: 3 }
    map { input: GAMEPAD_LTRIGGER type: GAMEPAD_TYPE_BUTTON index: 6 }
    map { input: GAMEPAD_LSHOULDER type: GAMEPAD_TYPE_BUTTON index: 4 }
    map { input: GAMEPAD_RTRIGGER type: GAMEPAD_TYPE_BUTTON index: 7 }
    map { input: GAMEPAD_RSHOULDER type: GAMEPAD_TYPE_BUTTON index: 5 }
    map { input: GAMEPAD_START type: GAMEPAD_TYPE_BUTTON index: 9 }
    map { input: GAMEPAD_BACK type: GAMEPAD_TYPE_BUTTON index: 8 }
}

:backhand_index_pointing_up: I updated the mapping - Y/X were swapped.

The engine prints a warning if the gamepad is not found:
WARNING:INPUT: No gamepad map found for gamepad 0 (H700 Gamepad). The raw gamepad map will be used.

Maybe @Red_Wisp built the engine in the release mode, i.e. not --variant debug, so the engine didn’t show anything.
(btw I didn’t test their example)

3 Likes

Has anyone tried to run Defold on Raspberry Pi? I don’t have this device unfortunately, and it would be interesting to check it out.

Have you checked the gamepad description above? I would like to add it to the Defold database.
It works for me, all buttons are in place.

Finally, I managed to find a second hand rgb30. This is so fun, @aglitchman, thank you! :slightly_smiling_face:
I’m so eager to test its limits. It works perfectly!

(The game looks crystal clear on the screen. it’s just my phone’s camera that sucks!)

7 Likes

I tried running on arkos. It seems like it’s based on Ubuntu 19.10 which might be the first issue? Building · christianhaitian/arkos Wiki · GitHub

ark@rgb30:~$ /roms2/ports/test.sh 
./test.arm64: /lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by ./test.arm64)
./test.arm64: /lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./test.arm64)
ark@rgb30:~$ ldd --version
ldd (Ubuntu GLIBC 2.30-0ubuntu2.2) 2.30

Yes, Defold requires a newer version of GLIBC.

Even if you build your own Defold binaries on an old Ubuntu, the cloud server (extender) builds binaries that require a newer GLIBC. And without the extender, it’s impossible to develop large games; it’s needed in 99% of cases. So, you also will have to make your own version of the extender.

So, my take is: it’s easier to update ArkOS internals or just not use it. Plus, it doesn’t support X11 or Wayland (right?), so Defold won’t run on it anyway.

2 Likes

I’m not sure about X11 or Wayland, but you’re probably right!

I was able to run on rocknix with your instructions above. Thank you, this is super fun!

1 Like

What made me decide to use this engine? Until I found this thread.

I tried to build an arm64 build. But can’t run it.

The error information is “error while loading shared libraries: libxi.so6: cannot open shared object file: No such file or directory“.

I’m used RG CubeXX on muOS.

Does it support X11 or Wayland?

No.

No X11 and Wayland.

What does it support? How should Defold open a window and set up graphics context for rendering?

I use stock os in anbernic rg35xxh. can you show example of sh file please?

those didnt work

#!/bin/sh
echo "Starting Shadertoysample..."
progdir=`dirname "$0"`
cd "$progdir"
chmod +x ./Shadertoysample.arm64
./Shadertoysample.arm64
#!/bin/sh
echo $0 $*
progdir=`dirname "$0"`


export LD_LIBRARY_PATH="$progdir:$progdir/lib:/usr/lib:/lib"
export DISPLAY=:0
export SDL_FBDEV=/dev/fb0

eç
cd "$progdir"


chmod +x ./Shadertoysample.arm64
echo "Launching Shadertoysample.arm64..."
./Shadertoysample.arm64 "$@"

stock os port and muos portmaster arent same thing. exporting to portmaster seems easy on godot engine https://www.youtube.com/watch?v=HpedCKGbaY4 but I bought new sd card to install muos.

The sh scripts of the stock OS ports seem interesting. I need a dynamic libretro.so for ARM64 games, or I would have to create a separate libretro.so for each game, which I don’t want to do.

#!/bin/sh
echo $0 $*
progdir=dirname "$0"

RA_CFG=/.config/retroarch/retroarch.cfg
RA_CORE=/mnt/vendor/deep/retro/cores
RA_WORK=/mnt/vendor/deep/retro

#cd $RA_WORK/
HOME=$RA_WORK/ $RA_WORK/retroarch -c $RA_CFG -v -L $RA_CORE/cannonball_libretro.so “$progdir/Cannonball/epr-10187.88”

#!/bin/sh
echo $0 $*
progdir=dirname "$0"

RA_CFG=/.config/retroarch/retroarch.cfg
RA_CORE=/mnt/vendor/deep/retro/cores
RA_WORK=/mnt/vendor/deep/retro

#cd $RA_WORK/
HOME=$RA_WORK/ $RA_WORK/retroarch -c $RA_CFG -v -L $RA_CORE/xrick_libretro.so “$progdir/Rick_Dangerous/data.zip”

#!/bin/sh
echo $0 $*
progdir=dirname "$0"

RA_CFG=/.config/retroarch/retroarch.cfg
RA_CORE=/mnt/vendor/deep/retro/cores
RA_WORK=/mnt/vendor/deep/retro

#cd $RA_WORK/
HOME=$RA_WORK/ $RA_WORK/retroarch -c $RA_CFG -v -L $RA_CORE/nxengine_libretro.so “$progdir/Cave_Story/Doukutsu.exe”

I’m not sure. Maybe GL4ES? I saw WestonPack .