From 81240c775578b2b86bc7ae521be048defc49a142 Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Tue, 10 Oct 2017 00:49:08 +0300 Subject: Fixed bug causing exit on any button press, scanlines overlay --- .../snes9x2010.hmod/usr/bin/clover-canoe-shvc | 41 +++++++++++++---- retroarch.hmod/bin/retroarch-clover-child | 50 +++++++++++---------- .../.config/retroarch/overlay/scanlines.cfg | 5 +++ .../.config/retroarch/overlay/scanlines.png | Bin 0 -> 4223 bytes retroarch.hmod/etc/libretro/crt720.overlay | 1 + retroarch.hmod/etc/libretro/gpu720.overlay | 1 + retroarch.hmod/etc/libretro/ppu.overlay | 1 + retroarch.hmod/etc/libretro/ppu.ratio | 2 +- retroarch.hmod/etc/libretro/retroarch.cfg | 8 ++-- retroarch.hmod/readme.txt | 8 ++-- retroarch.hmod/usr/bin/clover-kachikachi | 9 +++- 11 files changed, 84 insertions(+), 42 deletions(-) create mode 100644 retroarch.hmod/etc/libretro/.config/retroarch/overlay/scanlines.cfg create mode 100644 retroarch.hmod/etc/libretro/.config/retroarch/overlay/scanlines.png create mode 100644 retroarch.hmod/etc/libretro/crt720.overlay create mode 100644 retroarch.hmod/etc/libretro/gpu720.overlay create mode 100644 retroarch.hmod/etc/libretro/ppu.overlay diff --git a/core_modules/snes9x2010.hmod/usr/bin/clover-canoe-shvc b/core_modules/snes9x2010.hmod/usr/bin/clover-canoe-shvc index 6ce93c6..6d052c5 100755 --- a/core_modules/snes9x2010.hmod/usr/bin/clover-canoe-shvc +++ b/core_modules/snes9x2010.hmod/usr/bin/clover-canoe-shvc @@ -19,8 +19,13 @@ decorative_options() done < "$fn" } -original_options=$@ options="" +retroarch=0 +clovercon_file=/dev/clovercon1 +video_mode=keep-aspect-ratio +mode1="-filter 2 -magfilter 1" +mode2="-filter 1 -magfilter 3" +mode3="-filter 1 --pixel-perfect" while [ $# -gt 0 ] ; do case "$1" in @@ -30,13 +35,18 @@ while [ $# -gt 0 ] ; do --replay-inputs) options="$options -replay-all -replay" ;; --record-inputs) options="$options -record-next -enable-pad-debug-controls" ;; --video-mode) - case "$2" in - keep-aspect-ratio) options="$options -filter 1 -magfilter 3" ;; - pixel-perfect) options="$options -filter 1 --pixel-perfect" ;; - crt-filter) options="$options -filter 2 -magfilter 1" ;; - esac + video_mode=$2 shift ;; + --no-scanlines) + mode1="-filter 1 -magfilter 1" + ;; + --no-smooth) + mode1="-filter 2 -magfilter 3" + ;; + --smooth43) + mode2="-filter 1 -magfilter 1" + ;; --rollback-mode) case "$2" in record) options="$options -rollback-mode 1" ;; @@ -50,7 +60,10 @@ while [ $# -gt 0 ] ; do --rollback-output-dir) options="$options -rollback-output-dir $2"; shift ;; --rollback-input-dir) options="$options -rollback-input-dir $2"; shift ;; --decorative-frame-path) options="$options --use-decorative-frame $2 $(decorative_options $2)"; shift ;; + -retroarch) retroarch=1 ;; --retroarch) retroarch=1 ;; + --core) core=$2; shift ;; + -core) core=$2; shift ;; *.sfrom) if [ -f "$1.gz" ]; then options="$options /tmp/ROM.sfrom" @@ -66,6 +79,12 @@ while [ $# -gt 0 ] ; do shift done +case "$video_mode" in + keep-aspect-ratio) options="$options $mode2" ;; + pixel-perfect) options="$options $mode3" ;; + crt-filter) options="$options $mode1" ;; +esac + read BUILD_TYPE < /etc/clover/buildtype case "$BUILD_TYPE" in devel) log="-log $title_code.log -log-append --debug-menu-settings /var/lib/clover/canoe/debug-menu.json --decorative-frames-path /usr/share/backgrounds" ;; @@ -73,8 +92,14 @@ test) log="-log $title_code.log" ;; *) ;; esac -if [ -z "$retroarch" ]; then +# Hold up to forcely disable RetroArch +[ -e "$clovercon_file" ] && [ "$(cat $clovercon_file)" == "1000" ] && retroarch=0 +# Hold down to forcely enable RetroArch +[ -e "$clovercon_file" ] && [ "$(cat $clovercon_file)" == "2000" ] && retroarch=1 + +if [ "$retroarch" == "0" ]; then exec canoe-shvc $options $log else - exec /bin/snes "$rom" $original_options + [ -z "$core" ] && exec snes $filename $args + [ -z "$core" ] || exec retroarch-clover $core $filename $args fi diff --git a/retroarch.hmod/bin/retroarch-clover-child b/retroarch.hmod/bin/retroarch-clover-child index 1a73236..11a87d6 100755 --- a/retroarch.hmod/bin/retroarch-clover-child +++ b/retroarch.hmod/bin/retroarch-clover-child @@ -17,9 +17,6 @@ t_suffix=_time.txt demo_time=30 shift 2 -crt=0 -allow_crt=0 - while [ $# -gt 0 ]; do [ "$1" == "--load-state-file" ] && load=$2 [ "$1" == "--save-on-quit" ] && save=$2 @@ -28,11 +25,9 @@ while [ $# -gt 0 ]; do [ "$1" == "--save-screenshot-on-quit" ] && screenshot=$2 [ "$1" == "--save-data-backing-file" ] && sram=$2 [ "$1" == "--graphic-filter" ] && filter=$2 - [ "$1" == "--enable-crt-scanlines" ] && crt=1 [ "$1" == "--video-mode" ] && [ "$2" == "crt-filter" ] && filter=crt720 [ "$1" == "--video-mode" ] && [ "$2" == "keep-aspect-ratio" ] && filter=gpu720 [ "$1" == "--video-mode" ] && [ "$2" == "pixel-perfect" ] && filter=ppu - [ "$1" == "--ra-allow-crt" ] && allow_crt=1 [ "$1" == "--ra-extra" ] && extra=$2 [ "$1" == "--ra-nosaves" ] && nosaves=1 [ "$1" == "--save-time-path" ] && timefile=$2 @@ -68,21 +63,12 @@ fi # pixel perfect - 1:1 for pixel perfect mode [ "$filter" == "ppu" ] && ratio=20 && smooth=false -# Allow scanlines only for simple systems -[ "$allow_crt" == "1" ] || crt=0 - smooth=$(cat /etc/libretro/$filter.smooth) sed -i -e 's/video_smooth = "[^"]*"/video_smooth = "'$smooth'"/g' /etc/libretro/retroarch.cfg ratio=$(cat /etc/libretro/$filter.ratio) sed -i -e 's/aspect_ratio_index = "[^"]*"/aspect_ratio_index = "'$ratio'"/g' /etc/libretro/retroarch.cfg - -# enable shader scanlines if need -if [ "$crt" == "1" ]; then - sed -i -e 's/video_shader = "[^"]*"/video_shader = "~\/shaders\/retroarch\.glslp"/g' /etc/libretro/retroarch.cfg - rsync -a -c /etc/libretro/shaders/scanline.glslp /etc/libretro/shaders/retroarch.glslp -else - sed -i -e 's/video_shader = "[^"]*"/video_shader = ""/g' /etc/libretro/retroarch.cfg -fi +overlay=$(cat /etc/libretro/$filter.overlay) +sed -i -e 's/input_overlay_enable = "[^"]*"/input_overlay_enable = "'$overlay'"/g' /etc/libretro/retroarch.cfg # Start timestamp ts=$(date +"%s") @@ -92,10 +78,14 @@ tm=0 retroarch -c "$HOME/retroarch.cfg" -vfL "$core" "$rom" $extra & rpid=$! -# We need last two files +# searching for input devices for i in $(ls /dev/input/event?) ;do - power_file=$reset_file - reset_file=$i + local id=$(basename $i) + local name=$(cat /sys/class/input/$id/device/name) + [ "$name" == "sunxi-knob" ] && power_file=$i + [ "$name" == "sunxi-keyboard" ] && reset_file=$i + [ "$name" == "Nintendo Clovercon - controller1" ] && controller1_file=$i + [ "$name" == "Nintendo Clovercon - controller2" ] && controller2_file=$i done dd if=$power_file of=/dev/null count=1 2> /dev/null & @@ -105,8 +95,14 @@ reset_pid=$! # Demo mode enabled if [ ! -z "$demo" ]; then - dd if=/dev/input/event2 of=/dev/null count=1 2> /dev/null & - anybutton_pid=$! + if [ ! -z "$controller1_file" ]; then + dd if=$controller1_file of=/dev/null count=1 2> /dev/null & + anybutton1_pid=$! + fi + if [ ! -z "$controller2_file" ]; then + dd if=$controller2_file of=/dev/null count=1 2> /dev/null & + anybutton2_pid=$! + fi fi sleep 3 @@ -119,7 +115,12 @@ while [ true ]; do kill -0 $power_pid 2> /dev/null || break if [ ! -z "$demo" ]; then # Exit on any button - kill -0 $anybutton_pid 2> /dev/null || break + if [ ! -z "$anybutton1_pid" ]; then + kill -0 $anybutton1_pid 2> /dev/null || break + fi + if [ ! -z "$anybutton2_pid" ]; then + kill -0 $anybutton2_pid 2> /dev/null || break + fi # Or after some time ts2=$(date +"%s") tp=$((ts2 - ts)) @@ -130,7 +131,8 @@ done kill $rpid 2> /dev/null kill -KILL $reset_pid 2> /dev/null kill -KILL $power_pid 2> /dev/null -[ ! -z "$demo" ] && kill -KILL $anybutton_pid 2> /dev/null +[ ! -z "$anybutton1_pid" ] && kill -KILL $anybutton1_pid 2> /dev/null +[ ! -z "$anybutton2_pid" ] && kill -KILL $anybutton2_pid 2> /dev/null [ ! -z "$save" ] && mkdir -p $(dirname "$save") [ ! -z "$sram" ] && mkdir -p $(dirname "$sram") @@ -154,6 +156,8 @@ echo $tm > "$timefile" grep video_smooth /etc/libretro/retroarch.cfg | grep true && current_smooth=true || current_smooth=false echo $current_smooth > /etc/libretro/$filter.smooth +grep video_smooth /etc/libretro/retroarch.cfg | grep true && current_overlay=true || current_overlay=false +echo $current_overlay > /etc/libretro/$filter.overlay current_ratio=$(cat /etc/libretro/retroarch.cfg | grep "aspect_ratio_index" | sed 's/[^0-9]*//g') echo $current_ratio > /etc/libretro/$filter.ratio diff --git a/retroarch.hmod/etc/libretro/.config/retroarch/overlay/scanlines.cfg b/retroarch.hmod/etc/libretro/.config/retroarch/overlay/scanlines.cfg new file mode 100644 index 0000000..9f3a7b3 --- /dev/null +++ b/retroarch.hmod/etc/libretro/.config/retroarch/overlay/scanlines.cfg @@ -0,0 +1,5 @@ +overlays = 1 +overlay0_overlay = scanlines.png +overlay0_full_screen = true +overlay0_descs = 0 +overlay0_rect = "0.0,0.0,1.0,1.0" diff --git a/retroarch.hmod/etc/libretro/.config/retroarch/overlay/scanlines.png b/retroarch.hmod/etc/libretro/.config/retroarch/overlay/scanlines.png new file mode 100644 index 0000000..9da2d1c Binary files /dev/null and b/retroarch.hmod/etc/libretro/.config/retroarch/overlay/scanlines.png differ diff --git a/retroarch.hmod/etc/libretro/crt720.overlay b/retroarch.hmod/etc/libretro/crt720.overlay new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/retroarch.hmod/etc/libretro/crt720.overlay @@ -0,0 +1 @@ +true diff --git a/retroarch.hmod/etc/libretro/gpu720.overlay b/retroarch.hmod/etc/libretro/gpu720.overlay new file mode 100644 index 0000000..c508d53 --- /dev/null +++ b/retroarch.hmod/etc/libretro/gpu720.overlay @@ -0,0 +1 @@ +false diff --git a/retroarch.hmod/etc/libretro/ppu.overlay b/retroarch.hmod/etc/libretro/ppu.overlay new file mode 100644 index 0000000..c508d53 --- /dev/null +++ b/retroarch.hmod/etc/libretro/ppu.overlay @@ -0,0 +1 @@ +false diff --git a/retroarch.hmod/etc/libretro/ppu.ratio b/retroarch.hmod/etc/libretro/ppu.ratio index b8626c4..8351c19 100644 --- a/retroarch.hmod/etc/libretro/ppu.ratio +++ b/retroarch.hmod/etc/libretro/ppu.ratio @@ -1 +1 @@ -4 +14 diff --git a/retroarch.hmod/etc/libretro/retroarch.cfg b/retroarch.hmod/etc/libretro/retroarch.cfg index 3bfda9b..124e8ff 100644 --- a/retroarch.hmod/etc/libretro/retroarch.cfg +++ b/retroarch.hmod/etc/libretro/retroarch.cfg @@ -45,7 +45,7 @@ video_refresh_rate = "60.000027" audio_rate_control_delta = "0.005000" audio_max_timing_skew = "0.050000" audio_volume = "0.000000" -input_overlay_opacity = "0.700000" +input_overlay_opacity = "0.500000" input_overlay_scale = "1.000000" menu_wallpaper_opacity = "0.300000" menu_footer_opacity = "1.000000" @@ -177,7 +177,7 @@ video_allow_rotate = "true" video_windowed_fullscreen = "true" video_crop_overscan = "false" video_scale_integer = "true" -video_smooth = "false" +video_smooth = "true" video_force_aspect = "true" video_threaded = "false" video_shared_context = "false" @@ -216,7 +216,7 @@ rgui_show_start_screen = "false" menu_navigation_wraparound_enable = "true" menu_navigation_browser_filter_supported_extensions_enable = "false" menu_show_advanced_settings = "true" -input_overlay_enable = "false" +input_overlay_enable = "true" input_overlay_enable_autopreferred = "true" input_overlay_hide_in_menu = "true" network_cmd_enable = "false" @@ -1561,6 +1561,7 @@ xmb_menu_color_theme = "4" xmb_shadows_enable = "true" xmb_show_settings = "true" xmb_show_history = "true" +input_overlay = "/etc/libretro/.config/retroarch/overlay/scanlines.cfg" xmb_font = "" netplay_nickname = "" video_filter = "" @@ -1569,7 +1570,6 @@ core_updater_buildbot_url = "" core_options_path = "" video_shader = "" menu_wallpaper = "" -input_overlay = "" video_font_path = "" content_history_dir = "" resampler_directory = "" diff --git a/retroarch.hmod/readme.txt b/retroarch.hmod/readme.txt index 4ed38a4..55a5924 100644 --- a/retroarch.hmod/readme.txt +++ b/retroarch.hmod/readme.txt @@ -1,7 +1,7 @@ === RetroArch module for hakchi === -version 0.8 +version 0.9 -This is a hakchi/hakchi2 module which adds libretro cores and RetroArch frontend to your NES Mini. +This is a hakchi/hakchi2 module which adds libretro cores and RetroArch frontend to your NES/SNES Mini. It will automatically detect unsupported NES games and run them instead of the default emulator. Save states will work as usual. @@ -23,12 +23,10 @@ Available executables and arguments: - /bin/retroarch RetroArch binary -Sometimes default emulator of NES mini is not working with some games when it should. So you can just add "--retroarch" command line argument to use RetroArch. +Sometimes default emulator of NES/SNES mini is not working with some games when it should. So you can just add "--retroarch" command line argument to use RetroArch. Known issues: - Nintendo 64 save-states are not working, battery backup working fine -- Default CRT filter is not working, scanlines shader added instead, only for NES - Cores by libretro, compiled by pcm NES Mini port by madmonkey diff --git a/retroarch.hmod/usr/bin/clover-kachikachi b/retroarch.hmod/usr/bin/clover-kachikachi index 349cd76..07e113e 100755 --- a/retroarch.hmod/usr/bin/clover-kachikachi +++ b/retroarch.hmod/usr/bin/clover-kachikachi @@ -28,7 +28,9 @@ fi while [ $# -gt 0 ]; do [ "$1" == "--retroarch" ] && emulator=retroarch - [ "$1" == "--core" ] && core=$2 + [ "$1" == "-retroarch" ] && emulator=retroarch + [ "$1" == "--core" ] && core=$2 + [ "$1" == "-core" ] && core=$2 shift done @@ -36,6 +38,11 @@ done args="$(echo $args | sed 's/--retroarch//g')" [ "$extension" == "qd" ] && emulator=kachikachi +# Hold up to forcely disable RetroArch +[ -e "$clovercon_file" ] && [ "$(cat $clovercon_file)" == "1000" ] && emulator=kachikachi +# Hold down to forcely enable RetroArch +[ -e "$clovercon_file" ] && [ "$(cat $clovercon_file)" == "2000" ] && emulator=retroarch + echo using $emulator if [ "$emulator" == "kachikachi" ]; then -- cgit v1.2.3