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
8c70b301
Commit
8c70b301
authored
Nov 23, 2001
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keyboard handling now works.
parent
3dba58aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
6 deletions
+92
-6
x11vnc.c
x11vnc.c
+92
-6
No files found.
x11vnc.c
View file @
8c70b301
...
@@ -18,6 +18,39 @@ Bool gotInput = FALSE;
...
@@ -18,6 +18,39 @@ Bool gotInput = FALSE;
Bool
disconnectAfterFirstClient
=
TRUE
;
Bool
disconnectAfterFirstClient
=
TRUE
;
/* keyboard handling */
char
modifiers
[
0x100
];
KeyCode
keycodes
[
0x100
],
leftShiftCode
,
rightShiftCode
,
altGrCode
;
void
init_keycodes
()
{
Display
*
dpy
;
KeySym
key
,
*
keymap
;
int
i
,
j
,
minkey
,
maxkey
,
syms_per_keycode
;
memset
(
modifiers
,
-
1
,
sizeof
(
modifiers
));
dpy
=
XOpenDisplay
(
""
);
XDisplayKeycodes
(
dpy
,
&
minkey
,
&
maxkey
);
keymap
=
XGetKeyboardMapping
(
dpy
,
minkey
,(
maxkey
-
minkey
+
1
),
&
syms_per_keycode
);
for
(
i
=
minkey
;
i
<=
maxkey
;
i
++
)
for
(
j
=
0
;
j
<
syms_per_keycode
;
j
++
)
{
key
=
keymap
[(
i
-
minkey
)
*
syms_per_keycode
+
j
];
if
(
key
>=
' '
&&
key
<
0x100
&&
i
==
XKeysymToKeycode
(
dpy
,
key
))
{
keycodes
[
key
]
=
i
;
modifiers
[
key
]
=
j
;
}
}
leftShiftCode
=
XKeysymToKeycode
(
dpy
,
XK_Shift_L
);
rightShiftCode
=
XKeysymToKeycode
(
dpy
,
XK_Shift_R
);
altGrCode
=
XKeysymToKeycode
(
dpy
,
XK_Mode_switch
);
XFree
((
char
*
)
keymap
);
}
/* the hooks */
/* the hooks */
void
clientGone
(
rfbClientPtr
cl
)
void
clientGone
(
rfbClientPtr
cl
)
...
@@ -31,12 +64,63 @@ void newClient(rfbClientPtr cl)
...
@@ -31,12 +64,63 @@ void newClient(rfbClientPtr cl)
cl
->
clientGoneHook
=
clientGone
;
cl
->
clientGoneHook
=
clientGone
;
}
}
#define LEFTSHIFT 1
#define RIGHTSHIFT 2
#define ALTGR 4
char
ModifierState
=
0
;
/* this function adjusts the modifiers according to mod (as from modifiers) and ModifierState */
void
tweakModifiers
(
char
mod
,
Bool
down
)
{
Bool
isShift
=
ModifierState
&
(
LEFTSHIFT
|
RIGHTSHIFT
);
if
(
mod
<
0
)
return
;
if
(
isShift
&&
mod
!=
1
)
{
if
(
ModifierState
&
LEFTSHIFT
)
XTestFakeKeyEvent
(
dpy
,
leftShiftCode
,
!
down
,
CurrentTime
);
if
(
ModifierState
&
RIGHTSHIFT
)
XTestFakeKeyEvent
(
dpy
,
rightShiftCode
,
!
down
,
CurrentTime
);
}
if
(
!
isShift
&&
mod
==
1
)
XTestFakeKeyEvent
(
dpy
,
leftShiftCode
,
down
,
CurrentTime
);
if
(
ModifierState
&
ALTGR
&&
mod
!=
2
)
XTestFakeKeyEvent
(
dpy
,
altGrCode
,
!
down
,
CurrentTime
);
if
(
!
(
ModifierState
&
ALTGR
)
&&
mod
==
2
)
XTestFakeKeyEvent
(
dpy
,
altGrCode
,
down
,
CurrentTime
);
}
void
keyboard
(
Bool
down
,
KeySym
keySym
,
rfbClientPtr
cl
)
void
keyboard
(
Bool
down
,
KeySym
keySym
,
rfbClientPtr
cl
)
{
{
KeyCode
k
=
XKeysymToKeycode
(
dpy
,
keySym
);
#define ADJUSTMOD(sym,state) \
if
(
k
!=
NoSymbol
)
if(keySym==sym) { if(down) ModifierState|=state; else ModifierState&=~state; }
XTestFakeKeyEvent
(
dpy
,
k
,
down
,
CurrentTime
);
gotInput
=
TRUE
;
ADJUSTMOD
(
XK_Shift_L
,
LEFTSHIFT
)
ADJUSTMOD
(
XK_Shift_R
,
RIGHTSHIFT
)
ADJUSTMOD
(
XK_Mode_switch
,
ALTGR
)
if
(
keySym
>=
' '
&&
keySym
<
0x100
)
{
KeyCode
k
;
/* if(down)
tweakModifiers(modifiers[keySym],True); */
tweakModifiers
(
modifiers
[
keySym
],
down
);
XTestFakeKeyEvent
(
dpy
,
XK_Shift_R
,
True
,
CurrentTime
);
k
=
XKeysymToKeycode
(
dpy
,
keySym
);
if
(
k
!=
NoSymbol
)
{
XTestFakeKeyEvent
(
dpy
,
k
,
down
,
CurrentTime
);
gotInput
=
TRUE
;
}
/*XTestFakeKeyEvent(dpy,keycodes[keySym],down,CurrentTime);*/
/*if(down)
tweakModifiers(modifiers[keySym],False);*/
gotInput
=
TRUE
;
}
else
{
KeyCode
k
=
XKeysymToKeycode
(
dpy
,
keySym
);
if
(
k
!=
NoSymbol
)
{
XTestFakeKeyEvent
(
dpy
,
k
,
down
,
CurrentTime
);
gotInput
=
TRUE
;
}
}
}
}
int
oldButtonMask
=
0
;
int
oldButtonMask
=
0
;
...
@@ -132,8 +216,8 @@ void checkForImageUpdates(rfbScreenInfoPtr s,char *b)
...
@@ -132,8 +216,8 @@ void checkForImageUpdates(rfbScreenInfoPtr s,char *b)
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
Screen
*
sc
;
//
Screen *sc;
Colormap
cm
;
//
Colormap cm;
XImage
*
framebufferImage
;
XImage
*
framebufferImage
;
char
*
backupImage
;
char
*
backupImage
;
int
xscreen
,
i
;
int
xscreen
,
i
;
...
@@ -162,6 +246,8 @@ int main(int argc,char** argv)
...
@@ -162,6 +246,8 @@ int main(int argc,char** argv)
dpy
=
XOpenDisplay
(
""
);
dpy
=
XOpenDisplay
(
""
);
xscreen
=
DefaultScreen
(
dpy
);
xscreen
=
DefaultScreen
(
dpy
);
init_keycodes
();
getImage
(
0
,
dpy
,
xscreen
,
&
framebufferImage
);
getImage
(
0
,
dpy
,
xscreen
,
&
framebufferImage
);
screen
=
rfbGetScreen
(
&
argc
,
argv
,
framebufferImage
->
width
,
screen
=
rfbGetScreen
(
&
argc
,
argv
,
framebufferImage
->
width
,
...
...
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