-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCustom Keyboard.gm9
138 lines (101 loc) · 4.25 KB
/
Custom Keyboard.gm9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
set WORKINGPATH "0:/gm9/customkyb"
if not find $[WORKINGPATH] NULL
echo "Patch directory not found.\nPlease follow the tutorial on GitHub."
goto exit
end
# Emunand check
set WORKINGDRIVE "1:"
set EMUFLAG "f"
if find 4:/title NULL
if ask "Emunand detected, do you want\nto install on it?"
set WORKINGDRIVE "4:"
set EMUFLAG "t"
end
end
# Main menu
@menu
labelsel -o -s "== Custom Keyboard Helper ==" mainmenu_*
goto exit
# Dump and Prepare Keyboard
@mainmenu_Dump_and_Prepare_Keyboard
# Asks the region, I'm not doing it automatically anymore
# because it didn't work for region changed systems.
labelsel -o -s "Select your region" regionmenu_*
goto exit
@regionmenu_USA
set USINGREGION "USA"
goto setvariables
@regionmenu_EUR
set USINGREGION "EUR"
goto setvariables
@regionmenu_Other
set USINGREGION "Other"
goto setvariables
@setvariables
if chk $[USINGREGION] "USA"
set KYBPATH "$[WORKINGDRIVE]/title/00040030/0000C802/content"
set TITLEID "000400300000C802"
set ROMFSHASH "F54C6631C98FA401FDED95AC961B450EF708526E4FC0BB3B6FFA590E34982426"
elif chk $[USINGREGION] "EUR"
set KYBPATH "$[WORKINGDRIVE]/title/00040030/0000D002/content"
set TITLEID "000400300000D002"
set ROMFSHASH "5E0D387D7740A330B01669083A55D39047FDB9F70C303C6BC101F4BC6D8B4766"
else
echo "Your region is not supported.\nOnly USA and EUR regions are supported."
goto exit
end
set ERRORMSG "Keyboard not found.\nMake sure you picked the right region.\nIf so, try to perform\na system update and try again."
find $[KYBPATH]/*.tmd TMD
# Build legit keyboard
set ERRORMSG "The keyboard is not legit.\nDid you install a custom one already?\nIf so, restore it first.\nFollow the uninstallation guide\nif you don't have a backup."
buildcia -l $[TMD]
set ERRORMSG ""
# Rename the og keyboard dump
find $[GM9OUT]/$[TITLEID]*.cia CIA
mv -k -n -o $[CIA] $[WORKINGPATH]/Original_Keyboard.cia
# Decrypt the keyboard to patch it
cp -w $[WORKINGPATH]/Original_Keyboard.cia $[WORKINGPATH]/Keyboard.cia
decrypt $[WORKINGPATH]/Keyboard.cia
# Get the romfs file and patch it
imgmount $[WORKINGPATH]/Keyboard.cia
find G:/*.app APPFILE
cp -w $[APPFILE] $[WORKINGPATH]/tmp.app
imgumount
imgmount $[WORKINGPATH]/tmp.app
cp -w G:/romfs.bin $[WORKINGPATH]/romfs.bin
imgumount
rm -s $[WORKINGPATH]/tmp.app
set ERRORMSG "The system seems very out of date. Make sure\nthe version is over 9.0 and try again."
sha $[WORKINGPATH]/romfs.bin $[ROMFSHASH]
set ERRORMSG "Something went wrong, do you\nhave the romfs-$[USINGREGION].bps file?"
applybps $[WORKINGPATH]/romfs-$[USINGREGION].bps $[WORKINGPATH]/romfs.bin $[WORKINGPATH]/romfs-patched.bin
rm -o -s $[WORKINGPATH]/romfs.bin
echo "Patch applied successfully.\nYou will find the original keyboard, the keyboard\nto patch, and the patched romfs.bin in:\n$[WORKINGPATH]"
echo "Now, you need to build it on your PC\nand encrypt it using this script after.\nDO NOT INSTALL IT YET or it will CRASH!\nSee you later!"
poweroff
# Encrypt Patched Keyboard
@mainmenu_Encrypt_Patched_Keyboard
if not find $[WORKINGPATH]/Keyboard_patched.cia NULL
echo "Patched Keyboard not found. It should be like this:\n$[WORKINGPATH]/Keyboard_patched.cia"
end
# It seems like gm9 doesn't install system apps with a script,
# probably for security reasons or a bug.
# Clean up
rm -o -s $[WORKINGPATH]/Keyboard.cia
rm -o -s $[WORKINGPATH]/romfs-patched.bin
echo "IMPORTANT: NEVER uninstall the CFW with the\ncustom keyboard installed or you will be\nsoftbricked! If you really want to uninstall it,\nrestore the original keyboard first."
echo "Custom Keyboard prepared successfully!\nPress A to reboot, then install it from the\nfollowing path using FBI or godmode9 and enjoy!\n$[WORKINGPATH]/Keyboard_patched.cia"
reboot
# Restore Keyboard
@mainmenu_Restore_Original_Keyboard
if not find $[WORKINGPATH]/Original_Keyboard.cia NULL
echo "Backup not found. It should be like this:\n$[WORKINGPATH]/Original_Keyboard.cia"
end
# Gm9 will tell if it fails then exit
if chk $[EMUFLAG] "t"
install -e $[WORKINGPATH]/Original_Keyboard.cia
else
install $[WORKINGPATH]/Original_Keyboard.cia
end
echo "Original Keyboard restored successfully!"
@exit