Skip to content

Commit 6926d0a

Browse files
committed
Fixed hibernate mod and added standby_watchdog source code.
1 parent afebd63 commit 6926d0a

File tree

5 files changed

+176
-4
lines changed

5 files changed

+176
-4
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ $(TARGET_NAME)_b_down.hmod: $(TARGET_NAME).hmod
1313
cp button.cfg mod/etc/options_menu/
1414
cd mod/; tar -czvf "../$(TARGET_NAME)_b_down.hmod" *
1515

16-
$(TARGET_NAME).hmod: mod/etc/options_menu/options mod/etc/options_menu/optiond mod/etc/options_menu/mod_uninstall/mod_uninstall
16+
$(TARGET_NAME).hmod: mod/etc/options_menu/options mod/etc/options_menu/optiond mod/etc/options_menu/mod_uninstall/mod_uninstall mod/bin/standby_watchdog
1717
$(CROSS_PREFIX)$(STRIP) mod/etc/options_menu/options
1818
$(CROSS_PREFIX)$(STRIP) mod/etc/options_menu/optiond
1919
$(CROSS_PREFIX)$(STRIP) mod/etc/options_menu/mod_uninstall/mod_uninstall
20+
$(CROSS_PREFIX)$(STRIP) mod/bin/standby_watchdog
2021
rm -f mod/etc/options_menu/button.cfg
2122
cd mod/; tar -czvf "../$(TARGET_NAME).hmod" *
2223

