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