summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/comm/keypebble/krfbdecoder.cpp59
1 files changed, 24 insertions, 35 deletions
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp
index 2c9ad71..db95154 100644
--- a/noncore/comm/keypebble/krfbdecoder.cpp
+++ b/noncore/comm/keypebble/krfbdecoder.cpp
@@ -798,44 +798,33 @@ void KRFBDecoder::sendKeyReleaseEvent( QKeyEvent *event )
798} 798}
799 799
800 800
801
802
803//
804// The RFB protocol spec says 'For most ordinary keys, the 'keysym'
805// is the same as the corresponding ASCII value.', but doesn't
806// elaborate what the most ordinary keys are. The spec also lists
807// a set (possibly subset, it's unspecified) of mappings for
808// "other common keys" (backspace, tab, return, escape, etc).
809//
801int KRFBDecoder::toKeySym( QKeyEvent *k ) 810int KRFBDecoder::toKeySym( QKeyEvent *k )
802{ 811{
803 int ke = 0; 812
804 813 //
805 ke = k->ascii(); 814 // Try and map these "other common keys" first.
806 // Markus: Crappy hack. I dont know why lower case letters are 815 //
807 // not defined in qkeydefs.h. The key() for e.g. 'l' == 'L'. 816 if ((k->key() >= Qt::Key_Escape) && (k->key() <= Qt::Key_F12)) {
808 // This sucks. :-( 817 for(int i = 0; keyMap[i].keycode != 0; i++) {
809 818 if (k->key() == keyMap[i].keycode) {
810 if ( (ke == 'a') || (ke == 'b') || (ke == 'c') || (ke == 'd')
811 || (ke == 'e') || (ke == 'f') || (ke == 'g') || (ke == 'h')
812 || (ke == 'i') || (ke == 'j') || (ke == 'k') || (ke == 'l')
813 || (ke == 'm') || (ke == 'n') || (ke == 'o') || (ke == 'p')
814 || (ke == 'q') || (ke == 'r') || (ke == 's') || (ke == 't')
815 || (ke == 'u') || (ke == 'v') ||( ke == 'w') || (ke == 'x')
816 || (ke == 'y') || (ke == 'z') ) {
817 ke = k->key();
818 ke = ke + 0x20;
819 return ke;
820 }
821
822 // qkeydefs = xkeydefs! :-)
823 if ( ( k->key() >= 0x0a0 ) && k->key() <= 0x0ff )
824 return k->key();
825
826 if ( ( k->key() >= 0x20 ) && ( k->key() <= 0x7e ) )
827 return k->key();
828
829 // qkeydefs != xkeydefs! :-(
830 // This is gonna suck :-(
831
832 int i = 0;
833 while ( keyMap[i].keycode ) {
834 if ( k->key() == keyMap[i].keycode )
835 return keyMap[i].keysym; 819 return keyMap[i].keysym;
836 i++;
837 } 820 }
838 821 }
839 return 0;
840} 822}
841 823
824 //
825 // If these keys aren't matched, return the ascii code and let the
826 // server figure it out. We don't return k->key(), as the data in
827 // key differs between input methods, and we don't want special cases.
828 //
829 return k->ascii();
830}