mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Added brightness setting dialogue to HOME more.. menu, some minor adaptions
This commit is contained in:
parent
ab110bf73d
commit
dc9dc794b0
@ -1064,16 +1064,17 @@ bool ShowProgress(u64 current, u64 total, const char* opstr)
|
||||
|
||||
int ShowBrightnessConfig(int set_brightness)
|
||||
{
|
||||
const int old_brightness = set_brightness;
|
||||
u32 btn_input, bar_count;
|
||||
int bar_x_pos, bar_y_pos, bar_width, bar_height;
|
||||
|
||||
const char *brightness_str =
|
||||
"[<] Decrease brightness\n"
|
||||
"[>] Increase brightness\n"
|
||||
"[X] Use the volume slider as control\n"
|
||||
"[\x1B] Decrease brightness\n"
|
||||
"[\x1A] Increase brightness\n"
|
||||
" \n"
|
||||
"[A] Set screen brightness\n"
|
||||
"[B] Exit";
|
||||
"[X] Use volume slider control\n"
|
||||
"[A] Set current brightness\n"
|
||||
"[B] Cancel";
|
||||
static const u16 brightness_slider_colmasks[] = {
|
||||
COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_WHITE
|
||||
};
|
||||
@ -1094,7 +1095,7 @@ int ShowBrightnessConfig(int set_brightness)
|
||||
// draw initial UI stuff
|
||||
DrawStringF(MAIN_SCREEN,
|
||||
(SCREEN_WIDTH_MAIN - GetDrawStringWidth(brightness_str)) / 2,
|
||||
(SCREEN_HEIGHT / 4) * 3, COLOR_STD_FONT, COLOR_STD_BG, brightness_str);
|
||||
(SCREEN_HEIGHT / 4) * 2, COLOR_STD_FONT, COLOR_STD_BG, brightness_str);
|
||||
|
||||
// draw all color gradient bars
|
||||
for (int x = 0; x < bar_width; x++) {
|
||||
@ -1117,9 +1118,9 @@ int ShowBrightnessConfig(int set_brightness)
|
||||
}
|
||||
|
||||
while(1) {
|
||||
int old_br, slider_x_pos, slider_y_pos;
|
||||
int prev_brightness, slider_x_pos, slider_y_pos;
|
||||
|
||||
old_br = set_brightness;
|
||||
prev_brightness = set_brightness;
|
||||
slider_y_pos = bar_y_pos + (bar_height * 3) + font_height;
|
||||
|
||||
if (set_brightness != BRIGHTNESS_AUTOMATIC) {
|
||||
@ -1148,8 +1149,9 @@ int ShowBrightnessConfig(int set_brightness)
|
||||
set_brightness += 10;
|
||||
} else if (btn_input & BUTTON_X) {
|
||||
set_brightness = BRIGHTNESS_AUTOMATIC;
|
||||
break;
|
||||
} else if (btn_input & BUTTON_B) {
|
||||
set_brightness = 0;
|
||||
set_brightness = old_brightness;
|
||||
break;
|
||||
} else if (btn_input & BUTTON_A) {
|
||||
break;
|
||||
@ -1158,10 +1160,11 @@ int ShowBrightnessConfig(int set_brightness)
|
||||
if (set_brightness != BRIGHTNESS_AUTOMATIC)
|
||||
set_brightness = clamp(set_brightness, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
|
||||
|
||||
if (set_brightness != old_br)
|
||||
if (set_brightness != prev_brightness)
|
||||
SetScreenBrightness(set_brightness);
|
||||
}
|
||||
|
||||
ClearScreen(MAIN_SCREEN, COLOR_STD_BG);
|
||||
SetScreenBrightness(set_brightness);
|
||||
return set_brightness;
|
||||
}
|
||||
|
@ -1883,6 +1883,7 @@ u32 HomeMoreMenu(char* current_path) {
|
||||
int bsupport = ++n_opt;
|
||||
int hsrestore = ((CheckHealthAndSafetyInject("1:") == 0) || (CheckHealthAndSafetyInject("4:") == 0)) ? (int) ++n_opt : -1;
|
||||
int clock = ++n_opt;
|
||||
int bright = ++n_opt;
|
||||
int sysinfo = ++n_opt;
|
||||
int readme = (FindVTarFileInfo(VRAM0_README_MD, NULL)) ? (int) ++n_opt : -1;
|
||||
|
||||
@ -1892,6 +1893,7 @@ u32 HomeMoreMenu(char* current_path) {
|
||||
if (bsupport > 0) optionstr[bsupport - 1] = "Build support files";
|
||||
if (hsrestore > 0) optionstr[hsrestore - 1] = "Restore H&S";
|
||||
if (clock > 0) optionstr[clock - 1] = "Set RTC date&time";
|
||||
if (bright > 0) optionstr[bright - 1] = "Configure brightness";
|
||||
if (sysinfo > 0) optionstr[sysinfo - 1] = "System info";
|
||||
if (readme > 0) optionstr[readme - 1] = "Show ReadMe";
|
||||
|
||||
@ -1993,6 +1995,15 @@ u32 HomeMoreMenu(char* current_path) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (user_select == bright) { // brightness config dialogue
|
||||
s32 old_brightness, new_brightness;
|
||||
if (!LoadSupportFile("gm9bright.cfg", &old_brightness, 4))
|
||||
old_brightness = BRIGHTNESS_AUTOMATIC; // auto by default
|
||||
new_brightness = ShowBrightnessConfig(old_brightness);
|
||||
if (old_brightness != new_brightness)
|
||||
SaveSupportFile("gm9bright.cfg", &new_brightness, 4);
|
||||
return 0;
|
||||
}
|
||||
else if (user_select == sysinfo) { // Myria's system info
|
||||
char* sysinfo_txt = (char*) malloc(STD_BUFFER_SIZE);
|
||||
if (!sysinfo_txt) return 1;
|
||||
@ -2027,6 +2038,7 @@ u32 GodMode(int entrypoint) {
|
||||
bool bootmenu = bootloader && (BOOTMENU_KEY != BUTTON_START) && CheckButton(BOOTMENU_KEY);
|
||||
bool godmode9 = !bootloader;
|
||||
|
||||
|
||||
// FIRM from FCRAM handling
|
||||
FirmHeader* firm_in_mem = (FirmHeader*) __FIRMTMP_ADDR; // should be safe here
|
||||
if (bootloader) { // check for FIRM in FCRAM, but prevent bootloops
|
||||
@ -2065,6 +2077,11 @@ u32 GodMode(int entrypoint) {
|
||||
InitExtFS();
|
||||
CalibrateTouchFromFlash();
|
||||
|
||||
// brightness from file?
|
||||
s32 brightness = -1;
|
||||
if (LoadSupportFile("gm9bright.cfg", &brightness, 0x4))
|
||||
SetScreenBrightness(brightness);
|
||||
|
||||
// custom font handling
|
||||
if (CheckSupportFile("font.pbm")) {
|
||||
u8* pbm = (u8*) malloc(0x10000); // arbitrary, should be enough by far
|
||||
|
Loading…
x
Reference in New Issue
Block a user