[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: font and keyboard problems



On Fri, 3 Nov 2000, Otto Klingesberger wrote:

> Hello,
> i have started testing rdesktop today, but i have two seroius
> problems:
> 
> 1) Text ist sometimes drawn with mirrored fonts but after
> a refresh, the drawing is correct.

I think I've seen this happen on a FreeBSD box using eXceed as an X
server, but not on a Linux box using XFree86, so it may be platform
specific.  What OS and X server are you using?

> 2) Keyboard input does not work. 
> I saw the commandline parameter 
>  -k: keyboard layout (hex) which is set to 0x409 in the
> source code.
> I dont think that the layout code ist the matter, because also
> the keys, which are similar on german and us keyboards,
> do not work. btw:what is the code for a german keyboard ?


The keyboard codes are all listed in the registry on the NT terminal
server:  look under
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Keyboard Layouts
using regedit.  It looks like German is 0x407

The keyboard support in the distributed version is rather lacking - non
of the extended keys work and the caps lock / num lock don't always work
properly.  I submitted a patch to this mailing list a couple of days ago
to fix this.  Since I don't think this list is archived anywhere I am
attaching it again.  This should hopefully make your whole keyboard work,
including the windows key and menu key!  If you find this makes your caps
lock and num lock keys work incorrectly then let me know and I'll send you
a slightly different patch that I have.

I've not yet seen any traffic on this list from the author.  Does anybody
know if he is still developing or otherwise engaged?  It would be usefull
to have this list and any patches submitted to archived on the web site. 

Regards,
Ben.

/   Ben McKeegan, I.T. Manager                                         \
\   Fitzwilliam College, University of Cambridge, UK.                  /

diff -u rdesktop-1.0.0.orig/constants.h rdesktop-1.0.0/constants.h
--- rdesktop-1.0.0.orig/constants.h	Mon Oct 16 09:44:47 2000
+++ rdesktop-1.0.0/constants.h	Thu Nov  2 10:47:03 2000
@@ -146,6 +146,7 @@
 
 /* Device flags */
 #define KBD_FLAG_RIGHT          0x0001
+#define KBD_FLAG_EXT            0x0100
 #define KBD_FLAG_QUIET          0x1000
 #define KBD_FLAG_DOWN           0x4000
 #define KBD_FLAG_UP             0x8000
diff -u rdesktop-1.0.0.orig/xwin.c rdesktop-1.0.0/xwin.c
--- rdesktop-1.0.0.orig/xwin.c	Mon Oct 16 09:44:48 2000
+++ rdesktop-1.0.0/xwin.c	Thu Nov  2 10:51:17 2000
@@ -19,6 +19,7 @@
 */
 
 #include <X11/Xlib.h>
+#include <X11/Xutil.h>
 #include <time.h>
 #include "rdesktop.h"
 
@@ -36,6 +37,7 @@
 {
 	Screen *screen;
 	XSetWindowAttributes attribs;
+        XSizeHints *sizehints;
 	unsigned long input_mask;
 	int i;
 
@@ -67,6 +69,13 @@
 			0, 0, width, height, 0, 8, InputOutput, visual,
 			CWBackingStore | CWBackPixel, &attribs);
 
+        sizehints = XAllocSizeHints();
+        if (sizehints) {
+          sizehints->flags=PPosition;
+          XSetWMNormalHints(display,wnd,sizehints);
+          XFree(sizehints);
+        }
+
 	XStoreName(display, wnd, title);
 	XMapWindow(display, wnd);
 
@@ -99,18 +108,47 @@
 
 	switch (key)
 	{
-		case 0x62: /* left arrow */
-			return 0x48;
-		case 0x64: /* up arrow */
-			return 0x4b;
-		case 0x66: /* down arrow */
-			return 0x4d;
-		case 0x68: /* right arrow */
-			return 0x50;
-		case 0x73: /* Windows key */
-			DEBUG("CHECKPOINT\n");
+	  case 0x61: /* home */
+	    return 0x47 | 0x80;
+	  case 0x62: /* up arrow */
+	    return 0x48 | 0x80;
+	  case 0x63: /* page up */
+	    return 0x49 | 0x80;
+	  case 0x64: /* left arrow */
+	    return 0x4b | 0x80;
+
+	  case 0x66: /* right arrow */
+	    return 0x4d | 0x80;
+	  case 0x67: /* end */
+	    return 0x4f | 0x80;
+	  case 0x68: /* down arrow */
+	    return 0x50 | 0x80;
+	  case 0x69: /* page down */
+	    return 0x51 | 0x80;
+	  case 0x6a: /* insert */
+	    return 0x52 | 0x80;
+	  case 0x6b: /* delete */
+	    return 0x53 | 0x80;
+	  case 0x6c: /* keypad enter */
+	    return 0x1c | 0x80;
+	  case 0x6d: /* right ctrl */
+	    return 0x1d | 0x80;
+	  case 0x6f: /* ctrl - print screen */
+	    return 0x37 | 0x80;
+	  case 0x70: /* keypad '/' */
+	    return 0x35 | 0x80;
+	  case 0x71: /* right alt */
+	    return 0x38 | 0x80;
+	  case 0x72: /* ctrl break */
+	    return 0x46 | 0x80;
+	  case 0x73: /* left window key */
+	    return 0xff; /* real scancode is 5b */
+	  case 0x74: /* right window key */
+	    return 0xff; /* real scancode is 5c */
+	  case 0x75: /* menu key */
+	    return 0x5d | 0x80;
 	}
-
+	
 	return 0;
 }
 
@@ -150,8 +188,29 @@
 				if (scancode == 0)
 					break;
 
-				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, 0,
+				if (scancode == 0xff) {
+				  /* Window keys equivalent to ctrl-esc */
+				  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
+						 0,0x1d, 0); /* ctrl down */
+				  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
+						 0,1, 0); /* esc down */
+				  break;
+				}
+
+				if (scancode & 0x80)
+				  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
+						 KBD_FLAG_EXT,
+						 scancode & 0x7f, 0);
+				else
+				  rdp_send_input(ev_time, RDP_INPUT_SCANCODE, 0,
+						 scancode, 0);
+
+				/* Handle caps lock and num lock */
+				if (scancode==0x3a || scancode==0x45)
+				  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
+						KBD_FLAG_DOWN | KBD_FLAG_UP,
 						scancode, 0);
+				  
 				break;
 
 			case KeyRelease:
@@ -159,9 +218,31 @@
 				if (scancode == 0)
 					break;
 
-				rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
-						KBD_FLAG_DOWN | KBD_FLAG_UP,
+				if (scancode == 0xff) {
+				  /* Window keys equivalent to ctrl-esc */
+				  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
+						 KBD_FLAG_DOWN | KBD_FLAG_UP,
+						 0x1, 0); /* esc up */
+				  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
+						 KBD_FLAG_DOWN | KBD_FLAG_UP,
+						 0x1d, 0); /* ctrl up */
+				  break;
+				}
+				  
+				/* Handle caps lock and num lock */
+				if (scancode==0x3a || scancode==0x45)
+				  rdp_send_input(ev_time, RDP_INPUT_SCANCODE, 0,
 						scancode, 0);
+				  
+				if (scancode & 0x80)
+				  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
+						 KBD_FLAG_EXT |
+						 KBD_FLAG_DOWN | KBD_FLAG_UP,
+						 scancode & 0x7f, 0);
+				else
+				  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
+						 KBD_FLAG_DOWN | KBD_FLAG_UP,
+						 scancode, 0);
 				break;
 
 			case ButtonPress: