Handling of keys that are substrings of other keys

This commit is contained in:
Markus Gans 2018-07-29 23:49:11 +02:00
parent d4a163065d
commit 8c575e0aad
5 changed files with 1645 additions and 52 deletions

View File

@ -1,5 +1,6 @@
2017-07-29 Markus Gans <guru.mail@muenster.de> 2017-07-29 Markus Gans <guru.mail@muenster.de>
* Added numeric Keypad [/], [*], [-], [+] support * Added numeric Keypad [/], [*], [-], [+] support
* Handling of keys that are substrings of other keys
* More tests in FKeyboard unit test * More tests in FKeyboard unit test
2017-07-27 Markus Gans <guru.mail@muenster.de> 2017-07-27 Markus Gans <guru.mail@muenster.de>

View File

@ -151,6 +151,7 @@ class FKeyboard
void parseKeyBuffer(); void parseKeyBuffer();
int parseKeyString(); int parseKeyString();
int keyCorrection (const int&); int keyCorrection (const int&);
void substringKeyHandling();
void keyPressed(); void keyPressed();
void keyReleased(); void keyReleased();
void escapeKeyPressed(); void escapeKeyPressed();

View File

@ -368,32 +368,32 @@ fmetakeymap Fmetakey[] =
{ fc::Fmkey_greater_than , "\033>" }, // M-> { fc::Fmkey_greater_than , "\033>" }, // M->
{ fc::Fmkey_question_mark , "\033?" }, // M-? { fc::Fmkey_question_mark , "\033?" }, // M-?
{ fc::Fmkey_at , "\033@" }, // M-@ { fc::Fmkey_at , "\033@" }, // M-@
{ fc::Fmkey_A , "\033A" }, // M-A { fc::Fmkey_A , "\033A" }, // shift-M-A
{ fc::Fmkey_B , "\033B" }, // M-B { fc::Fmkey_B , "\033B" }, // shift-M-B
{ fc::Fmkey_C , "\033C" }, // M-C { fc::Fmkey_C , "\033C" }, // shift-M-C
{ fc::Fmkey_D , "\033D" }, // M-D { fc::Fmkey_D , "\033D" }, // shift-M-D
{ fc::Fmkey_E , "\033E" }, // M-E { fc::Fmkey_E , "\033E" }, // shift-M-E
{ fc::Fmkey_F , "\033F" }, // M-F { fc::Fmkey_F , "\033F" }, // shift-M-F
{ fc::Fmkey_G , "\033G" }, // M-G { fc::Fmkey_G , "\033G" }, // shift-M-G
{ fc::Fmkey_H , "\033H" }, // M-H { fc::Fmkey_H , "\033H" }, // shift-M-H
{ fc::Fmkey_I , "\033I" }, // M-I { fc::Fmkey_I , "\033I" }, // shift-M-I
{ fc::Fmkey_J , "\033J" }, // M-J { fc::Fmkey_J , "\033J" }, // shift-M-J
{ fc::Fmkey_K , "\033K" }, // M-K { fc::Fmkey_K , "\033K" }, // shift-M-K
{ fc::Fmkey_L , "\033L" }, // M-L { fc::Fmkey_L , "\033L" }, // shift-M-L
{ fc::Fmkey_M , "\033M" }, // M-M { fc::Fmkey_M , "\033M" }, // shift-M-M
{ fc::Fmkey_N , "\033N" }, // M-N { fc::Fmkey_N , "\033N" }, // shift-M-N
{ fc::Fmkey_O , "\033O" }, // M-O { fc::Fmkey_O , "\033O" }, // shift-M-O
{ fc::Fmkey_P , "\033P" }, // M-P { fc::Fmkey_P , "\033P" }, // shift-M-P
{ fc::Fmkey_Q , "\033Q" }, // M-Q { fc::Fmkey_Q , "\033Q" }, // shift-M-Q
{ fc::Fmkey_R , "\033R" }, // M-R { fc::Fmkey_R , "\033R" }, // shift-M-R
{ fc::Fmkey_S , "\033S" }, // M-S { fc::Fmkey_S , "\033S" }, // shift-M-S
{ fc::Fmkey_T , "\033T" }, // M-T { fc::Fmkey_T , "\033T" }, // shift-M-T
{ fc::Fmkey_U , "\033U" }, // M-U { fc::Fmkey_U , "\033U" }, // shift-M-U
{ fc::Fmkey_V , "\033V" }, // M-V { fc::Fmkey_V , "\033V" }, // shift-M-V
{ fc::Fmkey_W , "\033W" }, // M-W { fc::Fmkey_W , "\033W" }, // shift-M-W
{ fc::Fmkey_X , "\033X" }, // M-X { fc::Fmkey_X , "\033X" }, // shift-M-X
{ fc::Fmkey_Y , "\033Y" }, // M-Y { fc::Fmkey_Y , "\033Y" }, // shift-M-Y
{ fc::Fmkey_Z , "\033Z" }, // M-Z { fc::Fmkey_Z , "\033Z" }, // shift-M-Z
{ fc::Fmkey_left_square_bracket , "\033[" }, // M-[ { fc::Fmkey_left_square_bracket , "\033[" }, // M-[
{ fc::Fmkey_backslash , "\033\\"}, // M-'\' { fc::Fmkey_backslash , "\033\\"}, // M-'\'
{ fc::Fmkey_right_square_bracket , "\033]" }, // M-] { fc::Fmkey_right_square_bracket , "\033]" }, // M-]

