Make mkcontrollers script work when building as a submodule

This commit is contained in:
2026-05-12 21:38:08 -04:00
parent 8ae99120b5
commit 6f62e674d5

View File

@@ -1,10 +1,12 @@
#!/bin/bash
rootdir=$1
curl https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/refs/heads/master/gamecontrollerdb.txt | grep -v '^#' | grep -v '^$' | sed s/',$'//g > mappings.txt
filelen=$(wc -l mappings.txt | cut -d ' ' -f 1)
cat > ../include/akgl/SDL_GameControllerDB.h <<EOF
cat > ${rootdir}/include/akgl/SDL_GameControllerDB.h <<EOF
#ifndef _SDL_GAMECONTROLLERDB_H_
#define _SDL_GAMECONTROLLERDB_H_
@@ -20,11 +22,11 @@ counter=0
cat mappings.txt | while read LINE;
do
if [[ $counter -gt 0 ]]; then
printf ",\n" >> ../include/akgl/SDL_GameControllerDB.h;
printf ",\n" >> ${rootdir}/include/akgl/SDL_GameControllerDB.h;
fi
printf " \"${LINE}\"" >> ../include/akgl/SDL_GameControllerDB.h;
printf " \"${LINE}\"" >> ${rootdir}/include/akgl/SDL_GameControllerDB.h;
counter=$((counter + 1))
done
printf "\n};\n" >> ../include/akgl/SDL_GameControllerDB.h
printf "#endif // _SDL_GAMECONTROLLERDB_H_\n" >> ../include/akgl/SDL_GameControllerDB.h
printf "\n};\n" >> ${rootdir}/include/akgl/SDL_GameControllerDB.h
printf "#endif // _SDL_GAMECONTROLLERDB_H_\n" >> ${rootdir}/include/akgl/SDL_GameControllerDB.h