Cleaned up native scan code to Qt key conversion code for windows. Use known key definitions instead of hardcoded values when possible.

This commit is contained in:
harry 2023-01-23 21:20:19 -05:00
parent f4a9fa6898
commit 53288c0a75
1 changed files with 90 additions and 90 deletions

View File

@ -80,99 +80,99 @@ static uint32_t AltKeyCodeR = 0xffea;
static uint32_t MetaKeyCodeR = 0xffe8;
#endif
/* mapt to convert keyboard native scan code to qt keys */
/* map to convert keyboard native scan code to qt keys */
static QMap<NativeScanCode, _KeyValue> s_nativeScanCodesMap =
#if defined(WIN32)
{
{1, {27, 16777216}},
{2, {49, 49}},
{3, {50, 50}},
{4, {51, 51}},
{5, {52, 52}},
{6, {53, 53}},
{7, {54, 54}},
{8, {55, 55}},
{9, {56, 56}},
{10, {57, 57}},
{11, {48, 48}},
{12, {189, 45}},
{13, {187, 61}},
{14, {8, 16777219}},
{15, {9, 16777217}},
{16, {81, 81}},
{17, {87, 87}},
{18, {69, 69}},
{19, {82, 82}},
{20, {84, 84}},
{21, {89, 89}},
{22, {85, 85}},
{23, {73, 73}},
{24, {79, 79}},
{25, {80, 80}},
{26, {219, 91}},
{27, {221, 93}},
{28, {13, 16777220}},
{29, {17, 16777249}},
{30, {65, 65}},
{31, {83, 83}},
{32, {68, 68}},
{33, {70, 70}},
{34, {71, 71}},
{35, {72, 72}},
{36, {74, 74}},
{37, {75, 75}},
{38, {76, 76}},
{39, {186, 59}},
{40, {222, 39}},
{41, {192, 96}},
{42, {16, 16777248}},
{43, {220, 92}},
{44, {90, 90}},
{45, {88, 88}},
{46, {67, 67}},
{47, {86, 86}},
{48, {66, 66}},
{49, {78, 78}},
{50, {77, 77}},
{51, {188, 44}},
{52, {190, 46}},
{53, {191, 47}},
{54, {16, 16777248}},
{55, {106, 42}},
{56, {18, 16777251}},
{58, {20, 16777252}},
{59, {112, 16777264}},
{60, {113, 16777265}},
{61, {114, 16777266}},
{62, {115, 16777267}},
{63, {116, 16777268}},
{64, {117, 16777269}},
{65, {118, 16777270}},
{66, {119, 16777271}},
{67, {120, 16777272}},
{68, {121, 16777273}},
{69, {19, 16777224}},
{70, {145, 16777254}},
{71, {36, 16777232}},
{74, {109, 45}},
{76, {12, 16777227}},
{78, {107, 43}},
{79, {35, 16777233}},
{82, {45, 16777222}},
{83, {46, 16777223}},
{87, {122, 16777274}},
{88, {123, 16777275}},
{256, {176, 16777347}},
{284, {13, 16777221}},
{285, {17, 16777249}},
{309, {111, 47}},
{312, {18, 16777251}},
{325, {144, 16777253}},
{338, {45, 16777222}},
{339, {46, 16777223}},
{347, {91, 16777250}},
{348, {92, 16777250}},
{349, {93, 16777301}},
{ 1, { VK_ESCAPE , Qt::Key_Escape }},
{ 2, { '1' , Qt::Key_1 }},
{ 3, { '2' , Qt::Key_2 }},
{ 4, { '3' , Qt::Key_3 }},
{ 5, { '4' , Qt::Key_4 }},
{ 6, { '5' , Qt::Key_5 }},
{ 7, { '6' , Qt::Key_6 }},
{ 8, { '7' , Qt::Key_7 }},
{ 9, { '8' , Qt::Key_8 }},
{ 10, { '9' , Qt::Key_9 }},
{ 11, { '0' , Qt::Key_0 }},
{ 12, { VK_OEM_MINUS , Qt::Key_Minus }},
{ 13, { VK_OEM_PLUS , Qt::Key_Equal }},
{ 14, { VK_BACK , Qt::Key_Backspace }},
{ 15, { VK_TAB , Qt::Key_Tab }},
{ 16, { 'Q' , Qt::Key_Q }},
{ 17, { 'W' , Qt::Key_W }},
{ 18, { 'E' , Qt::Key_E }},
{ 19, { 'R' , Qt::Key_R }},
{ 20, { 'T' , Qt::Key_T }},
{ 21, { 'Y' , Qt::Key_Y }},
{ 22, { 'U' , Qt::Key_U }},
{ 23, { 'I' , Qt::Key_I }},
{ 24, { 'O' , Qt::Key_O }},
{ 25, { 'P' , Qt::Key_P }},
{ 26, { VK_OEM_4 , Qt::Key_BracketLeft }},
{ 27, { VK_OEM_6 , Qt::Key_BracketRight }},
{ 28, { VK_RETURN , Qt::Key_Return }},
{ 29, { VK_LCONTROL , Qt::Key_Control }},
{ 30, { 'A' , Qt::Key_A }},
{ 31, { 'S' , Qt::Key_S }},
{ 32, { 'D' , Qt::Key_D }},
{ 33, { 'F' , Qt::Key_F }},
{ 34, { 'G' , Qt::Key_G }},
{ 35, { 'H' , Qt::Key_H }},
{ 36, { 'J' , Qt::Key_J }},
{ 37, { 'K' , Qt::Key_K }},
{ 38, { 'L' , Qt::Key_L }},
{ 39, { VK_OEM_1 , Qt::Key_Semicolon }},
{ 40, { VK_OEM_7 , Qt::Key_Apostrophe }},
{ 41, { VK_OEM_3 , Qt::Key_QuoteLeft }},
{ 42, { VK_LSHIFT , Qt::Key_Shift }},
{ 43, { VK_OEM_5 , Qt::Key_Backslash }},
{ 44, { 'Z' , Qt::Key_Z }},
{ 45, { 'X' , Qt::Key_X }},
{ 46, { 'C' , Qt::Key_C }},
{ 47, { 'V' , Qt::Key_V }},
{ 48, { 'B' , Qt::Key_B }},
{ 49, { 'N' , Qt::Key_N }},
{ 50, { 'M' , Qt::Key_M }},
{ 51, { VK_OEM_COMMA , Qt::Key_Comma }},
{ 52, { VK_OEM_PERIOD , Qt::Key_Period }},
{ 53, { VK_OEM_2 , Qt::Key_Slash }},
{ 54, { VK_RSHIFT , Qt::Key_Shift }},
{ 55, { VK_MULTIPLY , Qt::Key_Asterisk }},
{ 56, { VK_LMENU , Qt::Key_Alt }},
{ 58, { VK_CAPITAL , Qt::Key_CapsLock }},
{ 59, { VK_F1 , Qt::Key_F1 }},
{ 60, { VK_F2 , Qt::Key_F2 }},
{ 61, { VK_F3 , Qt::Key_F3 }},
{ 62, { VK_F4 , Qt::Key_F4 }},
{ 63, { VK_F5 , Qt::Key_F5 }},
{ 64, { VK_F6 , Qt::Key_F6 }},
{ 65, { VK_F7 , Qt::Key_F7 }},
{ 66, { VK_F8 , Qt::Key_F8 }},
{ 67, { VK_F9 , Qt::Key_F9 }},
{ 68, { VK_F10 , Qt::Key_F10 }},
{ 69, { VK_PAUSE , Qt::Key_Pause }},
{ 70, { VK_SCROLL , Qt::Key_ScrollLock }},
{ 71, { VK_HOME , Qt::Key_Home }},
{ 74, { VK_SUBTRACT , Qt::Key_Minus }},
{ 76, { VK_CLEAR , Qt::Key_Clear }},
{ 78, { VK_ADD , Qt::Key_Plus }},
{ 79, { VK_END , Qt::Key_End }},
{ 82, { VK_INSERT , Qt::Key_Insert }},
{ 83, { VK_DELETE , Qt::Key_Delete }},
{ 87, { VK_F11 , Qt::Key_F11 }},
{ 88, { VK_F12 , Qt::Key_F12 }},
{256, { VK_MEDIA_NEXT_TRACK, Qt::Key_MediaNext }},
{284, { VK_RETURN , Qt::Key_Enter }},
{285, { VK_RCONTROL , Qt::Key_Control }},
{309, { VK_DIVIDE , Qt::Key_Slash }},
{312, { VK_RMENU , Qt::Key_Alt }},
{325, { VK_NUMLOCK , Qt::Key_NumLock }},
{338, { VK_INSERT , Qt::Key_Insert }},
{339, { VK_DELETE , Qt::Key_Delete }},
{347, { VK_LWIN , Qt::Key_Meta }},
{348, { VK_RWIN , Qt::Key_Meta }},
{349, { VK_APPS , Qt::Key_Menu }},
};
#else
{