Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
libvncserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
libvncserver
Commits
b2865b4f
Commit
b2865b4f
authored
Apr 23, 2002
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
KBDDEBUG
parent
49bfc728
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
3 deletions
+31
-3
x11vnc.c
x11vnc.c
+31
-3
No files found.
x11vnc.c
View file @
b2865b4f
...
@@ -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
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment