@@ -742,30 +742,20 @@ std::string keyboard_pad_handler::GetKeyName(const QKeyEvent* keyEvent)
742742
743743 switch (keyEvent->key ())
744744 {
745- case Qt::Key_Alt:
746- return " Alt" ;
747- case Qt::Key_AltGr:
748- return " AltGr" ;
749- case Qt::Key_Shift:
750- return " Shift" ;
751- case Qt::Key_Control:
752- return " Ctrl" ;
753- case Qt::Key_Meta:
754- return " Meta" ;
755- case Qt::Key_NumLock:
756- return QKeySequence (keyEvent->key ()).toString (QKeySequence::NativeText).toStdString ();
745+ case Qt::Key_Alt: return " Alt" ;
746+ case Qt::Key_AltGr: return " AltGr" ;
747+ case Qt::Key_Shift: return " Shift" ;
748+ case Qt::Key_Control: return " Ctrl" ;
749+ case Qt::Key_Meta: return " Meta" ;
750+ case Qt::Key_NumLock: return QKeySequence (keyEvent->key ()).toString (QKeySequence::NativeText).toStdString ();
757751#ifdef __APPLE__
758752 // On macOS, the arrow keys are considered to be part of the keypad;
759753 // since most Mac keyboards lack a keypad to begin with,
760754 // we change them to regular arrows to avoid confusion
761- case Qt::Key_Left:
762- return " ←" ;
763- case Qt::Key_Up:
764- return " ↑" ;
765- case Qt::Key_Right:
766- return " →" ;
767- case Qt::Key_Down:
768- return " ↓" ;
755+ case Qt::Key_Left: return " ←" ;
756+ case Qt::Key_Up: return " ↑" ;
757+ case Qt::Key_Right: return " →" ;
758+ case Qt::Key_Down: return " ↓" ;
769759#endif
770760 default :
771761 break ;
@@ -793,30 +783,20 @@ std::set<u32> keyboard_pad_handler::GetKeyCodes(const cfg::string& cfg_string)
793783
794784u32 keyboard_pad_handler::GetKeyCode (const QString& keyName)
795785{
796- if (keyName.isEmpty ())
797- return Qt::NoButton;
786+ if (keyName.isEmpty ()) return Qt::NoButton;
798787 if (const int native_scan_code = native_scan_code_from_string (keyName.toStdString ()); native_scan_code >= 0 )
799788 return Qt::Key_unknown + native_scan_code; // Special cases that can't be expressed with Qt::Key
800- if (keyName == " Alt" )
801- return Qt::Key_Alt;
802- if (keyName == " AltGr" )
803- return Qt::Key_AltGr;
804- if (keyName == " Shift" )
805- return Qt::Key_Shift;
806- if (keyName == " Ctrl" )
807- return Qt::Key_Control;
808- if (keyName == " Meta" )
809- return Qt::Key_Meta;
789+ if (keyName == " Alt" ) return Qt::Key_Alt;
790+ if (keyName == " AltGr" ) return Qt::Key_AltGr;
791+ if (keyName == " Shift" ) return Qt::Key_Shift;
792+ if (keyName == " Ctrl" ) return Qt::Key_Control;
793+ if (keyName == " Meta" ) return Qt::Key_Meta;
810794#ifdef __APPLE__
811795 // QKeySequence doesn't work properly for the arrow keys on macOS
812- if (keyName == " Num←" )
813- return Qt::Key_Left;
814- if (keyName == " Num↑" )
815- return Qt::Key_Up;
816- if (keyName == " Num→" )
817- return Qt::Key_Right;
818- if (keyName == " Num↓" )
819- return Qt::Key_Down;
796+ if (keyName == " Num←" ) return Qt::Key_Left;
797+ if (keyName == " Num↑" ) return Qt::Key_Up;
798+ if (keyName == " Num→" ) return Qt::Key_Right;
799+ if (keyName == " Num↓" ) return Qt::Key_Down;
820800#endif
821801
822802 const QKeySequence seq (keyName);
@@ -834,46 +814,26 @@ int keyboard_pad_handler::native_scan_code_from_string([[maybe_unused]] const st
834814{
835815 // NOTE: Qt throws a Ctrl key at us when using Alt Gr, so there is no point in distinguishing left and right Alt at the moment
836816#ifdef _WIN32
837- if (key == " Shift Left" )
838- return 42 ;
839- if (key == " Shift Right" )
840- return 54 ;
841- if (key == " Ctrl Left" )
842- return 29 ;
843- if (key == " Ctrl Right" )
844- return 285 ;
845- if (key == " Num+0" || key == " Num+Ins" )
846- return 82 ;
847- if (key == " Num+1" || key == " Num+End" )
848- return 79 ;
849- if (key == " Num+2" || key == " Num+Down" )
850- return 80 ;
851- if (key == " Num+3" || key == " Num+PgDown" )
852- return 81 ;
853- if (key == " Num+4" || key == " Num+Left" )
854- return 75 ;
855- if (key == " Num+5" || key == " Num+Clear" )
856- return 76 ;
857- if (key == " Num+6" || key == " Num+Right" )
858- return 77 ;
859- if (key == " Num+7" || key == " Num+Home" )
860- return 71 ;
861- if (key == " Num+8" || key == " Num+Up" )
862- return 72 ;
863- if (key == " Num+9" || key == " Num+PgUp" )
864- return 73 ;
865- if (key == " Num+," || key == " Num+Del" )
866- return 83 ;
867- if (key == " Num+/" )
868- return 309 ;
869- if (key == " Num+*" )
870- return 55 ;
871- if (key == " Num+-" )
872- return 74 ;
873- if (key == " Num++" )
874- return 78 ;
875- if (key == " Num+Enter" )
876- return 284 ;
817+ if (key == " Shift Left" ) return 42 ;
818+ if (key == " Shift Right" ) return 54 ;
819+ if (key == " Ctrl Left" ) return 29 ;
820+ if (key == " Ctrl Right" ) return 285 ;
821+ if (key == " Num+0" || key == " Num+Ins" ) return 82 ;
822+ if (key == " Num+1" || key == " Num+End" ) return 79 ;
823+ if (key == " Num+2" || key == " Num+Down" ) return 80 ;
824+ if (key == " Num+3" || key == " Num+PgDown" ) return 81 ;
825+ if (key == " Num+4" || key == " Num+Left" ) return 75 ;
826+ if (key == " Num+5" || key == " Num+Clear" ) return 76 ;
827+ if (key == " Num+6" || key == " Num+Right" ) return 77 ;
828+ if (key == " Num+7" || key == " Num+Home" ) return 71 ;
829+ if (key == " Num+8" || key == " Num+Up" ) return 72 ;
830+ if (key == " Num+9" || key == " Num+PgUp" ) return 73 ;
831+ if (key == " Num+," || key == " Num+Del" ) return 83 ;
832+ if (key == " Num+/" ) return 309 ;
833+ if (key == " Num+*" ) return 55 ;
834+ if (key == " Num+-" ) return 74 ;
835+ if (key == " Num++" ) return 78 ;
836+ if (key == " Num+Enter" ) return 284 ;
877837#else
878838 // TODO
879839#endif
@@ -887,52 +847,31 @@ std::string keyboard_pad_handler::native_scan_code_to_string(int native_scan_cod
887847#ifdef _WIN32
888848 // NOTE: the other Qt function "nativeVirtualKey" does not distinguish between VK_SHIFT and VK_RSHIFT key in Qt at the moment
889849 // NOTE: Qt throws a Ctrl key at us when using Alt Gr, so there is no point in distinguishing left and right Alt at the moment
890- case 42 :
891- return " Shift Left" ;
892- case 54 :
893- return " Shift Right" ;
894- case 29 :
895- return " Ctrl Left" ;
896- case 285 :
897- return " Ctrl Right" ;
898- case 82 :
899- return " Num+0" ; // Also "Num+Ins" depending on numlock
900- case 79 :
901- return " Num+1" ; // Also "Num+End" depending on numlock
902- case 80 :
903- return " Num+2" ; // Also "Num+Down" depending on numlock
904- case 81 :
905- return " Num+3" ; // Also "Num+PgDown" depending on numlock
906- case 75 :
907- return " Num+4" ; // Also "Num+Left" depending on numlock
908- case 76 :
909- return " Num+5" ; // Also "Num+Clear" depending on numlock
910- case 77 :
911- return " Num+6" ; // Also "Num+Right" depending on numlock
912- case 71 :
913- return " Num+7" ; // Also "Num+Home" depending on numlock
914- case 72 :
915- return " Num+8" ; // Also "Num+Up" depending on numlock
916- case 73 :
917- return " Num+9" ; // Also "Num+PgUp" depending on numlock
918- case 83 :
919- return " Num+," ; // Also "Num+Del" depending on numlock
920- case 309 :
921- return " Num+/" ;
922- case 55 :
923- return " Num+*" ;
924- case 74 :
925- return " Num+-" ;
926- case 78 :
927- return " Num++" ;
928- case 284 :
929- return " Num+Enter" ;
850+ case 42 : return " Shift Left" ;
851+ case 54 : return " Shift Right" ;
852+ case 29 : return " Ctrl Left" ;
853+ case 285 : return " Ctrl Right" ;
854+ case 82 : return " Num+0" ; // Also "Num+Ins" depending on numlock
855+ case 79 : return " Num+1" ; // Also "Num+End" depending on numlock
856+ case 80 : return " Num+2" ; // Also "Num+Down" depending on numlock
857+ case 81 : return " Num+3" ; // Also "Num+PgDown" depending on numlock
858+ case 75 : return " Num+4" ; // Also "Num+Left" depending on numlock
859+ case 76 : return " Num+5" ; // Also "Num+Clear" depending on numlock
860+ case 77 : return " Num+6" ; // Also "Num+Right" depending on numlock
861+ case 71 : return " Num+7" ; // Also "Num+Home" depending on numlock
862+ case 72 : return " Num+8" ; // Also "Num+Up" depending on numlock
863+ case 73 : return " Num+9" ; // Also "Num+PgUp" depending on numlock
864+ case 83 : return " Num+," ; // Also "Num+Del" depending on numlock
865+ case 309 : return " Num+/" ;
866+ case 55 : return " Num+*" ;
867+ case 74 : return " Num+-" ;
868+ case 78 : return " Num++" ;
869+ case 284 : return " Num+Enter" ;
930870#else
931871 // TODO
932872 // NOTE for MacOs: nativeScanCode may not work
933873#endif
934- default :
935- return " " ;
874+ default : return " " ;
936875 }
937876}
938877
0 commit comments