Commit b2865b4f authored by dscho's avatar dscho

KBDDEBUG

parent 49bfc728
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <sys/shm.h> #include <sys/shm.h>
#endif #endif
#define KEYSYM_H #define KEYSYM_H
#undef Bool
#define KeySym RFBKeySym
#include "rfb.h" #include "rfb.h"
Display *dpy = 0; Display *dpy = 0;
...@@ -24,6 +26,7 @@ Bool sharedMode = FALSE; ...@@ -24,6 +26,7 @@ Bool sharedMode = FALSE;
Bool disconnectAfterFirstClient = TRUE; Bool disconnectAfterFirstClient = TRUE;
/* keyboard handling */ /* keyboard handling */
#define KBDDEBUG
char modifiers[0x100]; char modifiers[0x100];
KeyCode keycodes[0x100],leftShiftCode,rightShiftCode,altGrCode; KeyCode keycodes[0x100],leftShiftCode,rightShiftCode,altGrCode;
...@@ -38,12 +41,23 @@ void init_keycodes() ...@@ -38,12 +41,23 @@ void init_keycodes()
XDisplayKeycodes(dpy,&minkey,&maxkey); XDisplayKeycodes(dpy,&minkey,&maxkey);
keymap=XGetKeyboardMapping(dpy,minkey,(maxkey - minkey + 1),&syms_per_keycode); keymap=XGetKeyboardMapping(dpy,minkey,(maxkey - minkey + 1),&syms_per_keycode);
#ifdef KBDDEBUG
fprintf(stderr,"minkey=%d, maxkey=%d, syms_per_keycode=%d\n",
minkey,maxkey,syms_per_keycode);
#endif
for (i = minkey; i <= maxkey; i++) for (i = minkey; i <= maxkey; i++)
for(j=0;j<syms_per_keycode;j++) { for(j=0;j<syms_per_keycode;j++) {
key=keymap[(i-minkey)*syms_per_keycode+j]; key=keymap[(i-minkey)*syms_per_keycode+j];
#ifdef KBDDEBUG
fprintf(stderr,"keymap(i=0x%x,j=%d)==0x%lx\n",i,j,key);
#endif
if(key>=' ' && key<0x100 && i==XKeysymToKeycode(dpy,key)) { if(key>=' ' && key<0x100 && i==XKeysymToKeycode(dpy,key)) {
keycodes[key]=i; keycodes[key]=i;
modifiers[key]=j; modifiers[key]=j;
#ifdef KBDDEBUG
fprintf(stderr,"key 0x%lx (%c): keycode=0x%x, modifier=%d\n",
key,(char)key,i,j);
#endif
} }
} }
...@@ -51,6 +65,11 @@ void init_keycodes() ...@@ -51,6 +65,11 @@ void init_keycodes()
rightShiftCode=XKeysymToKeycode(dpy,XK_Shift_R); rightShiftCode=XKeysymToKeycode(dpy,XK_Shift_R);
altGrCode=XKeysymToKeycode(dpy,XK_Mode_switch); altGrCode=XKeysymToKeycode(dpy,XK_Mode_switch);
#ifdef KBDDEBUG
fprintf(stderr,"leftShift=0x%x, rightShift=0x%x, altGr=0x%x\n",
leftShiftCode,rightShiftCode,altGrCode);
#endif
XFree ((char *) keymap); XFree ((char *) keymap);
} }
...@@ -61,7 +80,7 @@ void clientGone(rfbClientPtr cl) ...@@ -61,7 +80,7 @@ void clientGone(rfbClientPtr cl)
exit(0); exit(0);
} }
void newClient(rfbClientPtr cl) enum rfbNewClientAction newClient(rfbClientPtr cl)
{ {
if(disconnectAfterFirstClient) if(disconnectAfterFirstClient)
cl->clientGoneHook = clientGone; cl->clientGoneHook = clientGone;
...@@ -69,6 +88,7 @@ void newClient(rfbClientPtr cl) ...@@ -69,6 +88,7 @@ void newClient(rfbClientPtr cl)
cl->clientData = (void*)-1; cl->clientData = (void*)-1;
else else
cl->clientData = (void*)0; cl->clientData = (void*)0;
return(RFB_CLIENT_ACCEPT);
} }
#define LEFTSHIFT 1 #define LEFTSHIFT 1
...@@ -81,6 +101,10 @@ char ModifierState = 0; ...@@ -81,6 +101,10 @@ char ModifierState = 0;
void tweakModifiers(char mod,Bool down) void tweakModifiers(char mod,Bool down)
{ {
Bool isShift=ModifierState&(LEFTSHIFT|RIGHTSHIFT); Bool isShift=ModifierState&(LEFTSHIFT|RIGHTSHIFT);
#ifdef KBDDEBUG
fprintf(stderr,"tweakModifiers: 0x%x %s\n",
mod,down?"down":"up");
#endif
if(mod<0) return; if(mod<0) return;
if(isShift && mod!=1) { if(isShift && mod!=1) {
if(ModifierState&LEFTSHIFT) if(ModifierState&LEFTSHIFT)
...@@ -108,6 +132,11 @@ void keyboard(Bool down,KeySym keySym,rfbClientPtr cl) ...@@ -108,6 +132,11 @@ void keyboard(Bool down,KeySym keySym,rfbClientPtr cl)
ADJUSTMOD(XK_Shift_R,RIGHTSHIFT) ADJUSTMOD(XK_Shift_R,RIGHTSHIFT)
ADJUSTMOD(XK_Mode_switch,ALTGR) ADJUSTMOD(XK_Mode_switch,ALTGR)
#ifdef KBDDEBUG
fprintf(stderr,"keyboard: down=%s, keySym=0x%lx (%s), ModState=0x%x\n",
down?"down":"up",keySym,XKeysymToString(keySym),ModifierState);
#endif
if(keySym>=' ' && keySym<0x100) { if(keySym>=' ' && keySym<0x100) {
KeyCode k; KeyCode k;
if(down) if(down)
...@@ -119,7 +148,6 @@ void keyboard(Bool down,KeySym keySym,rfbClientPtr cl) ...@@ -119,7 +148,6 @@ void keyboard(Bool down,KeySym keySym,rfbClientPtr cl)
XTestFakeKeyEvent(dpy,k,down,CurrentTime); XTestFakeKeyEvent(dpy,k,down,CurrentTime);
gotInput = TRUE; gotInput = TRUE;
} }
/*XTestFakeKeyEvent(dpy,keycodes[keySym],down,CurrentTime);*/
if(down) if(down)
tweakModifiers(modifiers[keySym],False); tweakModifiers(modifiers[keySym],False);
gotInput = TRUE; gotInput = TRUE;
...@@ -462,7 +490,7 @@ int main(int argc,char** argv) ...@@ -462,7 +490,7 @@ int main(int argc,char** argv)
rfbClientPtr cl; rfbClientPtr cl;
for(cl=screen->rfbClientHead;cl;cl=cl->next) for(cl=screen->rfbClientHead;cl;cl=cl->next)
if(!strcmp(message+1,cl->host)) { if(!strcmp(message+1,cl->host)) {
cl->clientData=(cl->clientData==0)?-1:0; cl->clientData=(void*)((cl->clientData==0)?-1:0);
break; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment