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)
|
int ShowBrightnessConfig(int set_brightness)
|
||||||
{
|
{
|
||||||
|
const int old_brightness = set_brightness;
|
||||||
u32 btn_input, bar_count;
|
u32 btn_input, bar_count;
|
||||||
int bar_x_pos, bar_y_pos, bar_width, bar_height;
|
int bar_x_pos, bar_y_pos, bar_width, bar_height;
|
||||||
|
|
||||||
const char *brightness_str =
|
const char *brightness_str =
|
||||||
"[<] Decrease brightness\n"
|
"[\x1B] Decrease brightness\n"
|
||||||
"[>] Increase brightness\n"
|
"[\x1A] Increase brightness\n"
|
||||||
"[X] Use the volume slider as control\n"
|
" \n"
|
||||||
"\n"
|
"[X] Use volume slider control\n"
|
||||||
"[A] Set screen brightness\n"
|
"[A] Set current brightness\n"
|
||||||
"[B] Exit";
|
"[B] Cancel";
|
||||||
static const u16 brightness_slider_colmasks[] = {
|
static const u16 brightness_slider_colmasks[] = {
|
||||||
COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_WHITE
|
COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_WHITE
|
||||||
};
|
};
|
||||||
@ -1094,7 +1095,7 @@ int ShowBrightnessConfig(int set_brightness)
|
|||||||
// draw initial UI stuff
|
// draw initial UI stuff
|
||||||
DrawStringF(MAIN_SCREEN,
|
DrawStringF(MAIN_SCREEN,
|
||||||
(SCREEN_WIDTH_MAIN - GetDrawStringWidth(brightness_str)) / 2,
|
(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
|
// draw all color gradient bars
|
||||||
for (int x = 0; x < bar_width; x++) {
|
for (int x = 0; x < bar_width; x++) {
|
||||||
@ -1117,9 +1118,9 @@ int ShowBrightnessConfig(int set_brightness)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while(1) {
|
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;
|
slider_y_pos = bar_y_pos + (bar_height * 3) + font_height;
|
||||||
|
|
||||||
if (set_brightness != BRIGHTNESS_AUTOMATIC) {
|
if (set_brightness != BRIGHTNESS_AUTOMATIC) {
|
||||||
@ -1148,8 +1149,9 @@ int ShowBrightnessConfig(int set_brightness)
|
|||||||
set_brightness += 10;
|
set_brightness += 10;
|
||||||
} else if (btn_input & BUTTON_X) {
|
} else if (btn_input & BUTTON_X) {
|
||||||
set_brightness = BRIGHTNESS_AUTOMATIC;
|
set_brightness = BRIGHTNESS_AUTOMATIC;
|
||||||
|
break;
|
||||||
} else if (btn_input & BUTTON_B) {
|
} else if (btn_input & BUTTON_B) {
|
||||||
set_brightness = 0;
|
set_brightness = old_brightness;
|
||||||
break;
|
break;
|
||||||
} else if (btn_input & BUTTON_A) {
|
} else if (btn_input & BUTTON_A) {
|
||||||
break;
|
break;
|
||||||
@ -1158,10 +1160,11 @@ int ShowBrightnessConfig(int set_brightness)
|
|||||||
if (set_brightness != BRIGHTNESS_AUTOMATIC)
|
if (set_brightness != BRIGHTNESS_AUTOMATIC)
|
||||||
set_brightness = clamp(set_brightness, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
|
set_brightness = clamp(set_brightness, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
|
||||||
|
|
||||||
if (set_brightness != old_br)
|
if (set_brightness != prev_brightness)
|
||||||
SetScreenBrightness(set_brightness);
|
SetScreenBrightness(set_brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearScreen(MAIN_SCREEN, COLOR_STD_BG);
|
ClearScreen(MAIN_SCREEN, COLOR_STD_BG);
|
||||||
|
SetScreenBrightness(set_brightness);
|
||||||
return set_brightness;
|
return set_brightness;
|
||||||
}
|
}
|
||||||
|
@ -1883,6 +1883,7 @@ u32 HomeMoreMenu(char* current_path) {
|
|||||||
int bsupport = ++n_opt;
|
int bsupport = ++n_opt;
|
||||||
int hsrestore = ((CheckHealthAndSafetyInject("1:") == 0) || (CheckHealthAndSafetyInject("4:") == 0)) ? (int) ++n_opt : -1;
|
int hsrestore = ((CheckHealthAndSafetyInject("1:") == 0) || (CheckHealthAndSafetyInject("4:") == 0)) ? (int) ++n_opt : -1;
|
||||||
int clock = ++n_opt;
|
int clock = ++n_opt;
|
||||||
|
int bright = ++n_opt;
|
||||||
int sysinfo = ++n_opt;
|
int sysinfo = ++n_opt;
|
||||||
int readme = (FindVTarFileInfo(VRAM0_README_MD, NULL)) ? (int) ++n_opt : -1;
|
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 (bsupport > 0) optionstr[bsupport - 1] = "Build support files";
|
||||||
if (hsrestore > 0) optionstr[hsrestore - 1] = "Restore H&S";
|
if (hsrestore > 0) optionstr[hsrestore - 1] = "Restore H&S";
|
||||||
if (clock > 0) optionstr[clock - 1] = "Set RTC date&time";
|
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 (sysinfo > 0) optionstr[sysinfo - 1] = "System info";
|
||||||
if (readme > 0) optionstr[readme - 1] = "Show ReadMe";
|
if (readme > 0) optionstr[readme - 1] = "Show ReadMe";
|
||||||
|
|
||||||
@ -1993,6 +1995,15 @@ u32 HomeMoreMenu(char* current_path) {
|
|||||||
}
|
}
|
||||||
return 0;
|
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
|
else if (user_select == sysinfo) { // Myria's system info
|
||||||
char* sysinfo_txt = (char*) malloc(STD_BUFFER_SIZE);
|
char* sysinfo_txt = (char*) malloc(STD_BUFFER_SIZE);
|
||||||
if (!sysinfo_txt) return 1;
|
if (!sysinfo_txt) return 1;
|
||||||
@ -2026,6 +2037,7 @@ u32 GodMode(int entrypoint) {
|
|||||||
bool bootloader = IS_UNLOCKED && (entrypoint == ENTRY_NANDBOOT);
|
bool bootloader = IS_UNLOCKED && (entrypoint == ENTRY_NANDBOOT);
|
||||||
bool bootmenu = bootloader && (BOOTMENU_KEY != BUTTON_START) && CheckButton(BOOTMENU_KEY);
|
bool bootmenu = bootloader && (BOOTMENU_KEY != BUTTON_START) && CheckButton(BOOTMENU_KEY);
|
||||||
bool godmode9 = !bootloader;
|
bool godmode9 = !bootloader;
|
||||||
|
|
||||||
|
|
||||||
// FIRM from FCRAM handling
|
// FIRM from FCRAM handling
|
||||||
FirmHeader* firm_in_mem = (FirmHeader*) __FIRMTMP_ADDR; // should be safe here
|
FirmHeader* firm_in_mem = (FirmHeader*) __FIRMTMP_ADDR; // should be safe here
|
||||||
@ -2065,6 +2077,11 @@ u32 GodMode(int entrypoint) {
|
|||||||
InitExtFS();
|
InitExtFS();
|
||||||
CalibrateTouchFromFlash();
|
CalibrateTouchFromFlash();
|
||||||
|
|
||||||
|
// brightness from file?
|
||||||
|
s32 brightness = -1;
|
||||||
|
if (LoadSupportFile("gm9bright.cfg", &brightness, 0x4))
|
||||||
|
SetScreenBrightness(brightness);
|
||||||
|
|
||||||
// custom font handling
|
// custom font handling
|
||||||
if (CheckSupportFile("font.pbm")) {
|
if (CheckSupportFile("font.pbm")) {
|
||||||
u8* pbm = (u8*) malloc(0x10000); // arbitrary, should be enough by far
|
u8* pbm = (u8*) malloc(0x10000); // arbitrary, should be enough by far
|
||||||
|
Loading…
x
Reference in New Issue
Block a user