@@ -29,11 +30,14 @@ mod/etc/options_menu/optiond: src/daemon.o src/framework/controller.o
2930
mod/etc/options_menu/mod_uninstall/mod_uninstall: src/mod_uninstall.o
3031
$(CROSS_PREFIX)$(CXX) src/mod_uninstall.o src/framework/*.o $(LDLIBS) $(LDFLAGS) -o mod/etc/options_menu/mod_uninstall/mod_uninstall
3132

33+
mod/bin/standby_watchdog: src/standby_watchdog.o src/framework/controller.o src/framework/powerwatch.o
34+
$(CROSS_PREFIX)$(CXX) src/standby_watchdog.o src/framework/controller.o src/framework/powerwatch.o -o mod/bin/standby_watchdog
35+
3236
%.o: %.cpp
3337
$(CROSS_PREFIX)$(CXX) $(CXXFLAGS) -c $< -o $@
3438

3539
clean:
3640
find -name "*.o" -type f -delete
37-
rm -f mod/etc/options_menu/options mod/etc/options_menu/optiond mod/etc/options_menu/mod_uninstall/mod_uninstall mod/etc/options_menu/button.cfg $(TARGET_NAME).hmod $(TARGET_NAME)_b_down.hmod
41+
rm -f mod/etc/options_menu/options mod/etc/options_menu/optiond mod/etc/options_menu/mod_uninstall/mod_uninstall mod/bin/standby_watchdog mod/etc/options_menu/button.cfg $(TARGET_NAME).hmod $(TARGET_NAME)_b_down.hmod
3842

3943
.PHONY: clean

mod/bin/standby_watchdog

-17.8 KB
Binary file not shown.

mod/readme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
=== Options Menu v1.3.3 by CompCom ===
1+
=== Options Menu v1.3.4 by CompCom ===
22
The Options Menu is a custom menu that can be launched by holding controller button combo (L+R) for more than 1 second at any point during the console’s operation.
33

44
Current features provided by the options menu include: Hmod Uninstaller, Hibernate Mod and Retroarch Settings Management.

mod/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
------------------------------
2-
Name: Options Menu v1.3.3
2+
Name: Options Menu v1.3.4
33
Creator: CompCom
44
Category: System
55
------------------------------

src/standby_watchdog.cpp

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/**
2+
* Copyright (C) 2018 Swingflip and CompCom
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version 3
7+
* of the License, or (at your option) any later version.
8+
*/
9+
10+
#include "framework/controller.h"
11+
#include "framework/powerwatch.h"
12+
13+
#include <thread>
14+
#include <chrono>
15+
#include <cstdlib>
16+
#include <cstring>
17+
#include <unistd.h>
18+
#include <sys/reboot.h>
19+
#include <linux/reboot.h>
20+
21+
Controller c(1);
22+
PowerWatch pw;
23+
const auto fpsTime = std::chrono::milliseconds(200);
24+
auto nextUpdateTime = std::chrono::system_clock::now()+fpsTime;
25+
26+
int DisplayMenu()
27+
{
28+
system("standby ReloadImagePayload");
29+
system("cat /tmp/power_menu_screen > /dev/fb0");
30+
auto fpsTime = std::chrono::milliseconds(33); // Check for input faster
31+
//system("echo DEBUG: Displaying hibernate menu...");
32+
for(;;)
33+
{
34+
c.Update();
35+
if(c.PeekButtonStatus(A)) //Accept (Hibernate)
36+
{
37+
//system("echo DEBUG: Accepted hibernate...");
38+
return 1;
39+
}
40+
else if(c.PeekButtonStatus(X)) //Accept (Standby)
41+
{
42+
//system("echo DEBUG: Accepted standby...");
43+
return 2;
44+
}
45+
else if(c.PeekButtonStatus(Y)) //Cancel
46+
{
47+
//system("echo DEBUG: Cancelled hibernate...");
48+
return 3;
49+
}
50+
else if(pw.buttonPress())
51+
{
52+
return 3;
53+
}
54+
system("cat /tmp/power_menu_screen > /dev/fb0"); // This will fix the framebuffer getting overwritten by a stack process
55+
std::this_thread::sleep_until(nextUpdateTime);
56+
nextUpdateTime+=fpsTime;
57+
}
58+
}
59+
60+
int GetState()
61+
{
62+
for(;;)
63+
{
64+
c.Update();
65+
if(c.PeekButtonStatus(L) && c.PeekButtonStatus(R) && c.GetButtonStatus(UP))
66+
{
67+
system("standby DisplayMenu");
68+
return DisplayMenu();
69+
}
70+
else
71+
{
72+
std::this_thread::sleep_until(nextUpdateTime);
73+
nextUpdateTime+=fpsTime;
74+
}
75+
}
76+
}
77+
78+
void Hibernate()
79+
{
80+
system("standby Hibernate");
81+
82+
for(;;)
83+
{
84+
c.Update();
85+
if(c.PeekButtonStatus(L) && c.PeekButtonStatus(R) && c.GetButtonStatus(UP)) //L+R+SELECT = Hibernate / Reboot from Hibernate
86+
{
87+
//system("echo Core Temperature at the time of reboot out of hibernation: $(hakchi hwmon)c");
88+
system("echo 1 > /sys/devices/virtual/disp/disp/attr/lcd");
89+
break;
90+
}
91+
else if(c.PeekButtonStatus(L) && c.PeekButtonStatus(R) && c.GetButtonStatus(DOWN))
92+
{
93+
//system("echo Core Temperature at the time of shutdown out of hibernation: $(hakchi hwmon)c");
94+
system("standby HibernateReboot &");
95+
exit(0);
96+
}
97+
else if(pw.buttonPress())
98+
{
99+
system("standby Resume &");
100+
exit(0);
101+
}
102+
std::this_thread::sleep_until(nextUpdateTime);
103+
nextUpdateTime+=fpsTime;
104+
}
105+
}
106+
107+
void Standby()
108+
{
109+
system("standby Standby");
110+
111+
for(;;)
112+
{
113+
c.Update();
114+
if(c.PeekButtonStatus(L) && c.PeekButtonStatus(R) && c.GetButtonStatus(UP)) //L+R+SELECT = Hibernate / Reboot from Hibernate
115+
{
116+
//system("echo Core Temperature at the time of reboot out of standby: $(hakchi hwmon)c");
117+
system("echo Rebooting console out from standby mode...");
118+
sync();
119+
setuid(0);
120+
reboot(RB_AUTOBOOT);
121+
exit(0);
122+
}
123+
if(c.PeekButtonStatus(L) && c.PeekButtonStatus(R) && c.GetButtonStatus(DOWN))
124+
{
125+
//system("echo Core Temperature at the time of shutdown out of standby: $(hakchi hwmon)c");
126+
system("echo Shutting down console out from standby mode...");
127+
sync();
128+
setuid(0);
129+
reboot(LINUX_REBOOT_CMD_POWER_OFF);
130+
exit(0);
131+
}
132+
std::this_thread::sleep_until(nextUpdateTime);
133+
nextUpdateTime+=fpsTime;
134+
}
135+
}
136+
137+
int main(int argc, char * argv[])
138+
{
139+
if(argc == 2 && strcmp(argv[1], "--displayMenu") == 0)
140+
{
141+
switch(DisplayMenu())
142+
{
143+
case 1:
144+
Hibernate();
145+
break;
146+
case 2:
147+
Standby();
148+
break;
149+
}
150+
system("rm -f /tmp/power_menu_screen");
151+
}
152+
else
153+
{
154+
for(;;)
155+
{
156+
switch(GetState())
157+
{
158+
case 1:
159+
Hibernate();
160+
break;
161+
case 2:
162+
Standby();
163+
break;
164+
}
165+
system("standby Resume");
166+
}
167+
}
168+
}

0 commit comments

Comments
 (0)