qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [Patch] AltGr on vnc and adding extra keys with no compiling
@ 2007-08-23 22:09 Ricardo
  2007-08-26 17:43 ` Thiemo Seufer
  0 siblings, 1 reply; 4+ messages in thread
From: Ricardo @ 2007-08-23 22:09 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 916 bytes --]

Hi

On my keyboard Alt Gr is mapped to ISO_Level3_Shift. Using sdl it
worked fine without any modification, but using vnc I was unable to
use Alt Gr.
I added a line on /usr/share/keymaps/modifiers refering to my key:

ISO_Level3_Shift 0xb8

But, unfortunately it didn't work....

Surfing on the qemu code, I realized that the ISO_Level3_Shitf wasn't
declared on the vnc_keysym.h file. So I added this line to that file:

{"ISO_Level3_Shift", 0xfe03}, /* ISO_Level3

And finally Alt Gr worked!


I think that it should be a good idea to allow the user to add keysym
manually by number and name. Instead of just name. This will allow to
add keysyms with no qemu recompiling. this can be done very easilly.
Just modfying get_keysym on keymaps.c


I attach a pacth with this two improves.


         Regards and congratulations for a great program!


PS: Please CC me
-- 
Ricardo Ribalda
http://www.ii.uam.es/~rribalda/

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: vnc-keyboard.diff --]
[-- Type: text/x-patch; name="vnc-keyboard.diff", Size: 14970 bytes --]

--- qemu-old/keymaps/es	Sun Dec 12 18:56:30 2004
+++ qemu-new/keymaps/es	Tue Aug 08 23:41:55 2006
@@ -103,3 +103,58 @@
 underscore 0x35 shift
 dead_belowdot 0x35 altgr
 dead_abovedot 0x35 shift altgr
+
+
+# Dead keys
+aacute 0x1e dead_acute
+Aacute 0x1e dead_acute shift
+eacute 0x12 dead_acute
+Eacute 0x12 dead_acute shift
+iacute 0x17 dead_acute
+Iacute 0x17 dead_acute shift
+oacute 0x18 dead_acute
+Oacute 0x18 dead_acute shift
+uacute 0x16 dead_acute
+Uacute 0x16 dead_acute shift
+yacute 0x15 dead_acute
+Yacute 0x15 dead_acute shift
+
+agrave 0x1e dead_grave
+Agrave 0x1e dead_grave shift
+egrave 0x12 dead_grave
+Egrave 0x12 dead_grave shift
+igrave 0x17 dead_grave
+Igrave 0x17 dead_grave shift
+ograve 0x18 dead_grave
+Ograve 0x18 dead_grave shift
+ugrave 0x16 dead_grave
+Ugrave 0x16 dead_grave shift
+
+adiaeresis 0x1e dead_diaeresis
+Adiaeresis 0x1e dead_diaeresis shift
+ediaeresis 0x12 dead_diaeresis
+Ediaeresis 0x12 dead_diaeresis shift
+idiaeresis 0x17 dead_diaeresis
+Idiaeresis 0x17 dead_diaeresis shift
+odiaeresis 0x18 dead_diaeresis
+Odiaeresis 0x18 dead_diaeresis shift
+udiaeresis 0x16 dead_diaeresis
+Udiaeresis 0x16 dead_diaeresis shift
+ydiaeresis 0x15 dead_diaeresis
+
+acircumflex 0x1e dead_circumflex
+Acircumflex 0x1e dead_circumflex shift
+ecircumflex 0x12 dead_circumflex
+Ecircumflex 0x12 dead_circumflex shift
+icircumflex 0x17 dead_circumflex
+Icircumflex 0x17 dead_circumflex shift
+ocircumflex 0x18 dead_circumflex
+Ocircumflex 0x18 dead_circumflex shift
+ucircumflex 0x16 dead_circumflex
+Ucircumflex 0x16 dead_circumflex shift
+
+acute 0x39 dead_acute
+grave 0x39 dead_grave
+diaeresis 0x39 dead_diaeresis
+asciicircum 0x39 dead_circumflex
+
--- qemu-old/keymaps.c	Sun Apr 30 23:28:35 2006
+++ qemu-new/keymaps.c	Tue Aug 08 23:39:58 2006
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+
 static int get_keysym(const char *name)
 {
     name2keysym_t *p;
@@ -32,13 +33,26 @@
     return 0;
 }
 
+
+#define KEYMOD_SHIFT 0x01
+#define KEYMOD_CTRL  0x02
+#define KEYMOD_ALT   0x04
+#define KEYMOD_DEAD  0x08
+
 #define MAX_NORMAL_KEYCODE 512
 #define MAX_EXTRA_COUNT 256
+
 typedef struct {
-    uint16_t keysym2keycode[MAX_NORMAL_KEYCODE];
+    uint16_t keycode;
+    uint8_t keymod;
+    int deadsym;
+} keydata_t;
+
+typedef struct {
+    keydata_t keysym2keycode[MAX_NORMAL_KEYCODE];
     struct {
 	int keysym;
-	uint16_t keycode;
+        keydata_t kdata;
     } keysym2keycode_extra[MAX_EXTRA_COUNT];
     int extra_count;
 } kbd_layout_t;
@@ -50,6 +64,7 @@
     char file_name[1024];
     char line[1024];
     int len;
+    int upper;
 
     snprintf(file_name, sizeof(file_name),
              "%s/keymaps/%s", bios_dir, language);
@@ -82,17 +97,61 @@
 	    if (*end_of_keysym) {
 		int keysym;
 		*end_of_keysym = 0;
+                uint8_t keymod;
+                int deadsym;
+                
+                keymod = 0;
+                deadsym = 0;
+                upper = 0;
+redo:
+                if (upper==1){
+                    char *c;
+                    for(c=line;*c;c++)
+                        *c=toupper(*c);
+                    keymod |= KEYMOD_SHIFT;
+                    upper++;
+                }
 		keysym = get_keysym(line);
 		if (keysym == 0) {
                     //		    fprintf(stderr, "Warning: unknown keysym %s\n", line);
 		} else {
 		    const char *rest = end_of_keysym + 1;
 		    int keycode = strtol(rest, NULL, 0);
+                    char *modifier;
+                    modifier = strtok (rest," ");
+                    modifier = strtok (NULL," ");
+                    while ( modifier != NULL) {
+                        if (!strcmp(modifier, "shift")) {
+                            keymod |= KEYMOD_SHIFT;
+                        } else
+                        if (!strcmp(modifier, "addupper")) {
+                            upper++;
+                        } else
+                        if (!strcmp(modifier, "ctrl")) {
+                            keymod |= KEYMOD_CTRL;
+                        } else
+                        if (!strcmp(modifier, "alt")) {
+                            keymod |= KEYMOD_ALT;
+                        } else
+                        if (!strcmp(modifier, "altgr")) {
+                            keymod |= KEYMOD_CTRL | KEYMOD_ALT;
+                        } else
+                        if (!strncmp(modifier, "dead_",5)) {
+                            keymod |= KEYMOD_DEAD;
+                            deadsym = get_keysym(modifier);
+                        } 
+                        modifier = strtok (NULL," ");
+                    }
 		    /* if(keycode&0x80)
 		       keycode=(keycode<<8)^0x80e0; */
 		    if (keysym < MAX_NORMAL_KEYCODE) {
 			//fprintf(stderr,"Setting keysym %s (%d) to %d\n",line,keysym,keycode);
-			k->keysym2keycode[keysym] = keycode;
+                        k->keysym2keycode[keysym].
+                            keycode = keycode;
+                        k->keysym2keycode[keysym].
+                            keymod = keymod;
+                        k->keysym2keycode[keysym].
+                            deadsym = deadsym;
 		    } else {
 			if (k->extra_count >= MAX_EXTRA_COUNT) {
 			    fprintf(stderr,
@@ -105,11 +164,18 @@
 #endif
 			    k->keysym2keycode_extra[k->extra_count].
 				keysym = keysym;
-			    k->keysym2keycode_extra[k->extra_count].
+                            k->keysym2keycode_extra[k->extra_count].kdata.
 				keycode = keycode;
+                            k->keysym2keycode_extra[k->extra_count].kdata.
+                                keymod = keymod;
+                            k->keysym2keycode_extra[k->extra_count].kdata.
+                                deadsym = deadsym;
+                
 			    k->extra_count++;
 			}
 		    }
+                    if (upper==1)
+                        goto redo;
 		}
 	    }
 	}
@@ -123,14 +189,11 @@
     return parse_keyboard_layout(language, 0);
 }
 
-static int keysym2scancode(void *kbd_layout, int keysym)
+static keydata_t *find_keysym(void *kbd_layout, int keysym)
 {
     kbd_layout_t *k = kbd_layout;
     if (keysym < MAX_NORMAL_KEYCODE) {
-	if (k->keysym2keycode[keysym] == 0)
-	    fprintf(stderr, "Warning: no scancode found for keysym %d\n",
-		    keysym);
-	return k->keysym2keycode[keysym];
+        return &k->keysym2keycode[keysym];
     } else {
 	int i;
 #ifdef XK_ISO_Left_Tab
@@ -138,8 +201,9 @@
 	    keysym = XK_Tab;
 #endif
 	for (i = 0; i < k->extra_count; i++)
-	    if (k->keysym2keycode_extra[i].keysym == keysym)
-		return k->keysym2keycode_extra[i].keycode;
+            if (k->keysym2keycode_extra[i].keysym == keysym) {
+                return &k->keysym2keycode_extra[i].kdata;
     }
-    return 0;
+    }
+    return NULL;
 }
--- qemu-old/sdl.c	Tue Jun 13 14:03:53 2006
+++ qemu-new/sdl.c	Tue Aug 08 23:40:08 2006
@@ -104,7 +104,11 @@
     keysym = ev->keysym.sym;
     if (keysym == 0 && ev->keysym.scancode == 113)
         keysym = SDLK_MODE;
-    return keysym2scancode(kbd_layout, keysym);
+    keydata_t *eventdata = find_keysym(kbd_layout, keysym);
+    if (eventdata==NULL)
+        return 0;
+    else
+        return eventdata->keycode;
 }
 
 /* specific keyboard conversions from scan codes */
--- qemu-old/vnc.c	Tue Jun 13 18:35:24 2006
+++ qemu-new/vnc.c	Tue Aug 08 23:41:37 2006
@@ -31,6 +31,23 @@
 #include "vnc_keysym.h"
 #include "keymaps.c"
 
+
+static uint8_t modifiers_state[2][256];
+
+typedef struct {
+    int left;
+    int right;
+    int bit;
+} modifier_t;
+
+static modifier_t test_modifier[]={
+    {0x2a,  0x36,   KEYMOD_SHIFT},
+    {0x1d,  0x9d,   KEYMOD_CTRL},
+    {0x38,  0xb8,   KEYMOD_ALT},
+    {0,0,0},
+};
+
+
 typedef struct Buffer
 {
     size_t capacity;
@@ -699,12 +716,9 @@
     }
 }
 
-static void do_key_event(VncState *vs, int down, uint32_t sym)
-{
-    int keycode;
-
-    keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
 
+static void do_keycode(int keycode, int down)
+{
     if (keycode & 0x80)
 	kbd_put_keycode(0xe0);
     if (down)
@@ -713,11 +727,88 @@
 	kbd_put_keycode(keycode | 0x80);
 }
 
+static void do_modifier(int keycode, int down, int level)
+{
+    do_keycode(keycode,down);
+    modifiers_state[level][keycode] = down;
+    if (level==0) {
+        modifiers_state[1][keycode] = down;
+    }
+}
+
+static void set_modifiers(uint8_t reqstate,int down,int full)
+{
+    modifier_t *m;
+    for(m=test_modifier; m->bit; m++) {
+        int requested = reqstate & m->bit;
+        /* Release unwanted modifiers */
+        if (!down || full) {
+            if (modifiers_state[1][m->left] && !requested)
+                do_modifier(m->left,0,1);
+            if (modifiers_state[1][m->right] && !requested)
+                do_modifier(m->right,0,1);
+        }
+        /* Press desired modifiers */
+        if (down || full) {
+            int already_set = modifiers_state[1][m->left] | modifiers_state[1][m->right];
+            if (!already_set && requested)
+                do_modifier(m->left,1,1);
+        }
+    }
+}
+
+static void restore_modifiers()
+{
+    /* Restore modifiers from reference */
+    modifier_t *m;
+    for(m=test_modifier; m->bit; m++) {
+        if (modifiers_state[0][m->left] != modifiers_state[1][m->left])
+            do_modifier(m->left,modifiers_state[0][m->left],0);
+        if (modifiers_state[0][m->right] != modifiers_state[1][m->right])
+            do_modifier(m->right,modifiers_state[0][m->right],0);
+    }    
+}
+
 static void key_event(VncState *vs, int down, uint32_t sym)
 {
-    if (sym >= 'A' && sym <= 'Z')
-	sym = sym - 'A' + 'a';
-    do_key_event(vs, down, sym);
+    keydata_t *eventdata;
+    eventdata = find_keysym(vs->kbd_layout, sym & 0xFFFF);
+    if (eventdata==NULL)
+        return;
+    switch(eventdata->keycode) {
+    case 0x2a:                          /* Left Shift */
+    case 0x36:                          /* Right Shift */
+    case 0x1d:                          /* Left CTRL */
+    case 0x9d:                          /* Right CTRL */
+    case 0x38:                          /* Left ALT */
+    case 0xb8:                          /* Right ALT */
+        do_modifier(eventdata->keycode, down, 0);
+        return;
+    case 0x3a: /* caps lock */
+        /* TODO: handle properly caps lock + shift combinations */
+        return;
+        break;
+    }
+
+    if (down) {
+        /* Send deadkey */
+        if (eventdata->keymod & KEYMOD_DEAD) {
+            keydata_t *deaddata;
+            deaddata = find_keysym(vs->kbd_layout, eventdata->deadsym);
+            if (deaddata!=NULL) {
+                set_modifiers(deaddata->keymod,0,1);
+                do_keycode(deaddata->keycode,1);
+                do_keycode(deaddata->keycode,0);
+                restore_modifiers();
+            }
+        }
+        set_modifiers(eventdata->keymod,1,0);
+    }
+
+    do_keycode(eventdata->keycode,down);
+        
+    if (!down)
+        restore_modifiers();
 }
 
 static void framebuffer_update_request(VncState *vs, int incremental,
--- qemu-old/vnc_keysym.h	Sun Apr 30 23:28:36 2006
+++ qemu-new/vnc_keysym.h	Tue Aug 08 23:39:35 2006
@@ -247,6 +247,33 @@
 {"F14", 0xffcb},       /* XK_F14 */
 {"F15", 0xffcc},       /* XK_F15 */
 {"Sys_Req", 0xff15},   /* XK_Sys_Req */
+{"KP_Space", 0xff80},      /* XK_KP_Space */
+{"KP_Tab", 0xff89},        /* XK_KP_Tab */
+{"KP_Enter", 0xff8d},      /* XK_KP_Enter */
+{"KP_F1", 0xff91},         /* XK_KP_F1 */
+{"KP_F2", 0xff92},         /* XK_KP_F2 */
+{"KP_F3", 0xff93},         /* XK_KP_F3 */
+{"KP_F4", 0xff94},         /* XK_KP_F4 */
+{"KP_Home", 0xff95},       /* XK_KP_Home */
+{"KP_Left", 0xff96},       /* XK_KP_Left */
+{"KP_Up", 0xff97},         /* XK_KP_Up */
+{"KP_Right", 0xff98},      /* XK_KP_Right */
+{"KP_Down", 0xff99},       /* XK_KP_Down */
+{"KP_Prior", 0xff9a},      /* XK_KP_Prior */
+{"KP_Page_Up", 0xff9a},    /* XK_KP_Page_Up */
+{"KP_Next", 0xff9b},       /* XK_KP_Next */
+{"KP_Page_Down", 0xff9b},  /* XK_KP_Page_Down */
+{"KP_End", 0xff9c},        /* XK_KP_End */
+{"KP_Begin", 0xff9d},      /* XK_KP_Begin */
+{"KP_Insert", 0xff9e},     /* XK_KP_Insert */
+{"KP_Delete", 0xff9f},     /* XK_KP_Delete */
+{"KP_Equal", 0xffbd},      /* XK_KP_Equal */
+{"KP_Multiply", 0xffaa},   /* XK_KP_Multiply */
+{"KP_Add", 0xffab},        /* XK_KP_Add */
+{"KP_Separator", 0xffac},  /* XK_KP_Separator */
+{"KP_Subtract", 0xffad},   /* XK_KP_Subtract */
+{"KP_Decimal", 0xffae},    /* XK_KP_Decimal */
+{"KP_Divide", 0xffaf},     /* XK_KP_Divide */
 {"KP_0", 0xffb0},      /* XK_KP_0 */
 {"KP_1", 0xffb1},      /* XK_KP_1 */
 {"KP_2", 0xffb2},      /* XK_KP_2 */
@@ -257,13 +284,6 @@
 {"KP_7", 0xffb7},      /* XK_KP_7 */
 {"KP_8", 0xffb8},      /* XK_KP_8 */
 {"KP_9", 0xffb9},      /* XK_KP_9 */
-{"KP_Add", 0xffab},    /* XK_KP_Add */
-{"KP_Decimal", 0xffae},  /* XK_KP_Decimal */
-{"KP_Divide", 0xffaf},   /* XK_KP_Divide */
-{"KP_Enter", 0xff8d},    /* XK_KP_Enter */
-{"KP_Equal", 0xffbd},    /* XK_KP_Equal */
-{"KP_Multiply", 0xffaa}, /* XK_KP_Multiply */
-{"KP_Subtract", 0xffad}, /* XK_KP_Subtract */
 {"help", 0xff6a},        /* XK_Help */
 {"Menu", 0xff67},        /* XK_Menu */
 {"Print", 0xff61},       /* XK_Print */
@@ -271,5 +291,27 @@
 {"Num_Lock", 0xff7f},    /* XK_Num_Lock */
 {"Pause", 0xff13},       /* XK_Pause */
 {"Escape", 0xff1b},      /* XK_Escape */
+
+/* dead keys */
+{"dead_grave", 0xfe50},               /* XK_dead_grave */
+{"dead_acute", 0xfe51},               /* XK_dead_acute */
+{"dead_circumflex", 0xfe52},          /* XK_dead_circumflex */
+{"dead_tilde", 0xfe53},               /* XK_dead_tilde */
+{"dead_macron", 0xfe54},              /* XK_dead_macron */
+{"dead_breve", 0xfe55},               /* XK_dead_breve */
+{"dead_abovedot", 0xfe56},            /* XK_dead_abovedot */
+{"dead_diaeresis", 0xfe57},           /* XK_dead_diaeresis */
+{"dead_abovering", 0xfe58},           /* XK_dead_abovering */
+{"dead_doubleacute", 0xfe59},         /* XK_dead_doubleacute */
+{"dead_caron", 0xfe5a},               /* XK_dead_caron */
+{"dead_cedilla", 0xfe5b},             /* XK_dead_cedilla */
+{"dead_ogonek", 0xfe5c},              /* XK_dead_ogonek */
+{"dead_iota", 0xfe5d},                /* XK_dead_iota */
+{"dead_voiced_sound", 0xfe5e},        /* XK_dead_voiced_sound */
+{"dead_semivoiced_sound", 0xfe5f},    /* XK_dead_semivoiced_sound */
+{"dead_belowdot", 0xfe60},            /* XK_dead_belowdot */
+{"dead_hook", 0xfe61},                /* XK_dead_hook */
+{"dead_horn", 0xfe62},                /* XK_dead_horn */
+
 {0,0},
 };

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [Patch] AltGr on vnc and adding extra keys with no compiling
  2007-08-23 22:09 [Qemu-devel] [Patch] AltGr on vnc and adding extra keys with no compiling Ricardo
@ 2007-08-26 17:43 ` Thiemo Seufer
  2007-08-27 19:19   ` Ricardo
  0 siblings, 1 reply; 4+ messages in thread
From: Thiemo Seufer @ 2007-08-26 17:43 UTC (permalink / raw)
  To: Ricardo; +Cc: qemu-devel

Ricardo wrote:
> Hi
> 
> On my keyboard Alt Gr is mapped to ISO_Level3_Shift. Using sdl it
> worked fine without any modification, but using vnc I was unable to
> use Alt Gr.
> I added a line on /usr/share/keymaps/modifiers refering to my key:
> 
> ISO_Level3_Shift 0xb8
> 
> But, unfortunately it didn't work....
> 
> Surfing on the qemu code, I realized that the ISO_Level3_Shitf wasn't
> declared on the vnc_keysym.h file. So I added this line to that file:
> 
> {"ISO_Level3_Shift", 0xfe03}, /* ISO_Level3
> 
> And finally Alt Gr worked!
> 
> 
> I think that it should be a good idea to allow the user to add keysym
> manually by number and name. Instead of just name. This will allow to
> add keysyms with no qemu recompiling. this can be done very easilly.
> Just modfying get_keysym on keymaps.c
> 
> 
> I attach a pacth with this two improves.

Thanks. Please update it for current CVS and resend.


Thiemo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [Patch] AltGr on vnc and adding extra keys with no compiling
  2007-08-26 17:43 ` Thiemo Seufer