View File

@ -187,6 +187,9 @@ void FKeyboard::escapeKeyHandling()
input_data_pending = false; input_data_pending = false;
escapeKeyPressed(); escapeKeyPressed();
} }
// Handling of keys that are substrings of other keys
substringKeyHandling();
} }
@ -242,8 +245,8 @@ inline int FKeyboard::getTermcapKey()
for (n = len; n < fifo_buf_size; n++) // Remove founded entry for (n = len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n - len] = fifo_buf[n]; fifo_buf[n - len] = fifo_buf[n];
for (; n - len < len; n++) // Fill rest with '\0' for (n = n - len; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n - len] = '\0'; fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0'); input_data_pending = bool(fifo_buf[0] != '\0');
return fc::Fkey[i].num; return fc::Fkey[i].num;
@ -280,8 +283,8 @@ inline int FKeyboard::getMetaKey()
for (n = len; n < fifo_buf_size; n++) // Remove founded entry for (n = len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n - len] = fifo_buf[n]; fifo_buf[n - len] = fifo_buf[n];
for (; n - len < len; n++) // Fill rest with '\0' for (n = n - len; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n - len] = '\0'; fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0'); input_data_pending = bool(fifo_buf[0] != '\0');
return fc::Fmetakey[i].num; return fc::Fmetakey[i].num;
@ -513,6 +516,36 @@ int FKeyboard::keyCorrection (const int& keycode)
return key_correction; return key_correction;
} }
//----------------------------------------------------------------------
void FKeyboard::substringKeyHandling()
{
// Some keys (Meta-O, Meta-[, Meta-]) used substrings
// of other keys and are only processed after a timeout
if ( fifo_in_use
&& fifo_offset == 2
&& fifo_buf[0] == 0x1b
&& (fifo_buf[1] == 'O' || fifo_buf[1] == '[' || fifo_buf[1] == ']')
&& fifo_buf[2] == '\0'
&& isKeypressTimeout() )
{
fifo_offset = 0;
fifo_buf[0] = 0x00;
fifo_in_use = false;
input_data_pending = false;
if ( fifo_buf[1] == 'O' )
key = fc::Fmkey_O;
else if ( fifo_buf[1] == '[' )
key = fc::Fmkey_left_square_bracket;
else
key = fc::Fmkey_right_square_bracket;
keyPressed();
keyReleased();
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FKeyboard::keyPressed() void FKeyboard::keyPressed()
{ {

File diff suppressed because it is too large Load Diff