spacing. Use a separate boolean to tell if we have specified a new value for controls. This allows negative settings. Fix zmy outputting brightness when contrast is specified.

This commit is contained in:
Isaac Connor 2021-10-05 17:45:43 -04:00
parent ba26235763
commit 52129c94ec
1 changed files with 46 additions and 31 deletions

View File

@ -257,9 +257,16 @@ int main(int argc, char *argv[]) {
int image_idx = -1;
int scale = -1;
int brightness = -1;
bool have_brightness = false;
int contrast = -1;
bool have_contrast = false;
int hue = -1;
bool have_hue = false;
int colour = -1;
bool have_colour = false;
char *zoneString = nullptr;
char *username = nullptr;
char *password = nullptr;
@ -349,23 +356,31 @@ int main(int argc, char *argv[]) {
break;
case 'B':
function |= ZMU_BRIGHTNESS;
if ( optarg )
if (optarg) {
have_brightness = true;
brightness = atoi(optarg);
}
break;
case 'C':
function |= ZMU_CONTRAST;
if ( optarg )
if (optarg) {
have_contrast = true;
contrast = atoi(optarg);
}
break;
case 'H':
function |= ZMU_HUE;
if ( optarg )
if (optarg) {
have_hue = true;
hue = atoi(optarg);
}
break;
case 'O':
function |= ZMU_COLOUR;
if ( optarg )
if (optarg) {
have_colour = true;
colour = atoi(optarg);
}
break;
case 'U':
username = optarg;
@ -652,13 +667,13 @@ int main(int argc, char *argv[]) {
}
if (function & ZMU_BRIGHTNESS) {
if (verbose) {
if ( brightness >= 0 )
if (have_brightness)
printf("New brightness: %d\n", monitor->actionBrightness(brightness));
else
printf("Current brightness: %d\n", monitor->actionBrightness());
} else {
if (have_output) fputc(separator, stdout);
if ( brightness >= 0 )
if (have_brightness)
printf("%d", monitor->actionBrightness(brightness));
else
printf("%d", monitor->actionBrightness());
@ -667,13 +682,13 @@ int main(int argc, char *argv[]) {
}
if (function & ZMU_CONTRAST) {
if (verbose) {
if ( contrast >= 0 )
printf("New brightness: %d\n", monitor->actionContrast(contrast));
if (have_contrast)
printf("New contrast: %d\n", monitor->actionContrast(contrast));
else
printf("Current contrast: %d\n", monitor->actionContrast());
} else {
if (have_output) fputc(separator, stdout);
if ( contrast >= 0 )
if (have_contrast)
printf("%d", monitor->actionContrast(contrast));
else
printf("%d", monitor->actionContrast());
@ -682,13 +697,13 @@ int main(int argc, char *argv[]) {
}
if (function & ZMU_HUE) {
if (verbose) {
if ( hue >= 0 )
if (have_hue)
printf("New hue: %d\n", monitor->actionHue(hue));
else
printf("Current hue: %d\n", monitor->actionHue());
} else {
if (have_output) fputc(separator, stdout);
if ( hue >= 0 )
if (have_hue)
printf("%d", monitor->actionHue(hue));
else
printf("%d", monitor->actionHue());
@ -697,13 +712,13 @@ int main(int argc, char *argv[]) {
}
if (function & ZMU_COLOUR) {
if (verbose) {
if ( colour >= 0 )
if (have_colour)
printf("New colour: %d\n", monitor->actionColour(colour));
else
printf("Current colour: %d\n", monitor->actionColour());
} else {
if (have_output) fputc(separator, stdout);
if ( colour >= 0 )
if (have_colour)
printf("%d", monitor->actionColour(colour));
else
printf("%d", monitor->actionColour());