diff --git a/include/arm11/atp.h b/include/arm11/atp.h index 27caa2b..ce53093 100644 --- a/include/arm11/atp.h +++ b/include/arm11/atp.h @@ -73,6 +73,7 @@ typedef atp_error_t (*atp_itemprovider_t)( typedef atp_pageopt_t (*atp_keyhandler_t)( INPUT(atp_callerdata_t) some_data_provided_by_caller, + INPUT(atp_counter_t) index_of_selected_item, INPUT(atp_boolean_t) is_x_key_down, INPUT(atp_boolean_t) is_y_key_down, INPUT(atp_boolean_t) is_l_key_down, diff --git a/source/arm11/atp.c b/source/arm11/atp.c index 346a3b9..2502e4b 100644 --- a/source/arm11/atp.c +++ b/source/arm11/atp.c @@ -294,7 +294,7 @@ atp_error_t atp_select( atp_text_t title, atp_counter_t cnt, atp_itemprovider_t { if( handler == NULL ) continue; - atp_pageopt_t opt = handler( data, key&KEY_X, key&KEY_Y, key&KEY_L, key&KEY_R, key&KEY_START, key&KEY_SELECT ); + atp_pageopt_t opt = handler( data, item_sel, key&KEY_X, key&KEY_Y, key&KEY_L, key&KEY_R, key&KEY_START, key&KEY_SELECT ); switch( opt ) { case ATP_PAGE_REFRESH: diff --git a/source/arm11/filebrowser.c b/source/arm11/filebrowser.c index 876d775..992d09b 100644 --- a/source/arm11/filebrowser.c +++ b/source/arm11/filebrowser.c @@ -195,7 +195,7 @@ static void help_page( atp_text_t *wording, atp_counter_t length ) extern void oaf_config_page(); -static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_boolean_t x, atp_boolean_t y, atp_boolean_t l, atp_boolean_t r, atp_boolean_t start, atp_boolean_t select ) +static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t, atp_boolean_t x, atp_boolean_t y, atp_boolean_t l, atp_boolean_t r, atp_boolean_t start, atp_boolean_t select ) { if( start ) { diff --git a/source/arm11/open_agb_firm.c b/source/arm11/open_agb_firm.c index 5c16e9e..ffaf1d1 100644 --- a/source/arm11/open_agb_firm.c +++ b/source/arm11/open_agb_firm.c @@ -119,15 +119,20 @@ static KHandle g_frameReadyEvent = 0; // -------------------------- // code for oaf config page // -------------------------- +#define LIGHT_MIN (MCU_getSystemModel() > 3 ? 16 : 20) +#define LIGHT_MAX (MCU_getSystemModel() > 3 ? 142 : 117) static atp_error_t config_item( atp_callerdata_t data, atp_counter_t index, atp_itemcfg_t *cfg ) { const char *scaler_val[] = {"上屏无缩放", "上屏GPU放大", "上屏DMA放大", "下屏无缩放"}; static char buf[16]; + cfg->extra_text_color = ATP_COLOR_GREEN; if( index == 0 ) { ee_snprintf(buf, sizeof(buf), "%d", g_oafConfig.backlight); cfg->text = "屏幕亮度"; cfg->extra_text = buf; + if( g_oafConfig.backlight == LIGHT_MIN || g_oafConfig == LIGHT_MAX ) + cfg->extra_text_color = ATP_COLOR_RED; } else if( index == 1 ) { @@ -145,13 +150,34 @@ static atp_error_t config_item( atp_callerdata_t data, atp_counter_t index, atp_ cfg->extra_text = g_oafConfig.saveOverride ? "禁用" : "启用"; } cfg->value = index; - cfg->extra_text_color = ATP_COLOR_GREEN; return ATP_SUCCESS; } +static atp_pageopt_t config_adjust( atp_callerdata_t data, atp_counter_t index, atp_boolean_t x, atp_boolean_t y, atp_boolean_t l, atp_boolean_t r, atp_boolean_t start, atp_boolean_t select ) +{ + if( index == 0 ) + { + u8 light = g_oafConfig.brightness; + if( l ) + { + light -= 10; + if( light % 10 ) light = light + (10-light%10); + } + else if( r ) + { + light += 10; + if( light % 10 ) light = light - light % 10; + } + if( light > LIGHT_MAX ) light = LIGHT_MAX; + else if( light < LIGHT_MIN ) light = LIGHT_MIN; + g_oafConfig.brightness = light; + } + return ATP_PAGE_UPDATE; +} + void oaf_config_page() { - atp_select( "参数配置", 4, config_item, NULL, NULL, 0, 0, NULL ); + atp_select( "参数配置", 4, config_item, config_adjust, NULL, 0, 0, NULL ); } static u32 fixRomPadding(u32 romFileSize)