浏览代码

fix: enhance input handling for flash mode selection and improve user instructions

TheWildJames 3 月之前
父节点
当前提交
013934990a
共有 1 个文件被更改,包括 38 次插入19 次删除
  1. 38 19
      .github/actions/build-kernel/patches/bypass.patch

+ 38 - 19
.github/actions/build-kernel/patches/bypass.patch

@@ -1,32 +1,51 @@
-diff --git a/anykernel.sh b/anykernel.sh
-index 35b6e59..e2bcb62 100755
---- a/anykernel.sh
-+++ b/anykernel.sh
-@@ -45,6 +45,52 @@ esac
+diff --git a/AnyKernel3/anykernel.sh b/AnyKernel3/anykernel.sh
+--- a/AnyKernel3/anykernel.sh	2026-05-23 20:16:58.305522267 -0400
++++ b/AnyKernel3/anykernel.sh	2026-05-23 21:32:11.537813431 -0400
+@@ -45,6 +45,72 @@
  ui_print " " "  -> Wild Kernels Supported: $ksu_supported"
  $ksu_supported || abort "  -> Non-GKI device, abort."
  
 +handle_input() {
-+    while true; do
-+        case $(getevent -lqc 2>/dev/null | grep -m1 'DOWN') in
-+            *KEY_POWER*) echo "cancel"; return ;;
-+            *KEY_VOLUMEUP*) echo "bypass"; return ;;
-+            *KEY_VOLUMEDOWN*) echo "normal"; return ;;
++    # 1) try picking a node that advertises volume/power keys via /proc
++    if [ -r /proc/bus/input/devices ]; then
++        node=$(awk -v RS= '/KEY/ && /KEY_VOLUMEUP|KEY_VOLUMEDOWN|KEY_POWER/ {
++            if (match($0, /event[0-9]+/)) print "/dev/input/" substr($0, RSTART, RLENGTH)
++        }' /proc/bus/input/devices | head -n1)
++        if [ -n "$node" ] && [ -e "$node" ]; then
++            case $(getevent -lqc "$node" 2>/dev/null | grep -m1 'DOWN' || true) in
++                *KEY_VOLUMEUP*) echo "bypass"; return 0 ;;
++                *KEY_VOLUMEDOWN*) echo "normal"; return 0 ;;
++                *KEY_POWER*) echo "cancel"; return 0 ;;
++            esac
++        fi
++    fi
++
++    # 2) fallback: scan a small range of common event nodes
++    for ev in /dev/input/event{0..12}; do
++        [ -e "$ev" ] || continue
++        case $(getevent -lqc "$ev" 2>/dev/null | grep -m1 'DOWN' || true) in
++            *KEY_VOLUMEUP*) echo "bypass"; return 0 ;;
++            *KEY_VOLUMEDOWN*) echo "normal"; return 0 ;;
++            *KEY_POWER*) echo "cancel"; return 0 ;;
 +        esac
 +    done
++
++    # 3) final global attempt (may block on some recoveries)
++    case $(getevent -lqc 2>/dev/null | grep -m1 'DOWN' || true) in
++        *KEY_VOLUMEUP*) echo "bypass"; return 0 ;;
++        *KEY_VOLUMEDOWN*) echo "normal"; return 0 ;;
++        *KEY_POWER*) echo "cancel"; return 0 ;;
++    esac
++
++    return 1
 +}
 +
 +choose_flash_mode() {
 +    ui_print " "
-+    ui_print "  -> Most users do not need Bypass; try Normal first! This does not help bypass root detection; it only swaps the Image for compatibility workarounds! Use it only when Normal fails to boot due to kernel module incompatibilities!"
++    ui_print "  -> Most users do not need Bypass; try Normal first!"
++    ui_print "  -> This only swaps the Image for compatibility workarounds."
++    ui_print "  -> VOL+ = Bypass | VOL- = Normal | POWER = Cancel"
 +    ui_print " "
-+    ui_print "  -> Choose Kernel Image:"
-+    ui_print " "
-+    ui_print "  -> VOL+ = Bypass"
-+    ui_print " "
-+    ui_print "  -> VOL- = Normal"
-+    ui_print " "
-+    ui_print "  -> POWER = Cancel"
 +
 +    while true; do
 +        case $(handle_input) in
@@ -54,4 +73,4 @@ index 35b6e59..e2bcb62 100755
 +
  # boot install
  split_boot
- 
+