From 26fd4b58944ac4754c43d6a867f8739568d978a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Ram=C3=B3n=20Troncoso?= Date: Sat, 6 Aug 2016 21:31:52 +0200 Subject: [PATCH] Changed command-line arguments to keep backwards compatibility. Changed check on arguments to force the usage of mode when color preset is changed (original behavior). Updated README --- README | 18 +++++++++--------- main.cpp | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README b/README index 7e6e3dd..301a07d 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -This program can change the colors on your MSI steelseries keyboard. The keyboards have 3 regions that can have different colors for each one. +This program can change the colors on your MSI steelseries keyboard. Depending on the model, the keyboards have 3 or 7 regions that can have different colors for each one. Prerequisites (tested on Ubuntu 14.04 only): @@ -22,11 +22,12 @@ Options: -h, --help Displays this help. -v, --version Displays version information. -m, --mode set color : normal, gaming, breathe, demo, wave - -c, --color set a using the format: region,red,green,blue - with rgb values between 0 and 255 - -p, --preset set a color using the format: - region,color,intensity (only valid for - left/middle/right regions) + -r, --rgb set an color using the format: + region,red,green,blue with rgb values between 0 and 255 + -c, --color set a preset using the format: + region,color,intensity (only valid for left/middle/right + regions). When using this option, a mode must be + specified with -m Available regions: @@ -59,8 +60,7 @@ light Example: -./msi-keyboard -m normal -p left,red,high -p middle,purple,high -p right,sky,high -c touchpad,255,0,0 - +./msi-keyboard -m normal -c left,red,high -c middle,purple,high -c right,sky,high -r touchpad,255,0,0 -r logo,255,255,255 Licensing: @@ -72,4 +72,4 @@ Copyright (c) 2013 | Steve Lacy slacy.me | Fractal wearefractal.com contact@wear Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +$The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/main.cpp b/main.cpp index eb47962..8c0d1f4 100644 --- a/main.cpp +++ b/main.cpp @@ -154,8 +154,8 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, KeyboardOpti QCommandLineOption versionOption = parser.addVersionOption(); QCommandLineOption mode(QStringList() << "m" << "mode", "set color : normal, gaming, breathe, demo, wave", "mode"); - QCommandLineOption color(QStringList() << "c" << "color", "set a using the format: region,red,green,blue with rgb values between 0 and 255", "color"); - QCommandLineOption colorPreset(QStringList() << "p" << "preset", "set a color using the format: region,color,intensity (only valid for left/middle/right regions)", "preset"); + QCommandLineOption color(QStringList() << "r" << "rgb", "set an color using the format: region,red,green,blue with rgb values between 0 and 255", "rgb"); + QCommandLineOption colorPreset(QStringList() << "c" << "color", "set a preset using the format: region,color,intensity (only valid for left/middle/right regions). When using this option, a mode must be specified with -m", "color"); parser.addOption(mode); parser.addOption(color); @@ -237,7 +237,7 @@ Available preset intensities (only for left/middle/right regions): Example: %4 -)").arg(regions.join('\n')).arg(colors.join('\n')).arg(intensities.join('\n')).arg(QString(argv[0]) + " -m normal -p left,red,high -p middle,purple,high -p right,sky,high -c touchpad,255,0,0"); +)").arg(regions.join('\n')).arg(colors.join('\n')).arg(intensities.join('\n')).arg(QString(argv[0]) + " -m normal -c left,red,high -c middle,purple,high -c right,sky,high -r touchpad,255,0,0 -r logo,255,255,255"); std::cout << qPrintable(colorHelp) << std::endl; @@ -245,8 +245,8 @@ Example: } } - if(!keyboardOptions.modeSet && !keyboardOptions.colorSet && !keyboardOptions.presetSet) { - std::cerr << "Please set a mode or at least one color region to change." << std::endl; + if((!keyboardOptions.modeSet || !keyboardOptions.presetSet) && !keyboardOptions.colorSet ) { + std::cerr << "Please set either a mode together with at least one region to change a color preset, or a color region to change rgb color." << std::endl; return 1; }else{ Keyboard k;