├── button.cfg ├── mod ├── uninstall ├── etc │ ├── options_menu │ │ ├── scripts │ │ │ ├── reboot.sh │ │ │ ├── shutdown.sh │ │ │ ├── ChangeCombo │ │ │ ├── PauseUI.sh │ │ │ ├── ResumeUI.sh │ │ │ ├── DumpFile.sh │ │ │ ├── USB_RW.sh │ │ │ ├── GetSpriteSheet.sh │ │ │ ├── RADebug.sh │ │ │ └── BenchMark.sh │ │ ├── images │ │ │ └── banner.png │ │ ├── advanced_commands │ │ │ ├── c0040_DisplayTop │ │ │ ├── c0050_BenchMark │ │ │ ├── c9999_Exit │ │ │ ├── c9999_Back │ │ │ ├── c0500_USB_RW │ │ │ ├── c0060_DumpFile │ │ │ ├── c0900_ClearCache │ │ │ ├── c0890_ChangeCombo │ │ │ ├── c0030_DisplayTemp │ │ │ ├── c0020_ModUninstall │ │ │ └── c0700_RADebug │ │ ├── commands │ │ │ ├── c9999_Exit │ │ │ ├── c0020_reboot │ │ │ ├── c0009_hibernate │ │ │ ├── c0010_shutdown │ │ │ ├── c0070_AdvancedOptions │ │ │ ├── c0080_NetworkOptions │ │ │ └── c0060_RetroarchOptions │ │ ├── network │ │ │ ├── commands │ │ │ │ ├── c0011_Reconnect │ │ │ │ ├── c0010_ShowIP │ │ │ │ ├── c0012_ShowSSID │ │ │ │ ├── c9999_Exit │ │ │ │ └── c9999_Back │ │ │ └── scripts │ │ │ │ ├── show-ssid.sh │ │ │ │ ├── reconnect.sh │ │ │ │ └── show-my-ip.sh │ │ ├── retroarch │ │ │ ├── commands │ │ │ │ ├── c9999_Exit │ │ │ │ ├── c0030_BackupNand │ │ │ │ ├── c0080_DeleteRemaps │ │ │ │ ├── c9999_Back │ │ │ │ ├── c0050_RestoreNand │ │ │ │ ├── c0020_DefaultSettings │ │ │ │ ├── c0061_DeleteBackups │ │ │ │ ├── c0061_SyncBios │ │ │ │ ├── c0040_BackupUsb │ │ │ │ ├── c0070_DeleteOverrides │ │ │ │ ├── c0060_RestoreUsb │ │ │ │ ├── c0090_ToggleLoadScreens │ │ │ │ ├── c0010_DefaultSettingsAll │ │ │ │ └── c0082_DeleteBios │ │ │ └── scripts │ │ │ │ ├── delete-remaps.sh │ │ │ │ ├── RASettingsBackup │ │ │ │ ├── delete-backups.sh │ │ │ │ ├── sync-bios.sh │ │ │ │ ├── delete-overrides.sh │ │ │ │ ├── delete-bios.sh │ │ │ │ ├── default-settings.sh │ │ │ │ ├── default-settings-all.sh │ │ │ │ ├── restore-nand.sh │ │ │ │ ├── restore-usb.sh │ │ │ │ ├── backup-usb.sh │ │ │ │ ├── backup-nand.sh │ │ │ │ └── toggle-loadscreens.sh │ │ └── mod_uninstall │ │ │ └── FinishUninstall.sh │ ├── hibernate_mod │ │ ├── 1.png.xz │ │ └── hibernating.png.xz │ └── init.d │ │ └── S8103OptionsMenu ├── install ├── readme ├── readme.md └── bin │ └── standby ├── src ├── framework │ ├── sdl_helper.h │ ├── powerwatch.h │ ├── sdl_context.h │ ├── controller.h │ ├── texture.h │ ├── sdl_context.cpp │ ├── powerwatch.cpp │ ├── controller.cpp │ ├── texture.cpp │ └── font8x8_basic.h ├── command.h ├── daemon.cpp ├── command.cpp ├── standby_watchdog.cpp ├── mod_uninstall.cpp └── main.cpp ├── Makefile ├── README.md └── LICENSE /button.cfg: -------------------------------------------------------------------------------- 1 | 305 707 707 -------------------------------------------------------------------------------- /mod/uninstall: -------------------------------------------------------------------------------- 1 | rm -f "$rootfs/etc/options_menu/button.cfg" 2 | -------------------------------------------------------------------------------- /mod/etc/options_menu/scripts/reboot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usleep 100000 && sync && reboot 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/scripts/shutdown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usleep 100000 && sync && gameover 4 | -------------------------------------------------------------------------------- /mod/etc/hibernate_mod/1.png.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompCom/OptionsMenu/HEAD/mod/etc/hibernate_mod/1.png.xz -------------------------------------------------------------------------------- /mod/etc/options_menu/images/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompCom/OptionsMenu/HEAD/mod/etc/options_menu/images/banner.png -------------------------------------------------------------------------------- /mod/etc/hibernate_mod/hibernating.png.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompCom/OptionsMenu/HEAD/mod/etc/hibernate_mod/hibernating.png.xz -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c0040_DisplayTop: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Run Top 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=top -b -n 1 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/scripts/ChangeCombo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompCom/OptionsMenu/HEAD/mod/etc/options_menu/scripts/ChangeCombo -------------------------------------------------------------------------------- /mod/etc/options_menu/commands/c9999_Exit: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Exit 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=TRUE 4 | COMMAND_STR=echo "Closing Options Menu" 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/network/commands/c0011_Reconnect: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Reconnect 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/reconnect.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c0050_BenchMark: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Benchmark Tool 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/BenchMark.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/network/commands/c0010_ShowIP: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Display IP Address 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/show-my-ip.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/network/commands/c0012_ShowSSID: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Search for SSIDs 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/show-ssid.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c9999_Exit: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Exit 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=TRUE 4 | COMMAND_STR=echo "Closing Options Menu" 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/network/commands/c9999_Exit: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Exit 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=TRUE 4 | COMMAND_STR=echo "Closing Options Menu" 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c9999_Exit: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Exit 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=TRUE 4 | COMMAND_STR=echo "Closing Options Menu" 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/delete-remaps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -r /etc/libretro/.config/retroarch/config/remaps/* 4 | echo "Remaps deleted." 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/RASettingsBackup: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompCom/OptionsMenu/HEAD/mod/etc/options_menu/retroarch/scripts/RASettingsBackup -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/delete-backups.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf /etc/ra_backup/ 4 | rm -rf /media/data/ra_backup 5 | echo "Backup files deleted." 6 | -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c9999_Back: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Back 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | COMMAND_STR=usleep 50000 && %options_path%/options & -------------------------------------------------------------------------------- /mod/etc/options_menu/network/commands/c9999_Back: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Back 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | COMMAND_STR=usleep 50000 && %options_path%/options & -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0030_BackupNand: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Backup Settings to NAND 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/backup-nand.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0080_DeleteRemaps: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Delete remap files 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/delete-remaps.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c9999_Back: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Back 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | COMMAND_STR=usleep 50000 && %options_path%/options & -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0050_RestoreNand: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Restore Settings from NAND 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/restore-nand.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c0500_USB_RW: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Toggle Write Access on USB 2 | COMMAND_TYPE=INTERNAL 3 | USB_ONLY=TRUE 4 | COMMAND_STR=sh %script_dir%/USB_RW.sh 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0020_DefaultSettings: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Restore Default Settings 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/default-settings.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0061_DeleteBackups: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Delete all settings backups 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/delete-backups.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0061_SyncBios: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Transfer BIOS file(s) 2 | COMMAND_TYPE=INTERNAL 3 | USB_ONLY=TRUE 4 | COMMAND_STR=sh %script_dir%/sync-bios.sh 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c0060_DumpFile: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Dump File Structure (to USB) 2 | COMMAND_TYPE=INTERNAL 3 | USB_ONLY=TRUE 4 | COMMAND_STR=sh %script_dir%/DumpFile.sh 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0040_BackupUsb: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Backup Settings to USB 2 | COMMAND_TYPE=INTERNAL 3 | USB_ONLY=TRUE 4 | COMMAND_STR=sh %script_dir%/backup-usb.sh 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0070_DeleteOverrides: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Delete game and core overrides 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/delete-overrides.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c0900_ClearCache: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Clear Cache 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=free -m && sync && echo 1 > /proc/sys/vm/drop_caches && free -m 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0060_RestoreUsb: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Restore Settings from USB 2 | COMMAND_TYPE=INTERNAL 3 | USB_ONLY=TRUE 4 | COMMAND_STR=sh %script_dir%/restore-usb.sh 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0090_ToggleLoadScreens: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Toggle RA and Canoe load screens 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/toggle-loadscreens.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/commands/c0020_reboot: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Reboot Device 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | COMMAND_STR=sh %script_dir%/ResumeUI.sh && sh %script_dir%/reboot.sh & 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0010_DefaultSettingsAll: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Restore Default Settings (All) 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=sh %script_dir%/default-settings-all.sh 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/commands/c0082_DeleteBios: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Delete BIOS file(s) from NAND 2 | COMMAND_TYPE=INTERNAL 3 | USB_ONLY=TRUE 4 | COMMAND_STR=sh %script_dir%/delete-bios.sh 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c0890_ChangeCombo: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Change Options Button Combo 2 | COMMAND_TYPE=INTERNAL 3 | IGNORE_INTERRUPT=TRUE 4 | COMMAND_STR=exec %script_dir%/ChangeCombo 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/commands/c0009_hibernate: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Hibernate/Standby 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | COMMAND_STR=standby_watchdog --displayMenu && sh %script_dir%/ResumeUI.sh & -------------------------------------------------------------------------------- /mod/etc/options_menu/commands/c0010_shutdown: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Shutdown Device 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | COMMAND_STR=sh %script_dir%/ResumeUI.sh && sh %script_dir%/shutdown.sh & 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c0030_DisplayTemp: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Display Temp 2 | COMMAND_TYPE=INTERNAL 3 | COMMAND_STR=echo "Current Temperature: $(cat "/sys/class/thermal/thermal_zone0/temp")c" 4 | -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c0020_ModUninstall: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Module Uninstaller 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | COMMAND_STR=%options_path%/mod_uninstall/mod_uninstall && sh %script_dir%/ResumeUI.sh & 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/mod_uninstall/FinishUninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | source /etc/preinit 4 | script_init 5 | 6 | mkdir -p "$installpath/transfer" 7 | copy "/tmp/uninstall" "$installpath/transfer" 8 | sync 9 | reboot 10 | -------------------------------------------------------------------------------- /mod/etc/options_menu/advanced_commands/c0700_RADebug: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=RetroArch Debugger (USB logs) 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | USB_ONLY=TRUE 5 | COMMAND_STR=sh %script_dir%/RADebug.sh && sh %script_dir%/ResumeUI.sh & 6 | -------------------------------------------------------------------------------- /mod/etc/options_menu/commands/c0070_AdvancedOptions: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Advanced Options 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | COMMAND_STR=usleep 50000 && %options_path%/options --commandPath %options_path%/advanced_commands/ --title "Advanced Options" & 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/scripts/PauseUI.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | source /etc/preinit 4 | script_init 5 | 6 | if type -t uipause 1> /dev/null; then 7 | uipause 8 | else 9 | lsof -n | grep -F "/dev/fb0" | awk '{print $1}' | sort -u | xargs -r kill -s STOP 10 | fi 11 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/sync-bios.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ ! -d "/media/data/ra_bios" ] && mkdir -p /media/data/ra_bios 4 | rsync -a /media/data/ra_bios/* /etc/libretro/system 5 | rsync -a /etc/libretro/system/* /media/data/ra_bios 6 | echo "BIOS file(s) transfered." 7 | -------------------------------------------------------------------------------- /mod/etc/options_menu/commands/c0080_NetworkOptions: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Network Options 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | COMMAND_STR=usleep 50000 && %options_path%/options --commandPath %options_path%/network/commands/ --scriptPath %options_path%/network/scripts --title "Network Options" & 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/commands/c0060_RetroarchOptions: -------------------------------------------------------------------------------- 1 | COMMAND_NAME=Retroarch Options 2 | COMMAND_TYPE=EXTERNAL 3 | RESTART_UI=FALSE 4 | COMMAND_STR=usleep 50000 && %options_path%/options --commandPath %options_path%/retroarch/commands/ --scriptPath %options_path%/retroarch/scripts --title "Retroarch Options" & 5 | -------------------------------------------------------------------------------- /mod/etc/options_menu/scripts/ResumeUI.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | source /etc/preinit 4 | script_init 5 | 6 | usleep 200000 7 | if type -t uiresume 1> /dev/null; then 8 | uiresume 9 | else 10 | lsof -n | grep -F "/dev/fb0" | awk '{print $1}' | sort -u | xargs -r kill -s CONT 11 | fi 12 | rm /tmp/options.flag 13 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/delete-overrides.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mv /etc/libretro/.config/retroarch/config/remaps /etc/libretro/.config/retroarch/ 4 | rm -r /etc/libretro/.config/retroarch/config/* 5 | mv /etc/libretro/.config/retroarch/remaps /etc/libretro/.config/retroarch/config/ 6 | echo "Overrides deleted." 7 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/delete-bios.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mv /etc/libretro/system/NstDatabase.xml /etc/libretro 4 | mv /etc/libretro/system/PPSSPP /etc/libretro 5 | rm -rf /etc/libretro/system/* 6 | mv /etc/libretro/NstDatabase.xml /etc/libretro/system 7 | mv /etc/libretro/PPSSPP /etc/libretro/system 8 | echo "BIOS file(s) deleted." 9 | -------------------------------------------------------------------------------- /mod/etc/options_menu/network/scripts/show-ssid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Scanning for available networks..." 4 | wpa_cli scan >/dev/null 2>& 1 5 | if ( ifconfig wlan0 | head -3 | tail -1 | grep UP ) > /dev/null 2>& 1 6 | then 7 | wpa_cli scan_results | sed -r "s/\\/.*//g;s/'wlan0'//g;" | awk '{print $4" "$5}' 8 | else 9 | echo "Cannot find any WiFi Networks." 10 | fi 11 | echo "Scan complete." 12 | -------------------------------------------------------------------------------- /mod/etc/init.d/S8103OptionsMenu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | start() { 4 | /etc/options_menu/optiond & 5 | } 6 | 7 | stop() { 8 | killall optiond 9 | killall options 10 | rm -f /tmp/options.flag 11 | } 12 | 13 | case "$1" in 14 | start) 15 | start 16 | ;; 17 | stop) 18 | stop 19 | ;; 20 | restart) 21 | stop 22 | start 23 | ;; 24 | *) 25 | echo "optiond: Please use start, stop, or restart." 26 | exit 1 27 | ;; 28 | esac 29 | -------------------------------------------------------------------------------- /mod/etc/options_menu/scripts/DumpFile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #Create Data directories if it's not already created and mounted... 4 | mkdir -m 777 /media/data/ 5 | mkdir -m 777 /media/data/log 6 | 7 | #Clear down the log files 8 | rm /media/data/log/Hakchi_file_structure.log 9 | 10 | echo "Dumping complete file structure to /media/data/log/ ..." 11 | echo "$(ls -lhAR /)" &> /media/data/log/Hakchi_file_structure.log 12 | echo "File structure dump was successful!" 13 | -------------------------------------------------------------------------------- /src/framework/sdl_helper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #ifndef SDL_HELPER_H_ 11 | #define SDL_HELPER_H_ 12 | 13 | #include "sdl_context.h" 14 | #include "texture.h" 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /mod/etc/options_menu/scripts/USB_RW.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Script originally by Daniel Radtke 4 | # 5 | source /etc/preinit 6 | script_init 7 | 8 | script_path="$(dirname "$0")" 9 | 10 | if [ "$cfg_usb_rw" == "y" ]; then 11 | unset cfg_usb_rw 12 | echo "USB write access disabled..." 13 | else 14 | cfg_usb_rw='y' 15 | echo "USB write access enabled..." 16 | fi 17 | 18 | save_config 19 | echo " " 20 | echo "Rebooting console in 5 seconds..." 21 | 22 | sleep(5) 23 | 24 | reboot -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/default-settings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -f "/etc/options_menu/retroarch/default_files/retroarch.cfg" ]; then 4 | cp /etc/options_menu/retroarch/default_files/retroarch.cfg /etc/libretro/ 5 | cp /etc/options_menu/retroarch/default_files/retroarch-core-options.cfg /etc/libretro/ 6 | echo "Restored Default Settings." 7 | else 8 | echo "Cannot locate default configuration files." 9 | echo "Please ensure you have the latest RetroArch 'Neo' installed" 10 | fi 11 | -------------------------------------------------------------------------------- /mod/etc/options_menu/network/scripts/reconnect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Testing internet connection..." 4 | sleep 1 5 | if nc -zw1 google.com 443; then 6 | echo "You are already connected to the internet." 7 | else 8 | echo "Restarting network. Please wait." 9 | /etc/init.d/S92networking restart 10 | echo "Testing internet connection..." 11 | sleep 5 12 | if nc -zw1 google.com 443; then 13 | echo "Success! You are now connected to the internet." 14 | else 15 | echo "Connection failed. Please connect your WiFi adapter." 16 | fi 17 | fi 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/framework/powerwatch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #ifndef POWERWATCH_H_ 11 | #define POWERWATCH_H_ 12 | 13 | struct PowerWatch 14 | { 15 | int powerFd = -1, resetFd = -1; 16 | 17 | PowerWatch(); 18 | ~PowerWatch(); 19 | bool buttonPress(); 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /mod/etc/options_menu/network/scripts/show-my-ip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Grabbing Internal IP..." 4 | 5 | ifconfig | grep "inet " | grep -v 127.0.0.1|awk 'match($0, /([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/) {print "Your internal IP is: " substr($0,RSTART,RLENGTH)}' 6 | 7 | echo "Grabbing External IP... (Might take a bit)" 8 | 9 | PUBLIC_IP=$(wget http://ipecho.net/plain -O - -q) 10 | 11 | wget -q --tries=10 --timeout=10 --spider http://google.com 12 | 13 | if [[ $? -eq 0 ]]; then 14 | echo "You are online!" 15 | echo "Your external IP is:" $PUBLIC_IP 16 | else 17 | echo "You are offline" 18 | fi 19 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/default-settings-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -f "/etc/options_menu/retroarch/default_files/retroarch.cfg" ]; then 4 | cp /etc/options_menu/retroarch/default_files/retroarch.cfg /etc/libretro/ 5 | cp /etc/options_menu/retroarch/default_files/retroarch-core-options.cfg /etc/libretro/ 6 | rm -r /etc/libretro/.config/retroarch/config/* 7 | mkdir -m 777 /etc/libretro/.config/retroarch/config/remaps 8 | echo "Restored Default Settings." 9 | else 10 | echo "Cannot locate default configuration files." 11 | echo "Please ensure you have the latest RetroArch 'Neo' installed" 12 | fi 13 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/restore-nand.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -f "/etc/ra_backup/retroarch.cfg" ]; then 4 | echo "Backup file does not exist." 5 | else 6 | /etc/options_menu/retroarch/scripts/RASettingsBackup "Restore" "/etc/options_menu/retroarch/default_files/retroarch.cfg" "/etc/libretro/retroarch.cfg" "$rootfs/etc/ra_backup/retroarch.cfg" 7 | /etc/options_menu/retroarch/scripts/RASettingsBackup "Restore" "/etc/options_menu/retroarch/default_files/retroarch-core-options.cfg" "/etc/libretro/retroarch-core-options.cfg" "$rootfs/etc/ra_backup/retroarch-core-options.cfg" 8 | rm -rf /etc/libretro/.config/retroarch/config/ 9 | cp -r /etc/ra_backup/config /etc/libretro/.config/retroarch 10 | echo "Retroarch configs restored." 11 | fi 12 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/restore-usb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -f "/media/data/ra_backup/retroarch.cfg" ]; then 4 | echo "Backup file does not exist." 5 | else 6 | /etc/options_menu/retroarch/scripts/RASettingsBackup "Restore" "/etc/options_menu/retroarch/default_files/retroarch.cfg" "/etc/libretro/retroarch.cfg" "/media/data/ra_backup/retroarch.cfg" 7 | /etc/options_menu/retroarch/scripts/RASettingsBackup "Restore" "/etc/options_menu/retroarch/default_files/retroarch-core-options.cfg" "/etc/libretro/retroarch-core-options.cfg" "/media/data/ra_backup/retroarch-core-options.cfg" 8 | rm -rf /etc/libretro/.config/retroarch/config/ 9 | cp -r /media/data/ra_backup/config /etc/libretro/.config/retroarch 10 | echo "Retroarch configs restored." 11 | fi 12 | -------------------------------------------------------------------------------- /mod/install: -------------------------------------------------------------------------------- 1 | transfer_default 2 | chmod +x "$rootfs/etc/options_menu/options" 3 | chmod +x "$rootfs/etc/options_menu/optiond" 4 | chmod +x "$rootfs/etc/options_menu/mod_uninstall/mod_uninstall" 5 | chmod +x "$rootfs/etc/options_menu/scripts/ChangeCombo" 6 | chmod +x "$rootfs/etc/options_menu/retroarch/scripts/RASettingsBackup" 7 | chmod +x "$rootfs/bin/standby" 8 | chmod +x "$rootfs/bin/standby_watchdog" 9 | rm -f "$rootfs/etc/init.d/S83standby_watchdog" 10 | rm -f "$rootfs/etc/options_menu/retroarch/commands/c0025_ToggleLoadScreens" 11 | rm -f "$installpath/hmod/uninstall-hibernate_mod"* 12 | rm -f "$installpath/hmod/uninstall-options_deluxe_"* 13 | rm -f "$installpath/hmod/uninstall-options_menu_"* 14 | rm -f "$installpath/hmod/uninstall-Hakchi_Options_Loadscreen_toggle" 15 | return 1 16 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/backup-usb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | Backup_To_USB() 4 | { 5 | if [ -d /media/data/ra_backup ]; then 6 | rm -rf /media/data/ra_backup/ 7 | fi 8 | 9 | mkdir -pm 777 /media/data/ra_backup 10 | /etc/options_menu/retroarch/scripts/RASettingsBackup "Backup" "/etc/options_menu/retroarch/default_files/retroarch.cfg" "/etc/libretro/retroarch.cfg" "/media/data/ra_backup/retroarch.cfg" 11 | /etc/options_menu/retroarch/scripts/RASettingsBackup "Backup" "/etc/options_menu/retroarch/default_files/retroarch-core-options.cfg" "/etc/libretro/retroarch-core-options.cfg" "/media/data/ra_backup/retroarch-core-options.cfg" 12 | cp -r /etc/libretro/.config/retroarch/config /media/data/ra_backup 13 | } 14 | 15 | Backup_To_USB && echo "Retroarch config backed up to USB:/data/ra_backup" 16 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/backup-nand.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | source /etc/preinit 4 | script_init 5 | 6 | Backup_To_NAND() 7 | { 8 | if [ -d "$rootfs/etc/ra_backup" ]; then 9 | rm -rf "$rootfs/etc/ra_backup/" 10 | fi 11 | 12 | mkdir -pm 777 "$rootfs/etc/ra_backup" 13 | /etc/options_menu/retroarch/scripts/RASettingsBackup "Backup" "/etc/options_menu/retroarch/default_files/retroarch.cfg" "/etc/libretro/retroarch.cfg" "$rootfs/etc/ra_backup/retroarch.cfg" 14 | /etc/options_menu/retroarch/scripts/RASettingsBackup "Backup" "/etc/options_menu/retroarch/default_files/retroarch-core-options.cfg" "/etc/libretro/retroarch-core-options.cfg" "$rootfs/etc/ra_backup/retroarch-core-options.cfg" 15 | cp -r /etc/libretro/.config/retroarch/config "$rootfs/etc/ra_backup" 16 | } 17 | 18 | Backup_To_NAND && echo "Retroarch config backed up to /etc/ra_backup" 19 | -------------------------------------------------------------------------------- /mod/readme: -------------------------------------------------------------------------------- 1 | === Options Menu v1.3.4 by CompCom === 2 | The Options Menu is a custom menu that can be launched by holding controller button combo (L+R) for more than 1 second at any point during the console’s operation. 3 | 4 | Current features provided by the options menu include: Hmod Uninstaller, Hibernate Mod and Retroarch Settings Management. 5 | 6 | Full documentation for the options menu can be found at https://github.com/CompCom/OptionsMenu 7 | 8 | Contributions: 9 | Hibernate Mod and Hakchi-Option-Pack scripts courtesy of Swingflip 10 | Retroarch Configuration scripts courtesy of BsLeNuL 11 | Thanks to ThanosRD for assistance with UI Layout/Design 12 | 13 | Extra thanks to DNA64 (viral_dna) and Swingflip for always testing features. 14 | Also thanks to the following people for testing the options menu: BsLeNuL, DefKorns, DR1001, Patton Plays, ThanosRD 15 | -------------------------------------------------------------------------------- /src/command.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #ifndef COMMAND_H_ 11 | #define COMMAND_H_ 12 | 13 | #include "framework/sdl_helper.h" 14 | 15 | class Controller; 16 | 17 | struct Command 18 | { 19 | Command(); 20 | Command(std::ifstream & in); 21 | void RunCommand(SDL_Context & sdl_context, Controller * controller, Sprite & menuL, Sprite & menuU) const; 22 | 23 | std::string name; 24 | std::string command; 25 | bool runInternal = true; 26 | bool restartUI = false; 27 | bool ignoreInterrupt = false; 28 | bool usbOnly = false; 29 | Texture texture; 30 | std::string previewImage; 31 | int previewImageX = 0; 32 | int previewImageY = 0; 33 | int previewImageWidth = -1; 34 | int previewImageHeight = -1; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/framework/sdl_context.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #ifndef SDL_CONTEXT_H_ 11 | #define SDL_CONTEXT_H_ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | class PowerWatch; 18 | class SDL_Window; 19 | class SDL_Renderer; 20 | 21 | struct SDL_Context 22 | { 23 | public: 24 | SDL_Context(std::chrono::milliseconds fpsTime = std::chrono::milliseconds(33), bool powerButtonExit = true); 25 | ~SDL_Context(); 26 | void StartFrame(); 27 | void EndFrame(); 28 | 29 | SDL_Window* window; 30 | SDL_Renderer* renderer; 31 | std::chrono::milliseconds fpsTime; 32 | PowerWatch * powerwatch; 33 | 34 | private: 35 | std::chrono::time_point nextFrameTime; 36 | bool powerButtonExit; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/framework/controller.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | #ifndef CONTROLLER_H_ 10 | #define CONTROLLER_H_ 11 | 12 | #include 13 | 14 | enum GameButton : uint16_t { A=304, B=305, X=307, Y=308, L=310, R=311, SELECT=314, START=315, LEFT=704, RIGHT=705, UP=706, DOWN=707 }; 15 | 16 | struct ButtonEvent 17 | { 18 | char unk0[8]; 19 | unsigned short unk1; 20 | GameButton button; 21 | unsigned short pressed; 22 | unsigned short zero; 23 | }; 24 | 25 | class Controller 26 | { 27 | private: 28 | int fd = -1; 29 | ButtonEvent buttonBuffer[10]; 30 | std::map buttons; 31 | public: 32 | Controller(int id); 33 | ~Controller(); 34 | bool PeekButtonStatus(GameButton button); 35 | bool GetButtonStatus(GameButton button); 36 | void Update(); 37 | void Reset(); 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /mod/readme.md: -------------------------------------------------------------------------------- 1 | ------------------------------ 2 | Name: Options Menu v1.3.4 3 | Creator: CompCom 4 | Category: System 5 | ------------------------------ 6 | ## What is the options menu? 7 | The Options Menu is a custom menu that can be launched by holding controller button combo (L+R) for more than 1 second at any point during the console’s operation. 8 | 9 | Current features provided by the options menu include: 10 | 11 | - Hmod Uninstaller 12 | - Hibernate Mod 13 | - Retroarch Settings Management 14 | 15 | ## Documentation 16 | Full documentation for the options menu can be found [here](https://github.com/CompCom/OptionsMenu). 17 | 18 | ## Contributions and Thanks 19 | ### Contributions 20 | - Hibernate Mod and Hakchi-Option-Pack scripts courtesy of Swingflip 21 | - Retroarch Configuration scripts courtesy of BsLeNuL 22 | - Thanks to ThanosRD for assistance with UI Layout/Design 23 | ### Testing 24 | Extra thanks to DNA64 (viral_dna) and Swingflip for always testing features. 25 | 26 | Also thanks to the following people for testing the options menu: 27 | 28 | - BsLeNuL 29 | - DefKorns 30 | - DR1001 31 | - Patton Plays 32 | - ThanosRD 33 | -------------------------------------------------------------------------------- /mod/etc/options_menu/scripts/GetSpriteSheet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Get Sprite Sheet code based on External UI hmod by DanTheMan827 4 | 5 | source /etc/preinit 6 | script_init 7 | 8 | region="$sfregion" 9 | # For backwards compatibility with previous hakchi versions 10 | [ "$(cat "$mountpoint/etc/clover/REGION")" == "EUR" ] && region="eur" 11 | 12 | case "$sftype-$region" in 13 | nes-usa) 14 | echo -ne "$mountpoint/usr/share/clover-ui/resources/sprites/nes.png" 15 | ;; 16 | nes-eur) 17 | echo -ne "$mountpoint/usr/share/clover-ui/resources/sprites/nes.png" 18 | ;; 19 | nes-jpn) 20 | echo -ne "$mountpoint/usr/share/clover-ui/resources/sprites/hvc.png" 21 | ;; 22 | hvcj-jpn) 23 | echo -ne "$mountpoint/usr/share/ui/hvc/resources/sprites/packed.png" 24 | ;; 25 | snes-usa) 26 | echo -ne "$mountpoint/usr/share/ui/snes-usa/resources/sprites/packed.png" 27 | ;; 28 | snes-eur) 29 | echo -ne "$mountpoint/usr/share/ui/snes-eur/resources/sprites/packed.png" 30 | ;; 31 | snes-jpn) 32 | echo -ne "$mountpoint/usr/share/ui/shvc/resources/sprites/packed.png" 33 | ;; 34 | esac 35 | -------------------------------------------------------------------------------- /mod/etc/options_menu/scripts/RADebug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #Create Data directories if it's not already created and mounted... 4 | mkdir -m 777 /media/data/ 5 | mkdir -m 777 /media/data/log 6 | mkdir -m 777 /media/data/log/RetroArchConfig 7 | 8 | #Clear down the log files 9 | rm /media/data/log/Hakchi_retroarch_debug.log 10 | rm -rf /media/data/log/RetroArchConfig/* 11 | 12 | echo "$(chmod -R 777 /etc/libretro)" >> /media/data/log/Hakchi_retroarch_debug.log #Set full permissions for retroarch 13 | echo "Dumping retroarch config to log folder..." >> /media/data/log/Hakchi_retroarch_debug.log 14 | echo "$(cp -r /etc/libretro/.config /media/data/log/RetroArchConfig)" >> /media/data/log/Hakchi_retroarch_debug.log 15 | echo "$(cp -r /etc/libretro/retroarch-core-options.cfg /media/data/log/RetroArchConfig)" >> /media/data/log/Hakchi_retroarch_debug.log 16 | echo "$(cp -r /etc/libretro/retroarch.cfg /media/data/log/RetroArchConfig)" >> /media/data/log/Hakchi_retroarch_debug.log 17 | if /bin/retroarch-mini null &> /media/data/log/Hakchi_retroarch_debug.log ; then 18 | echo "RetroArch successfully ran using the test rig at $(date)" >> /media/data/log/Hakchi_retroarch_debug.log 19 | else 20 | echo "RetroArch FAILED to run using the test rig at $(date)" >> /media/data/log/Hakchi_retroarch_debug.log 21 | fi -------------------------------------------------------------------------------- /src/framework/texture.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #ifndef TEXTURE_H_ 11 | #define TEXTURE_H_ 12 | 13 | #include 14 | #include 15 | 16 | struct Texture 17 | { 18 | std::shared_ptr texture; 19 | SDL_Rect rect; 20 | Texture(); 21 | Texture(const std::string & text, int fontSize, SDL_Renderer* renderer, int x = 0, int y = 0, bool centerText = false, const int color = 0xFFFFFFFF); 22 | Texture(const std::string & pngFilePath, SDL_Renderer* renderer, int x = 0, int y = 0, bool centerImg = false); 23 | void Draw(SDL_Renderer* renderer); 24 | void Draw(SDL_Renderer* renderer, SDL_RendererFlip flip_enum); 25 | }; 26 | 27 | struct Sprite 28 | { 29 | std::shared_ptr texture; 30 | SDL_Rect sRect, dRect; 31 | void Draw(SDL_Renderer * renderer); 32 | }; 33 | 34 | SDL_Texture * LoadTexturePNG(SDL_Renderer *renderer, std::string file, SDL_Rect * rect = nullptr); 35 | SDL_Texture * WriteText(const std::string & text, int fontSize, SDL_Renderer* renderer, int & textureWidth, int & textureHeight, const int color = 0xFFFFFF); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /mod/etc/options_menu/retroarch/scripts/toggle-loadscreens.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | source /etc/preinit 4 | script_init 5 | 6 | ok=0 7 | 8 | echo "Toggling RetroArch and Canoe loading screens." && echo " " 9 | 10 | if [ -f "$rootfs/share/retroarch/assets/RAloading-min.png" ] && [ -f "$rootfs/share/retroarch/assets/loading-min.png" ]; then 11 | mv "$rootfs/share/retroarch/assets/RAloading-min.png" "$rootfs/share/retroarch/assets/RAloading-min.png_DISABLED" 12 | echo "RetroArch loading screen disabled..." && echo " " 13 | mv "$rootfs/share/retroarch/assets/loading-min.png" "$rootfs/share/retroarch/assets/loading-min.png_DISABLED" 14 | echo "Canoe loading screen disabled..." && echo " " 15 | ok=1 16 | fi 17 | 18 | if [ -f "$rootfs/share/retroarch/assets/RAloading-min.png_DISABLED" ] && [ -f "$rootfs/share/retroarch/assets/loading-min.png_DISABLED" ] && [ "$ok" == 0 ]; then 19 | mv "$rootfs/share/retroarch/assets/RAloading-min.png_DISABLED" "$rootfs/share/retroarch/assets/RAloading-min.png" 20 | echo "RetroArch loading screen enabled..." && echo " " 21 | mv "$rootfs/share/retroarch/assets/loading-min.png_DISABLED" "$rootfs/share/retroarch/assets/loading-min.png" 22 | echo "Canoe loading screen enabled..." && echo " " 23 | ok=1 24 | fi 25 | 26 | if [ "$ok" == 1 ]; then 27 | echo "RetroArch load screen toggle complete!" 28 | else 29 | echo "Failed to locate load screens... Please ensure you are using the latest RetroArch 'Neo' Build!" 30 | fi 31 | -------------------------------------------------------------------------------- /src/framework/sdl_context.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #include "sdl_context.h" 11 | #include "powerwatch.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | SDL_Context::SDL_Context(std::chrono::milliseconds fpsTime, bool powerButtonExit) : fpsTime(fpsTime), powerButtonExit(powerButtonExit) 18 | { 19 | powerwatch = new PowerWatch(); 20 | window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1280, 720, SDL_WINDOW_FULLSCREEN); 21 | renderer = SDL_CreateRenderer(window, -1, 0); 22 | if(renderer == NULL) { 23 | std::cerr << "Cannot create renderer.\n"; 24 | SDL_DestroyWindow(window); 25 | exit(1); 26 | } 27 | nextFrameTime = std::chrono::system_clock::now()+fpsTime; 28 | } 29 | 30 | SDL_Context::~SDL_Context() 31 | { 32 | delete powerwatch; 33 | SDL_DestroyRenderer(renderer); 34 | SDL_DestroyWindow(window); 35 | SDL_Quit(); 36 | } 37 | 38 | void SDL_Context::StartFrame() 39 | { 40 | if(powerButtonExit && powerwatch->buttonPress()) 41 | exit(1); 42 | SDL_RenderClear(renderer); 43 | } 44 | 45 | void SDL_Context::EndFrame() 46 | { 47 | SDL_RenderPresent(renderer); 48 | std::this_thread::sleep_until(nextFrameTime); 49 | nextFrameTime += fpsTime; 50 | } 51 | -------------------------------------------------------------------------------- /src/daemon.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #include "framework/controller.h" 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | int main() 17 | { 18 | Controller c(1); 19 | GameButton button1 = L, button2 = R, button3 = R; 20 | 21 | std::ifstream in("/etc/options_menu/button.cfg"); 22 | if(in.is_open()) 23 | { 24 | int temp; 25 | in >> temp; 26 | button1 = (GameButton)temp; 27 | in >> temp; 28 | button2 = (GameButton)temp; 29 | in >> temp; 30 | button3 = (GameButton)temp; 31 | in.close(); 32 | } 33 | 34 | system("sh /etc/options_menu/scripts/GetSpriteSheet.sh > /tmp/spritesheet"); 35 | 36 | const auto waitTime = std::chrono::milliseconds(100); 37 | const short holdThreshold = 10; 38 | short holdCount = 0; 39 | 40 | for(;;) 41 | { 42 | c.Update(); 43 | if(c.PeekButtonStatus(button1) && c.PeekButtonStatus(button2) && c.PeekButtonStatus(button3)) 44 | { 45 | ++holdCount; 46 | if(holdCount >= holdThreshold) 47 | { 48 | if(system("[ ! -f \"/tmp/options.flag\" ] && [ $(free -m | awk 'NR==3 { print $4; }') -gt 35 ] && /bin/sh /etc/options_menu/scripts/PauseUI.sh") == 0) 49 | system("exec /etc/options_menu/options"); 50 | holdCount = 0; 51 | c.Update(); 52 | c.Reset(); 53 | } 54 | } 55 | else if(holdCount) 56 | holdCount = 0; 57 | std::this_thread::sleep_for(waitTime); 58 | } 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /mod/etc/options_menu/scripts/BenchMark.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo " MM " 4 | echo " MM MM " 5 | echo " MM MM User: $USER" 6 | if [ -z "$HOSTNAME" ]; then 7 | echo " MM MM Hostname: Not Applicable" 8 | else 9 | echo " MM MM Hostname: $HOSTNAME" 10 | fi 11 | echo " MMMMMMMMMM MM MM MMMMMMMMMM OS: $MODNAME $(uname -s -m)" 12 | echo " MM MM MM MM Kernel: $(uname -r)" 13 | echo " MM MM Terminal Build: v0.1 (alpha)" 14 | echo " MM MM Shell: SHELL" 15 | echo " MM MM ModPath: $MODPATH" 16 | echo " MM MMMMMM MM Installed Binaries: $(ls /bin/ -1 | wc -l)" 17 | echo " MM MMMM MMMM MM " 18 | echo " MM MMMM MMMM MM " 19 | echo " MMMMMM MMMMMM " 20 | echo " " 21 | sleep 2 22 | echo "======================================================================================" 23 | echo " http://github.com/swingflip" 24 | echo "======================================================================================" 25 | echo "Disk mounting information:" 26 | echo "$(df)" 27 | #top has a big overhead for some reason on the mini. Doesn't give much useful information anyway... 28 | sleep 2 29 | echo "======================================================================================" 30 | echo "CPU analysis information:" 31 | echo "$(top -b -n 1 | head -n 15)" 32 | sleep 2 33 | echo "======================================================================================" 34 | echo "RAM analysis information:" 35 | echo "$(free)" 36 | echo "======================================================================================" 37 | echo "Benchmark ran successfully!!" 38 | echo "" 39 | -------------------------------------------------------------------------------- /src/framework/powerwatch.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #include "powerwatch.h" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | PowerWatch::PowerWatch() 19 | { 20 | #ifdef __arm__ 21 | if(auto dir = opendir("/dev/input/")) 22 | { 23 | while(auto entry = readdir(dir)) 24 | { 25 | std::string name(entry->d_name); 26 | if(name.find("event") != std::string::npos) 27 | { 28 | std::ifstream in("/sys/class/input/"+name+"/device/name"); 29 | if(in.good()) 30 | { 31 | std::string temp; 32 | std::getline(in, temp); 33 | in.close(); 34 | if(temp.compare("sunxi-knob") == 0 || temp.compare("gpio-keys") == 0) 35 | powerFd = open(("/dev/input/"+name).c_str(), O_RDONLY | O_NONBLOCK); 36 | else if(temp.compare("sunxi-keyboard") == 0) 37 | resetFd = open(("/dev/input/"+name).c_str(), O_RDONLY | O_NONBLOCK); 38 | } 39 | } 40 | } 41 | closedir(dir); 42 | } 43 | else 44 | { 45 | std::cerr << "Cannot open input folder.\n"; 46 | exit(1); 47 | } 48 | 49 | if(powerFd == -1 || resetFd == -1) 50 | { 51 | std::cerr << "Cannot access power buttons.\n"; 52 | exit(1); 53 | } 54 | #endif 55 | } 56 | 57 | PowerWatch::~PowerWatch() 58 | { 59 | if(powerFd != -1) 60 | close(powerFd); 61 | if(resetFd != -1) 62 | close(resetFd); 63 | } 64 | 65 | bool PowerWatch::buttonPress() 66 | { 67 | #ifndef __arm__ 68 | return 0; 69 | #endif 70 | static char c[16]; 71 | return (read(powerFd, c, 16) > 0) || (read(resetFd, c, 16) > 0); 72 | } 73 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TARGET_NAME = options_deluxe 2 | CXX = g++ 3 | STRIP = strip 4 | CXXFLAGS = -std=c++11 -Os `sdl2-config --cflags` 5 | LDLIBS = `sdl2-config --libs` -lpng 6 | LDFLAGS = 7 | SOURCES = src/main.cpp src/command.cpp src/framework/sdl_context.cpp src/framework/texture.cpp src/framework/controller.cpp src/framework/powerwatch.cpp 8 | OBJECTS = $(SOURCES:.cpp=.o) 9 | 10 | all: $(TARGET_NAME).hmod $(TARGET_NAME)_b_down.hmod 11 | 12 | $(TARGET_NAME)_b_down.hmod: $(TARGET_NAME).hmod 13 | cp button.cfg mod/etc/options_menu/ 14 | cd mod/; tar -czvf "../$(TARGET_NAME)_b_down.hmod" * 15 | 16 | $(TARGET_NAME).hmod: mod/etc/options_menu/options mod/etc/options_menu/optiond mod/etc/options_menu/mod_uninstall/mod_uninstall mod/bin/standby_watchdog 17 | $(CROSS_PREFIX)$(STRIP) mod/etc/options_menu/options 18 | $(CROSS_PREFIX)$(STRIP) mod/etc/options_menu/optiond 19 | $(CROSS_PREFIX)$(STRIP) mod/etc/options_menu/mod_uninstall/mod_uninstall 20 | $(CROSS_PREFIX)$(STRIP) mod/bin/standby_watchdog 21 | rm -f mod/etc/options_menu/button.cfg 22 | cd mod/; tar -czvf "../$(TARGET_NAME).hmod" * 23 | 24 | mod/etc/options_menu/options: $(OBJECTS) 25 | $(CROSS_PREFIX)$(CXX) $(OBJECTS) $(LDLIBS) $(LDFLAGS) -o mod/etc/options_menu/options 26 | 27 | mod/etc/options_menu/optiond: src/daemon.o src/framework/controller.o 28 | $(CROSS_PREFIX)$(CXX) $(LDFLAGS) src/daemon.o src/framework/controller.o -o mod/etc/options_menu/optiond 29 | 30 | mod/etc/options_menu/mod_uninstall/mod_uninstall: src/mod_uninstall.o 31 | $(CROSS_PREFIX)$(CXX) src/mod_uninstall.o src/framework/*.o $(LDLIBS) $(LDFLAGS) -o mod/etc/options_menu/mod_uninstall/mod_uninstall 32 | 33 | mod/bin/standby_watchdog: src/standby_watchdog.o src/framework/controller.o src/framework/powerwatch.o 34 | $(CROSS_PREFIX)$(CXX) src/standby_watchdog.o src/framework/controller.o src/framework/powerwatch.o -o mod/bin/standby_watchdog 35 | 36 | %.o: %.cpp 37 | $(CROSS_PREFIX)$(CXX) $(CXXFLAGS) -c $< -o $@ 38 | 39 | clean: 40 | find -name "*.o" -type f -delete 41 | rm -f mod/etc/options_menu/options mod/etc/options_menu/optiond mod/etc/options_menu/mod_uninstall/mod_uninstall mod/bin/standby_watchdog mod/etc/options_menu/button.cfg $(TARGET_NAME).hmod $(TARGET_NAME)_b_down.hmod 42 | 43 | .PHONY: clean 44 | -------------------------------------------------------------------------------- /src/framework/controller.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #include "controller.h" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | Controller::Controller(int id) 20 | { 21 | #ifdef __arm__ 22 | std::stringstream s; 23 | s << "/dev/input/by-path/platform-twi." << id << "-event-joystick"; 24 | fd = open(s.str().c_str(), O_RDONLY | O_NONBLOCK); 25 | if(fd == -1) 26 | { 27 | std::cerr << "Cannot access controller.\n"; 28 | exit(1); 29 | } 30 | #endif // __arm__ 31 | 32 | Reset(); 33 | } 34 | Controller::~Controller() 35 | { 36 | #ifdef __arm__ 37 | if(fd != -1) 38 | close(fd); 39 | #endif // __arm__ 40 | } 41 | bool Controller::PeekButtonStatus(GameButton button) 42 | { 43 | return buttons[button]; 44 | } 45 | bool Controller::GetButtonStatus(GameButton button) 46 | { 47 | bool result = buttons[button]; 48 | if(result) buttons[button] = 0; 49 | return result; 50 | } 51 | void Controller::Update() 52 | { 53 | #ifdef __arm__ 54 | int len; 55 | while((len = read(fd, &buttonBuffer, sizeof(ButtonEvent)*10)) > 0) 56 | { 57 | len/=sizeof(ButtonEvent); 58 | for(int i = 0; i < len; ++i) 59 | { 60 | auto & buttonEvent = buttonBuffer[i]; 61 | //Unk1 equals 1 when displaying button press status 62 | if(buttonEvent.unk1 == 1) 63 | { 64 | buttons[buttonEvent.button] = buttonEvent.pressed; 65 | } 66 | } 67 | } 68 | #endif // __arm__ 69 | } 70 | void Controller::Reset() 71 | { 72 | buttons[A] = 0; 73 | buttons[B] = 0; 74 | buttons[X] = 0; 75 | buttons[Y] = 0; 76 | buttons[L] = 0; 77 | buttons[R] = 0; 78 | buttons[SELECT] = 0; 79 | buttons[START] = 0; 80 | buttons[LEFT] = 0; 81 | buttons[RIGHT] = 0; 82 | buttons[UP] = 0; 83 | buttons[DOWN] = 0; 84 | } 85 | -------------------------------------------------------------------------------- /mod/bin/standby: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | source /etc/preinit 4 | script_init 5 | 6 | Hibernate() 7 | { 8 | xz -dc "$rootfs/etc/hibernate_mod/hibernating.png.xz" > /dev/fb0 9 | echo "Initiating shutdown followed by hibernate mode..." 10 | echo 0 > /sys/devices/virtual/disp/disp/attr/lcd 11 | echo "Initialising hibernation mode..." 12 | #echo Core Temperature at the time of hibernation: $(hakchi hwmon)c; 13 | echo "Hibernation mode active! Awaiting input..." 14 | } 15 | 16 | Standby() 17 | { 18 | xz -dc "$rootfs/etc/hibernate_mod/hibernating.png.xz" > /dev/fb0 19 | /etc/init.d/S8103OptionsMenu stop 20 | echo "Initiating shutdown followed by standby mode..." 21 | udevadm control --stop-exec-queue 22 | killall udevd 23 | modprobe -r clvcon 24 | killall -9 clover-mcp 25 | Uikill TERM 26 | echo 0 > /sys/devices/virtual/disp/disp/attr/lcd 27 | [ -b '/dev/sda1' ] && umount /dev/sda1 28 | echo "Initialising standby mode..." 29 | #echo "Core Temperature at the time of standby: $(hakchi hwmon)c" 30 | echo "Standby mode active! Awaiting input..." 31 | } 32 | 33 | #UI Commands from latest hakchi version 34 | Uilist(){ 35 | lsof -n | grep -F "/dev/fb0" | grep -v "standby" | grep -v "busybox" | awk '{print $1}' | sort -u 36 | } 37 | 38 | Uikill(){ 39 | [ -z "$1" ] && return 1 40 | Uilist | xargs -r kill -s "$1" 41 | } 42 | 43 | DisplayMenu() 44 | { 45 | Uikill STOP 46 | #xz -dc "$rootfs/etc/hibernate_mod/1.png.xz" > /dev/fb0 47 | } 48 | 49 | Resume() 50 | { 51 | rm -f /tmp/power_menu_screen 52 | Uikill CONT 53 | } 54 | 55 | HibernateReboot() 56 | { 57 | echo "Shutting down console out from hibernation mode..." 58 | Resume 59 | sync 60 | reboot 61 | } 62 | 63 | ReloadImagePayload() 64 | { 65 | payloadCount=$(find "$rootfs/etc/hibernate_mod/" -type f -name *.png.xz | wc -l) 66 | #echo $payloadCount 67 | payloadCount=$(($payloadCount-1)) #Deduct 1 to account for the hibernate.png.xz 68 | #echo $payloadCount 69 | if [ $payloadCount = 1 ]; then #lite version in play... 70 | #echo "Lite version in play" 71 | if [ ! -f /tmp/power_menu_screen ]; then 72 | #echo "File doesn't exist" 73 | xz -dc "$rootfs/etc/hibernate_mod/1.png.xz" > /tmp/power_menu_screen 74 | fi 75 | else 76 | #echo "Deluxe version in play" 77 | DIFF=$(($payloadCount-1+1)) 78 | RANDOM=$$ 79 | 80 | selectedImage="$rootfs/etc/hibernate_mod/"$(($(($RANDOM%$DIFF))+1))".png.xz" 81 | #echo $selectedImage 82 | rm -f /tmp/power_menu_screen #Just incase 83 | 84 | xz -dc $selectedImage > /tmp/power_menu_screen 85 | fi 86 | } 87 | 88 | ${1+"$@"} 89 | -------------------------------------------------------------------------------- /src/command.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #include "command.h" 11 | #include "framework/controller.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | Command::Command() {} 18 | 19 | Command::Command(std::ifstream & in) 20 | { 21 | std::string temp; 22 | while(in.good()) 23 | { 24 | std::getline(in, temp); 25 | if(temp[0]=='#') 26 | continue; 27 | int index = temp.find('='); 28 | std::string param = temp.substr(0, index), value = temp.substr(index+1); 29 | if(param.compare("COMMAND_NAME")==0) 30 | name = value; 31 | else if(param.compare("COMMAND_TYPE")==0) 32 | runInternal = (value == "INTERNAL"); 33 | else if(param.compare("RESTART_UI")==0) 34 | restartUI = (value == "TRUE"); 35 | else if(param.compare("IGNORE_INTERRUPT")==0) 36 | ignoreInterrupt = (value == "TRUE"); 37 | else if(param.compare("COMMAND_STR")==0) 38 | command = value; 39 | else if(param.compare("USB_ONLY")==0) 40 | usbOnly = (value == "TRUE"); 41 | else if(param.compare("PREVIEW_IMAGE")==0) 42 | previewImage = value; 43 | else if(param.compare("PREVIEW_IMAGE_X")==0) 44 | previewImageX = std::stoi(value); 45 | else if(param.compare("PREVIEW_IMAGE_Y")==0) 46 | previewImageY = std::stoi(value); 47 | else if(param.compare("PREVIEW_IMAGE_WIDTH")==0) 48 | previewImageWidth = std::stoi(value); 49 | else if(param.compare("PREVIEW_IMAGE_HEIGHT")==0) 50 | previewImageHeight = std::stoi(value); 51 | } 52 | in.close(); 53 | } 54 | 55 | void Command::RunCommand(SDL_Context & sdl_context, Controller * controller, Sprite & menuL, Sprite & menuU) const 56 | { 57 | std::list textList; 58 | FILE* pipe = popen(command.c_str(), "r"); 59 | if(pipe) 60 | { 61 | auto renderer = sdl_context.renderer; 62 | SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); 63 | char buffer[128] = {0}; 64 | 65 | auto render = [&](Texture * closeText = nullptr) 66 | { 67 | sdl_context.StartFrame(); 68 | menuU.Draw(renderer); 69 | menuL.Draw(renderer); 70 | int y = 100; 71 | for(auto & t : textList) 72 | { 73 | t.rect.y = y; 74 | t.Draw(renderer); 75 | y+=10; 76 | } 77 | if(closeText) 78 | closeText->Draw(renderer); 79 | sdl_context.EndFrame(); 80 | }; 81 | 82 | while(!feof(pipe)) 83 | { 84 | if(fgets(buffer, 128, pipe) > 0) 85 | { 86 | std::string sBuffer(buffer); 87 | int pos = sBuffer.find('\n'); 88 | if(pos > 0) 89 | sBuffer[pos] = '\0'; 90 | textList.push_back(Texture(sBuffer, 8, renderer, 30)); 91 | 92 | if(textList.size() > 40) 93 | { 94 | textList.erase(textList.begin()); 95 | } 96 | } 97 | 98 | controller->Update(); 99 | if(!ignoreInterrupt && controller->GetButtonStatus(B)) 100 | break; 101 | 102 | render(); 103 | } 104 | pclose(pipe); 105 | Texture closeText("Press B to exit.", 12, renderer, 30, 610); 106 | 107 | while (!controller->GetButtonStatus(B)) 108 | { 109 | controller->Update(); 110 | render(&closeText); 111 | } 112 | SDL_SetRenderDrawColor(renderer, 0x6e, 0x6e, 0x6e, 0xFF); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/framework/texture.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #include "texture.h" 11 | #include "font8x8_basic.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #if SDL_BYTEORDER == SDL_BIG_ENDIAN 18 | #define rmask 0xff000000 19 | #define gmask 0x00ff0000 20 | #define bmask 0x0000ff00 21 | #define amask 0x000000ff 22 | #else 23 | #define rmask 0x000000ff 24 | #define gmask 0x0000ff00 25 | #define bmask 0x00ff0000 26 | #define amask 0xff000000 27 | #endif 28 | 29 | Texture::Texture() {} 30 | 31 | Texture::Texture(const std::string & text, int fontSize, SDL_Renderer* renderer, int x, int y, bool centerText, const int color) 32 | { 33 | texture = std::shared_ptr(WriteText(text, fontSize, renderer, rect.w, rect.h, color), SDL_DestroyTexture); 34 | rect.x = (centerText) ? x-rect.w/2 : x; 35 | rect.y = (centerText) ? y-rect.h/2 : y; 36 | } 37 | 38 | Texture::Texture(const std::string & pngFilePath, SDL_Renderer* renderer, int x, int y, bool centerImg) 39 | { 40 | texture = std::shared_ptr(LoadTexturePNG(renderer, pngFilePath, &rect), SDL_DestroyTexture); 41 | rect.x = (centerImg) ? x-rect.w/2 : x; 42 | rect.y = (centerImg) ? y-rect.h/2 : y; 43 | } 44 | 45 | void Texture::Draw(SDL_Renderer* renderer) 46 | { 47 | if(texture.get()) 48 | SDL_RenderCopyEx(renderer, texture.get(), NULL, &rect, 0, NULL, SDL_FLIP_NONE); 49 | } 50 | 51 | void Texture::Draw(SDL_Renderer* renderer, SDL_RendererFlip flip_enum) 52 | { 53 | if(texture.get()) 54 | SDL_RenderCopyEx(renderer, texture.get(), NULL, &rect, 0, NULL, flip_enum); 55 | } 56 | 57 | void Sprite::Draw(SDL_Renderer * renderer) 58 | { 59 | SDL_RenderCopyEx(renderer, texture.get(), &sRect, &dRect, 0, NULL, SDL_FLIP_NONE); 60 | } 61 | 62 | SDL_Texture * LoadTexturePNG(SDL_Renderer *renderer, std::string file, SDL_Rect * rect) 63 | { 64 | SDL_Texture* texture = nullptr; 65 | 66 | png_image png; 67 | memset(&png, 0, sizeof(png)); 68 | png.version = PNG_IMAGE_VERSION; 69 | png.opaque = NULL; 70 | 71 | if(png_image_begin_read_from_file(&png, file.c_str()) == 0) 72 | { 73 | std::cerr << "Cannot open png file: " << file << "\n"; 74 | return nullptr; 75 | } 76 | //Set PNG Format 77 | png.format = PNG_FORMAT_RGBA; 78 | if(png.width == 0 || png.height == 0) 79 | { 80 | std::cerr << "Invalid png: " << file << "\n"; 81 | png_image_free(&png); 82 | return nullptr; 83 | } 84 | if(rect) 85 | { 86 | rect->h = png.height; 87 | rect->w = png.width; 88 | } 89 | //Create surface 90 | auto surface = SDL_CreateRGBSurface(0, png.width, png.height, 32, rmask, gmask, bmask, amask); 91 | 92 | if(surface) 93 | { 94 | //Read png data to surface 95 | png_image_finish_read(&png, NULL, surface->pixels, 0, NULL); 96 | png_image_free(&png); 97 | //Convert surface to texture 98 | texture = SDL_CreateTextureFromSurface(renderer, surface); 99 | SDL_FreeSurface(surface); 100 | } 101 | else 102 | { 103 | std::cerr << "Error creating surface for: " << file << "\n"; 104 | exit(1); 105 | } 106 | 107 | SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); 108 | return texture; 109 | } 110 | 111 | SDL_Texture * WriteText(const std::string & text, int fontSize, SDL_Renderer* renderer, int & textureWidth, int & textureHeight, const int color) 112 | { 113 | if(text.size()==0) 114 | return nullptr; 115 | textureWidth = fontSize*text.size(); 116 | textureHeight = fontSize; 117 | auto surface = SDL_CreateRGBSurface(0, 8*text.size(), 8, 32, rmask, gmask, bmask, amask); 118 | uint* pixels = reinterpret_cast(surface->pixels); 119 | int pitch = 8*text.size(); 120 | for(unsigned int i = 0; i < text.size(); ++i) 121 | { 122 | auto bitmap = font8x8_basic[text[i]]; 123 | int offset = i*8; 124 | for(int y = 0; y < 8; ++y) 125 | { 126 | for(int x = 0; x < 8; ++x) 127 | { 128 | pixels[x+offset+(y*pitch)] = (bitmap[y] & 1 << x) ? color : 0; 129 | } 130 | } 131 | } 132 | auto texture = SDL_CreateTextureFromSurface(renderer, surface); 133 | SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); 134 | SDL_FreeSurface(surface); 135 | return texture; 136 | } 137 | -------------------------------------------------------------------------------- /src/standby_watchdog.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Swingflip and CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #include "framework/controller.h" 11 | #include "framework/powerwatch.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | Controller c(1); 22 | PowerWatch pw; 23 | const auto fpsTime = std::chrono::milliseconds(200); 24 | auto nextUpdateTime = std::chrono::system_clock::now()+fpsTime; 25 | 26 | int DisplayMenu() 27 | { 28 | system("standby ReloadImagePayload"); 29 | system("cat /tmp/power_menu_screen > /dev/fb0"); 30 | auto fpsTime = std::chrono::milliseconds(33); // Check for input faster 31 | //system("echo DEBUG: Displaying hibernate menu..."); 32 | for(;;) 33 | { 34 | c.Update(); 35 | if(c.PeekButtonStatus(A)) //Accept (Hibernate) 36 | { 37 | //system("echo DEBUG: Accepted hibernate..."); 38 | return 1; 39 | } 40 | else if(c.PeekButtonStatus(X)) //Accept (Standby) 41 | { 42 | //system("echo DEBUG: Accepted standby..."); 43 | return 2; 44 | } 45 | else if(c.PeekButtonStatus(Y)) //Cancel 46 | { 47 | //system("echo DEBUG: Cancelled hibernate..."); 48 | return 3; 49 | } 50 | else if(pw.buttonPress()) 51 | { 52 | return 3; 53 | } 54 | system("cat /tmp/power_menu_screen > /dev/fb0"); // This will fix the framebuffer getting overwritten by a stack process 55 | std::this_thread::sleep_until(nextUpdateTime); 56 | nextUpdateTime+=fpsTime; 57 | } 58 | } 59 | 60 | int GetState() 61 | { 62 | for(;;) 63 | { 64 | c.Update(); 65 | if(c.PeekButtonStatus(L) && c.PeekButtonStatus(R) && c.GetButtonStatus(UP)) 66 | { 67 | system("standby DisplayMenu"); 68 | return DisplayMenu(); 69 | } 70 | else 71 | { 72 | std::this_thread::sleep_until(nextUpdateTime); 73 | nextUpdateTime+=fpsTime; 74 | } 75 | } 76 | } 77 | 78 | void Hibernate() 79 | { 80 | system("standby Hibernate"); 81 | 82 | for(;;) 83 | { 84 | c.Update(); 85 | if(c.PeekButtonStatus(L) && c.PeekButtonStatus(R) && c.GetButtonStatus(UP)) //L+R+SELECT = Hibernate / Reboot from Hibernate 86 | { 87 | //system("echo Core Temperature at the time of reboot out of hibernation: $(hakchi hwmon)c"); 88 | system("echo 1 > /sys/devices/virtual/disp/disp/attr/lcd"); 89 | break; 90 | } 91 | else if(c.PeekButtonStatus(L) && c.PeekButtonStatus(R) && c.GetButtonStatus(DOWN)) 92 | { 93 | //system("echo Core Temperature at the time of shutdown out of hibernation: $(hakchi hwmon)c"); 94 | system("standby HibernateReboot &"); 95 | exit(0); 96 | } 97 | else if(pw.buttonPress()) 98 | { 99 | system("standby Resume &"); 100 | exit(0); 101 | } 102 | std::this_thread::sleep_until(nextUpdateTime); 103 | nextUpdateTime+=fpsTime; 104 | } 105 | } 106 | 107 | void Standby() 108 | { 109 | system("standby Standby"); 110 | 111 | for(;;) 112 | { 113 | c.Update(); 114 | if(c.PeekButtonStatus(L) && c.PeekButtonStatus(R) && c.GetButtonStatus(UP)) //L+R+SELECT = Hibernate / Reboot from Hibernate 115 | { 116 | //system("echo Core Temperature at the time of reboot out of standby: $(hakchi hwmon)c"); 117 | system("echo Rebooting console out from standby mode..."); 118 | sync(); 119 | setuid(0); 120 | reboot(RB_AUTOBOOT); 121 | exit(0); 122 | } 123 | if(c.PeekButtonStatus(L) && c.PeekButtonStatus(R) && c.GetButtonStatus(DOWN)) 124 | { 125 | //system("echo Core Temperature at the time of shutdown out of standby: $(hakchi hwmon)c"); 126 | system("echo Shutting down console out from standby mode..."); 127 | sync(); 128 | setuid(0); 129 | reboot(LINUX_REBOOT_CMD_POWER_OFF); 130 | exit(0); 131 | } 132 | std::this_thread::sleep_until(nextUpdateTime); 133 | nextUpdateTime+=fpsTime; 134 | } 135 | } 136 | 137 | int main(int argc, char * argv[]) 138 | { 139 | if(argc == 2 && strcmp(argv[1], "--displayMenu") == 0) 140 | { 141 | switch(DisplayMenu()) 142 | { 143 | case 1: 144 | Hibernate(); 145 | break; 146 | case 2: 147 | Standby(); 148 | break; 149 | } 150 | system("rm -f /tmp/power_menu_screen"); 151 | } 152 | else 153 | { 154 | for(;;) 155 | { 156 | switch(GetState()) 157 | { 158 | case 1: 159 | Hibernate(); 160 | break; 161 | case 2: 162 | Standby(); 163 | break; 164 | } 165 | system("standby Resume"); 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/mod_uninstall.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2020 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #include "framework/controller.h" 11 | #include "framework/powerwatch.h" 12 | #include "framework/sdl_helper.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | struct Mod 21 | { 22 | std::string name; 23 | Texture texture; 24 | void Draw(SDL_Renderer* renderer) 25 | { 26 | texture.Draw(renderer); 27 | } 28 | }; 29 | 30 | int main(int argc, char * argv[]) 31 | { 32 | std::string folderLocation(argv[0]); 33 | folderLocation = folderLocation.substr(0, folderLocation.find_last_of('/')+1); 34 | std::vector installedMods; 35 | 36 | { 37 | char buf[256]; 38 | auto pipe = popen("hakchi pack_list", "r"); 39 | if(pipe) 40 | { 41 | while(!feof(pipe)) 42 | { 43 | if(fgets(buf, 256, pipe) > 0) 44 | installedMods.push_back({buf}); 45 | } 46 | pclose(pipe); 47 | } 48 | } 49 | 50 | if(installedMods.size() == 0) 51 | { 52 | std::cerr << "Cannot find mods"; 53 | return 1; 54 | } 55 | 56 | if(SDL_Init(SDL_INIT_VIDEO) != 0) 57 | { 58 | std::cerr << "Cannot initialise SDL.\n"; 59 | return 1; 60 | } 61 | 62 | Controller controller(1); 63 | PowerWatch powerWatch; 64 | auto window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1280, 720, SDL_WINDOW_FULLSCREEN); 65 | auto renderer = SDL_CreateRenderer(window, -1, 0); 66 | if(renderer == NULL) { 67 | std::cerr << "Cannot create renderer.\n"; 68 | SDL_DestroyWindow(window); 69 | return 1; 70 | } 71 | SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); 72 | 73 | Texture titleText("Module Uninstaller", 36, renderer, 640, 60, true); 74 | Texture modListText("Installed Modules", 18, renderer, 30, 120); 75 | Texture modUninstallText("Modules To Uninstall", 18, renderer, 890, 120); 76 | 77 | for(Mod & mod : installedMods) 78 | { 79 | mod.texture = Texture(mod.name, 14, renderer); 80 | mod.texture.rect.x = 60; 81 | } 82 | 83 | Texture pointerTexture("->", 14, renderer, 30, 150, false, 0xFF00FF00); 84 | Texture instructionsText("START - Uninstall Mods/Exit A - Add mod to uninstall list B - Undo", 12, renderer, 640, 648, true); 85 | int installListOffset = 0; 86 | int currentId = 0; 87 | const int displayCount = 20; 88 | std::vector uninstallList; 89 | const auto fpsTime = std::chrono::milliseconds(33); 90 | auto nextFrameTime = std::chrono::system_clock::now()+fpsTime; 91 | for(;;) 92 | { 93 | SDL_Event e; 94 | //Poll for quit event (CTRL+C)/Close 95 | while (SDL_PollEvent(&e)) { 96 | if (e.type == SDL_QUIT) { 97 | return 0; 98 | } 99 | } 100 | 101 | controller.Update(); 102 | if(powerWatch.buttonPress()) 103 | { 104 | break; 105 | } 106 | if(controller.GetButtonStatus(UP)) 107 | { 108 | if(currentId > 0) 109 | { 110 | currentId--; 111 | pointerTexture.rect.y = 150 + 20*currentId; 112 | } 113 | else if(installListOffset) 114 | { 115 | installListOffset--; 116 | } 117 | } 118 | else if(controller.GetButtonStatus(DOWN)) 119 | { 120 | if(currentId < displayCount-1 && installListOffset + currentId+1 < installedMods.size()) 121 | { 122 | currentId++; 123 | pointerTexture.rect.y = 150 + 20*currentId; 124 | } 125 | else if(installListOffset + displayCount < installedMods.size()) 126 | { 127 | installListOffset++; 128 | } 129 | } 130 | else if(controller.GetButtonStatus(A)) 131 | { 132 | if(currentId != -1 && installedMods.size()) 133 | { 134 | installedMods[installListOffset+currentId].texture.rect.x = 890; 135 | uninstallList.push_back(installedMods[installListOffset+currentId]); 136 | installedMods.erase(installedMods.begin()+installListOffset+currentId); 137 | if(installListOffset && (installListOffset + displayCount) > installedMods.size()) 138 | { 139 | --installListOffset; 140 | } 141 | if(installListOffset==0 && currentId >= installedMods.size()) 142 | { 143 | currentId = installedMods.size()-1; 144 | pointerTexture.rect.y = 150 + 20*currentId; 145 | } 146 | } 147 | } 148 | else if(controller.GetButtonStatus(B)) 149 | { 150 | if(uninstallList.size()) 151 | { 152 | uninstallList.back().texture.rect.x = 60; 153 | installedMods.push_back(uninstallList.back()); 154 | uninstallList.pop_back(); 155 | if(currentId == -1) 156 | { 157 | currentId = 0; 158 | pointerTexture.rect.y = 150; 159 | } 160 | } 161 | } 162 | else if(controller.GetButtonStatus(START)) 163 | { 164 | if(uninstallList.size() == 0) 165 | break; 166 | Texture warning("Are you sure you want to remove these modules?", 24, renderer, 640, 248, true); 167 | Texture buttons("Yes - Start+Select No - B", 24, renderer, 640, 300, true); 168 | for(;;) 169 | { 170 | controller.Update(); 171 | if(controller.GetButtonStatus(B) || powerWatch.buttonPress()) 172 | { 173 | uninstallList.clear(); 174 | break; 175 | } 176 | else if(controller.PeekButtonStatus(START) && controller.PeekButtonStatus(SELECT)) 177 | { 178 | break; 179 | } 180 | SDL_RenderClear(renderer); 181 | warning.Draw(renderer); 182 | buttons.Draw(renderer); 183 | SDL_RenderPresent(renderer); 184 | std::this_thread::sleep_until(nextFrameTime); 185 | nextFrameTime += fpsTime; 186 | } 187 | if(uninstallList.size()) 188 | { 189 | std::ofstream out("/tmp/uninstall"); 190 | if(out.is_open()) 191 | { 192 | for(auto & mod : uninstallList) 193 | { 194 | out << mod.name << " "; 195 | } 196 | out.close(); 197 | system(("/bin/sh " + folderLocation + "/FinishUninstall.sh &").c_str()); 198 | } 199 | } 200 | break; 201 | } 202 | 203 | SDL_RenderClear(renderer); 204 | titleText.Draw(renderer); 205 | modListText.Draw(renderer); 206 | modUninstallText.Draw(renderer); 207 | pointerTexture.Draw(renderer); 208 | instructionsText.Draw(renderer); 209 | int y = 150; 210 | for(int i = installListOffset, len = i+std::min(displayCount,(int)installedMods.size()-i); i < len; ++i) 211 | { 212 | installedMods[i].texture.rect.y = y; 213 | installedMods[i].texture.Draw(renderer); 214 | y+=20; 215 | } 216 | y = 150; 217 | for(auto & mod : uninstallList) 218 | { 219 | mod.texture.rect.y = y; 220 | mod.texture.Draw(renderer); 221 | y+=20; 222 | } 223 | 224 | SDL_RenderPresent(renderer); 225 | 226 | //Simple FPS limiter 227 | std::this_thread::sleep_until(nextFrameTime); 228 | nextFrameTime += fpsTime; 229 | } 230 | 231 | SDL_DestroyRenderer(renderer); 232 | SDL_DestroyWindow(window); 233 | SDL_Quit(); 234 | return 0; 235 | } 236 | -------------------------------------------------------------------------------- /src/framework/font8x8_basic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 8x8 monochrome bitmap fonts for rendering 3 | * Author: Daniel Hepper 4 | * 5 | * License: Public Domain 6 | * 7 | * Based on: 8 | * // Summary: font8x8.h 9 | * // 8x8 monochrome bitmap fonts for rendering 10 | * // 11 | * // Author: 12 | * // Marcel Sondaar 13 | * // International Business Machines (public domain VGA fonts) 14 | * // 15 | * // License: 16 | * // Public Domain 17 | * 18 | * Fetched from: http://dimensionalrift.homelinux.net/combuster/mos3/?p=viewsource&file=/modules/gfx/font8_8.asm 19 | **/ 20 | 21 | // Constant: font8x8_basic 22 | // Contains an 8x8 font map for unicode points U+0000 - U+007F (basic latin) 23 | unsigned char font8x8_basic[128][8] = { 24 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul) 25 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001 26 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002 27 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003 28 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004 29 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005 30 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006 31 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007 32 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008 33 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009 34 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A 35 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B 36 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C 37 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D 38 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E 39 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F 40 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010 41 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011 42 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012 43 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013 44 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014 45 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015 46 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016 47 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017 48 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018 49 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019 50 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A 51 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B 52 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C 53 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D 54 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E 55 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F 56 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space) 57 | { 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!) 58 | { 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (") 59 | { 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#) 60 | { 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($) 61 | { 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%) 62 | { 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&) 63 | { 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (') 64 | { 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (() 65 | { 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ()) 66 | { 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*) 67 | { 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+) 68 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,) 69 | { 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-) 70 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.) 71 | { 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/) 72 | { 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0) 73 | { 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1) 74 | { 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2) 75 | { 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3) 76 | { 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4) 77 | { 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5) 78 | { 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6) 79 | { 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7) 80 | { 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8) 81 | { 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9) 82 | { 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:) 83 | { 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (//) 84 | { 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<) 85 | { 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=) 86 | { 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>) 87 | { 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?) 88 | { 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@) 89 | { 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A) 90 | { 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B) 91 | { 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C) 92 | { 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D) 93 | { 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E) 94 | { 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F) 95 | { 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G) 96 | { 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H) 97 | { 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I) 98 | { 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J) 99 | { 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K) 100 | { 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L) 101 | { 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M) 102 | { 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N) 103 | { 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O) 104 | { 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P) 105 | { 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q) 106 | { 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R) 107 | { 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S) 108 | { 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T) 109 | { 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U) 110 | { 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V) 111 | { 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W) 112 | { 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X) 113 | { 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y) 114 | { 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z) 115 | { 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([) 116 | { 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\) 117 | { 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (]) 118 | { 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^) 119 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_) 120 | { 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`) 121 | { 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a) 122 | { 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b) 123 | { 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c) 124 | { 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d) 125 | { 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e) 126 | { 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f) 127 | { 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g) 128 | { 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h) 129 | { 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i) 130 | { 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j) 131 | { 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k) 132 | { 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l) 133 | { 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m) 134 | { 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n) 135 | { 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o) 136 | { 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p) 137 | { 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q) 138 | { 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r) 139 | { 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s) 140 | { 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t) 141 | { 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u) 142 | { 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v) 143 | { 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w) 144 | { 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x) 145 | { 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y) 146 | { 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z) 147 | { 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({) 148 | { 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|) 149 | { 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (}) 150 | { 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~) 151 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F 152 | }; 153 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017-2018 CompCom 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version. 8 | */ 9 | 10 | #include "framework/sdl_helper.h" 11 | #include "framework/controller.h" 12 | #include "framework/powerwatch.h" 13 | #include "command.h" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | void sReplace(std::string & command, std::string oldString, std::string newString) 22 | { 23 | size_t pos; 24 | while((pos = command.find(oldString)) != std::string::npos) 25 | { 26 | command.replace(pos, oldString.size(), newString); 27 | } 28 | } 29 | 30 | static struct ExitManager 31 | { 32 | std::string exitCommand; 33 | bool runExitCommand = true; 34 | ~ExitManager() 35 | { 36 | if(runExitCommand) 37 | system(exitCommand.c_str()); 38 | } 39 | } _exitManager; 40 | 41 | int main(int argc, char * argv[]) 42 | { 43 | std::string optionsLocation(argv[0]); 44 | optionsLocation = optionsLocation.substr(0, optionsLocation.find_last_of('/')+1); 45 | _exitManager.exitCommand = "/bin/sh " + optionsLocation + "/scripts/ResumeUI.sh"; 46 | std::string commandLocation(optionsLocation + "commands/"); 47 | std::string scriptLocation(optionsLocation + "scripts/"); 48 | std::string spriteSheetLocation; 49 | std::ifstream in("/tmp/spritesheet"); 50 | std::getline(in, spriteSheetLocation); 51 | in.close(); 52 | std::string titleString("Options"); 53 | 54 | //Check for external drive 55 | bool usbReady = false; 56 | if(auto dir = opendir("/media/hakchi/")) 57 | { 58 | closedir(dir); 59 | usbReady = true; 60 | } 61 | 62 | //Parse args 63 | for(int i = 1; i < argc; ++i) 64 | { 65 | if(strcmp(argv[i], "--commandPath") == 0) 66 | { 67 | commandLocation = argv[i+1]; 68 | ++i; 69 | } 70 | else if(strcmp(argv[i], "--scriptPath") == 0) 71 | { 72 | scriptLocation = argv[i+1]; 73 | ++i; 74 | } 75 | else if(strcmp(argv[i], "--title") == 0) 76 | { 77 | titleString = argv[i+1]; 78 | ++i; 79 | } 80 | } 81 | 82 | //Read commands from command folder 83 | std::vector commands; 84 | if(auto dir = opendir(commandLocation.c_str())) 85 | { 86 | //Find all commands in folder 87 | std::list fileList; 88 | while(auto entry = readdir(dir)) 89 | { 90 | if(entry->d_type == DT_REG && entry->d_name[0] == 'c') 91 | fileList.push_back(entry->d_name); 92 | } 93 | closedir(dir); 94 | 95 | fileList.sort(); 96 | for(auto & file : fileList) 97 | { 98 | in.open(commandLocation+file); 99 | if(in.is_open()) 100 | { 101 | Command c(in); 102 | if(!(commands.size() == 0 && c.command.size() == 0)) 103 | { 104 | if(!c.usbOnly || (c.usbOnly && usbReady)) 105 | { 106 | sReplace(c.command, "%options_path%", optionsLocation); 107 | sReplace(c.command, "%script_dir%", scriptLocation); 108 | commands.push_back(c); 109 | } 110 | } 111 | } 112 | } 113 | } 114 | else 115 | { 116 | std::cerr << "Cannot open input folder.\n"; 117 | exit(1); 118 | } 119 | 120 | int currentCommandId = 0; 121 | const int DisplayItemCount = 16; 122 | 123 | //Create SDL Window/Renderer and Controller Handler 124 | SDL_Context sdl_context(std::chrono::milliseconds(33), false); 125 | auto renderer = sdl_context.renderer; 126 | Controller controller(1); 127 | 128 | //Create Options Flag to prevent multiple menu launches 129 | system("touch /tmp/options.flag"); 130 | 131 | //Create Background 132 | auto spriteSheet = std::shared_ptr(LoadTexturePNG(renderer, spriteSheetLocation), SDL_DestroyTexture); 133 | Texture banner(optionsLocation + "/images/banner.png", renderer, 640, 185, true); 134 | Sprite menuU = { spriteSheet, {1,43,432,40}, {-8,-24,1296,120} }; 135 | Sprite menuL = { spriteSheet, {1,1,432,40}, {-8,630,1296,120} }; 136 | SDL_SetRenderDrawColor(renderer, 0x6e, 0x6e, 0x6e, 0xFF); 137 | 138 | //Create Textures for Strings 139 | Texture titleText(titleString, 36, renderer, 640, 185, true); 140 | Texture pointerText("->", 16, renderer, 20, 260, false, 0xFF00FF00); 141 | SDL_Rect & pointerRect = pointerText.rect; 142 | Texture CompComText("created by CompCom", 16, renderer, 1100, 620, true); 143 | Texture scrollUp("^", 16, renderer, 30, 248); 144 | Texture scrollDown = scrollUp; 145 | scrollDown.rect.y = 252+DisplayItemCount*18; 146 | 147 | //Create Command Texture 148 | for(Command & c : commands) 149 | c.texture = Texture(c.name, 16, renderer, 50, 0); 150 | 151 | int topListItemNumber = 1; 152 | std::shared_ptr PreviewImage; 153 | auto SetCurrentCommand = [&] (int newCommandId) 154 | { 155 | currentCommandId = newCommandId; 156 | const Command & currentCommand = commands[currentCommandId]; 157 | 158 | bool updateCommandYPos = false; 159 | if(currentCommandId < topListItemNumber) 160 | { 161 | topListItemNumber = currentCommandId; 162 | updateCommandYPos = true; 163 | } 164 | else if(currentCommandId >= topListItemNumber+DisplayItemCount) 165 | { 166 | topListItemNumber = currentCommandId-DisplayItemCount+1; 167 | updateCommandYPos = true; 168 | } 169 | if(updateCommandYPos) 170 | { 171 | int y = 260; 172 | for(int i = 0, count = std::min(DisplayItemCount,static_cast(commands.size())); i < count; ++i) 173 | { 174 | commands[i+topListItemNumber].texture.rect.y = y; 175 | y += 18; 176 | } 177 | } 178 | 179 | pointerRect.y = currentCommand.texture.rect.y; 180 | if(currentCommand.previewImage.size()) 181 | { 182 | PreviewImage = std::make_shared(currentCommand.previewImage, renderer, currentCommand.previewImageX, currentCommand.previewImageY); 183 | double wAspectRatio = (double)currentCommand.previewImageHeight / (double)PreviewImage->rect.h * (double)PreviewImage->rect.w; 184 | double hAspectRatio = (double)currentCommand.previewImageWidth / (double)PreviewImage->rect.w * (double)PreviewImage->rect.h; 185 | if (currentCommand.previewImageWidth > 0) 186 | { 187 | PreviewImage->rect.w = currentCommand.previewImageWidth; 188 | if (currentCommand.previewImageHeight <= 0) 189 | { 190 | PreviewImage->rect.h = hAspectRatio; 191 | } 192 | } 193 | if (currentCommand.previewImageHeight > 0) 194 | { 195 | PreviewImage->rect.h = currentCommand.previewImageHeight; 196 | if (currentCommand.previewImageWidth <= 0) 197 | { 198 | PreviewImage->rect.w = wAspectRatio; 199 | } 200 | } 201 | } 202 | else 203 | PreviewImage.reset(); 204 | }; 205 | SetCurrentCommand(0); 206 | 207 | for(;;) 208 | { 209 | //Clear Buffer and Update Input State 210 | sdl_context.StartFrame(); 211 | controller.Update(); 212 | 213 | SDL_Event e; 214 | //Poll for quit event (CTRL+C)/Close 215 | while (SDL_PollEvent(&e)) { 216 | if (e.type == SDL_QUIT) { 217 | return 0; 218 | } 219 | } 220 | 221 | if(sdl_context.powerwatch->buttonPress()) 222 | { 223 | break; 224 | } 225 | if(controller.GetButtonStatus(A) || controller.GetButtonStatus(START)) 226 | { 227 | if(commands[currentCommandId].runInternal) 228 | { 229 | commands[currentCommandId].RunCommand(sdl_context, &controller, menuL, menuU); 230 | } 231 | else 232 | { 233 | system(commands[currentCommandId].command.c_str()); 234 | _exitManager.runExitCommand = commands[currentCommandId].restartUI; 235 | break; 236 | } 237 | } 238 | else if(controller.GetButtonStatus(UP)) 239 | { 240 | int newCommandId = currentCommandId; 241 | do { newCommandId = (newCommandId-1+commands.size())%commands.size(); } 242 | while(commands[newCommandId].command.size() == 0); 243 | SetCurrentCommand(newCommandId); 244 | } 245 | else if(controller.GetButtonStatus(DOWN)) 246 | { 247 | int newCommandId = currentCommandId; 248 | do { newCommandId = (newCommandId+1)%commands.size(); } 249 | while(commands[newCommandId].command.size() == 0); 250 | SetCurrentCommand(newCommandId); 251 | } 252 | else if(controller.GetButtonStatus(B)) 253 | SetCurrentCommand(commands.size()-1); 254 | 255 | //Draw all textures 256 | banner.Draw(renderer); 257 | menuU.Draw(renderer); 258 | menuL.Draw(renderer); 259 | titleText.Draw(renderer); 260 | for(int i = 0, count = std::min(DisplayItemCount,static_cast(commands.size())); i < count; ++i) 261 | { 262 | commands[i+topListItemNumber].texture.Draw(renderer); 263 | } 264 | if(PreviewImage.get()) 265 | PreviewImage->Draw(renderer); 266 | pointerText.Draw(renderer); 267 | CompComText.Draw(renderer); 268 | 269 | // Display Scroll Arrows when needed 270 | if(topListItemNumber != 0) 271 | scrollUp.Draw(renderer); 272 | if((topListItemNumber + DisplayItemCount) < commands.size()) 273 | scrollDown.Draw(renderer, SDL_FLIP_VERTICAL); 274 | 275 | //Render Framebuffer and Wait for Next Frame 276 | sdl_context.EndFrame(); 277 | } 278 | 279 | return 0; 280 | } 281 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Options Menu Documentation 2 | ## What is the options menu? 3 | The Options Menu is a custom menu that can be launched via a controller button combo at any point during the console’s operation. It features a variety of commands to enhance the user experience of the console. 4 | 5 | The options menu is easily extendible, allowing for other developers to add their own custom commands to the menu via hmods. 6 | 7 | ## Options Explained 8 | Below is a detailed guide on what specific options actually do and what their purpose is. 9 | ## Default Options 10 | 11 | #### Hibernate/Standby 12 | This option launches Swingflip’s power menu. The power menu will provide the following options: 13 | 14 | - **Hibernate** - Put the console in a low power state, turn the screen off and when woken up the console will resume whatever you were doing before you put the console in hibernate. 15 | - **Standby** - Put the console in lowest power state possible, turn the screen off and when woken up the console will reboot and start the console from a fresh boot. 16 | 17 | > **Note:** Basically... Standby saves more energy however when you remotely wake the console it will start up as a fresh boot where hibernate will resume where ever you left off when you put it in to hibernate. 18 | 19 | To wake the console when in hibernate or standby please refer to the below table: 20 | 21 | |Button combination|Hibernate Mode |Standby Mode | 22 | |------------------|---------------|-----------------| 23 | | L + R + UP |Resume Console |Reboot Console | 24 | | L + R + DOWN |Reboot Console |Shutdown Console | 25 | 26 | #### Shutdown Device 27 | This option will safely shut down the console.\* 28 | 29 | 30 | #### Restart Device 31 | This option will safely restart the console.\* 32 | 33 | #### Retroarch Options 34 | This option will open a menu for managing retroarch configurations (see below). 35 | 36 | #### Advanced Options 37 | This option will open a menu containing more advanced features (see below). 38 | 39 | 40 | >\***Note:** You should **NOT** turn off your console via the options/power menu while running retroarch. Ensure you properly exit retroarch before shutting down/restarting or you may experience a loss of saves. 41 | 42 | 43 | 44 | ## Retroarch Options 45 | #### Restore Default Settings (All) 46 | Replaces your current retroarch config files with the default files included in the module. This option deletes all game/core overrides and remap files. 47 | #### Restore Default Settings 48 | Replaces your current retroarch config files with the default files included in the module. Does not erase your game/core overrides and remap files. 49 | #### Backup Settings to NAND 50 | Copies your current retroarch config files to a backup file located at /etc/ra_backup/ 51 | #### Backup Settings to USB (usb only) 52 | Copies your current retroarch config files to a backup file located at USB:/data/ra_backup/ 53 | #### Restore Settings from NAND 54 | Overwrites your retroarch configs with the backups located at /etc/ra_backup/ 55 | #### Restore Settings from USB (usb only) 56 | Overwrites your retroarch configs with the backups located at USB:/data/ra_backup/ 57 | #### Delete all settings backups 58 | Removes all backup files on both NAND and USB. 59 | #### Transfer BIOS file(s) 60 | Copies bios files to USB:/data/ra_bios. Restores bios files from this folder to NAND. 61 | #### Delete game and core overrides 62 | Removes only the game and core overrides. Does not modify the Retroarch settings and remap files. 63 | #### Delete remap files 64 | Removes only the remap files. Does not modify the Retroarch settings, game and core overrides. 65 | #### Delete BIOS file(s) from NAND 66 | Removes all bios files from NAND only. 67 | #### Toggle RA and Canoe load screens 68 | Toggle the RetroArch and Canoe loading screens on or off. 69 | 70 | ## Advanced Options 71 | #### Module Uninstaller 72 | This option launches the module uninstaller program. This program allows you to remove modules from your device. Press the up and down buttons to select a module. Press A to add a module to the uninstall list. Press B to remove a module from the uninstall list. Pressing start will exit if no modules are added to the uninstall list. If there are modules on the uninstall this you will be prompted to ensure you want to remove them press START+SELECT to remove selected modules or B to cancel. 73 | 74 | >**Caution:** The uninstaller will list all modules on the device including the default hakchi modules. Only delete modules you have added yourself. Deleting the default hakchi modules can have unintended effects on your console. 75 | 76 | 77 | #### Display Temp 78 | This option will display the current temperature of the CPU. 79 | 80 | #### Run Top 81 | This option runs and displays the output of the top binary. This shows the current CPU, memory usage and list of running processes. 82 | 83 | #### Benchmark Tool 84 | This option will go through and echo out useful information regarding your console. 85 | It will also include information on your: 86 | 87 | - Current disk mounting information 88 | - CPU analysis information 89 | - RAM analysis information 90 | 91 | > **Note:** The information is displayed in 4 parts and has a 2 second wait between each part 92 | 93 | #### Dump File Structure (to USB) 94 | This option will map and echo out your complete file and directory structure for your console and any mounted disks. The log file will be saved to your mounted USB/SD card at: 95 | 96 | /media/data/log/Hakchi_file_structure.log 97 | 98 | > **Note:** If these folders do not exist, they will be created when the option is ran. 99 | 100 | The log file will also include information on: 101 | 102 | - Symbolic Links (Overmounts) 103 | - File and directory permissions 104 | 105 | #### Toggle Write Access on USB 106 | This option will toggle read write access on your USB device. By default, if you don't have a saves folder located on your USB/SD, write access is disabled. If you wish to write logs or use your external mounted storage and **not** use external saves... This is the toggle for you. 107 | 108 | > **Note:** If you already use external saves. You don't need to use this toggle. 109 | 110 | #### RetroArch Debugger (USB logs) 111 | This option will run your locally installed RetroArch in full verbose mode. It will also copy the config files for your RetroArch and save them to: 112 | 113 | /media/data/log/RetroArchConfig 114 | 115 | The full verbose log will be located here: 116 | 117 | /media/data/log/Hakchi_retroarch_debug.log 118 | 119 | 120 | > **Note:** Depending on what you are trying to do, you might have limited functionality within RetroArch when running it via the debugger. This app is primarily designed to debug cores, custom configs and themes. 121 | 122 | #### Change Options Button Combo 123 | This option will allow you to change the button combo used to launch the options menu. You will need to restart the console after setting a new combo. 124 | 125 | #### Clear Cache 126 | This option will force the kernel to clear the page cache and free up unused memory. You should not need to call this as the system should manage memory fine on it's own. 127 | 128 | ## Network Options 129 | #### Display IP Address 130 | This option will display both your public and internal ip addresses if you have a network adapter connected to your device. 131 | 132 | #### Reconnect 133 | This option will restart the network service on your device if you are not connected to the internet already. 134 | 135 | #### Search for SSIDs 136 | This option will scan and display a list of available SSIDs. 137 | 138 | ## Developer Information 139 | ### General Information 140 | The options mod is comprised of two executables. The `optiond` executable acts as a watchdog that waits for the controller combo to be held down and executes the `options` executable. All files are stored with the `/etc/options_menu/` folder. There are two important folders for the usage of the options menu these are the commands and scripts folders. The commands folder stores the options to be displayed on the menu. The scripts folder contains scripts executed by these commands. 141 | ### Command Line Arguments 142 | >Note: The options menu should always be called with the full file path. 143 | >/etc/options_menu/options 144 | 145 | | Argument | Description | 146 | |----------|-------------| 147 | |--commandPath <Command Folder Path>|Set a custom command folder.| 148 | |--scriptPath <Script Folder Path>|Set custom script folder.| 149 | |--title <Window Title>|Set custom title for options menu screen.| 150 | 151 | ### Command Files 152 | Command Files must be named in the following format: 153 | 154 | cxxxx_CommandName 155 | 156 | Command Files should contain the following fields: 157 | 158 | | Field | Description | 159 | |-------|-------------| 160 | |COMMAND_NAME|Display Name of command.| 161 | |COMMAND_TYPE|Specifies whether command is run inside the options menu pseudo terminal (internally) or run externally. Possible values `INTERNAL` or `EXTERNAL`| 162 | |RESTART_UI|Specifies if the paused UI should be resumed after running command (external commands only). If you set this value to `FALSE` you must manually resume the UI using `/bin/sh /etc/options_menu/script/ResumeUI.sh` after executing your code.| 163 | |COMMAND_STR|Command string to be executed. Commands must be single line only. To execute multi-line scripts use a script file.| 164 | |PREVIEW_IMAGE|Specifies the path to a thumbnail/icon to the oprion menu.| 165 | |PREVIEW_IMAGE_X|Position the thumbnail/icon on the X axys| 166 | |PREVIEW_IMAGE_Y|Position the thumbnail/icon on the Y axys.| 167 | |PREVIEW_IMAGE_WIDTH|Sets the width for the thumbnail/icon.| 168 | |PREVIEW_IMAGE_HEIGHT|Sets the height for the thumbnail/icon.| 169 | 170 | >Note: Fields and values are case sensitive. Values should be separated from fields using '=' without spaces. 171 | 172 | #### Command String Variables 173 | The command string supports the use of the following variables: 174 | 175 | |Variable | Description| 176 | |---------|------------| 177 | |%options_path% | Path to the folder containing the options binary.| 178 | |%script_dir% | Path to the current script folder set in the options binary.| 179 | 180 | ### Compiling Options Menu 181 | The options menu can be compiled using the makefile provided. To compile the options menu you must have the SDL2 and libpng libraries as well as GNU Make installed. To cross-compile the options menu call `make` with the `CROSS_PREFIX` set to the prefix of your cross-compiler toolchain eg. `make CROSS_PREFIX=arm-linux-gnueabihf-`. 182 | 183 | ## Contributions and Thanks 184 | ### Contributions 185 | - Hibernate Mod and Hakchi-Option-Pack scripts courtesy of Swingflip 186 | - Retroarch Configuration scripts courtesy of BsLeNuL 187 | - Thanks to ThanosRD for assistance with UI Layout/Design 188 | ### Testing 189 | Extra thanks to DNA64 (viral_dna) and Swingflip for always testing features. 190 | 191 | Also thanks to the following people for testing the options menu: 192 | 193 | - BsLeNuL 194 | - DefKorns 195 | - DR1001 196 | - Patton Plays 197 | - ThanosRD -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . --------------------------------------------------------------------------------