@@ -22,8 +22,6 @@ For more information, please refer to <https://unlicense.org> */
2222
2323#include "ntp.h"
2424
25- PadState pad ;
26-
2725bool setsysInternetTimeSyncIsOn () {
2826 Result rs = setsysInitialize ();
2927 if (R_FAILED (rs )) {
@@ -86,12 +84,12 @@ bool setNetworkSystemClock(time_t time) {
8684 return true;
8785}
8886
89- int consoleExitWithMsg (char * msg ) {
87+ int consoleExitWithMsg (char * msg , PadState * pad ) {
9088 printf ("%s\n\nPress + to quit..." , msg );
9189
9290 while (appletMainLoop ()) {
93- padUpdate (& pad );
94- u64 kDown = padGetButtonsDown (& pad );
91+ padUpdate (pad );
92+ u64 kDown = padGetButtonsDown (pad );
9593
9694 if (kDown & HidNpadButton_Plus ) {
9795 consoleExit (NULL );
@@ -104,7 +102,7 @@ int consoleExitWithMsg(char* msg) {
104102 return 0 ;
105103}
106104
107- bool toggleHBMenuPath (char * curPath ) {
105+ bool toggleHBMenuPath (char * curPath , PadState * pad ) {
108106 const char * HB_MENU_NRO_PATH = "sdmc:/hbmenu.nro" ;
109107 const char * HB_MENU_BAK_PATH = "sdmc:/hbmenu.nro.bak" ;
110108 const char * DEFAULT_RESTORE_PATH = "sdmc:/switch/switch-time.nro" ;
@@ -117,35 +115,35 @@ bool toggleHBMenuPath(char* curPath) {
117115 rs = access (HB_MENU_BAK_PATH , F_OK );
118116 if (R_FAILED (rs )) {
119117 printf ("could not find %s to restore. failed: 0x%x" , HB_MENU_BAK_PATH , rs );
120- consoleExitWithMsg ("" );
118+ consoleExitWithMsg ("" , pad );
121119 return false;
122120 }
123121
124122 rs = rename (curPath , DEFAULT_RESTORE_PATH );
125123 if (R_FAILED (rs )) {
126124 printf ("fsFsRenameFile(%s, %s) failed: 0x%x" , curPath , DEFAULT_RESTORE_PATH , rs );
127- consoleExitWithMsg ("" );
125+ consoleExitWithMsg ("" , pad );
128126 return false;
129127 }
130128 rs = rename (HB_MENU_BAK_PATH , HB_MENU_NRO_PATH );
131129 if (R_FAILED (rs )) {
132130 printf ("fsFsRenameFile(%s, %s) failed: 0x%x" , HB_MENU_BAK_PATH , HB_MENU_NRO_PATH , rs );
133- consoleExitWithMsg ("" );
131+ consoleExitWithMsg ("" , pad );
134132 return false;
135133 }
136134 } else {
137135 // replace hbmenu
138136 rs = rename (HB_MENU_NRO_PATH , HB_MENU_BAK_PATH );
139137 if (R_FAILED (rs )) {
140138 printf ("fsFsRenameFile(%s, %s) failed: 0x%x" , HB_MENU_NRO_PATH , HB_MENU_BAK_PATH , rs );
141- consoleExitWithMsg ("" );
139+ consoleExitWithMsg ("" , pad );
142140 return false;
143141 }
144142 rs = rename (curPath , HB_MENU_NRO_PATH );
145143 if (R_FAILED (rs )) {
146144 printf ("fsFsRenameFile(%s, %s) failed: 0x%x" , curPath , HB_MENU_NRO_PATH , rs );
147145 rename (HB_MENU_BAK_PATH , HB_MENU_NRO_PATH ); // hbmenu already moved, try to move it back
148- consoleExitWithMsg ("" );
146+ consoleExitWithMsg ("" , pad );
149147 return false;
150148 }
151149 }
@@ -157,30 +155,32 @@ bool toggleHBMenuPath(char* curPath) {
157155
158156int main (int argc , char * argv []) {
159157 consoleInit (NULL );
158+ printf ("SwitchTime v0.1.3\n\n" );
159+
160160 padConfigureInput (8 , HidNpadStyleSet_NpadStandard );
161+ PadState pad ;
161162 padInitializeAny (& pad );
162- printf ("SwitchTime v0.1.3\n\n" );
163163
164164 if (!setsysInternetTimeSyncIsOn ()) {
165165 // printf("Trying setsysSetUserSystemClockAutomaticCorrectionEnabled...\n");
166166 // if (R_FAILED(enableSetsysInternetTimeSync())) {
167167 // return consoleExitWithMsg("Internet time sync is not enabled. Please enable it in System Settings.");
168168 // }
169169 // doesn't work without rebooting? not worth it
170- return consoleExitWithMsg ("Internet time sync is not enabled. Please enable it in System Settings." );
170+ return consoleExitWithMsg ("Internet time sync is not enabled. Please enable it in System Settings." , & pad );
171171 }
172172
173173 // Main loop
174174 while (appletMainLoop ()) {
175175 printf (
176176 "\n\n"
177177 "Press:\n\n"
178- "UP/DOWN to change hour | LEFT/RIGHT to change day | R/ZR to change year \n"
178+ "UP/DOWN to change hour | LEFT/RIGHT to change day | X/B to 10 minutes \n"
179179 "L/ZL to change month | R/ZR to change year\n"
180180 "A to confirm time | Y to reset to current time (Cloudflare time server)\n"
181181 " | + to quit\n\n\n" );
182182
183- int dayChange = 0 , hourChange = 0 , monthChange = 0 ,yearsChange = 0 ;
183+ int yearsChange = 0 , monthChange = 0 , dayChange = 0 , hourChange = 0 , tenMinChange = 0 ;
184184 while (appletMainLoop ()) {
185185 padUpdate (& pad );
186186 u64 kDown = padGetButtonsDown (& pad );
@@ -190,7 +190,7 @@ int main(int argc, char* argv[]) {
190190 return 0 ; // return to hbmenu
191191 }
192192 if (kDown & HidNpadButton_Minus ) {
193- if (!toggleHBMenuPath (argv [0 ])) {
193+ if (!toggleHBMenuPath (argv [0 ], & pad )) {
194194 return 0 ;
195195 }
196196 }
@@ -199,15 +199,15 @@ int main(int argc, char* argv[]) {
199199 Result rs = timeGetCurrentTime (TimeType_UserSystemClock , (u64 * )& currentTime );
200200 if (R_FAILED (rs )) {
201201 printf ("timeGetCurrentTime failed with %x" , rs );
202- return consoleExitWithMsg ("" );
202+ return consoleExitWithMsg ("" , & pad );
203203 }
204204
205205 struct tm * p_tm_timeToSet = localtime (& currentTime );
206206 p_tm_timeToSet -> tm_year += yearsChange ;
207207 p_tm_timeToSet -> tm_mon += monthChange ;
208208 p_tm_timeToSet -> tm_mday += dayChange ;
209209 p_tm_timeToSet -> tm_hour += hourChange ;
210-
210+ p_tm_timeToSet -> tm_min += tenMinChange * 10 ;
211211 time_t timeToSet = mktime (p_tm_timeToSet );
212212
213213 if (kDown & HidNpadButton_A ) {
@@ -241,6 +241,10 @@ int main(int argc, char* argv[]) {
241241 monthChange -- ;
242242 } else if (kDown & HidNpadButton_ZL ) {
243243 monthChange ++ ;
244+ } else if (kDown & HidNpadButton_B ) {
245+ tenMinChange -- ;
246+ } else if (kDown & HidNpadButton_X ) {
247+ tenMinChange ++ ;
244248 }
245249
246250 char timeToSetStr [25 ];
@@ -249,4 +253,4 @@ int main(int argc, char* argv[]) {
249253 consoleUpdate (NULL );
250254 }
251255 }
252- }
256+ }
0 commit comments