-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
67 lines (53 loc) · 1.72 KB
/
main.c
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
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <psppower.h>
PSP_MODULE_INFO("psp-info", 0, 1, 0);
int exit_callback(int arg1, int arg2, void* common){
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void* argp) {
int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void) {
int thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if (thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main() {
int battery_temp, battery_voltage, battery_charging;
SetupCallbacks();
pspDebugScreenInit();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
pspDebugScreenClear();
struct SceCtrlData padData;
if (scePowerIsBatteryExist() == 1){
battery_temp = scePowerGetBatteryTemp();
battery_voltage = scePowerGetBatteryVolt();
battery_charging = scePowerIsBatteryCharging();
pspDebugScreenPrintf("Battery temperature: %d C\n", battery_temp);
pspDebugScreenPrintf("Battery voltage: %d v\n", battery_voltage);
if (battery_charging == 1)
pspDebugScreenPrintf("Battery is charging\n");
else
pspDebugScreenPrintf("Battery is not charging\n");
}
else {
pspDebugScreenPrintf("No battery was detected\n");
}
pspDebugScreenPrintf("Press START to refresh values.\n");
while(1){
sceCtrlReadBufferPositive(&padData,1);
if(padData.Buttons & PSP_CTRL_START){
pspDebugScreenPrintf("Refreshing values.");
main();
}
}
}