From 0a33131ce60d1a481bfb4e18f817c27ae70636c2 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 29 Oct 2016 15:20:41 +0200 Subject: [PATCH 1/7] Add -lk (list keys) help) --- src/main.cpp | 111 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 101 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 83f7d0f..3a927ef 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,6 +46,96 @@ void usage() { cout< 1) { string argCmd = argv[1]; - if (argCmd == "-h" || argCmd == "--help") { usage(); return 0; } - else if (argCmd == "-s" && argc == 3) return setStartupEffect(argv[2]); - else if (argCmd == "-a" && argc == 3) return setAllKeys(argv[2], true); - else if (argCmd == "-an" && argc == 3) return setAllKeys(argv[2], false); - else if (argCmd == "-g" && argc == 4) return setGroupKeys(argv[2], argv[3], true); - else if (argCmd == "-gn" && argc == 4) return setGroupKeys(argv[2], argv[3], false); - else if (argCmd == "-k" && argc == 4) return setKey(argv[2], argv[3], true); - else if (argCmd == "-kn" && argc == 4) return setKey(argv[2], argv[3], false); - else if (argCmd == "-c" && argc == 2) return commit(); - else if (argCmd == "-p" && argc == 3) return loadProfile(argv[2]); + if (argCmd == "-h" || argCmd == "--help") { usage(); return 0; } + else if (argCmd == "-lk" || argCmd == "--list-keys") { listkeys(); return 0; } + else if (argCmd == "-s" && argc == 3) return setStartupEffect(argv[2]); + else if (argCmd == "-a" && argc == 3) return setAllKeys(argv[2], true); + else if (argCmd == "-an" && argc == 3) return setAllKeys(argv[2], false); + else if (argCmd == "-g" && argc == 4) return setGroupKeys(argv[2], argv[3], true); + else if (argCmd == "-gn" && argc == 4) return setGroupKeys(argv[2], argv[3], false); + else if (argCmd == "-k" && argc == 4) return setKey(argv[2], argv[3], true); + else if (argCmd == "-kn" && argc == 4) return setKey(argv[2], argv[3], false); + else if (argCmd == "-c" && argc == 2) return commit(); + else if (argCmd == "-p" && argc == 3) return loadProfile(argv[2]); } usage(); return 1; From e66e6af5606573a4b1591e9ae69b07e34515b24c Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 29 Oct 2016 15:35:31 +0200 Subject: [PATCH 2/7] Add -lk (list keys) help) --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 3a927ef..d30f9a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,6 +32,7 @@ void usage() { cout<<" -p porfilefile :\tLoad a profile\n"; cout<<"\n"; cout<<" -h | --help :\t\tthis help message\n"; + cout<<" -lk | --list-keys :\t\tList keys in groups\n"; cout<<"\n"; cout<<"color formats :\t\tRRGGBB (hex value for red, green and blue)\n"; cout<<"\n"; From 0068071c0c632442391777d95edd9d12813f31ff Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 29 Oct 2016 15:36:14 +0200 Subject: [PATCH 3/7] Add -lk (list keys) help) --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d30f9a9..edec6d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,7 +32,7 @@ void usage() { cout<<" -p porfilefile :\tLoad a profile\n"; cout<<"\n"; cout<<" -h | --help :\t\tthis help message\n"; - cout<<" -lk | --list-keys :\t\tList keys in groups\n"; + cout<<" -lk | --list-keys :\tList keys in groups\n"; cout<<"\n"; cout<<"color formats :\t\tRRGGBB (hex value for red, green and blue)\n"; cout<<"\n"; From 76a8e09fe15fe3984837386774fcac28173361d4 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 29 Oct 2016 16:42:44 +0200 Subject: [PATCH 4/7] align key name to const name --- src/classes/Keyboard.cpp | 50 ++++++++++++++++++++++++++++++++++++---- src/classes/Keyboard.h | 8 ++++++- src/main.cpp | 15 ++++++++++++ 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/classes/Keyboard.cpp b/src/classes/Keyboard.cpp index 4c668bf..5ee7a14 100644 --- a/src/classes/Keyboard.cpp +++ b/src/classes/Keyboard.cpp @@ -155,6 +155,8 @@ bool Keyboard::getKeyAddress(Key key, KeyAddress &keyAddress) { case Key::backspace: keyAddress.id = 0x2a; break; case Key::tab: keyAddress.id = 0x2b; break; case Key::space: keyAddress.id = 0x2c; break; + + /* case Key::apostrophe: keyAddress.id = 0x2d; break; // * case Key::tilde: keyAddress.id = 0x2e; break; case Key::open_bracket: keyAddress.id = 0x2f; break; @@ -168,6 +170,21 @@ bool Keyboard::getKeyAddress(Key key, KeyAddress &keyAddress) { case Key::comma: keyAddress.id = 0x36; break; case Key::dot: keyAddress.id = 0x37; break; case Key::minus: keyAddress.id = 0x38; break; + */ + + case Key::minus: keyAddress.id = 0x2d; break; // * + case Key::equal: keyAddress.id = 0x2e; break; + case Key::open_bracket: keyAddress.id = 0x2f; break; + case Key::close_bracket: keyAddress.id = 0x30; break; + case Key::backslash: keyAddress.id = 0x31; break; // * + case Key::dollar: keyAddress.id = 0x32; break; // * + case Key::semicolon: keyAddress.id = 0x33; break; // * + case Key::quote: keyAddress.id = 0x34; break; // * + case Key::tilde: keyAddress.id = 0x35; break; // * + case Key::comma: keyAddress.id = 0x36; break; + case Key::period: keyAddress.id = 0x37; break; + case Key::slash: keyAddress.id = 0x38; break; + case Key::caps_lock: keyAddress.id = 0x39; break; case Key::f1: keyAddress.id = 0x3a; break; case Key::f2: keyAddress.id = 0x3b; break; @@ -211,7 +228,9 @@ bool Keyboard::getKeyAddress(Key key, KeyAddress &keyAddress) { case Key::num_9: keyAddress.id = 0x61; break; case Key::num_0: keyAddress.id = 0x62; break; case Key::num_dot: keyAddress.id = 0x63; break; - case Key::backslash: keyAddress.id = 0x64; break; + + case Key::intl_backslash: keyAddress.id = 0x64; break; + case Key::menu: keyAddress.id = 0x65; break; case Key::ctrl_left: keyAddress.id = 0xe0; break; case Key::shift_left: keyAddress.id = 0xe1; break; @@ -290,6 +309,8 @@ bool Keyboard::parseKey(std::string key, KeyAddress &keyAddress) { else if (key == "back" || key == "backspace") parsedKey = Key::backspace; else if (key == "tab") parsedKey = Key::tab; else if (key == "space") parsedKey = Key::space; + + /* else if (key == "'" || key == "?") parsedKey = Key::apostrophe; else if (key == "tilde" || key == "^" || key == "~") parsedKey = Key::tilde; else if (key == "open_bracket" || key == "openbracket" || key == "è" || key == "ü") parsedKey = Key::open_bracket; @@ -302,6 +323,22 @@ bool Keyboard::parseKey(std::string key, KeyAddress &keyAddress) { else if (key == "," || key == "comma") parsedKey = Key::comma; else if (key == "." || key == "dot") parsedKey = Key::dot; else if (key == "-" || key == "minus") parsedKey = Key::minus; + */ + + else if (key == "tilde") parsedKey = Key::tilde; + else if (key == "minus") parsedKey = Key::minus; + else if (key == "equal") parsedKey = Key::equal; + else if (key == "open_bracket") parsedKey = Key::open_bracket; + else if (key == "close_bracket") parsedKey = Key::close_bracket; + else if (key == "backslash") parsedKey = Key::backslash; + else if (key == "semicolon") parsedKey = Key::semicolon; + else if (key == "quote") parsedKey = Key::quote; + else if (key == "dollar") parsedKey = Key::dollar; + else if (key == "comma") parsedKey = Key::comma; + else if (key == "period") parsedKey = Key::period; + else if (key == "slash") parsedKey = Key::slash; + + else if (key == "caps_lock" || key == "capslock") parsedKey = Key::caps_lock; else if (key == "f1") parsedKey = Key::f1; else if (key == "f2") parsedKey = Key::f2; @@ -345,7 +382,10 @@ bool Keyboard::parseKey(std::string key, KeyAddress &keyAddress) { else if (key == "num9") parsedKey = Key::num_9; else if (key == "num0") parsedKey = Key::num_0; else if (key == "num." || key == "num_dot" || key == "numdot") parsedKey = Key::num_dot; - else if (key == "<" || key == ">" || key == "\\" || key == "backslash") parsedKey = Key::backslash; + + //else if (key == "<" || key == ">" || key == "\\" || key == "backslash") parsedKey = Key::backslash; + else if (key == "intl_backslash") parsedKey = Key::intl_backslash; + else if (key == "menu") parsedKey = Key::menu; else if (key == "ctrl_left" || key == "ctrlleft" || key == "ctrll") parsedKey = Key::ctrl_left; else if (key == "shift_left" || key == "shiftleft" || key == "shiftl") parsedKey = Key::shift_left; @@ -583,12 +623,12 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) { } bool Keyboard::setAllKeys(KeyColors colors) { - KeyValue keyValues[119]; - for (int i = 0; i < 119; i++) { + KeyValue keyValues[117]; + for (int i = 0; i < 117; i++) { getKeyAddress((Key)i, keyValues[i].key); keyValues[i].colors = colors; } - setKeys(keyValues, 119); + setKeys(keyValues, 117); return true; } diff --git a/src/classes/Keyboard.h b/src/classes/Keyboard.h index ca4b824..d1b52ef 100644 --- a/src/classes/Keyboard.h +++ b/src/classes/Keyboard.h @@ -10,7 +10,7 @@ class Keyboard { enum class PowerOnEffect { rainbow, color }; enum class KeyAddressGroup { logo, indicators, multimedia, keys }; - enum class Key { // 119 items + enum class Key { // 117 items logo, caps, num, scroll, game, backlight, mute, play, stop, prev, next, @@ -23,8 +23,14 @@ class Keyboard { n1, n2, n3, n4, n5, n6, n7, n8, n9, n0, tab, caps_lock, space, backspace, enter, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, + tilde, minus, equal, + open_bracket, close_bracket, backslash, + semicolon, quote, dollar, + intl_backslash, comma, period, slash + /* unknown, egrave, eaigu, semicolon, agrave, dollar, apostrophe, degree, backslash, // Need best names comma, dot, minus, open_bracket, close_bracket, tilde + */ }; enum class KeyGroup { logo, indicators, multimedia, fkeys, modifiers, arrows, numeric, functions, keys}; diff --git a/src/main.cpp b/src/main.cpp index edec6d9..c3105a3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -120,6 +120,20 @@ void listkeys() { cout<<" space\n"; cout<<" backspace, back\n"; cout<<" enter\n"; + cout<<" tilde\n"; + cout<<" minus\n"; + cout<<" equal\n"; + cout<<" open_bracket\n"; + cout<<" close_bracket\n"; + cout<<" backslash\n"; + cout<<" semicolon\n"; + cout<<" dollar\n"; + cout<<" quote\n"; + cout<<" intl_backslash\n"; + cout<<" comma\n"; + cout<<" period\n"; + cout<<" slash\n"; + /* cout<<" \n"; cout<<" Keys EN-US FR-CH\n"; cout<<" k1 : tilde §\n"; @@ -135,6 +149,7 @@ void listkeys() { cout<<" k11 : , ,\n"; cout<<" k12 : . .\n"; cout<<" k13 : / -\n"; + */ } int commit() { From 7dcbf6807714938cba7a7927464b97d71c8d4357 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 29 Oct 2016 18:56:17 +0200 Subject: [PATCH 5/7] Update sample profils --- sample_profiles/keys_v_gradiant_fr_ch-latin1 | 67 ++++++++++---------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/sample_profiles/keys_v_gradiant_fr_ch-latin1 b/sample_profiles/keys_v_gradiant_fr_ch-latin1 index 4f3af24..11314d8 100644 --- a/sample_profiles/keys_v_gradiant_fr_ch-latin1 +++ b/sample_profiles/keys_v_gradiant_fr_ch-latin1 @@ -16,18 +16,18 @@ g indicators $raw0 k mute $raw0 # Raw 1 : -k esc $raw1 +k escape $raw1 g fkeys $raw1 -k printscreen $raw1 -k scrolllock $raw1 -k pausebreak $raw1 -k play $raw1 +k print_screen $raw1 +k scroll_lock $raw1 +k pause_break $raw1 +k play_pause $raw1 k stop $raw1 k prev $raw1 k next $raw1 # Raw 2 : -k ° $raw2 +k tilde $raw2 k 1 $raw2 k 2 $raw2 k 3 $raw2 @@ -38,16 +38,16 @@ k 7 $raw2 k 8 $raw2 k 9 $raw2 k 0 $raw2 -k ? $raw2 -k tilde $raw2 +k minus $raw2 +k equal $raw2 k backspace $raw2 k insert $raw2 k home $raw2 -k pageup $raw2 -k numlock $raw2 -k numslash $raw2 -k numasterisk $raw2 -k numminus $raw2 +k page_up $raw2 +k num_lock $raw2 +k num_slash $raw2 +k num_asterisk $raw2 +k num_minus $raw2 # Raw 3 : k tab $raw3 @@ -61,17 +61,18 @@ k u $raw3 k i $raw3 k o $raw3 k p $raw3 -k è $raw3 -k ¨ $raw3 +k open_bracket $raw3 +k close_bracket $raw3 +# k backslash $raw3 k delete $raw3 k end $raw3 -k pagedown $raw3 +k page_down $raw3 k num7 $raw3 k num8 $raw3 k num9 $raw3 # Raw 4 : -k capslock $raw4 +k caps_lock $raw4 k a $raw4 k s $raw4 k d $raw4 @@ -81,18 +82,18 @@ k h $raw4 k j $raw4 k k $raw4 k l $raw4 -k é $raw4 -k à $raw4 -k $ $raw4 +k semicolon $raw4 +k quote $raw4 +k dollar $raw4 k enter $raw4 k num4 $raw4 k num5 $raw4 k num6 $raw4 -k num+ $raw4 +k num_plus $raw4 # Raw 5 : -k shiftl $raw5 -k < $raw5 +k shift_left $raw5 +k intl_backslash $raw5 k y $raw5 k x $raw5 k c $raw5 @@ -100,24 +101,24 @@ k v $raw5 k b $raw5 k n $raw5 k m $raw5 -k , $raw5 -k . $raw5 -k - $raw5 -k shiftr $raw5 +k comma $raw5 +k period $raw5 +k slash $raw5 +k shift_right $raw5 k top $raw5 k num1 $raw5 k num2 $raw5 k num3 $raw5 # Raw 6 : -k ctrll $raw6 -k winl $raw6 -k altl $raw6 +k ctrl_left $raw6 +k win_left $raw6 +k alt_left $raw6 k space $raw6 -k altr $raw6 -k winr $raw6 +k alt_right $raw6 +k win_right $raw6 k menu $raw6 -k ctrlr $raw6 +k ctrl_right $raw6 k left $raw6 k bottom $raw6 k right $raw6 From 21d048c4a5fab9fc8ed983e3712182c9a7ff9348 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 29 Oct 2016 18:59:01 +0200 Subject: [PATCH 6/7] Rename num_dot to num_period --- sample_profiles/keys_v_gradiant_fr_ch-latin1 | 2 +- src/classes/Keyboard.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sample_profiles/keys_v_gradiant_fr_ch-latin1 b/sample_profiles/keys_v_gradiant_fr_ch-latin1 index 11314d8..0a56625 100644 --- a/sample_profiles/keys_v_gradiant_fr_ch-latin1 +++ b/sample_profiles/keys_v_gradiant_fr_ch-latin1 @@ -123,7 +123,7 @@ k left $raw6 k bottom $raw6 k right $raw6 k num0 $raw6 -k num. $raw6 +k num_period $raw6 k numenter $raw6 # Commit diff --git a/src/classes/Keyboard.cpp b/src/classes/Keyboard.cpp index 5ee7a14..cf28fc0 100644 --- a/src/classes/Keyboard.cpp +++ b/src/classes/Keyboard.cpp @@ -381,7 +381,7 @@ bool Keyboard::parseKey(std::string key, KeyAddress &keyAddress) { else if (key == "num8") parsedKey = Key::num_8; else if (key == "num9") parsedKey = Key::num_9; else if (key == "num0") parsedKey = Key::num_0; - else if (key == "num." || key == "num_dot" || key == "numdot") parsedKey = Key::num_dot; + else if (key == "num." || key == "num_period" || key == "numperiod") parsedKey = Key::num_dot; //else if (key == "<" || key == ">" || key == "\\" || key == "backslash") parsedKey = Key::backslash; else if (key == "intl_backslash") parsedKey = Key::intl_backslash; From 66b38d59cbd5cafa3e236e53c1cb7956199996c0 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 29 Oct 2016 19:05:57 +0200 Subject: [PATCH 7/7] Add keynames shortcuts --- src/classes/Keyboard.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/classes/Keyboard.cpp b/src/classes/Keyboard.cpp index cf28fc0..781a01d 100644 --- a/src/classes/Keyboard.cpp +++ b/src/classes/Keyboard.cpp @@ -325,18 +325,18 @@ bool Keyboard::parseKey(std::string key, KeyAddress &keyAddress) { else if (key == "-" || key == "minus") parsedKey = Key::minus; */ - else if (key == "tilde") parsedKey = Key::tilde; - else if (key == "minus") parsedKey = Key::minus; - else if (key == "equal") parsedKey = Key::equal; - else if (key == "open_bracket") parsedKey = Key::open_bracket; - else if (key == "close_bracket") parsedKey = Key::close_bracket; - else if (key == "backslash") parsedKey = Key::backslash; - else if (key == "semicolon") parsedKey = Key::semicolon; - else if (key == "quote") parsedKey = Key::quote; - else if (key == "dollar") parsedKey = Key::dollar; - else if (key == "comma") parsedKey = Key::comma; - else if (key == "period") parsedKey = Key::period; - else if (key == "slash") parsedKey = Key::slash; + else if (key == "tilde" || key == "~") parsedKey = Key::tilde; + else if (key == "minus" || key == "-") parsedKey = Key::minus; + else if (key == "equal" || key == "=") parsedKey = Key::equal; + else if (key == "open_bracket" || key == "[") parsedKey = Key::open_bracket; + else if (key == "close_bracket" || key == "]") parsedKey = Key::close_bracket; + else if (key == "backslash" || key == "\\") parsedKey = Key::backslash; + else if (key == "semicolon" || key == ";") parsedKey = Key::semicolon; + else if (key == "quote" || key == "\"") parsedKey = Key::quote; + else if (key == "dollar" || key == "$") parsedKey = Key::dollar; + else if (key == "comma" || key == ",") parsedKey = Key::comma; + else if (key == "period" || key == ".") parsedKey = Key::period; + else if (key == "slash" || key == "/") parsedKey = Key::slash; else if (key == "caps_lock" || key == "capslock") parsedKey = Key::caps_lock; @@ -384,7 +384,7 @@ bool Keyboard::parseKey(std::string key, KeyAddress &keyAddress) { else if (key == "num." || key == "num_period" || key == "numperiod") parsedKey = Key::num_dot; //else if (key == "<" || key == ">" || key == "\\" || key == "backslash") parsedKey = Key::backslash; - else if (key == "intl_backslash") parsedKey = Key::intl_backslash; + else if (key == "intl_backslash" || key == "<") parsedKey = Key::intl_backslash; else if (key == "menu") parsedKey = Key::menu; else if (key == "ctrl_left" || key == "ctrlleft" || key == "ctrll") parsedKey = Key::ctrl_left;