Added F10-F12 For Custom KeyBinds (#507)

* added F10-F12 keys

* updated version strings to 5.2.2

* updated spec to reflect new keys
This commit is contained in:
ykeara
2020-08-11 20:02:34 -05:00
committed by GitHub
parent c8f519ec0b
commit 15f5534f69
8 changed files with 109 additions and 47 deletions
+44
View File
@@ -55,6 +55,24 @@ std::optional<Token> getFunctionNumber( const char& character ) noexcept
}
}
std::optional<Token> getFunctionNumberExtended( const char& character ) noexcept
{
switch ( character )
{
case '0':
return Token::KEY_F10;
case '1':
return Token::KEY_F11;
case '2':
return Token::KEY_F12;
// Theoretically we could extende out to f19, but as F12 is the only
// function key on Standard Keyboard.
default:
LOG( INFO ) << "Unknown function key number: " << character;
return std::nullopt;
}
}
std::optional<Token> checkIfLegalCapitalLiteral( std::string input ) noexcept
{
// C++ can't do string comparisons in switches. :(
@@ -200,6 +218,26 @@ std::vector<Token>
break;
}
}
else if ( *ch == 'G' )
{
++ch;
if ( ch == end )
{
break;
}
const auto token = getFunctionNumberExtended( *ch );
if ( token.has_value() )
{
tokens.push_back( *token );
continue;
}
else
{
// Spec says to abort on errors and submit correct values before
// error.
break;
}
}
std::string characters;
characters.push_back( *ch );
@@ -428,6 +466,12 @@ bool isLiteral( const Token token ) noexcept
return true;
case Token::KEY_F9:
return true;
case Token::KEY_F10:
return true;
case Token::KEY_F11:
return true;
case Token::KEY_F12:
return true;
case Token::KEY_BACKSPACE:
return true;