diff options
Diffstat (limited to 'mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb')
-rw-r--r-- | mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb | 137 |
1 files changed, 79 insertions, 58 deletions
diff --git a/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb b/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb index 06d7f798..1c05a523 100644 --- a/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb +++ b/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb @@ -1,58 +1,79 @@ -checkUsbStorage(){ - local trigger="/sys/bus/platform/devices/sunxi_hcd_host0/otg_ed_test" - local disk="/dev/sda1" - - if [ -f "$trigger" ]; then - echo "1" > "$trigger" - local timeout=5 - while [ $timeout -gt 0 ] && ! [ -b "$disk" ]; do - echo "waiting for media $timeout" - let timeout=timeout-1 - sleep 1 - done - fi - - [ -b "$disk" ] || return 1 - - local ro="defaults,nosuid,nodev,noatime,ro" - local rw="defaults,nosuid,nodev,noatime,rw" - mount -o $ro "$disk" "$mountpoint/media" || return 1 - - local saves="$modname/saves" - - if [ -d "$mountpoint/media/$saves" ] || [ -d "$mountpoint/media/$modname/transfer" ] || [ "$cfg_usb_rw" == "y" ]; then - mount -o remount,$rw "$disk" - fi - [ -d "$mountpoint/media/$saves" ] && mount_bind "$mountpoint/media/$saves" "$mountpoint/var/lib/clover/profiles/0" - - local bootlogo0="boot.png" - local bootlogo1="$mountpoint/media/$modname/$bootlogo0" - local bootlogo2="$rootfs/etc/$bootlogo0" - if [ -f "$bootlogo1" ]; then - rsync -ac "$bootlogo1" "$bootlogo2" - showImage "$bootlogo2" - cfg_boot_logo='' - else - [ -f "$bootlogo2" ] && rm "$bootlogo2" && source "$preinit.d/p7010_bootlogo" - fi - - return 0 -} - -checkUsbGamepath(){ - local disk="/dev/sda1" - [ -b "$disk" ] || return 1 - - local games="$modname/games" - if containsGames "$mountpoint/media/$games"; then - if ! mkdir -p "$rootfs$gamepath"; then - rm -rf "$rootfs$gamepath" - mkdir -p "$rootfs$gamepath" || return 1 - fi - mount_bind "$mountpoint/media/$games" "$rootfs$gamepath" - return 0 - else - echo "no romz found at: $disk:/$games" - return 1 - fi -} +disableUsbDevice(){
+ #disable usb
+ echo 0 > "/sys/devices/sunxi_usb/usb_role"
+}
+
+switchToUsbDevice(){
+ disableUsbDevice
+
+ # enable device mode
+ echo 2 > "/sys/devices/sunxi_usb/usb_role"
+
+ # make sure the usb gadgets are disabled
+ echo 0 > "/sys/devices/virtual/android_usb/android0/enable"
+}
+
+switchToUsbHost(){
+ # make sure the usb gadgets are disabled
+ echo 0 > "/sys/devices/virtual/android_usb/android0/enable"
+
+ disableUsbDevice
+
+ # enable host mode
+ echo 1 > "/sys/devices/sunxi_usb/usb_role"
+}
+
+checkUsbStorage(){
+ local disk="/dev/sda1"
+
+ local timeout=5
+ while [ $timeout -gt 0 ] && ! [ -b "$disk" ]; do
+ echo "waiting for media $timeout"
+ let timeout=timeout-1
+ sleep 1
+ done
+
+ [ -b "$disk" ] || return 1
+
+ local ro="defaults,nosuid,nodev,noatime,ro"
+ local rw="defaults,nosuid,nodev,noatime,rw"
+ mount -o $ro "$disk" "$mountpoint/media" || return 1
+
+ local saves="$modname/saves"
+
+ if [ -d "$mountpoint/media/$saves" ] || [ -d "$mountpoint/media/$modname/transfer" ] || [ "$cfg_usb_rw" == "y" ]; then
+ mount -o remount,$rw "$disk"
+ fi
+ [ -d "$mountpoint/media/$saves" ] && mount_bind "$mountpoint/media/$saves" "$mountpoint/var/lib/clover/profiles/0"
+
+ local bootlogo0="boot.png"
+ local bootlogo1="$mountpoint/media/$modname/$bootlogo0"
+ local bootlogo2="$rootfs/etc/$bootlogo0"
+ if [ -f "$bootlogo1" ]; then
+ rsync -ac "$bootlogo1" "$bootlogo2"
+ showImage "$bootlogo2"
+ cfg_boot_logo=''
+ else
+ [ -f "$bootlogo2" ] && rm "$bootlogo2" && source "$preinit.d/p7010_bootlogo"
+ fi
+
+ return 0
+}
+
+checkUsbGamepath(){
+ local disk="/dev/sda1"
+ [ -b "$disk" ] || return 1
+
+ local games="$modname/games"
+ if containsGames "$mountpoint/media/$games"; then
+ if ! mkdir -p "$rootfs$gamepath"; then
+ rm -rf "$rootfs$gamepath"
+ mkdir -p "$rootfs$gamepath" || return 1
+ fi
+ mount_bind "$mountpoint/media/$games" "$rootfs$gamepath"
+ return 0
+ else
+ echo "no romz found at: $disk:/$games"
+ return 1
+ fi
+}
|