[vlc-devel] [PATCH] Changed to work on other keyboard layouts

Cristian Militaru cristipiticul at gmail.com
Thu Jan 5 17:59:00 CET 2012


From: Cristian Militaru <cristipiticul at yahoo.com>

---
 modules/gui/qt4/util/customwidgets.cpp   |   16 ++++-
 modules/gui/qt4/util/keysFromScanCodes.h |  111 ++++++++++++++++++++++++++++++
 po/fr.po                                 |   37 +++++-----
 3 files changed, 144 insertions(+), 20 deletions(-)
 create mode 100644 modules/gui/qt4/util/keysFromScanCodes.h

diff --git a/modules/gui/qt4/util/customwidgets.cpp b/modules/gui/qt4/util/customwidgets.cpp
index 16c6563..37a00b7 100644
--- a/modules/gui/qt4/util/customwidgets.cpp
+++ b/modules/gui/qt4/util/customwidgets.cpp
@@ -28,8 +28,12 @@
 # include "config.h"
 #endif
 
+int keyFromScanCode[255];
+bool keysInitiated = false;
+
 #include "customwidgets.hpp"
 #include "qt4.hpp"               /* needed for qtr,  but not necessary */
+#include "keysFromScanCodes.h"
 
 #include <QPainter>
 #include <QRect>
