mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Allow POWER and HOME for poweroff / reboot
... also revised HID functions
This commit is contained in:
parent
4abb666c1f
commit
5172bf9205
@ -906,7 +906,13 @@ u32 GodMode() {
|
|||||||
if (pad_state & BUTTON_START) {
|
if (pad_state & BUTTON_START) {
|
||||||
exit_mode = (switched || (pad_state & BUTTON_LEFT)) ? GODMODE_EXIT_POWEROFF : GODMODE_EXIT_REBOOT;
|
exit_mode = (switched || (pad_state & BUTTON_LEFT)) ? GODMODE_EXIT_POWEROFF : GODMODE_EXIT_REBOOT;
|
||||||
break;
|
break;
|
||||||
}
|
} else if (pad_state & BUTTON_POWER) {
|
||||||
|
exit_mode = GODMODE_EXIT_POWEROFF;
|
||||||
|
break;
|
||||||
|
} else if (pad_state & BUTTON_HOME) {
|
||||||
|
exit_mode = GODMODE_EXIT_REBOOT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DeinitExtFS();
|
DeinitExtFS();
|
||||||
|
20
source/hid.c
20
source/hid.c
@ -1,4 +1,5 @@
|
|||||||
#include "hid.h"
|
#include "hid.h"
|
||||||
|
#include "i2c.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
u32 InputWait() {
|
u32 InputWait() {
|
||||||
@ -8,19 +9,30 @@ u32 InputWait() {
|
|||||||
timer_start();
|
timer_start();
|
||||||
while (true) {
|
while (true) {
|
||||||
u32 pad_state = HID_STATE;
|
u32 pad_state = HID_STATE;
|
||||||
if (!(~pad_state & BUTTON_ANY)) { // no buttons pressed
|
if (!(pad_state & BUTTON_ANY)) { // no buttons pressed
|
||||||
|
u32 special_key = i2cReadRegister(I2C_DEV_MCU, 0x10);
|
||||||
|
if (special_key == 0x01)
|
||||||
|
return pad_state | BUTTON_POWER;
|
||||||
|
else if (special_key == 0x04)
|
||||||
|
return pad_state | BUTTON_HOME;
|
||||||
pad_state_old = pad_state;
|
pad_state_old = pad_state;
|
||||||
delay = 0;
|
delay = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((pad_state == pad_state_old) &&
|
if ((pad_state == pad_state_old) &&
|
||||||
(!(~pad_state & BUTTON_ARROW) ||
|
(!(pad_state & BUTTON_ARROW) ||
|
||||||
(delay && (timer_msec() < delay))))
|
(delay && (timer_msec() < delay))))
|
||||||
continue;
|
continue;
|
||||||
//Make sure the key is pressed
|
// make sure the key is pressed
|
||||||
u32 t_pressed = 0;
|
u32 t_pressed = 0;
|
||||||
for(; (t_pressed < 0x13000) && (pad_state == HID_STATE); t_pressed++);
|
for(; (t_pressed < 0x13000) && (pad_state == HID_STATE); t_pressed++);
|
||||||
if (t_pressed >= 0x13000)
|
if (t_pressed >= 0x13000)
|
||||||
return ~pad_state;
|
return pad_state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CheckButton(u32 button) {
|
||||||
|
u32 t_pressed = 0;
|
||||||
|
for(; (t_pressed < 0x13000) && ((HID_STATE & button) == button); t_pressed++);
|
||||||
|
return (t_pressed >= 0x13000);
|
||||||
|
}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#define HID_STATE (*(volatile u32*)0x10146000)
|
#define HID_STATE (~(*(volatile u32*)0x10146000) & BUTTON_ANY)
|
||||||
|
|
||||||
|
|
||||||
#define BUTTON_A (1 << 0)
|
#define BUTTON_A (1 << 0)
|
||||||
#define BUTTON_B (1 << 1)
|
#define BUTTON_B (1 << 1)
|
||||||
@ -19,4 +20,9 @@
|
|||||||
#define BUTTON_ANY 0x00000FFF
|
#define BUTTON_ANY 0x00000FFF
|
||||||
#define BUTTON_ARROW (BUTTON_RIGHT|BUTTON_LEFT|BUTTON_UP|BUTTON_DOWN)
|
#define BUTTON_ARROW (BUTTON_RIGHT|BUTTON_LEFT|BUTTON_UP|BUTTON_DOWN)
|
||||||
|
|
||||||
|
// special buttons
|
||||||
|
#define BUTTON_POWER (1 << 12)
|
||||||
|
#define BUTTON_HOME (1 << 13)
|
||||||
|
|
||||||
u32 InputWait();
|
u32 InputWait();
|
||||||
|
bool CheckButton(u32 button);
|
||||||
|
@ -543,5 +543,5 @@ bool ShowProgress(u64 current, u64 total, const char* opstr)
|
|||||||
|
|
||||||
last_prog_width = prog_width;
|
last_prog_width = prog_width;
|
||||||
|
|
||||||
return !(~HID_STATE & BUTTON_B);
|
return !CheckButton(BUTTON_B);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user