@ 2007-08-27 19:19   ` Ricardo
  2007-08-28  4:28     ` Ricardo
  0 siblings, 1 reply; 4+ messages in thread
From: Ricardo @ 2007-08-27 19:19 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1718 bytes --]

Hi

  I attach the new patch. PLEASE REMOVE THE OLD ONE!!!, I sent a
completely wrong file :S (sorry).

  I have downloaded de cvs version and patched with this new file, wich solves:

  a) ISO_Level_3 is now correctly reconized as alt gr on vnc mode
  b) User can add its own keysym by number
  c) My sdl library gives two events for cap lock (press and release).
Now it is recognized correctly
  d) Some minor changes in order to compile correctly the program

  Everything has been tested with DOS 7.2 as target.


   Sorry again for the first mistake and congratulations again for a
GREAT program


               Regards

ps: please cc me
On 8/26/07, Thiemo Seufer <ths@networkno.de> wrote:
> Ricardo wrote:
> > Hi
> >
> > On my keyboard Alt Gr is mapped to ISO_Level3_Shift. Using sdl it
> > worked fine without any modification, but using vnc I was unable to
> > use Alt Gr.
> > I added a line on /usr/share/keymaps/modifiers refering to my key:
> >
> > ISO_Level3_Shift 0xb8
> >
> > But, unfortunately it didn't work....
> >
> > Surfing on the qemu code, I realized that the ISO_Level3_Shitf wasn't
> > declared on the vnc_keysym.h file. So I added this line to that file:
> >
> > {"ISO_Level3_Shift", 0xfe03}, /* ISO_Level3
> >
> > And finally Alt Gr worked!
> >
> >
> > I think that it should be a good idea to allow the user to add keysym
> > manually by number and name. Instead of just name. This will allow to
> > add keysyms with no qemu recompiling. this can be done very easilly.
> > Just modfying get_keysym on keymaps.c
> >
> >
> > I attach a pacth with this two improves.
>
> Thanks. Please update it for current CVS and resend.
>
>
> Thiemo
>


-- 
Ricardo Ribalda
http://www.ii.uam.es/~rribalda/

[-- Attachment #2: altgr-capslock-numkeysym.patch --]
[-- Type: text/x-patch, Size: 1448 bytes --]

Index: keymaps.c
===================================================================
RCS file: /sources/qemu/qemu/keymaps.c,v
retrieving revision 1.2
diff -r1.2 keymaps.c
26a27
>     unsigned int keysym;
27a29,34
>    
>     //User numerical added keysyms
>     if (1==sscanf(name,"0x%x",&keysym))
>             return keysym;
>     
>     //Normal ones
Index: sdl.c
===================================================================
RCS file: /sources/qemu/qemu/sdl.c,v
retrieving revision 1.42
diff -r1.42 sdl.c
204,206c204,206
<         /* SDL does not send the key up event, so we generate it */
<         kbd_put_keycode(keycode);
<         kbd_put_keycode(keycode | 0x80);
---
>     	if (ev->type == SDL_KEYUP)
> 		kbd_put_keycode(keycode | 0x80);
> 	else kbd_put_keycode(keycode);	
Index: vnc_keysym.h
===================================================================
RCS file: /sources/qemu/qemu/vnc_keysym.h,v
retrieving revision 1.2
diff -r1.2 vnc_keysym.h
217a218
> {"ISO_Level3_Shift", 0xfe03}, /* ISO_Level3
Index: keymaps/es
===================================================================
RCS file: /sources/qemu/qemu/keymaps/es,v
retrieving revision 1.1
diff -r1.1 es
73a74,75
> 0xfff1 0x27
> 0xffd1 0x27 shift
Index: keymaps/modifiers
===================================================================
RCS file: /sources/qemu/qemu/keymaps/modifiers,v
retrieving revision 1.2
diff -r1.2 modifiers
5a6
> ISO_Level3_Shift 0xb8

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [Patch] AltGr on vnc and adding extra keys with no compiling
  2007-08-27 19:19   ` Ricardo
@ 2007-08-28  4:28     ` Ricardo
  0 siblings, 0 replies; 4+ messages in thread
From: Ricardo @ 2007-08-28  4:28 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2144 bytes --]

Hi all

   I find out that in DOS some programs didn't handle correctly the
extended keyboard. Attach you will find a new patch with the bugs
solved on the previous patch + this new bug.


   Regards

On 8/27/07, Ricardo <ricardo.ribalda@gmail.com> wrote:
> Hi
>
>   I attach the new patch. PLEASE REMOVE THE OLD ONE!!!, I sent a
> completely wrong file :S (sorry).
>
>   I have downloaded de cvs version and patched with this new file, wich solves:
>
>   a) ISO_Level_3 is now correctly reconized as alt gr on vnc mode
>   b) User can add its own keysym by number
>   c) My sdl library gives two events for cap lock (press and release).
> Now it is recognized correctly
>   d) Some minor changes in order to compile correctly the program
>
>   Everything has been tested with DOS 7.2 as target.
>
>
>    Sorry again for the first mistake and congratulations again for a
> GREAT program
>
>
>                Regards
>
> ps: please cc me
> On 8/26/07, Thiemo Seufer <ths@networkno.de> wrote:
> > Ricardo wrote:
> > > Hi
> > >
> > > On my keyboard Alt Gr is mapped to ISO_Level3_Shift. Using sdl it
> > > worked fine without any modification, but using vnc I was unable to
> > > use Alt Gr.
> > > I added a line on /usr/share/keymaps/modifiers refering to my key:
> > >
> > > ISO_Level3_Shift 0xb8
> > >
> > > But, unfortunately it didn't work....
> > >
> > > Surfing on the qemu code, I realized that the ISO_Level3_Shitf wasn't
> > > declared on the vnc_keysym.h file. So I added this line to that file:
> > >
> > > {"ISO_Level3_Shift", 0xfe03}, /* ISO_Level3
> > >
> > > And finally Alt Gr worked!
> > >
> > >
> > > I think that it should be a good idea to allow the user to add keysym
> > > manually by number and name. Instead of just name. This will allow to
> > > add keysyms with no qemu recompiling. this can be done very easilly.
> > > Just modfying get_keysym on keymaps.c
> > >
> > >
> > > I attach a pacth with this two improves.
> >
> > Thanks. Please update it for current CVS and resend.
> >
> >
> > Thiemo
> >
>
>
> --
> Ricardo Ribalda
> http://www.ii.uam.es/~rribalda/
>
>


-- 
Ricardo Ribalda
http://www.ii.uam.es/~rribalda/

[-- Attachment #2: altgr-capslock-numkeysym-extendedkb.dff --]
[-- Type: application/octet-stream, Size: 3659 bytes --]

? backup-082720072326-pre-qemu.tgz
? description-pak
? doc-pak
? qemu_20070827-1_i386.deb
Index: keymaps.c
===================================================================
RCS file: /sources/qemu/qemu/keymaps.c,v
retrieving revision 1.2
diff -u -r1.2 keymaps.c
--- keymaps.c	30 Apr 2006 21:28:35 -0000	1.2
+++ keymaps.c	28 Aug 2007 04:08:17 -0000
@@ -24,7 +24,14 @@
 
 static int get_keysym(const char *name)
 {
+    unsigned int keysym;
     name2keysym_t *p;
+   
+    //User numerical added keysyms
+    if (1==sscanf(name,"0x%x",&keysym))
+            return keysym;
+    
+    //Normal ones
     for(p = name2keysym; p->name != NULL; p++) {
         if (!strcmp(p->name, name))
             return p->keysym;
Index: sdl.c
===================================================================
RCS file: /sources/qemu/qemu/sdl.c,v
retrieving revision 1.42
diff -u -r1.42 sdl.c
--- sdl.c	21 Jun 2007 21:08:02 -0000	1.42
+++ sdl.c	28 Aug 2007 04:09:19 -0000
@@ -201,9 +201,9 @@
         break;
     case 0x45: /* num lock */
     case 0x3a: /* caps lock */
