|
@@ -23,6 +23,46 @@ void light_defaultConfig()
|
23
|
23
|
light_verbosity = 0;
|
24
|
24
|
}
|
25
|
25
|
|
|
26
|
+LIGHT_BOOL light_checkOperations()
|
|
27
|
+{
|
|
28
|
+ LIGHT_BOOL valid = TRUE;
|
|
29
|
+ LIGHT_OP_MODE op = light_Configuration.operationMode;
|
|
30
|
+
|
|
31
|
+ /* Nothing to check if we just print info */
|
|
32
|
+ if(op == LIGHT_PRINT_HELP || op == LIGHT_PRINT_VERSION || op == LIGHT_LIST_CTRL)
|
|
33
|
+ {
|
|
34
|
+ return TRUE;
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ switch (light_Configuration.field) {
|
|
38
|
+ case LIGHT_BRIGHTNESS:
|
|
39
|
+ if(op != LIGHT_GET && op != LIGHT_SET &&
|
|
40
|
+ op != LIGHT_ADD && op != LIGHT_SUB)
|
|
41
|
+ {
|
|
42
|
+ valid = FALSE;
|
|
43
|
+ fprintf(stderr, "Wrong operation specified for brightness. You can use only -G -S -A or -U\n\n");
|
|
44
|
+ }
|
|
45
|
+ break;
|
|
46
|
+ case LIGHT_MAX_BRIGHTNESS:
|
|
47
|
+ if(op != LIGHT_GET)
|
|
48
|
+ {
|
|
49
|
+ valid = FALSE;
|
|
50
|
+ fprintf(stderr, "Wrong operation specified for max brightness. You can only use -G\n\n");
|
|
51
|
+ }
|
|
52
|
+ break;
|
|
53
|
+ case LIGHT_MIN_CAP:
|
|
54
|
+ if(op != LIGHT_GET && op != LIGHT_SET)
|
|
55
|
+ {
|
|
56
|
+ valid = FALSE;
|
|
57
|
+ fprintf(stderr, "Wrong operation specified for min cap. You can only use -G or -S\n\n");
|
|
58
|
+ }
|
|
59
|
+ default:
|
|
60
|
+ break;
|
|
61
|
+ }
|
|
62
|
+ return valid;
|
|
63
|
+}
|
|
64
|
+
|
|
65
|
+
|
26
|
66
|
LIGHT_BOOL light_parseArguments(int argc, char** argv)
|
27
|
67
|
{
|
28
|
68
|
int currFlag;
|
|
@@ -162,6 +202,12 @@ LIGHT_BOOL light_parseArguments(int argc, char** argv)
|
162
|
202
|
}
|
163
|
203
|
}
|
164
|
204
|
|
|
205
|
+ if(!light_checkOperations())
|
|
206
|
+ {
|
|
207
|
+ light_printHelp();
|
|
208
|
+ return FALSE;
|
|
209
|
+ }
|
|
210
|
+
|
165
|
211
|
/* If we need a <value> (for writing), make sure we have it! */
|
166
|
212
|
if(light_Configuration.operationMode == LIGHT_SET ||
|
167
|
213
|
light_Configuration.operationMode == LIGHT_ADD ||
|
|
@@ -449,12 +495,6 @@ LIGHT_BOOL light_execute()
|
449
|
495
|
writeVal = valueMode == LIGHT_RAW ?
|
450
|
496
|
LIGHT_CLAMP( light_Configuration.specifiedValueRaw, 0, rawMax ) :
|
451
|
497
|
LIGHT_CLAMP(((unsigned long) (light_Configuration.specifiedValuePercent * ((double)rawMax) ) / 100), 0, rawMax);
|
452
|
|
- /* If we are not attempting to set, fail! */
|
453
|
|
- if(light_Configuration.operationMode != LIGHT_SET)
|
454
|
|
- {
|
455
|
|
- fprintf(stderr, "Minimum cap can only be used with get/set operations.\n");
|
456
|
|
- return FALSE;
|
457
|
|
- }
|
458
|
498
|
|
459
|
499
|
if(!light_setMinCap(light_Configuration.specifiedController, writeVal))
|
460
|
500
|
{
|