@@ -247,9 +251,19 @@ static int keycmp( const void *a, const void *b )
 
 int qtEventToVLCKey( QKeyEvent *e )
 {
+    if(!keysInitiated)
+    {
+         initKeysFromScanCodes();
+         keysInitiated = true;
+    }
     int qtk = e->key();
+    int scanCode = e->nativeScanCode();
     uint32_t i_vlck = 0;
-
+    if( ((scanCode >= 24 && scanCode <= 35) || (scanCode >= 38 && scanCode <= 48) || (scanCode >= 52 && scanCode <= 61)) && qtk > 0xff)
+    {
+        //if a letter key is pressed but the code isn't ASCII
+        qtk = keyFromScanCode[scanCode];
+    } 
     if( qtk <= 0xff )
     {
         /* VLC and X11 use lowercase whereas Qt uses uppercase, this
diff --git a/modules/gui/qt4/util/keysFromScanCodes.h b/modules/gui/qt4/util/keysFromScanCodes.h
new file mode 100644
index 0000000..493b2cc
--- /dev/null
+++ b/modules/gui/qt4/util/keysFromScanCodes.h
@@ -0,0 +1,111 @@
+void initKeysFromScanCodes()
+{
+       //memset(keyFromScanCode, 0, sizeof(int[255]));
+       keyFromScanCode[9] = 16777216;	//Escape
+
+       keyFromScanCode[68] = 16777265;	//F2
+       keyFromScanCode[69] = 16777266;	//F3
+       keyFromScanCode[70] = 16777267;	//F4
+       keyFromScanCode[71] = 16777268;	//F5
+       keyFromScanCode[72] = 16777269;	//F6
+       keyFromScanCode[73] = 16777270;	//F7
+       keyFromScanCode[74] = 16777271;	//F8
+       keyFromScanCode[75] = 16777272;	//F9
+       keyFromScanCode[76] = 16777273;	//F10
+       keyFromScanCode[96] = 16777275;	//F12
+
+       keyFromScanCode[49] = 96;	       //`
+       keyFromScanCode[10] = 49;	       //1
+       keyFromScanCode[11] = 50;	       //2
+       keyFromScanCode[12] = 51;	       //3
+       keyFromScanCode[13] = 52;	       //4
+       keyFromScanCode[14] = 53;	       //5
+       keyFromScanCode[15] = 54;	       //6
+       keyFromScanCode[16] = 55;	       //7
+       keyFromScanCode[17] = 56;	       //8
+       keyFromScanCode[18] = 57;	       //9
+       keyFromScanCode[19] = 48;	       //0
+       keyFromScanCode[20] = 45;	       //-
+       keyFromScanCode[21] = 61;	       //=
+       keyFromScanCode[51] = 92;	       //\ 
+       //letters: 24-35
+       keyFromScanCode[24] = 81;	       //Q
+       keyFromScanCode[25] = 87;	       //W
+       keyFromScanCode[26] = 69;	       //E
+       keyFromScanCode[27] = 82;	       //R
+       keyFromScanCode[28] = 84;	       //T
+       keyFromScanCode[29] = 89;	       //Y
+       keyFromScanCode[30] = 85;	       //U
+       keyFromScanCode[31] = 73;	       //I
+       keyFromScanCode[32] = 79;	       //O
+       keyFromScanCode[33] = 80;	       //P
+       keyFromScanCode[34] = 91;	       //[
+       keyFromScanCode[35] = 93;	       //]
+       keyFromScanCode[36] = 16777220;	//Return
+       //letters: 38-48
+       keyFromScanCode[66] = 16777252;	//Caps Lock
+       keyFromScanCode[38] = 65;	       //A
+       keyFromScanCode[39] = 83;	       //S
+       keyFromScanCode[40] = 68;	       //D
+       keyFromScanCode[41] = 70;	       //F
+       keyFromScanCode[42] = 71;	       //G
+       keyFromScanCode[43] = 72;	       //H
+       keyFromScanCode[44] = 74;	       //J
+       keyFromScanCode[45] = 75;	       //K
+       keyFromScanCode[46] = 76;	       //L
+       keyFromScanCode[47] = 59;	       //;
+       keyFromScanCode[48] = 39;	       //'
+       //letters: 52-61
+       keyFromScanCode[50] = 16777248;	//LShift
+       keyFromScanCode[52] = 90;	       //Z
+       keyFromScanCode[53] = 88;	       //X
+       keyFromScanCode[54] = 67;	       //C
+       keyFromScanCode[55] = 86;	       //V
+       keyFromScanCode[56] = 66;	       //B
+       keyFromScanCode[57] = 78;	       //N
+       keyFromScanCode[58] = 77;	       //M
+       keyFromScanCode[59] = 44;	       //,
+       keyFromScanCode[60] = 46;	       //.
+       keyFromScanCode[61] = 47;	       ///
+       keyFromScanCode[62] = 16777248;	//RShift
+
+       keyFromScanCode[37] = 16777249;	//LCtrl
+       keyFromScanCode[64] = 16777251;	//LAlt
+       keyFromScanCode[65] = 32;	       //Space
+       keyFromScanCode[108] = 16777251;	//RAlt
+       keyFromScanCode[105] = 16777249;	//RCtrl
+
+       keyFromScanCode[113] = 16777234;	//Left  Arrow
+       keyFromScanCode[116] = 16777237;	//Down  Arrow
+       keyFromScanCode[114] = 16777236;	//Right Arrow
+       keyFromScanCode[111] = 16777235;	//Up    Arrow
+
+       keyFromScanCode[22] = 16777219;	//Backspace
+       keyFromScanCode[118] = 16777222;	//Insert
+       keyFromScanCode[110] = 16777232;	//Home
+       keyFromScanCode[112] = 16777238;	//Page Up
+       keyFromScanCode[119] = 16777223;	//Delete
+       keyFromScanCode[115] = 16777233;	//End
+       keyFromScanCode[117] = 16777239;	//Page Down
+
+       //NUM KEYS:
+
+       keyFromScanCode[77] = 16777253;    //%
+       keyFromScanCode[106] = 47;         ///
+       keyFromScanCode[63] = 42;          //*
+       keyFromScanCode[82] = 45;          //-
+       keyFromScanCode[86] = 43;          //+
+       keyFromScanCode[104] = 16777221;   //
+       keyFromScanCode[91] = 46;          //.
+       keyFromScanCode[90] = 48;          //0
+       keyFromScanCode[87] = 49;          //1
+       keyFromScanCode[88] = 50;          //2
+       keyFromScanCode[89] = 51;          //3
+       keyFromScanCode[83] = 52;          //4
+       keyFromScanCode[84] = 53;          //5
+       keyFromScanCode[85] = 54;          //6
+       keyFromScanCode[79] = 55;          //7
+       keyFromScanCode[80] = 56;          //8
+       keyFromScanCode[81] = 57;          //9
+}
+
diff --git a/po/fr.po b/po/fr.po
index f6e67a0..df4f7c6 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -30,7 +30,8 @@ msgid ""
 "see the file named COPYING for details.\n"
 "Written by the VideoLAN team; see the AUTHORS file.\n"
 msgstr ""
-"Ce programme est fourni SANS AUCUNE GARANTIE, tel qu'il est permis par la loi.\n"
+"Ce programme est fourni SANS AUCUNE GARANTIE, tel qu'il est permis par la "
+"loi.\n"
 "Vous pouvez le redistribuer selon les termes de la Licence Publique Générale "
 "GNU ;\n"
 "voir le fichier COPYING pour plus de détails.\n"
@@ -797,14 +798,14 @@ msgstr ""
 "raccourcis clavier principaux, lisez la page sur les <a href=\"http://wiki."
 "videolan.org/Hotkeys\">raccourcis</a>.</p><h3>Aide</h3><p>Avant de poser une "
 "question, référez vous d'abord à la <a href=\"http://wiki.videolan.org/"
-"Frequently_Asked_Questions\">FAQ</a>.</p><p>Vous pouvez ensuite demander "
-"(et apporter) de l'aide sur les <a href=\"http://forum.videolan.org"
-"\">Forums</a>, les <a href=\"http://www.videolan.org/vlc/lists.html\">listes "
-"de diffusion</a> ou notre cannal irc ( <a href=\"http://www.videolan.org/"
-"webirc/\"><em>#videolan</em></a> sur irc.freenode.net ).</p><h3>Contribuer "
-"au projet</h3><p>Vous pouvez aider le projet VideoLAN en donnant de votre "
-"temps pour aider la communauté, pour concevoir des interfaces, pour traduire "
-"la documentation, pour tester et pour coder. Vous pouvez aussi donner de "
+"Frequently_Asked_Questions\">FAQ</a>.</p><p>Vous pouvez ensuite demander (et "
+"apporter) de l'aide sur les <a href=\"http://forum.videolan.org\">Forums</"
+"a>, les <a href=\"http://www.videolan.org/vlc/lists.html\">listes de "
+"diffusion</a> ou notre cannal irc ( <a href=\"http://www.videolan.org/webirc/"
+"\"><em>#videolan</em></a> sur irc.freenode.net ).</p><h3>Contribuer au "
+"projet</h3><p>Vous pouvez aider le projet VideoLAN en donnant de votre temps "
+"pour aider la communauté, pour concevoir des interfaces, pour traduire la "
+"documentation, pour tester et pour coder. Vous pouvez aussi donner de "
 "l'argent ou du matériel pour nous aider. Et bien sûr, vous pouvez "
 "<b>promouvoir</b> le lecteur multimédia VLC.</p></body></html>"
 
@@ -1650,7 +1651,8 @@ msgid ""
 "The step size of the volume is adjustable using this option, in a range from "
 "0 to 1024."
 msgstr ""
-"Cette option permet de modifier le pas de réglage du volume audio, de 0 à 1024"
+"Cette option permet de modifier le pas de réglage du volume audio, de 0 à "
+"1024"
 
 #: src/libvlc-module.c:280
 msgid "Audio output frequency (Hz)"
@@ -18427,10 +18429,6 @@ msgstr " g                      Aller à l'élément courant"
 msgid " /                      Look for an item"
 msgstr " /                      Rechercher"
 
-#: modules/gui/ncurses.c:910
-msgid " ;                      Look for the next item"
-msgstr " ;                      Rechercher le prochain"
-
 #: modules/gui/ncurses.c:911
 msgid " A                      Add an entry"
 msgstr " A                      Ajouter"
@@ -18517,11 +18515,6 @@ msgstr " Source: <pas d'élément>"
 msgid " [ h for help ]"
 msgstr " [ h pour l'aide ]"
 
-#: modules/gui/ncurses.c:1136
-#, c-format
-msgid "Open: %s"
-msgstr "Ouvrir: %s"
-
 #: modules/gui/qt4/components/controller.cpp:339
 msgid "Shift+L"
 msgstr "Shift+L"
@@ -28268,6 +28261,12 @@ msgstr "Rafraîchir les flux"
 msgid "Enqueue"
 msgstr "Mettre à la file"
 
+#~ msgid " ;                      Look for the next item"
+#~ msgstr " ;                      Rechercher le prochain"
+
+#~ msgid "Open: %s"
+#~ msgstr "Ouvrir: %s"
+
 #~ msgid ""
 #~ "The specified sound font file (%s) is incorrect.\n"
 #~ "Please install a valid sound font and reconfigure it from the VLC "
-- 
1.7.5.4




More information about the vlc-devel mailing list