-        /* SDL does not send the key up event, so we generate it */
-        kbd_put_keycode(keycode);
-        kbd_put_keycode(keycode | 0x80);
+    	if (ev->type == SDL_KEYUP)
+		kbd_put_keycode(keycode | 0x80);
+	else kbd_put_keycode(keycode);	
         return;
     }
 
Index: vnc_keysym.h
===================================================================
RCS file: /sources/qemu/qemu/vnc_keysym.h,v
retrieving revision 1.2
diff -u -r1.2 vnc_keysym.h
--- vnc_keysym.h	7 Jan 2007 17:12:41 -0000	1.2
+++ vnc_keysym.h	28 Aug 2007 04:10:12 -0000
@@ -215,6 +215,7 @@
 {"Shift_R", 0xffe2},   /* XK_Shift_R */
 {"Super_L", 0xffeb},   /* XK_Super_L */
 {"Super_R", 0xffec},   /* XK_Super_R */
+{"ISO_Level3_Shift", 0xfe03}, /* ISO_Level3
 
     /* special keys */
 {"BackSpace", 0xff08}, /* XK_BackSpace */
Index: hw/ps2.c
===================================================================
RCS file: /sources/qemu/qemu/hw/ps2.c,v
retrieving revision 1.6
diff -u -r1.6 ps2.c
--- hw/ps2.c	20 Mar 2007 16:45:27 -0000	1.6
+++ hw/ps2.c	28 Aug 2007 04:12:48 -0000
@@ -146,17 +146,24 @@
     PS2State *s = (PS2State *)opaque;
     PS2Queue *q;
     int val, index;
