diff --git a/config.def.h b/config.def.h index 2f940765b0..2097ef4350 100644 --- a/config.def.h +++ b/config.def.h @@ -134,6 +134,8 @@ * thumbnails of different sizes */ #define DEFAULT_MATERIALUI_THUMBNAIL_BACKGROUND_ENABLE true +#define DEFAULT_SCREEN_BRIGHTNESS 100 + #define DEFAULT_CRT_SWITCH_RESOLUTION CRT_SWITCH_NONE #define DEFAULT_CRT_SWITCH_RESOLUTION_SUPER 2560 diff --git a/configuration.c b/configuration.c index ad442c02fe..bc897faf21 100644 --- a/configuration.c +++ b/configuration.c @@ -1851,6 +1851,7 @@ static struct config_uint_setting *populate_settings_uint( #ifdef HAVE_NETWORKING SETTING_UINT("streaming_mode", &settings->uints.streaming_mode, true, STREAMING_MODE_TWITCH, false); #endif + SETTING_UINT("screen_brightness", &settings->uints.screen_brightness, true, DEFAULT_SCREEN_BRIGHTNESS, false); SETTING_UINT("crt_switch_resolution", &settings->uints.crt_switch_resolution, true, DEFAULT_CRT_SWITCH_RESOLUTION, false); SETTING_UINT("input_bind_timeout", &settings->uints.input_bind_timeout, true, input_bind_timeout, false); SETTING_UINT("input_bind_hold", &settings->uints.input_bind_hold, true, input_bind_hold, false); diff --git a/configuration.h b/configuration.h index f3a2d1db0a..b6e360db23 100644 --- a/configuration.h +++ b/configuration.h @@ -177,6 +177,7 @@ typedef struct settings unsigned video_window_opacity; unsigned crt_switch_resolution; unsigned crt_switch_resolution_super; + unsigned screen_brightness; unsigned video_monitor_index; unsigned video_fullscreen_x; unsigned video_fullscreen_y; diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index d8ea25b7bb..2632ec0135 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -671,6 +671,7 @@ frontend_ctx_driver_t frontend_ctx_ctr = NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_dos.c b/frontend/drivers/platform_dos.c index 77bdb457ab..bbb6516e7e 100644 --- a/frontend/drivers/platform_dos.c +++ b/frontend/drivers/platform_dos.c @@ -202,6 +202,7 @@ frontend_ctx_driver_t frontend_ctx_dos = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index d4e504c41b..9358233ff9 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -194,6 +194,7 @@ frontend_ctx_driver_t frontend_ctx_emscripten = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 01adcae742..bd25054b3f 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -564,6 +564,7 @@ frontend_ctx_driver_t frontend_ctx_gx = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_orbis.c b/frontend/drivers/platform_orbis.c index 396e7b1c52..adcc898386 100644 --- a/frontend/drivers/platform_orbis.c +++ b/frontend/drivers/platform_orbis.c @@ -365,6 +365,7 @@ frontend_ctx_driver_t frontend_ctx_orbis = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_ps2.c b/frontend/drivers/platform_ps2.c index 9212de0119..4241d1d554 100644 --- a/frontend/drivers/platform_ps2.c +++ b/frontend/drivers/platform_ps2.c @@ -383,6 +383,7 @@ frontend_ctx_driver_t frontend_ctx_ps2 = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index c07bb81e3f..cb9ec63d51 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -707,6 +707,7 @@ frontend_ctx_driver_t frontend_ctx_ps3 = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index f4fb2325b2..3227e258d0 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -641,6 +641,7 @@ frontend_ctx_driver_t frontend_ctx_psp = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index 64518ab798..d01067c79d 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -201,6 +201,7 @@ frontend_ctx_driver_t frontend_ctx_qnx = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_switch.c b/frontend/drivers/platform_switch.c index 72aed2aeb7..2f14ca3947 100644 --- a/frontend/drivers/platform_switch.c +++ b/frontend/drivers/platform_switch.c @@ -928,6 +928,7 @@ frontend_ctx_driver_t frontend_ctx_switch = NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index 65124790d4..b512659484 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -1325,6 +1325,23 @@ static void frontend_unix_get_lakka_version(char *s, pclose(command_file); } + +static void frontend_unix_set_screen_brightness(int value) +{ + char svalue[16] = {0}; + #if defined(HAVE_LAKKA_SWITCH) + /* Values from 0 to 100 */ + int brightness = value; + #elif defined(HAVE_ODROIDGO2) + /* GOA screen PWM value does not linearly relate to perceived brightness */ + int brightness = (pow(1.0369f, value) - 1) * 7; + #endif + + snprintf(svalue, sizeof(svalue), "%d\n", brightness); + filestream_write_file("/sys/class/backlight/backlight/brightness", + svalue, strlen(svalue)); +} + #endif static void frontend_unix_get_env(int *argc, @@ -1905,6 +1922,7 @@ static void android_app_destroy(struct android_app *android_app) static void frontend_unix_deinit(void *data) { + settings_t *settings = config_get_ptr(); #ifdef ANDROID struct android_app *android_app = (struct android_app*)data; @@ -1913,6 +1931,12 @@ static void frontend_unix_deinit(void *data) android_app_destroy(android_app); #endif + +#ifdef HAVE_LAKKA + /* Reset brightness to maximum */ + if (settings->uints.screen_brightness != DEFAULT_SCREEN_BRIGHTNESS) + frontend_unix_set_screen_brightness(DEFAULT_SCREEN_BRIGHTNESS); +#endif } static void frontend_unix_init(void *data) @@ -2734,6 +2758,11 @@ frontend_ctx_driver_t frontend_ctx_unix = { frontend_unix_get_lakka_version, /* get_lakka_version */ #else NULL, /* get_lakka_version */ +#endif +#if defined(HAVE_LAKKA_SWITCH) || (defined(HAVE_LAKKA) && defined(HAVE_ODROIDGO2)) + frontend_unix_set_screen_brightness, /* set_screen_brightness */ +#else + NULL, /* set_screen_brightness */ #endif frontend_unix_watch_path_for_changes, frontend_unix_check_for_path_changes, diff --git a/frontend/drivers/platform_uwp.c b/frontend/drivers/platform_uwp.c index 471feb42ba..fbaf6e0434 100644 --- a/frontend/drivers/platform_uwp.c +++ b/frontend/drivers/platform_uwp.c @@ -471,6 +471,7 @@ frontend_ctx_driver_t frontend_ctx_uwp = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index 93221670f2..5a5558166f 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -326,6 +326,7 @@ frontend_ctx_driver_t frontend_ctx_wiiu = NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 480ade8ad6..8cbb4c682c 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -1146,6 +1146,7 @@ frontend_ctx_driver_t frontend_ctx_win32 = { frontend_win32_attach_console, /* attach_console */ frontend_win32_detach_console, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index 2ddfc887e9..3f7dc84e57 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -437,6 +437,7 @@ frontend_ctx_driver_t frontend_ctx_xdk = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/drivers/platform_xenon.c b/frontend/drivers/platform_xenon.c index 5966c1c336..36beb81ae9 100644 --- a/frontend/drivers/platform_xenon.c +++ b/frontend/drivers/platform_xenon.c @@ -93,6 +93,7 @@ frontend_ctx_driver_t frontend_ctx_qnx = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/frontend_driver.c b/frontend/frontend_driver.c index 5694e42c81..444822a4ec 100644 --- a/frontend/frontend_driver.c +++ b/frontend/frontend_driver.c @@ -63,6 +63,7 @@ static frontend_ctx_driver_t frontend_ctx_null = { NULL, /* attach_console */ NULL, /* detach_console */ NULL, /* get_lakka_version */ + NULL, /* set_screen_brightness */ NULL, /* watch_path_for_changes */ NULL, /* check_for_path_changes */ NULL, /* set_sustained_performance_mode */ diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index 591fc115f4..22f5d9a270 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -103,6 +103,8 @@ typedef struct frontend_ctx_driver void (*attach_console)(void); void (*detach_console)(void); void (*get_lakka_version)(char *, size_t); + /* TODO/FIXME: Need to implement some sort of startup brightness setting. */ + void (*set_screen_brightness)(int); void (*watch_path_for_changes)(struct string_list *list, int flags, path_change_data_t **change_data); bool (*check_for_path_changes)(path_change_data_t *change_data); void (*set_sustained_performance_mode)(bool on); @@ -210,6 +212,10 @@ void frontend_driver_attach_console(void); void frontend_driver_detach_console(void); +void frontend_driver_set_screen_brightness(int value); + +bool frontend_driver_can_set_screen_brightness(); + bool frontend_driver_can_watch_for_changes(void); void frontend_driver_watch_path_for_changes(struct string_list *list, int flags, path_change_data_t **change_data); diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 4eea948c77..8a0ed762f6 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -3,10 +3,6 @@ MSG_HASH( MENU_ENUM_LABEL_SWITCH_GPU_PROFILE, "switch_gpu_profile" ) -MSG_HASH( - MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL, - "switch_backlight_control" - ) #endif #if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) MSG_HASH( @@ -2976,6 +2972,10 @@ MSG_HASH( MENU_ENUM_LABEL_USE_THIS_DIRECTORY, "use_this_directory" ) +MSG_HASH( + MENU_ENUM_LABEL_BRIGHTNESS_CONTROL, + "screen_brightness" + ) MSG_HASH( MENU_ENUM_LABEL_VIDEO_ALLOW_ROTATE, "video_allow_rotate" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 314567ec40..4d4dcc4184 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -11808,6 +11808,14 @@ MSG_HASH( MSG_READ_ONLY, "Read-Only" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BRIGHTNESS_CONTROL, + "Screen Brightness" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_BRIGHTNESS_CONTROL, + "Increase or decrease the screen brightness." + ) #ifdef HAVE_LAKKA_SWITCH MSG_HASH( @@ -11818,14 +11826,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_SWITCH_GPU_PROFILE, "Overclock or underclock the Switch GPU." ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_SWITCH_BACKLIGHT_CONTROL, - "Screen brightness" - ) -MSG_HASH( - MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL, - "Increase or decrease the Switch screen brightness." - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_REBOOT_RCM, "Reboot into RCM" diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index d8aa2ff609..aff4147432 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -252,7 +252,6 @@ GENERIC_DEFERRED_PUSH(deferred_push_switch_cpu_profile, DISPLAYLIST_ #ifdef HAVE_LAKKA_SWITCH GENERIC_DEFERRED_PUSH(deferred_push_switch_gpu_profile, DISPLAYLIST_SWITCH_GPU_PROFILE) -GENERIC_DEFERRED_PUSH(deferred_push_switch_backlight_control, DISPLAYLIST_SWITCH_BACKLIGHT_CONTROL) #endif GENERIC_DEFERRED_PUSH(deferred_push_manual_content_scan_list, DISPLAYLIST_MANUAL_CONTENT_SCAN_LIST) @@ -759,7 +758,6 @@ static int menu_cbs_init_bind_deferred_push_compare_label( {MENU_ENUM_LABEL_DEFERRED_LATENCY_SETTINGS_LIST, deferred_push_latency_settings_list}, #ifdef HAVE_LAKKA_SWITCH {MENU_ENUM_LABEL_SWITCH_GPU_PROFILE, deferred_push_switch_gpu_profile}, - {MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL, deferred_push_switch_backlight_control}, #endif #if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) {MENU_ENUM_LABEL_SWITCH_CPU_PROFILE, deferred_push_switch_cpu_profile}, diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 70e2fd2fcd..d471576f73 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3430,27 +3430,6 @@ static int action_ok_set_switch_gpu_profile(const char *path, return menu_cbs_exit(); } -static int action_ok_set_switch_backlight(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - char command[PATH_MAX_LENGTH] = {0}; - int brightness = SWITCH_BRIGHTNESS[entry_idx]; - - snprintf(command, sizeof(command), - "echo %d > /sys/class/backlight/backlight/brightness", - brightness); - - system(command); - - snprintf(command, sizeof(command), - "Brightness set to %d%%", brightness); - - runloop_msg_queue_push(command, 1, 90, true, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - - return 0; -} - #endif static int action_ok_load_core_deferred(const char *path, @@ -7265,7 +7244,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, #endif #ifdef HAVE_LAKKA_SWITCH {MENU_ENUM_LABEL_SWITCH_GPU_PROFILE, action_ok_push_default}, - {MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL, action_ok_push_default}, #endif #if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) {MENU_ENUM_LABEL_SWITCH_CPU_PROFILE, action_ok_push_default}, @@ -7715,9 +7693,6 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, case MENU_SET_SWITCH_GPU_PROFILE: BIND_ACTION_OK(cbs, action_ok_set_switch_gpu_profile); break; - case MENU_SET_SWITCH_BRIGHTNESS: - BIND_ACTION_OK(cbs, action_ok_set_switch_backlight); - break; #endif #if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) case MENU_SET_SWITCH_CPU_PROFILE: diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 7177b306b5..0c926dc8cf 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -854,9 +854,10 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_switch_cpu_profile, MENU #ifdef HAVE_LAKKA_SWITCH DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_switch_gpu_profile, MENU_ENUM_SUBLABEL_SWITCH_GPU_PROFILE) -DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_switch_backlight_control, MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL) #endif +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_brightness_control, MENU_ENUM_SUBLABEL_BRIGHTNESS_CONTROL) + #if defined(_3DS) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_3ds_lcd_bottom, MENU_ENUM_SUBLABEL_VIDEO_3DS_LCD_BOTTOM) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_3ds_display_mode, MENU_ENUM_SUBLABEL_VIDEO_3DS_DISPLAY_MODE) @@ -3874,10 +3875,10 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_switch_gpu_profile); break; - case MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL: - BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_switch_backlight_control); - break; #endif + case MENU_ENUM_LABEL_BRIGHTNESS_CONTROL: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_brightness_control); + break; #if defined(_3DS) case MENU_ENUM_LABEL_VIDEO_3DS_LCD_BOTTOM: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_3ds_lcd_bottom); diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 7ec0ee21a2..db1f0bb7cf 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -674,7 +674,6 @@ DEFAULT_TITLE_MACRO(action_get_title_switch_cpu_profile, MENU_ENUM_LABE #ifdef HAVE_LAKKA_SWITCH DEFAULT_TITLE_MACRO(action_get_title_switch_gpu_profile, MENU_ENUM_LABEL_VALUE_SWITCH_GPU_PROFILE) -DEFAULT_TITLE_MACRO(action_get_title_switch_backlight_control, MENU_ENUM_LABEL_VALUE_SWITCH_BACKLIGHT_CONTROL) #endif DEFAULT_TITLE_SEARCH_FILTER_MACRO(action_get_title_deferred_history_list, MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_HISTORY) @@ -1121,8 +1120,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, #ifdef HAVE_LAKKA_SWITCH {MENU_ENUM_LABEL_SWITCH_GPU_PROFILE, action_get_title_switch_gpu_profile}, - {MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL, - action_get_title_switch_backlight_control}, #endif {MENU_ENUM_LABEL_DEFERRED_MANUAL_CONTENT_SCAN_LIST, action_get_title_manual_content_scan_list}, @@ -1509,9 +1506,6 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE: BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_gpu_profile); break; - case MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL: - BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_backlight_control); - break; #endif case MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_title_manual_content_scan_list); diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index f0a2939167..f381ee9a20 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -1588,9 +1588,6 @@ static int ozone_list_push(void *data, void *userdata, #ifdef HAVE_LAKKA_SWITCH entry.enum_idx = MENU_ENUM_LABEL_SWITCH_GPU_PROFILE; menu_displaylist_setting(&entry); - - entry.enum_idx = MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL; - menu_displaylist_setting(&entry); #endif if (settings->bools.menu_show_configurations && !settings->bools.kiosk_mode_enable) diff --git a/menu/drivers/ozone/ozone_texture.c b/menu/drivers/ozone/ozone_texture.c index a7d004f082..deb5b9b41f 100644 --- a/menu/drivers/ozone/ozone_texture.c +++ b/menu/drivers/ozone/ozone_texture.c @@ -424,10 +424,8 @@ uintptr_t ozone_entries_icon_get_texture(ozone_handle_t *ozone, return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_PAUSE]; case MENU_SETTING_GROUP: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_SETTING]; -#ifdef HAVE_LAKKA_SWITCH - case MENU_SET_SWITCH_BRIGHTNESS: + case MENU_SET_SCREEN_BRIGHTNESS: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_BRIGHTNESS]; -#endif case MENU_INFO_MESSAGE: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO]; case MENU_BLUETOOTH: diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index b905ce3891..ddc09d8a2e 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2862,10 +2862,8 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, return xmb->textures.list[XMB_TEXTURE_RELOAD]; case MENU_SETTING_ACTION_PAUSE_ACHIEVEMENTS: return xmb->textures.list[XMB_TEXTURE_PAUSE]; -#ifdef HAVE_LAKKA_SWITCH - case MENU_SET_SWITCH_BRIGHTNESS: + case MENU_SET_SCREEN_BRIGHTNESS: return xmb->textures.list[XMB_TEXTURE_BRIGHTNESS]; -#endif case MENU_SETTING_GROUP: return xmb->textures.list[XMB_TEXTURE_SETTING]; case MENU_INFO_MESSAGE: @@ -6845,9 +6843,6 @@ static int xmb_list_push(void *data, void *userdata, #ifdef HAVE_LAKKA_SWITCH entry.enum_idx = MENU_ENUM_LABEL_SWITCH_GPU_PROFILE; menu_displaylist_setting(&entry); - - entry.enum_idx = MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL; - menu_displaylist_setting(&entry); #endif if (menu_show_configurations && !kiosk_mode_enable) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 760ba644d9..49ab3b0c17 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5702,6 +5702,10 @@ unsigned menu_displaylist_build_list( PARSE_ONLY_BOOL, false) == 0) count++; + if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, + MENU_ENUM_LABEL_BRIGHTNESS_CONTROL, + PARSE_ONLY_UINT, false) == 0) + count++; if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, MENU_ENUM_LABEL_VIDEO_THREADED, PARSE_ONLY_BOOL, false) == 0) @@ -9713,29 +9717,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, info->need_refresh = true; info->need_clear = true; - break; - } - case DISPLAYLIST_SWITCH_BACKLIGHT_CONTROL: - { - unsigned i; - const size_t brightness_count = sizeof(SWITCH_BRIGHTNESS)/sizeof(SWITCH_BRIGHTNESS[1]); - - menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); - - for (i = 0; i < brightness_count; i++) - { - char title[PATH_MAX_LENGTH] = {0}; - - snprintf(title, sizeof(title), "Set to %d%%", SWITCH_BRIGHTNESS[i]); - - if (menu_entries_append_enum(info->list, title, "", 0, MENU_SET_SWITCH_BRIGHTNESS, 0, i)) - count++; - } - - info->need_push = true; - info->need_refresh = true; - info->need_clear = true; - break; } #endif /* HAVE_LAKKA_SWITCH */ @@ -11686,11 +11667,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, PARSE_ACTION, false) == 0) count++; - if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(info->list, - MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL, - PARSE_ACTION, false) == 0) - count++; - if (settings->bools.menu_show_reboot) if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(info->list, MENU_ENUM_LABEL_REBOOT, diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index c28dd490ae..f85f9ebb81 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -234,7 +234,6 @@ enum menu_displaylist_ctl_state DISPLAYLIST_CORE_CONTENT_DIRS_SUBDIR, #ifdef HAVE_LAKKA_SWITCH DISPLAYLIST_SWITCH_GPU_PROFILE, - DISPLAYLIST_SWITCH_BACKLIGHT_CONTROL, #endif #if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) DISPLAYLIST_SWITCH_CPU_PROFILE, diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 33565daa05..75778db540 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -194,9 +194,10 @@ enum menu_settings_type MENU_SETTINGS_SUBSYSTEM_LAST = MENU_SETTINGS_SUBSYSTEM_ADD + RARCH_MAX_SUBSYSTEMS, MENU_SETTINGS_CHEAT_MATCH, + MENU_SET_SCREEN_BRIGHTNESS, + #ifdef HAVE_LAKKA_SWITCH MENU_SET_SWITCH_GPU_PROFILE, - MENU_SET_SWITCH_BRIGHTNESS, #endif #if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) MENU_SET_SWITCH_CPU_PROFILE, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 1233bb34de..b4cfc36e15 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2947,6 +2947,15 @@ static void setting_get_string_representation_state_slot(rarch_setting_t *settin strlcat(s, " (Auto)", len); } +static void setting_get_string_representation_percentage(rarch_setting_t *setting, + char *s, size_t len) +{ + if (!setting) + return; + + snprintf(s, len, "%d%%", *setting->value.target.integer); +} + static void setting_get_string_representation_float_video_msg_color(rarch_setting_t *setting, char *s, size_t len) { @@ -7477,6 +7486,12 @@ static void general_write_handler(rarch_setting_t *setting) } } break; + case MENU_ENUM_LABEL_BRIGHTNESS_CONTROL: + { + frontend_driver_set_screen_brightness( + *setting->value.target.unsigned_integer); + } + break; default: break; } @@ -8402,14 +8417,6 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); - - CONFIG_ACTION( - list, list_info, - MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL, - MENU_ENUM_LABEL_VALUE_SWITCH_BACKLIGHT_CONTROL, - &group_info, - &subgroup_info, - parent_group); #endif #ifdef HAVE_LAKKA_SWITCH CONFIG_ACTION( @@ -10911,6 +10918,26 @@ static bool setting_append_list( &subgroup_info, parent_group); + if (frontend_driver_can_set_screen_brightness()) + { + CONFIG_UINT( + list, list_info, + &settings->uints.screen_brightness, + MENU_ENUM_LABEL_BRIGHTNESS_CONTROL, + MENU_ENUM_LABEL_VALUE_BRIGHTNESS_CONTROL, + DEFAULT_SCREEN_BRIGHTNESS, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + (*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_COMBOBOX; + (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint_special; + (*list)[list_info->index - 1].get_string_representation = + &setting_get_string_representation_percentage; + menu_settings_list_current_add_range(list, list_info, 5, 100, 5, true, true); + } + #if defined(HAVE_THREADS) CONFIG_BOOL( list, list_info, diff --git a/msg_hash.h b/msg_hash.h index 7c9264255b..09293979b5 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -965,6 +965,7 @@ enum msg_hash_enums #endif /* Video */ + MENU_LABEL(BRIGHTNESS_CONTROL), MENU_LABEL(CRT_SWITCH_RESOLUTION), MENU_LABEL(CRT_SWITCH_RESOLUTION_SUPER), MENU_LABEL(CRT_SWITCH_RESOLUTION_OUTPUT_DISPLAY_ID), @@ -2950,7 +2951,6 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, MENU_LABEL(SWITCH_GPU_PROFILE), - MENU_LABEL(SWITCH_BACKLIGHT_CONTROL), MENU_LABEL(SWITCH_CPU_PROFILE), MENU_ENUM_LABEL_VALUE_HOLD_START, diff --git a/retroarch.c b/retroarch.c index 10a0261098..3baff275a7 100644 --- a/retroarch.c +++ b/retroarch.c @@ -38644,6 +38644,21 @@ void frontend_driver_attach_console(void) frontend->attach_console(); } +void frontend_driver_set_screen_brightness(int value) +{ + struct rarch_state *p_rarch = &rarch_st; + frontend_ctx_driver_t *frontend = p_rarch->current_frontend_ctx; + if (frontend && frontend->set_screen_brightness) + frontend->set_screen_brightness(value); +} + +bool frontend_driver_can_set_screen_brightness() +{ + struct rarch_state *p_rarch = &rarch_st; + frontend_ctx_driver_t *frontend = p_rarch->current_frontend_ctx; + return (frontend && frontend->set_screen_brightness); +} + void frontend_driver_detach_console(void) { struct rarch_state *p_rarch = &rarch_st; diff --git a/switch_performance_profiles.h b/switch_performance_profiles.h index 2ee1fd9dc2..5d07ba6ed5 100644 --- a/switch_performance_profiles.h +++ b/switch_performance_profiles.h @@ -48,18 +48,6 @@ static char *SWITCH_GPU_SPEEDS[] = { "153 Mhz", "76 Mhz" }; - -static int SWITCH_BRIGHTNESS[] = { - 10, - 20, - 30, - 40, - 50, - 60, - 70, - 80, - 90, - 100}; #endif static char *SWITCH_CPU_PROFILES[] = {