mirror of
https://github.com/MatMoul/g810-led.git
synced 2024-12-23 09:16:11 +00:00
Clean code
This commit is contained in:
parent
3596a85315
commit
c8a579a8f2
267
src/main.cpp
267
src/main.cpp
@ -2,144 +2,149 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include "classes/Keyboard.h"
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include "classes/Keyboard.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
string appname = "g810-led";
|
||||||
|
|
||||||
void usage() {
|
void usage() {
|
||||||
string appname = "g810-led";
|
cout<<appname<<" Usages :"<<endl;
|
||||||
cout<<appname<<" Usages :\n";
|
cout<<"-----------------"<<endl;
|
||||||
cout<<"-----------------\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<" -s effect :\t\t\tSet keyboard startup effect"<<endl;
|
||||||
cout<<" -s effect :\t\t\tSet keyboard startup effect\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<" -a color :\t\t\tSet all keys"<<endl;
|
||||||
cout<<" -a color :\t\t\tSet all keys\n";
|
cout<<" -g group, color :\t\tSet a group of keys"<<endl;
|
||||||
cout<<" -g group, color :\t\tSet a group of keys\n";
|
cout<<" -k key, color :\t\tSet a key"<<endl;
|
||||||
cout<<" -k key, color :\t\tSet a key\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<" -an color :\t\t\tSet all keys without commit"<<endl;
|
||||||
cout<<" -an color :\t\t\tSet all keys without commit\n";
|
cout<<" -gn group, color :\t\tSet a group of keys without commit"<<endl;
|
||||||
cout<<" -gn group, color :\t\tSet a group of keys without commit\n";
|
cout<<" -kn key, color :\t\tSet a key without commit"<<endl;
|
||||||
cout<<" -kn key, color :\t\tSet a key without commit\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<" -c :\t\t\t\tCommit changes"<<endl;
|
||||||
cout<<" -c :\t\t\t\tCommit changes\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<" -fx-color color :\t\tSet static color effect"<<endl;
|
||||||
cout<<" -fx-color color :\t\tSet static color effect\n";
|
cout<<" -fx-breathing color, speed :\tSet breathing effect"<<endl;
|
||||||
cout<<" -fx-breathing color, speed :\tSet breathing effect\n";
|
cout<<" -fx-cycle speed :\t\tSet color cycle effect"<<endl;
|
||||||
cout<<" -fx-cycle speed :\t\tSet color cycle effect\n";
|
cout<<" -fx-hwave speed :\t\tSet horizontal color wave effect"<<endl;
|
||||||
cout<<" -fx-hwave speed :\t\tSet horizontal color wave effect\n";
|
cout<<" -fx-vwave speed :\t\tSet vertical color wave effect"<<endl;
|
||||||
cout<<" -fx-vwave speed :\t\tSet vertical color wave effect\n";
|
cout<<" -fx-cwave speed :\t\tSet center color wave effect"<<endl;
|
||||||
cout<<" -fx-cwave speed :\t\tSet center color wave effect\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<" -p profilefile :\t\tLoad a profile from a file"<<endl;
|
||||||
cout<<" -p profilefile :\t\tLoad a profile from a file\n";
|
cout<<" -pp profilepipe :\t\tLoad a profile from stdin"<<endl;
|
||||||
cout<<" -pp profilepipe :\t\tLoad a profile from stdin\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<" -h | --help :\t\t\tthis help message"<<endl;
|
||||||
cout<<" -h | --help :\t\t\tthis help message\n";
|
cout<<" -lk | --list-keys :\t\tList keys in groups"<<endl;
|
||||||
cout<<" -lk | --list-keys :\t\tList keys in groups\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"color formats :\t\t\tRRGGBB (hex value for red, green and blue)"<<endl;
|
||||||
cout<<"color formats :\t\t\tRRGGBB (hex value for red, green and blue)\n";
|
cout<<"speed formats :\t\t\tSS (hex value for speed)"<<endl;
|
||||||
cout<<"speed formats :\t\t\tSS (hex value for speed)\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"effect values :\t\t\trainbow, color"<<endl;
|
||||||
cout<<"effect values :\t\t\trainbow, color\n";
|
cout<<"key values :\t\t\tabc... 123... and other (use -lk for more detail)"<<endl;
|
||||||
cout<<"key values :\t\t\tabc... 123... and other\n";
|
cout<<"group values :\t\t\tlogo, indicators, fkeys, modifiers, multimedia, arrows, numeric, functions, keys, gkeys"<<endl;
|
||||||
cout<<"group values :\t\t\tlogo, indicators, fkeys, modifiers, multimedia, arrows, numeric, functions, keys, gkeys\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"samples :"<<endl;
|
||||||
cout<<"sample :\n";
|
cout<<appname<<" -k logo ff0000"<<endl;
|
||||||
cout<<appname<<" -k logo ff0000\n";
|
cout<<appname<<" -a 00ff00"<<endl;
|
||||||
cout<<appname<<" -a 00ff00\n";
|
cout<<appname<<" -g fkeys ff00ff"<<endl;
|
||||||
cout<<appname<<" -g fkeys ff00ff\n";
|
cout<<appname<<" -s color"<<endl;
|
||||||
cout<<appname<<" -s color\n";
|
cout<<appname<<" -fx-cycle 10"<<endl;
|
||||||
cout<<appname<<" -fx-cycle 10\n";
|
cout<<appname<<" -p profilefile"<<endl;
|
||||||
|
cout<<""<<endl;
|
||||||
|
cout<<"samples with pipe:"<<endl;
|
||||||
|
cout<<appname<<" -pp < profilefile"<<endl;
|
||||||
|
cout<<"echo -e \"k w ff0000\\nk a ff0000\\nk s ff0000\\nk d ff0000\\nc\" | "<<appname<<" -pp"<<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void listkeys() {
|
void listkeys() {
|
||||||
string appname = "g810-led";
|
cout<<appname<<" Keys in groups :"<<endl;
|
||||||
cout<<appname<<" Keys in groups :\n";
|
cout<<"-------------------------"<<endl;
|
||||||
cout<<"-------------------------\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"Group logo :"<<endl;
|
||||||
cout<<"Group logo :\n";
|
cout<<" logo"<<endl;
|
||||||
cout<<" logo\n";
|
cout<<" logo2"<<endl;
|
||||||
cout<<" logo2\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"Group indicators :"<<endl;
|
||||||
cout<<"Group indicators :\n";
|
cout<<" num_indicator, numindicator, num"<<endl;
|
||||||
cout<<" num_indicator, numindicator, num\n";
|
cout<<" caps_indicator, capsindicator, caps"<<endl;
|
||||||
cout<<" caps_indicator, capsindicator, caps\n";
|
cout<<" scroll_indicator, scrollindicator, scroll"<<endl;
|
||||||
cout<<" scroll_indicator, scrollindicator, scroll\n";
|
cout<<" game_mode, gamemode, game"<<endl;
|
||||||
cout<<" game_mode, gamemode, game\n";
|
cout<<" back_light, backlight, light"<<endl;
|
||||||
cout<<" back_light, backlight, light\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"Group fkeys :"<<endl;
|
||||||
cout<<"Group fkeys :\n";
|
cout<<" f1 - f12"<<endl;
|
||||||
cout<<" f1 - f12\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"Group modifiers :"<<endl;
|
||||||
cout<<"Group modifiers :\n";
|
cout<<" shift_left, shiftleft, shiftl"<<endl;
|
||||||
cout<<" shift_left, shiftleft, shiftl\n";
|
cout<<" ctrl_left, ctrlleft, ctrll"<<endl;
|
||||||
cout<<" ctrl_left, ctrlleft, ctrll\n";
|
cout<<" win_left, winleft, win_left"<<endl;
|
||||||
cout<<" win_left, winleft, win_left\n";
|
cout<<" alt_left, altleft, altl"<<endl;
|
||||||
cout<<" alt_left, altleft, altl\n";
|
cout<<" alt_right, altright, altr, altgr"<<endl;
|
||||||
cout<<" alt_right, altright, altr, altgr\n";
|
cout<<" win_right, winright, winr"<<endl;
|
||||||
cout<<" win_right, winright, winr\n";
|
cout<<" menu"<<endl;
|
||||||
cout<<" menu\n";
|
cout<<" ctrl_right, ctrlright, ctrlr"<<endl;
|
||||||
cout<<" ctrl_right, ctrlright, ctrlr\n";
|
cout<<" shift_right, shiftright, shiftr"<<endl;
|
||||||
cout<<" shift_right, shiftright, shiftr\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"Group multimedia :"<<endl;
|
||||||
cout<<"Group multimedia :\n";
|
cout<<" mute"<<endl;
|
||||||
cout<<" mute\n";
|
cout<<" play_pause, playpause, play"<<endl;
|
||||||
cout<<" play_pause, playpause, play\n";
|
cout<<" stop"<<endl;
|
||||||
cout<<" stop\n";
|
cout<<" previous, prev"<<endl;
|
||||||
cout<<" previous, prev\n";
|
cout<<" next"<<endl;
|
||||||
cout<<" next\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"Group arrows :"<<endl;
|
||||||
cout<<"Group arrows :\n";
|
cout<<" arrow_top, arrowtop, top"<<endl;
|
||||||
cout<<" arrow_top, arrowtop, top\n";
|
cout<<" arrow_left, arrowleft, left"<<endl;
|
||||||
cout<<" arrow_left, arrowleft, left\n";
|
cout<<" arrow_bottom, arrowbottom, bottom"<<endl;
|
||||||
cout<<" arrow_bottom, arrowbottom, bottom\n";
|
cout<<" arrow_right, arrowright, right"<<endl;
|
||||||
cout<<" arrow_right, arrowright, right\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"Group numeric :"<<endl;
|
||||||
cout<<"Group numeric :\n";
|
cout<<" num_lock, numlock"<<endl;
|
||||||
cout<<" num_lock, numlock\n";
|
cout<<" num_slash, numslash, num/"<<endl;
|
||||||
cout<<" num_slash, numslash, num/\n";
|
cout<<" num_asterisk, numasterisk, num*"<<endl;
|
||||||
cout<<" num_asterisk, numasterisk, num*\n";
|
cout<<" num_minus, numminus, num-"<<endl;
|
||||||
cout<<" num_minus, numminus, num-\n";
|
cout<<" num_plus, numplus, num+"<<endl;
|
||||||
cout<<" num_plus, numplus, num+\n";
|
cout<<" numenter"<<endl;
|
||||||
cout<<" numenter\n";
|
cout<<" num0 - num9"<<endl;
|
||||||
cout<<" num0 - num9\n";
|
cout<<" num_dot, numdot, num."<<endl;
|
||||||
cout<<" num_dot, numdot, num.\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"Group functions :"<<endl;
|
||||||
cout<<"Group functions :\n";
|
cout<<" escape, esc"<<endl;
|
||||||
cout<<" escape, esc\n";
|
cout<<" print_screen, printscreen, printscr"<<endl;
|
||||||
cout<<" print_screen, printscreen, printscr\n";
|
cout<<" scroll_lock, scrolllock"<<endl;
|
||||||
cout<<" scroll_lock, scrolllock\n";
|
cout<<" pause_break, pausebreak"<<endl;
|
||||||
cout<<" pause_break, pausebreak\n";
|
cout<<" insert, ins"<<endl;
|
||||||
cout<<" insert, ins\n";
|
cout<<" home"<<endl;
|
||||||
cout<<" home\n";
|
cout<<" page_up, pageup"<<endl;
|
||||||
cout<<" page_up, pageup\n";
|
cout<<" delete, del"<<endl;
|
||||||
cout<<" delete, del\n";
|
cout<<" end"<<endl;
|
||||||
cout<<" end\n";
|
cout<<" page_down, pagedown"<<endl;
|
||||||
cout<<" page_down, pagedown\n";
|
cout<<""<<endl;
|
||||||
cout<<"\n";
|
cout<<"Group keys :"<<endl;
|
||||||
cout<<"Group keys :\n";
|
cout<<" 0 - 9"<<endl;
|
||||||
cout<<" 0 - 9\n";
|
cout<<" a - z"<<endl;
|
||||||
cout<<" a - z\n";
|
cout<<" tab"<<endl;
|
||||||
cout<<" tab\n";
|
cout<<" caps_lock, capslock"<<endl;
|
||||||
cout<<" caps_lock, capslock\n";
|
cout<<" space"<<endl;
|
||||||
cout<<" space\n";
|
cout<<" backspace, back"<<endl;
|
||||||
cout<<" backspace, back\n";
|
cout<<" enter"<<endl;
|
||||||
cout<<" enter\n";
|
cout<<" tilde"<<endl;
|
||||||
cout<<" tilde\n";
|
cout<<" minus"<<endl;
|
||||||
cout<<" minus\n";
|
cout<<" equal"<<endl;
|
||||||
cout<<" equal\n";
|
cout<<" open_bracket"<<endl;
|
||||||
cout<<" open_bracket\n";
|
cout<<" close_bracket"<<endl;
|
||||||
cout<<" close_bracket\n";
|
cout<<" backslash"<<endl;
|
||||||
cout<<" backslash\n";
|
cout<<" semicolon"<<endl;
|
||||||
cout<<" semicolon\n";
|
cout<<" dollar"<<endl;
|
||||||
cout<<" dollar\n";
|
cout<<" quote"<<endl;
|
||||||
cout<<" quote\n";
|
cout<<" intl_backslash"<<endl;
|
||||||
cout<<" intl_backslash\n";
|
cout<<" comma"<<endl;
|
||||||
cout<<" comma\n";
|
cout<<" period"<<endl;
|
||||||
cout<<" period\n";
|
cout<<" slash"<<endl;
|
||||||
cout<<" slash\n";
|
cout<<"Group gkeys :"<<endl;
|
||||||
cout<<"Group gkeys :\n";
|
cout<<" g1 - g9"<<endl;
|
||||||
cout<<" g1 - g9\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int commit() {
|
int commit() {
|
||||||
@ -325,7 +330,6 @@ int setFXCWave(string speed) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseProfile(istream &is) {
|
int parseProfile(istream &is) {
|
||||||
@ -527,6 +531,7 @@ int main(int argc, char *argv[]) {
|
|||||||
string str = argv[0];
|
string str = argv[0];
|
||||||
size_t split = str.find_last_of("/\\");
|
size_t split = str.find_last_of("/\\");
|
||||||
str = str.substr(split + 1);
|
str = str.substr(split + 1);
|
||||||
|
appname = str;
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
string argCmd = argv[1];
|
string argCmd = argv[1];
|
||||||
if (argCmd == "-h" || argCmd == "--help") { usage(); return 0; }
|
if (argCmd == "-h" || argCmd == "--help") { usage(); return 0; }
|
||||||
|
Loading…
Reference in New Issue
Block a user