### Install Library Targets Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/utils/imgui/CMakeLists.txt Installs the main imgui library and any enabled binding targets with specified destinations. ```cmake install( TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}_target ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) foreach(BINDING_TARGET ${BINDING_TARGETS}) install( TARGETS ${BINDING_TARGET} EXPORT ${PROJECT_NAME}_target ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) endforeach() ``` -------------------------------- ### Define Boot Start Command Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/board/batocera/amlogic/s905gen3/tvbox-gen3/boot/s905_autoscript.txt Sets up the command to start the boot process using the 'booti' command with specified kernel, initrd, and DTB memory addresses. ```bash setenv boot_start booti ${kernel_addr} ${initrd_addr} ${dtb_mem_addr} ``` -------------------------------- ### Install Headers Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/utils/imgui/CMakeLists.txt Installs the imgui header files if IMGUI_SKIP_HEADERS is not set. ```cmake if(NOT IMGUI_SKIP_HEADERS) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/imgui.h ${CMAKE_CURRENT_SOURCE_DIR}/imconfig.h ${CMAKE_CURRENT_SOURCE_DIR}/imgui_internal.h ${CMAKE_CURRENT_SOURCE_DIR}/imstb_textedit.h ${CMAKE_CURRENT_SOURCE_DIR}/imstb_rectpack.h ${CMAKE_CURRENT_SOURCE_DIR}/imstb_truetype.h ${CMAKE_CURRENT_SOURCE_DIR}/misc/cpp/imgui_stdlib.h ) endif() ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/utils/imgui/CMakeLists.txt Initializes CMake, sets the project name, and defines the C++ standard for Apple platforms. ```cmake cmake_minimum_required(VERSION 3.16) project(imgui CXX) set(CMAKE_DEBUG_POSTFIX d) if(APPLE) set(CMAKE_CXX_STANDARD 11) enable_language(OBJCXX) endif() ``` -------------------------------- ### Boot from USB (Drive 0) Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/board/batocera/amlogic/s905/tvbox/boot/s905_autoscript.txt Attempts to load the environment file (uEnv.txt) from USB drive 0, import its variables, and then load the kernel, initrd, and FDT if they exist. If successful, it runs the defined boot start command. ```shell if fatload usb 0 ${env_addr} uEnv.txt; then env import -t ${env_addr} ${filesize}; setenv bootargs ${APPEND}; if fatload usb 0 ${kernel_addr} ${LINUX}; then if fatload usb 0 ${initrd_addr} ${INITRD}; then if fatload usb 0 ${dtb_mem_addr} ${FDT}; then run boot_start; fi; fi; fi; fi; ``` -------------------------------- ### Configure and Install Package Configuration File Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/utils/imgui/CMakeLists.txt Configures the imgui-config.cmake file from a template and installs it to the 'share/imgui' directory. This is essential for other projects to find and use the imgui library. ```cmake include(CMakePackageConfigHelpers) configure_package_config_file(imgui-config.cmake.in imgui-config.cmake INSTALL_DESTINATION share/imgui) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/imgui-config.cmake DESTINATION share/imgui) ``` -------------------------------- ### Install imgui_impl_opengl3 and loader header Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/utils/imgui/CMakeLists.txt Installs the imgui_impl_opengl3.h and imgui_impl_opengl3_loader.h header files when the IMGUI_BUILD_OPENGL3_BINDING option is enabled. These are placed in the 'include' directory. ```cmake if(IMGUI_BUILD_OPENGL3_BINDING) install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl3.h ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl3_loader.h DESTINATION include ) endif() ``` -------------------------------- ### Boot from USB (Drive 1) Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/board/batocera/amlogic/s905/tvbox/boot/s905_autoscript.txt Attempts to load the environment file (uEnv.txt) from USB drive 1, import its variables, and then load the kernel, initrd, and FDT if they exist. If successful, it runs the defined boot start command. ```shell if fatload usb 1 ${env_addr} uEnv.txt; then env import -t ${env_addr} ${filesize}; setenv bootargs ${APPEND}; if fatload usb 1 ${kernel_addr} ${LINUX}; then if fatload usb 1 ${initrd_addr} ${INITRD}; then if fatload usb 1 ${dtb_mem_addr} ${FDT}; then run boot_start; fi; fi; fi; fi; ``` -------------------------------- ### Install Project Targets File Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/utils/imgui/CMakeLists.txt Installs the project targets file, which is necessary for CMake to correctly link against the installed imgui library. It's placed in the 'share/PROJECT_NAME' directory. ```cmake install( EXPORT ${PROJECT_NAME}_target NAMESPACE ${PROJECT_NAME}:: FILE ${PROJECT_NAME}-targets.cmake DESTINATION share/${PROJECT_NAME} ) ``` -------------------------------- ### Boot from MMC (Card 0) Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/board/batocera/amlogic/s905/tvbox/boot/s905_autoscript.txt Attempts to load the environment file (uEnv.txt) from MMC card 0, import its variables, and then load the kernel, initrd, and FDT if they exist. If successful, it runs the defined boot start command. ```shell if fatload mmc 0 ${env_addr} uEnv.txt; then env import -t ${env_addr} ${filesize}; setenv bootargs ${APPEND}; if fatload mmc 0 ${kernel_addr} ${LINUX}; then if fatload mmc 0 ${initrd_addr} ${INITRD}; then if fatload mmc 0 ${dtb_mem_addr} ${FDT}; then run boot_start; fi; fi; fi; fi; ``` -------------------------------- ### Include Directory Configuration Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/utils/imgui/CMakeLists.txt Configures include directories for the imgui library, making headers available during build and installation. ```cmake target_include_directories( ${PROJECT_NAME} PUBLIC $ $ ) ``` -------------------------------- ### PrBoom Music Configuration Example Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/emulationstation/batocera-es-system/roms/prboom/game-musics/_info.txt Edit the prboom.cfg file to specify MP3 music files for game events. Replace FILE_NAME with your actual MP3 file names. ```config # Music mus_e1m1 "./game-musics/FILE_NAME.mp3" mus_e1m2 "./game-musics/FILE_NAME.mp3" ... ``` -------------------------------- ### Run Retrogame Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/controllers/pads/retrogame/RetroGame/README.md Execute the retrogame utility with root privileges. This command starts the background service that translates GPIO inputs to keyboard events. ```bash sudo ./retrogame ``` -------------------------------- ### Initialize WebSocket and Fetch Systems Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/emulationstation/batocera-es-web-ui/web/index.html Sets up the document ready handler, fetches the initial list of systems, and establishes a WebSocket connection for real-time updates. Handles WebSocket connection closure. ```javascript var PREVDATA = null; $(document).ready(function() { fetch('/systems') .then(response => response.json()) .then(data => { showSystems(data); }); var latestOutput = document.getElementById("jumbo"); // Construct the WebSocket URL based on the current location of the web page var wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:'; var wsHost = location.host; wsHost = wsHost.split(':')\[0\]+ ":8080" var wsUrl = wsProtocol + '//' + wsHost + '/'; var ws = new WebSocket(wsUrl); ws.onmessage = function(event) { var d = event.data; if (PREVDATA != d) { var dd = JSON.parse(d); latestOutput.innerHTML = describe(dd); PREVDATA = d; } }; ws.onclose = function() { var message = { "msg": "ERROR" }; latestOutput.innerHTML = describe(message); console.log("WebSocket connection closed"); }; }); $('#myCarousel').carousel(); ``` -------------------------------- ### Reboot System Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/controllers/pads/retrogame/RetroGame/README.md Reboot the Raspberry Pi to test if the retrogame service starts automatically at boot. ```bash sudo reboot ``` -------------------------------- ### Configure Retrogame to Launch at Startup Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/controllers/pads/retrogame/RetroGame/README.md Add the retrogame command to the /etc/rc.local file to ensure it runs automatically when the system boots. This makes the controller configuration persistent. ```bash sudo nano /etc/rc.local ``` ```bash /home/pi/Recalbox-Retrogame-2Players-Pi2/retrogame & ``` -------------------------------- ### Optimize JPEG Images Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/emulationstation/batocera-es-system/roms/xash3d_fwgs/images/README.md These commands optimize JPEG images by stripping metadata and applying progressive optimization. Ensure you have `jpegoptim` and `jpegtran` installed. ```sh jpegoptim --strip-all *.jpg ``` ```sh for f in *.jpg; do jpegtran -progressive -copy none -outfile $f -optimize $f; done ``` -------------------------------- ### Set Boot Environment Variables Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/board/batocera/amlogic/s905/fun-r1/boot/aml_autoscript.txt Configures essential boot parameters, including the boot command and autoscript loading logic. ```shell setenv bootfromnand 0 setenv bootcmd "run start_autoscript; run storeboot;" setenv start_autoscript "if usb start ; then run start_usb_autoscript; fi; if mmcinfo; then run start_mmc_autoscript; fi;" setenv start_mmc_autoscript "if fatload mmc 0 1020000 s905_autoscript; then autoscr 1020000; fi;" setenv start_usb_autoscript "if fatload usb 0 1020000 s905_autoscript; then autoscr 1020000; fi; if fatload usb 1 1020000 s905_autoscript; then autoscr 1020000; fi; if fatload usb 2 1020000 s905_autoscript; then autoscr 1020000; fi; if fatload usb 3 1020000 s905_autoscript; then autoscr 1020000; fi;" setenv upgrade_step "0" saveenv ``` -------------------------------- ### Win32 Backend Configuration Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/utils/imgui/CMakeLists.txt Includes the Win32 backend source file if IMGUI_BUILD_WIN32_BINDING is enabled. ```cmake if(IMGUI_BUILD_WIN32_BINDING) target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_win32.cpp) endif() ``` -------------------------------- ### Batocera Custom Script Template Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/core/batocera-userdatainit/datainit/system/template-custom.txt This is a template for a custom script that runs on boot and shutdown in Batocera. Rename it to custom.sh to enable it. It includes a check for the 'start' argument to ensure it runs only on boot. ```bash #!/bin/bash # This is a template for the custom script that will be launched on boot # and shutdown, after the gamelist has finished scanning. The first line here # is the shebang; the binary that should be called to execute it. # Rename this file to custom.sh to enable it. # This is an example file on changing the timezone. # Set logfile location and filename logfile=/tmp/scriptlog.txt # Test for the condition to avoid running the script after booting has succeeded. if test "$1" != "start" then exit 0 fi # Set the timezone. TZ=Europe/Paris hwclock --systz --localtime # Write to the log file, result should be a text file with three blank lines. echo "$1" > $logfile echo "$1" >> $logfile ``` -------------------------------- ### Mainline U-Boot Script for Amlogic S905 Gen3 Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/board/batocera/amlogic/s905gen3/tvbox-gen3/boot/boot.scr.txt This script initializes U-Boot, sets up memory addresses, and iterates through potential boot devices (USB, MMC) to load configuration and kernel files. It configures boot arguments, including MAC address if available, and initiates the kernel boot process. ```bash echo "start mainline u-boot" setenv loadaddr "0x44000000" setenv l_mmc "0 1 2 3" for devtype in "usb mmc" ; do if test "${devtype}" = "mmc"; then setenv l_mmc "1" fi for devnum in ${l_mmc} ; do if test -e ${devtype} ${devnum} uEnv.txt; then load ${devtype} ${devnum} ${loadaddr} uEnv.txt env import -t ${loadaddr} ${filesize} setenv bootargs ${APPEND} if printenv mac; then setenv bootargs ${bootargs} mac=${mac} elif printenv eth_mac; then setenv bootargs ${bootargs} mac=${eth_mac} fi if load ${devtype} ${devnum} ${kernel_addr_r} ${LINUX}; then if load ${devtype} ${devnum} ${ramdisk_addr_r} ${INITRD}; then if load ${devtype} ${devnum} ${fdt_addr_r} ${FDT}; then fdt addr ${fdt_addr_r} booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} fi fi fi fi done done ``` -------------------------------- ### Allegro5 Backend Configuration Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/utils/imgui/CMakeLists.txt Conditionally finds Allegro5, adds its include directories, and includes the Allegro5 backend source file if IMGUI_BUILD_ALLEGRO5_BINDING is enabled. ```cmake if(IMGUI_BUILD_ALLEGRO5_BINDING) find_path(ALLEGRO5_INCLUDE_DIRS allegro5/allegro.h) target_include_directories(${PROJECT_NAME} PRIVATE ${ALLEGRO5_INCLUDE_DIRS}) target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_allegro5.cpp) endif() ``` -------------------------------- ### MSVC Qt DLL Deployment with windeployqt Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/emulators/sugarbox/CMakeLists.txt This snippet executes the windeployqt tool to deploy necessary Qt DLLs for MSVC builds. It handles different build configurations (Debug, Release, etc.) and copies the required files to the installation directory. ```cmake IF(MSVC) install (CODE " set (_outpath ${CMAKE_INSTALL_PREFIX}) set (_file ${CMAKE_CURRENT_BINARY_DIR}/$<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>/Sugarbox.exe) set ( rel_or_debug $<$:--debug>$<$:--release>$<$:--release>$<$:--release> ) execute_process( COMMAND "${CMAKE_COMMAND}" -E env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}" --dry-run --no-compiler-runtime --list mapping ${rel_or_debug} ${_file} OUTPUT_VARIABLE _output OUTPUT_STRIP_TRAILING_WHITESPACE ) separate_arguments(_files WINDOWS_COMMAND ${_output}) while(_files) list(GET _files 0 _src) list(GET _files 1 _dest) execute_process( COMMAND "${CMAKE_COMMAND}" -E copy ${_src} ${CMAKE_INSTALL_PREFIX}/${_dest} ) list(REMOVE_AT _files 0 1) endwhile() " ) endif() ``` -------------------------------- ### Bash Script Template for Game Start/Stop Events Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/core/batocera-userdatainit/datainit/system/scripts/template-game-start-stop.txt This bash script serves as a template for handling game start and stop events in Batocera. It logs the event type and all passed arguments to a temporary file for debugging purposes. Ensure the script is named appropriately (e.g., script01.sh) and has execute permissions. ```bash #!/bin/bash # This is a template for the game start/stop custom script that will be # launched on game watch event. The first line here # is the shebang; the binary that should be called to execute it. # Rename this file to script01.sh and run # "chmod +x /userdata/system/scripts/script01.sh" to give it the executable bit # to use it. Any valid filename is usable. # This is an example file how Events on START or STOP can be used. # Set logfile location and filename logfile=/tmp/scriptlog.txt # Case selection for first parameter parsed, writing to a log file on game # watch events (starting and stopping a game): case $1 in gameStart) echo "START" > $logfile echo "$@" >> $logfile ;; gameStop) echo "END" >> $logfile ;; esac ``` -------------------------------- ### Boot Command Definition Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/board/batocera/amlogic/s905/tvbox/boot/s905_autoscript.txt Defines the primary boot command using the 'bootm' command, which loads the kernel, initrd, and device tree from the specified memory addresses. ```shell setenv boot_start bootm ${kernel_addr} ${initrd_addr} ${dtb_mem_addr} ``` -------------------------------- ### OSX Backend Configuration Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/utils/imgui/CMakeLists.txt Includes the OSX backend source file if IMGUI_BUILD_OSX_BINDING is enabled. ```cmake if(IMGUI_BUILD_OSX_BINDING) target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_osx.mm) endif() ``` -------------------------------- ### Clone and Compile Retrogame Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/package/batocera/controllers/pads/retrogame/RetroGame/README.md Clone the Retrogame repository and compile the utility using make. This is the initial step before configuring the controller. ```bash $ git clone https://github.com/ian57/Recalbox-Retrogame-2Players-Pi2 $ cd Raspicade-Retrogame-2Player-Pi2 $ make ``` -------------------------------- ### Ramdisk Boot Configuration Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/board/batocera/actions/atm7039/rg35xx/uEnv.txt Sets the operating system type to Linux and defines essential boot arguments for the RG35XX. Includes earlyprintk, clock ignore, SELinux disable, and init process. ```bash uenvcmd=setenv os_type linux; bootargs=earlyprintk clk_ignore_unused selinux=0 init=/init ``` -------------------------------- ### Creating a DLDI Image File (Linux) Source: https://github.com/knulli-cfw/distribution/blob/knulli-main/board/batocera/rockchip/rk3566/fsoverlay/usr/share/drastic_steward/drastic_readme.txt Use these commands on a Linux system to create a blank DLDI image file and format it with FAT. ```bash dd if=/dev/zero of=drastic_dldi.img bs=1M count= of=drastic_dldi.img mkdosfs drastic_dldi.img ```