Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions workspace/all/common/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,7 @@ int GFX_blitHardwareIndicator(SDL_Surface *dst, int x, int y, IndicatorType indi
int setting_min;
int setting_max;
int asset;
bool readonly = false;

int ow = SCALE1(PILL_SIZE + SETTINGS_WIDTH + 10 + 4);
int ox = x;
Expand All @@ -1898,13 +1899,15 @@ int GFX_blitHardwareIndicator(SDL_Surface *dst, int x, int y, IndicatorType indi
setting_min = BRIGHTNESS_MIN;
setting_max = BRIGHTNESS_MAX;
asset = ASSET_BRIGHTNESS;
readonly = GetMute() && GetMutedBrightness() != SETTINGS_DEFAULT_MUTE_NO_CHANGE;
}
else if (indicator_type == INDICATOR_COLORTEMP)
{
setting_value = GetColortemp();
setting_min = COLORTEMP_MIN;
setting_max = COLORTEMP_MAX;
asset = ASSET_COLORTEMP;
readonly = GetMute() && GetMutedColortemp() != SETTINGS_DEFAULT_MUTE_NO_CHANGE;
}
else // INDICATOR_VOLUME
{
Expand All @@ -1915,8 +1918,9 @@ int GFX_blitHardwareIndicator(SDL_Surface *dst, int x, int y, IndicatorType indi
asset = (setting_value > 0 ? ASSET_BLUETOOTH : ASSET_BLUETOOTH_OFF);
else
asset = (setting_value > 0 ? ASSET_VOLUME : ASSET_VOLUME_MUTE);
readonly = GetMute() && GetMutedVolume() != SETTINGS_DEFAULT_MUTE_NO_CHANGE;
}

// Draw the icon
SDL_Rect asset_rect;
GFX_assetRect(asset, &asset_rect);
Expand All @@ -1930,11 +1934,23 @@ int GFX_blitHardwareIndicator(SDL_Surface *dst, int x, int y, IndicatorType indi
GFX_blitPillColor(gfx.mode == MODE_MAIN ? ASSET_BAR_BG : ASSET_BAR_BG_MENU, dst,
&(SDL_Rect){ox, bar_y, SCALE1(SETTINGS_WIDTH), SCALE1(SETTINGS_SIZE)}, THEME_COLOR3, RGB_WHITE);

// Draw the progress bar fill
float percent = ((float)(setting_value - setting_min) / (setting_max - setting_min));
if (indicator_type == 1 || indicator_type == 3 || setting_value > 0)
// Draw the lock icon centered over the bar if the setting is read-only
if (readonly)
{
GFX_blitPillDark(ASSET_BAR, dst, &(SDL_Rect){ox, bar_y, SCALE1(SETTINGS_WIDTH) * percent, SCALE1(SETTINGS_SIZE)});
SDL_Rect lock_rect;
GFX_assetRect(ASSET_LOCK, &lock_rect);
int lx = ox + (SCALE1(SETTINGS_WIDTH) - lock_rect.w) / 2;
int ly = bar_y + (SCALE1(SETTINGS_SIZE) - lock_rect.h) / 2;
GFX_blitAssetColor(ASSET_LOCK, NULL, dst, &(SDL_Rect){lx, ly}, THEME_COLOR6_255);
}
else {
// Draw the progress bar fill
float percent = ((float)(setting_value - setting_min) / (setting_max - setting_min));
if (indicator_type == 1 || indicator_type == 3 || setting_value > 0)
{
if(!readonly)
GFX_blitPillDark(ASSET_BAR, dst, &(SDL_Rect){ox, bar_y, SCALE1(SETTINGS_WIDTH) * percent, SCALE1(SETTINGS_SIZE)});
}
}

return ow;
Expand Down
190 changes: 90 additions & 100 deletions workspace/tg5040/libmsettings/msettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,15 @@ static inline void SaveSettings(void) {
///////// Getters exposed in public API

int GetBrightness(void) { // 0-10
if (settings->mute && GetMutedBrightness() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return GetMutedBrightness();

return settings->brightness;
}
int GetColortemp(void) { // 0-10
if (settings->mute && GetMutedColortemp() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return GetMutedColortemp();

return settings->colortemperature;
}
int GetVolume(void) { // 0-20
Expand All @@ -514,6 +520,27 @@ int GetVolume(void) { // 0-20

return settings->speaker;
}
int GetContrast(void)
{
if (settings->mute && GetMutedContrast() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return GetMutedContrast();

return settings->contrast;
}
int GetSaturation(void)
{
if (settings->mute && GetMutedSaturation() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return GetMutedSaturation();

return settings->saturation;
}
int GetExposure(void)
{
if (settings->mute && GetMutedExposure() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return GetMutedExposure();

return settings->exposure;
}
// monitored and set by thread in keymon
int GetJack(void) {
return settings->jack;
Expand All @@ -530,18 +557,6 @@ int GetHDMI(void) {
int GetMute(void) {
return settings->mute;
}
int GetContrast(void)
{
return settings->contrast;
}
int GetSaturation(void)
{
return settings->saturation;
}
int GetExposure(void)
{
return settings->exposure;
}
int GetMutedBrightness(void)
{
return settings->toggled_brightness;
Expand Down Expand Up @@ -610,25 +625,55 @@ int GetMuteTurboR2(void)
///////// Setters exposed in public API

void SetBrightness(int value) {
if (settings->mute && GetMutedBrightness() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return SetRawBrightness(scaleBrightness(GetMutedBrightness()));

SetRawBrightness(scaleBrightness(value));
settings->brightness = value;
SaveSettings();
}
void SetColortemp(int value) {
if (settings->mute && GetMutedColortemp() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return SetRawColortemp(scaleColortemp(GetMutedColortemp()));

SetRawColortemp(scaleColortemp(value));
settings->colortemperature = value;
SaveSettings();
}
void SetVolume(int value) { // 0-20
if (settings->mute)
void SetContrast(int value) {
if (settings->mute && GetMutedContrast() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return SetRawContrast(scaleContrast(GetMutedContrast()));

SetRawContrast(scaleContrast(value));
settings->contrast = value;
SaveSettings();
}
void SetSaturation(int value) {
if (settings->mute && GetMutedSaturation() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return SetRawSaturation(scaleSaturation(GetMutedSaturation()));

SetRawSaturation(scaleSaturation(value));
settings->saturation = value;
SaveSettings();
}
void SetExposure(int value){
if (settings->mute && GetMutedExposure() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return SetRawExposure(scaleExposure(GetMutedExposure()));

SetRawExposure(scaleExposure(value));
settings->exposure = value;
SaveSettings();
}
void SetVolume(int value) // 0-20
{
if (settings->mute && GetMutedVolume() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
return SetRawVolume(scaleVolume(GetMutedVolume()));

SetRawVolume(scaleVolume(value));
if (settings->jack || settings->audiosink != AUDIO_SINK_DEFAULT)
settings->headphones = value;
else
settings->speaker = value;

SetRawVolume(scaleVolume(value));
SaveSettings();
}
// monitored and set by thread in keymon
Expand All @@ -650,89 +695,34 @@ void SetHDMI(int value){};

void SetMute(int value) {
settings->mute = value;
if (settings->mute) {
if (GetMutedVolume() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
SetRawVolume(scaleVolume(GetMutedVolume()));
// custom mute mode display settings
if(GetMutedBrightness() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
SetRawBrightness(scaleBrightness(GetMutedBrightness()));
if(GetMutedColortemp() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
SetRawColortemp(scaleColortemp(GetMutedColortemp()));
if(GetMutedContrast() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
SetRawContrast(scaleContrast(GetMutedContrast()));
if(GetMutedSaturation() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
SetRawSaturation(scaleSaturation(GetMutedSaturation()));
if(GetMutedExposure() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
SetRawExposure(scaleExposure(GetMutedExposure()));
if(is_brick && GetMuteDisablesDpad())
disableDpad(1);
if(is_brick && GetMuteEmulatesJoystick())
emulateJoystick(1);
if(GetMuteTurboA())
turboA(1);
if(GetMuteTurboB())
turboB(1);
if(GetMuteTurboX())
turboX(1);
if(GetMuteTurboY())
turboY(1);
if(GetMuteTurboL1())
turboL1(1);
if(GetMuteTurboL2())
turboL2(1);
if(GetMuteTurboR1())
turboR1(1);
if(GetMuteTurboR2())
turboR2(1);
}
else {
SetVolume(GetVolume());
SetBrightness(GetBrightness());
SetColortemp(GetColortemp());
SetContrast(GetContrast());
SetSaturation(GetSaturation());
SetExposure(GetExposure());
if(is_brick) {
if(GetMuteDisablesDpad())
disableDpad(0);
if(GetMuteEmulatesJoystick())
emulateJoystick(0);
}
if(GetMuteTurboA())
turboA(0);
if(GetMuteTurboB())
turboB(0);
if(GetMuteTurboX())
turboX(0);
if(GetMuteTurboY())
turboY(0);
if(GetMuteTurboL1())
turboL1(0);
if(GetMuteTurboL2())
turboL2(0);
if(GetMuteTurboR1())
turboR1(0);
if(GetMuteTurboR2())
turboR2(0);
}
}
void SetContrast(int value)
{
SetRawContrast(scaleContrast(value));
settings->contrast = value;
SaveSettings();
}
void SetSaturation(int value)
{
SetRawSaturation(scaleSaturation(value));
settings->saturation = value;
SaveSettings();
}
void SetExposure(int value)
{
SetRawExposure(scaleExposure(value));
settings->exposure = value;
SaveSettings();

SetVolume(GetVolume());
SetBrightness(GetBrightness());
SetColortemp(GetColortemp());
SetContrast(GetContrast());
SetSaturation(GetSaturation());
SetExposure(GetExposure());

if(is_brick && GetMuteDisablesDpad())
disableDpad(settings->mute);
if(is_brick && GetMuteEmulatesJoystick())
emulateJoystick(settings->mute);
if(GetMuteTurboA())
turboA(settings->mute);
if(GetMuteTurboB())
turboB(settings->mute);
if(GetMuteTurboX())
turboX(settings->mute);
if(GetMuteTurboY())
turboY(settings->mute);
if(GetMuteTurboL1())
turboL1(settings->mute);
if(GetMuteTurboL2())
turboL2(settings->mute);
if(GetMuteTurboR1())
turboR1(settings->mute);
if(GetMuteTurboR2())
turboR2(settings->mute);
}

void SetMutedBrightness(int value)
Expand Down Expand Up @@ -1145,7 +1135,7 @@ static int get_a2dp_simple_control_name(char *buf, size_t buflen) {
}

void SetRawVolume(int val) { // in: 0-100
if (settings->mute)
if (settings->mute && GetMutedVolume() != SETTINGS_DEFAULT_MUTE_NO_CHANGE)
val = scaleVolume(GetMutedVolume());

if (GetAudioSink() == AUDIO_SINK_BLUETOOTH) {
Expand Down
Loading
Loading