+    static int flag=0;
     
     q = &s->queue;
     if (q->count == 0) {
+	if (!flag){
+	   index=q->rptr - 1;
+	   flag=1;
+	}
+	else index=q->rptr - 2;
         /* NOTE: if no data left, we return the last keyboard one
            (needed for EMM386) */
         /* XXX: need a timer to do things correctly */
-        index = q->rptr - 1;
         if (index < 0)
-            index = PS2_QUEUE_SIZE - 1;
+            index += PS2_QUEUE_SIZE;
+
         val = q->data[index];
     } else {
+	flag=0;
         val = q->data[q->rptr];
         if (++q->rptr == PS2_QUEUE_SIZE)
             q->rptr = 0;
Index: keymaps/es
===================================================================
RCS file: /sources/qemu/qemu/keymaps/es,v
retrieving revision 1.1
diff -u -r1.1 es
--- keymaps/es	12 Dec 2004 16:56:30 -0000	1.1
+++ keymaps/es	28 Aug 2007 04:13:57 -0000
@@ -71,6 +71,8 @@
 Lstroke 0x26 shift altgr
 ntilde 0x27
 Ntilde 0x27 shift
+0xfff1 0x27
+0xffd1 0x27 shift
 dead_doubleacute 0x27 shift altgr
 dead_acute 0x28
 dead_diaeresis 0x28 shift
Index: keymaps/modifiers
===================================================================
RCS file: /sources/qemu/qemu/keymaps/modifiers,v
retrieving revision 1.2
diff -u -r1.2 modifiers
--- keymaps/modifiers	1 Mar 2005 21:43:42 -0000	1.2
+++ keymaps/modifiers	28 Aug 2007 04:13:59 -0000
@@ -3,6 +3,7 @@
 
 Alt_R 0xb8
 Mode_switch 0xb8
+ISO_Level3_Shift 0xb8
 Alt_L 0x38
 
 Control_R 0x9d

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-08-28  4:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-23 22:09 [Qemu-devel] [Patch] AltGr on vnc and adding extra keys with no compiling Ricardo
2007-08-26 17:43 ` Thiemo Seufer
2007-08-27 19:19   ` Ricardo
2007-08-28  4:28     ` Ricardo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).