From 079528470d8a1dfeab321ebdc2ab6c42943ed296 Mon Sep 17 00:00:00 2001 From: runge Date: Sun, 9 Jul 2006 01:48:31 +0000 Subject: [PATCH] x11vnc: add uinput support for full input into linux fb device (e.g. qt-embed). --- ChangeLog | 3 + configure.ac | 12 + x11vnc/ChangeLog | 5 + x11vnc/Makefile.am | 2 +- x11vnc/README | 221 ++++++--- x11vnc/help.c | 185 +++++-- x11vnc/keyboard.c | 8 +- x11vnc/linuxfb.c | 46 +- x11vnc/options.c | 1 + x11vnc/options.h | 1 + x11vnc/params.h | 9 +- x11vnc/pointer.c | 58 ++- x11vnc/remote.c | 38 ++ x11vnc/screen.c | 11 +- x11vnc/tkx11vnc | 3 + x11vnc/tkx11vnc.h | 3 + x11vnc/uinput.c | 1097 ++++++++++++++++++++++++++++++++++++++++++ x11vnc/uinput.h | 18 + x11vnc/util.c | 19 +- x11vnc/v4l.c | 12 + x11vnc/x11vnc.1 | 197 ++++++-- x11vnc/x11vnc.c | 4 + x11vnc/x11vnc_defs.c | 2 +- 23 files changed, 1748 insertions(+), 207 deletions(-) create mode 100644 x11vnc/uinput.c create mode 100644 x11vnc/uinput.h diff --git a/ChangeLog b/ChangeLog index abe46ab..50227e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2006-07-08 Karl Runge + * configure.ac: add for linux console. + 2006-07-04 Karl Runge * configure.ac: add getspnam. diff --git a/configure.ac b/configure.ac index 5169bef..6c73947 100644 --- a/configure.ac +++ b/configure.ac @@ -62,6 +62,8 @@ AH_TEMPLATE(HAVE_IRIX_XREADDISPLAY, [IRIX XReadDisplay available]) AH_TEMPLATE(HAVE_FBPM, [FBPM extension build environment present]) AH_TEMPLATE(HAVE_LINUX_VIDEODEV_H, [video4linux build environment present]) AH_TEMPLATE(HAVE_LINUX_FB_H, [linux fb device build environment present]) +AH_TEMPLATE(HAVE_LINUX_INPUT_H, [linux/input.h present]) +AH_TEMPLATE(HAVE_LINUX_UINPUT_H, [linux uinput device build environment present]) AC_ARG_WITH(xkeyboard, [ --without-xkeyboard disable xkeyboard extension support],,) @@ -83,6 +85,8 @@ AC_ARG_WITH(v4l, [ --without-v4l disable video4linux support],,) AC_ARG_WITH(fbdev, [ --without-fbdev disable linux fb device support],,) +AC_ARG_WITH(uinput, +[ --without-uinput disable linux uinput device support],,) if test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then AC_CHECK_LIB(X11, XGetImage, HAVE_X="true", @@ -237,6 +241,14 @@ if test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then AC_CHECK_HEADER(linux/fb.h, [AC_DEFINE(HAVE_LINUX_FB_H)],,) fi + if test "x$with_uinput" != "xno"; then + AC_CHECK_HEADER(linux/input.h, + [AC_DEFINE(HAVE_LINUX_INPUT_H) HAVE_LINUX_INPUT_H="true"],,) + if test "x$HAVE_LINUX_INPUT_H" = "xtrue"; then + AC_CHECK_HEADER(linux/uinput.h, + [AC_DEFINE(HAVE_LINUX_UINPUT_H)],, [#include ]) + fi + fi X_LIBS="$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS" fi diff --git a/x11vnc/ChangeLog b/x11vnc/ChangeLog index b0a905e..7c098bc 100644 --- a/x11vnc/ChangeLog +++ b/x11vnc/ChangeLog @@ -1,3 +1,8 @@ +2006-07-08 Karl Runge + * x11vnc: add uinput support (-pipeinput UINPUT:...) for full + mouse and key input to linux console (e.g. for qt-embedded apps) + add -allinput for handleEventsEagerly. + 2006-07-04 Karl Runge * x11vnc: 2nd -accept popup with WAIT, and UNIX: info for unixpw login. Use RFB_CLIENT_ON_HOLD for -unixpw. -unixpw white arrow diff --git a/x11vnc/Makefile.am b/x11vnc/Makefile.am index 0362a43..ab4898d 100644 --- a/x11vnc/Makefile.am +++ b/x11vnc/Makefile.am @@ -13,7 +13,7 @@ endif if HAVE_X bin_PROGRAMS=x11vnc -x11vnc_SOURCES = 8to24.c cleanup.c connections.c cursor.c gui.c help.c inet.c keyboard.c linuxfb.c options.c pm.c pointer.c rates.c remote.c scan.c screen.c selection.c solid.c sslcmds.c sslhelper.c unixpw.c user.c userinput.c util.c v4l.c win_utils.c x11vnc.c x11vnc_defs.c xdamage.c xevents.c xinerama.c xkb_bell.c xrandr.c xrecord.c xwrappers.c 8to24.h allowed_input_t.h blackout_t.h cleanup.h connections.h cursor.h enums.h gui.h help.h inet.h keyboard.h linuxfb.h options.h params.h pm.h pointer.h rates.h remote.h scan.h screen.h scrollevent_t.h selection.h solid.h sslcmds.h sslhelper.h ssltools.h tkx11vnc.h unixpw.h user.h userinput.h util.h v4l.h win_utils.h winattr_t.h x11vnc.h xdamage.h xevents.h xinerama.h xkb_bell.h xrandr.h xrecord.h xwrappers.h +x11vnc_SOURCES = 8to24.c cleanup.c connections.c cursor.c gui.c help.c inet.c keyboard.c linuxfb.c options.c pm.c pointer.c rates.c remote.c scan.c screen.c selection.c solid.c sslcmds.c sslhelper.c uinput.c unixpw.c user.c userinput.c util.c v4l.c win_utils.c x11vnc.c x11vnc_defs.c xdamage.c xevents.c xinerama.c xkb_bell.c xrandr.c xrecord.c xwrappers.c 8to24.h allowed_input_t.h blackout_t.h cleanup.h connections.h cursor.h enums.h gui.h help.h inet.h keyboard.h linuxfb.h options.h params.h pm.h pointer.h rates.h remote.h scan.h screen.h scrollevent_t.h selection.h solid.h sslcmds.h sslhelper.h ssltools.h tkx11vnc.h uinput.h unixpw.h user.h userinput.h util.h v4l.h win_utils.h winattr_t.h x11vnc.h xdamage.h xevents.h xinerama.h xkb_bell.h xrandr.h xrecord.h xwrappers.h INCLUDES=@X_CFLAGS@ x11vnc_LDADD=$(LDADD) @X_LIBS@ $(LD_CYGIPC) endif diff --git a/x11vnc/README b/x11vnc/README index 7c59b22..09c05e1 100644 --- a/x11vnc/README +++ b/x11vnc/README @@ -1,5 +1,5 @@ -x11vnc README file Date: Tue Jul 4 19:57:31 EDT 2006 +x11vnc README file Date: Sat Jul 8 19:22:13 EDT 2006 The following information is taken from these URLs: @@ -7196,7 +7196,7 @@ x11vnc: a VNC server for real X displays Here are all of x11vnc command line options: % x11vnc -opts (see below for -help long descriptions) -x11vnc: allow VNC connections to real X11 displays. 0.8.2 lastmod: 2006-07-04 +x11vnc: allow VNC connections to real X11 displays. 0.8.2 lastmod: 2006-07-08 x11vnc options: -display disp -auth file -id windowid @@ -7246,21 +7246,21 @@ x11vnc options: -fixscreen string -debug_scroll -noxrecord -grab_buster -nograb_buster -debug_grabs -debug_sel -pointer_mode n -input_skip n - -speeds rd,bw,lat -wmdt string -debug_pointer - -debug_keyboard -defer time -wait time - -wait_ui factor -nowait_bog -slow_fb time - -readtimeout n -nap -nonap - -sb time -nofbpm -fbpm - -noxdamage -xd_area A -xd_mem f - -sigpipe string -threads -nothreads - -fs f -gaps n -grow n - -fuzz n -debug_tiles -snapfb - -rawfb string -freqtab file -pipeinput cmd - -gui [gui-opts] -remote command -query variable - -QD variable -sync -noremote - -yesremote -unsafe -safer - -privremote -nocmds -allowedcmds list - -deny_all + -allinput -speeds rd,bw,lat -wmdt string + -debug_pointer -debug_keyboard -defer time + -wait time -wait_ui factor -nowait_bog + -slow_fb time -readtimeout n -nap + -nonap -sb time -nofbpm + -fbpm -noxdamage -xd_area A + -xd_mem f -sigpipe string -threads + -nothreads -fs f -gaps n + -grow n -fuzz n -debug_tiles + -snapfb -rawfb string -freqtab file + -pipeinput cmd -gui [gui-opts] -remote command + -query variable -QD variable -sync + -noremote -yesremote -unsafe + -safer -privremote -nocmds + -allowedcmds list -deny_all libvncserver options: -rfbport port TCP port for RFB protocol @@ -7294,7 +7294,7 @@ libvncserver-tight-extension options: % x11vnc -help -x11vnc: allow VNC connections to real X11 displays. 0.8.2 lastmod: 2006-07-04 +x11vnc: allow VNC connections to real X11 displays. 0.8.2 lastmod: 2006-07-08 (type "x11vnc -opts" to just list the options.) @@ -9457,6 +9457,9 @@ Options: means to act as though there is always user input. Default: 10 +-allinput Have x11vnc read and process all available client input + before proceeding. + -speeds rd,bw,lat x11vnc tries to estimate some speed parameters that are used to optimize scheduling (e.g. -pointer_mode 4, -wireframe, -scrollcopyrect) and other things. @@ -9613,13 +9616,19 @@ Options: For shared memory segments string is of the form: "shm:N@WxHxB" which specifies a shmid N and framebuffer Width, Height, and Bits - per pixel. To memory map mmap(2) a file use: - "map:/path/to/a/file@WxHxB". If there is trouble - with mmap, use "file:/..." for slower lseek(2) based - reading. Use "snap:..." to imply -snapfb mode and the - "file:" access (this is for devices that only provide - the fb all at once). If you do not supply a type "map" - is assumed if the file exists. + per pixel. + + For file polling to memory map mmap(2) a file use: + "map:/path/to/a/file@WxHxB", with WxHxB as above. + "mmap:..." is the same. If there is trouble with mmap, + use "file:/..." for slower lseek(2) based reading. + Use "snap:..." to imply -snapfb mode and the "file:" + access (this is for devices that only provide the fb + all at once). + + If you do not supply a type "map" is assumed if + the file exists (see the next paragraphs for some + exceptions to this.) If string is "setup:cmd", then the command "cmd" is run and the first line from it is read and used @@ -9627,13 +9636,14 @@ Options: determining WxHxB, etc. These are often done as root so take care. - If the string begins with "video", see the video4linux + If the string begins with "video", see the VIDEO4LINUX discusion below where the device may be queried for (and possibly set) the framebuffer parameters. - If the strings begins with "cons", see the linux - console discussion below where the framebuffer device - is opened and keystrokes are inserted into the console. + If the string begins with "cons", "/dev/fb", or + "fb", see the LINUX CONSOLE discussion below where + the framebuffer device is opened and keystrokes (and + possibly mouse events) are inserted into the console. Optional suffixes are ":R/G/B" and "+O" to specify red, green, and blue masks and an offset into the @@ -9653,11 +9663,12 @@ Options: (see ipcs(1) and fbset(1) for the first two examples) - All user input is discarded by default (but see the - -pipeinput option). Most of the X11 (screen, keyboard, - mouse) options do not make sense and many will cause - this mode to crash, so please think twice before - setting or changing them in a running x11vnc. + In general all user input is discarded by default (see + the -pipeinput option for how to use a helper program + to insert). Most of the X11 (screen, keyboard, mouse) + options do not make sense and many will cause this + mode to crash, so please think twice before setting or + changing them in a running x11vnc. If you DO NOT want x11vnc to close the X DISPLAY in rawfb mode, prepend a "+" e.g. +file:/dev/fb0... @@ -9676,13 +9687,13 @@ Options: SNAPFB_RAWFB_RESET=1 as well. If you want x11vnc to dynamically transform a 24bpp - rawfb to 32bpp (note that this will be slower) use - the -24to32 option. This would be useful for, say, - for a video camera that delivers the pixel data as + rawfb to 32bpp (note that this will be slower) also + supply the -24to32 option. This would be useful for, + say, a video camera that delivers the pixel data as 24bpp packed RGB. This is the default under "video" mode if the bpp is 24. - video4linux: on Linux some attempt is made to handle + VIDEO4LINUX: on Linux some attempt is made to handle video devices (webcams or TV tuners) automatically. The idea is the WxHxB will be extracted from the device itself. So if you do not supply "@WxHxB... @@ -9760,44 +9771,63 @@ Options: See the -pipeinput VID option below for a way to control the settings through the VNC Viewer via keystrokes. + As a shortcut, if the string begins "Video.." instead + of "video.." then -pipeinput VID is implied. As above, if you specify a "@WxHxB..." after the string they are used verbatim: the device is not queried for the current values. Otherwise the device will be queried. - Linux console: If the libvncserver LinuxVNC command is - on your system use that instead of the following method - because it will be faster and more accurate for Linux - text console. + LINUX CONSOLE: If the libvncserver LinuxVNC program + is on your system you may want to use that instead of + the following method because it will be faster and more + accurate for Linux text console. If the rawfb string begins with "cons" the framebuffer device /dev/fb0 is opened (this requires the appropriate - kernel modules) and so is /dev/tty0. The latter is - used to inject keystrokes (not all are supported, - but the basic ones are). You will need to be root to - inject keystrokes. /dev/tty0 refers to the active VT, - to indicate one explicitly, use "cons2", etc. using - the VT number. Note you can change VT remotely using - the chvt(1) command. Sometimes switching out and back - corrects the framebuffer. To skip injecting entirely - use "consx". + kernel modules to be installed) and so is /dev/tty0. + The latter is used to inject keystrokes (not all are + supported, but the basic ones are). You will need to + be root to inject keystrokes. /dev/tty0 refers to the + active VT, to indicate one explicitly, use "cons2", + etc. using the VT number. + + If the Linux version seems to be 2.6 or later and the + "uinput" module appears to be present, then the uinput + method will be used instead of /dev/ttyN. uinput allows + insertion of BOTH keystrokes and mouse input and so it + preferred when accessing graphical (e.g. QT-embedded) + linux console apps. See -pipeinput UINPUT below + for more information on this mode (you may want to + also use the -nodragging and -cursor none options). + Use "cons0", etc or -pipeinput CONS to force the + /dev/ttyN method. + + Note you can change VT remotely using the chvt(1) + command. Sometimes switching out and back corrects + the framebuffer state. + + To skip input injecting entirely use "consx". The strings "console", or "/dev/fb0" can be used instead of "cons". The latter can be used to specify - a different framebuffer device, e.g. /dev/fb1. If the - name is something nonstandard, use "cons:/dev/foofb" + a different framebuffer device, e.g. /dev/fb1. As a + shortcut the "/dev/" can be dropped. If the name is + something nonstandard, use "cons:/dev/foofb" If you do not want x11vnc to guess the framebuffer's - WxHxB and masks automatically, specify them with a + WxHxB and masks automatically (sometimes the kernel + given inaccurate information), specify them with a @WxHxB at the end of the string. Examples: -rawfb cons (same as -rawfb console) -rawfb /dev/fb0 (same) -rawfb cons3 (force /dev/tty3) - -rawfb consx (no keystrokes) + -rawfb consx (no keystrokes or mouse) -rawfb console:/dev/nonstd + -rawfb cons -pipeinput UINPUT:accel=1.5 -freqtab file For use with "-rawfb video" for TV tuner devices to specify station frequencies. Instead of using the built @@ -9826,6 +9856,8 @@ Options: value is stored in X11VNC_RAWFB_STR for the pipe command to use if it wants. Do 'env | grep X11VNC' for more. + Built-in pipeinput modes: + If cmd is "VID" and you are using the -rawfb for a video capture device, then an internal list of keyboard mappings is used to set parameters of the video. @@ -9844,7 +9876,57 @@ Options: If cmd is "CONS" or "CONSn" where n is a Linux console number, then the linux console keystroke - insertion (see -rawfb cons) is performed. + insertion to /dev/ttyN (see -rawfb cons) is performed. + + If cmd begins with "UINPUT" then the Linux uinput + module is used to insert both keystroke and mouse events + to the Linux console (see -rawfb above). This usually + is the /dev/input/uinput device file (you may need to + create it with "mknod /dev/input/uinput c 10 223" + and insert the module with "modprobe uinput". + + The UINPUT mode currently only does US keyboards (a + scan code option may be added), and not all keysyms + are supported. + + You may want to use the options -cursor none and + -nodragging in this mode. + + Additional tuning options may be supplied via: + UINPUT:opt1,opt2,... (a comma separated list). If an + option begins with "/" it is taken as the uinput + device file. + + Which uinput is injected can be controlled by an option + string made of the characters "K", "M", and "B" + (see the -input option), e.g. "KM" allows keystroke + and motion but not button clicks. + + A UINPUT option of the form: accel=f, or accel=fx+fy + sets the mouse motion "acceleration". This is used + to correct raw mouse relative motion into how much the + application cursor moves (x11vnc has no control over + how the application interprets the raw mouse motions). + Typically the acceleration for an X display is 2 (see + xset "m" option). "f" is a floating point number, + e.g. 2.0. Use "fx+fy" if you need to supply different + corrections for x and y. + + Note: the default acceleration is 2.0 since it seems + both X and qt-embedded often use this value. + + Even with a correct accel setting the mouse position + will get out of sync (probably due to a mouse + "threshold" setting where the acceleration doe not + apply, set xset(1)). The option reset=N sets the number + of ms (default 500) after which the cursor is attempted + to be reset (by forcing the mouse to (0, 0) via small + increments and then back out to (x, y) in 1 jump), This + correction seems to be needed but can cause jerkiness + or unexpected behavior. Use reset=0 to disable. + + Example: + -pipeinput UINPUT:accel=1.0 -cursor none -gui [gui-opts] Start up a simple tcl/tk gui based on the the remote control options -remote/-query described below. @@ -10166,6 +10248,8 @@ n reset_record reset RECORD extension (if avail.) pointer_mode:n set -pointer_mode to n. same as "pm" input_skip:n set -input_skip to n. + allinput enable use of -allinput mode. + noallinput disable use of -allinput mode. speeds:str set -speeds to str. wmdt:str set -wmdt to str. debug_pointer enable -debug_pointer, same as "dp" @@ -10195,6 +10279,8 @@ n snapfb enable -snapfb mode. nosnapfb disable -snapfb mode. rawfb:str set -rawfb mode to "str". + uinput_accel:f set uinput_accel to f. + uinput_reset:n set uinput_reset to n ms. progressive:n set libvncserver -progressive slice height parameter to n. desktop:str set -desktop name to str for new clients @@ -10268,7 +10354,6 @@ n remote command, we hope the name makes it obvious what the returned value corresponds to (hint: the ext_* variables correspond to the presence of X extensions): - ans= stop quit exit shutdown ping blacken zero refresh reset close disconnect id sid waitmapped nowaitmapped clip flashcmap noflashcmap shiftcmap @@ -10299,16 +10384,17 @@ n nodragging wireframe_mode wireframe wf nowireframe nowf wirecopyrect wcr nowirecopyrect nowcr scr_area scr_skip scr_inc scr_keys scr_term scr_keyrepeat - scr_parms scrollcopyrect scr noscrollcopyrect noscr - fixscreen noxrecord xrecord reset_record pointer_mode - pm input_skip input grabkbd nograbkbd grabptr - nograbptr client_input speeds wmdt debug_pointer dp - nodebug_pointer nodp debug_keyboard dk nodebug_keyboard - nodk deferupdate defer wait_ui wait_bog nowait_bog - slow_fb wait readtimeout nap nonap sb screen_blank - fbpm nofbpm fs gaps grow fuzz snapfb nosnapfb rawfb - progressive rfbport http nohttp httpport httpdir - enablehttpproxy noenablehttpproxy alwaysshared + scr_parms scrollcopyrect scr noscrollcopyrect + noscr fixscreen noxrecord xrecord reset_record + pointer_mode pm input_skip allinput noallinput input + grabkbd nograbkbd grabptr nograbptr client_input + speeds wmdt debug_pointer dp nodebug_pointer nodp + debug_keyboard dk nodebug_keyboard nodk deferupdate + defer wait_ui wait_bog nowait_bog slow_fb wait + readtimeout nap nonap sb screen_blank fbpm nofbpm + fs gaps grow fuzz snapfb nosnapfb rawfb uinput_accel + uinput_reset progressive rfbport http nohttp httpport + httpdir enablehttpproxy noenablehttpproxy alwaysshared noalwaysshared nevershared noalwaysshared dontdisconnect nodontdisconnect desktop debug_xevents nodebug_xevents debug_xevents debug_xdamage nodebug_xdamage @@ -10333,7 +10419,6 @@ n mouse_x mouse_y bpp depth indexed_color dpy_x dpy_y wdpy_x wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y rfbauth passwd viewpasswd - -QD variable Just like -query variable, but returns the default value for that parameter (no running x11vnc server is consulted) diff --git a/x11vnc/help.c b/x11vnc/help.c index 241e37c..6f2fb1f 100644 --- a/x11vnc/help.c +++ b/x11vnc/help.c @@ -2192,6 +2192,9 @@ void print_help(int mode) { " means to act as though there is always user input.\n" " Default: %d\n" "\n" +"-allinput Have x11vnc read and process all available client input\n" +" before proceeding.\n" +"\n" "-speeds rd,bw,lat x11vnc tries to estimate some speed parameters that\n" " are used to optimize scheduling (e.g. -pointer_mode\n" " 4, -wireframe, -scrollcopyrect) and other things.\n" @@ -2348,13 +2351,19 @@ void print_help(int mode) { " For shared memory segments string is of the\n" " form: \"shm:N@WxHxB\" which specifies a shmid\n" " N and framebuffer Width, Height, and Bits\n" -" per pixel. To memory map mmap(2) a file use:\n" -" \"map:/path/to/a/file@WxHxB\". If there is trouble\n" -" with mmap, use \"file:/...\" for slower lseek(2) based\n" -" reading. Use \"snap:...\" to imply -snapfb mode and the\n" -" \"file:\" access (this is for devices that only provide\n" -" the fb all at once). If you do not supply a type \"map\"\n" -" is assumed if the file exists.\n" +" per pixel.\n" +"\n" +" For file polling to memory map mmap(2) a file use:\n" +" \"map:/path/to/a/file@WxHxB\", with WxHxB as above.\n" +" \"mmap:...\" is the same. If there is trouble with mmap,\n" +" use \"file:/...\" for slower lseek(2) based reading.\n" +" Use \"snap:...\" to imply -snapfb mode and the \"file:\"\n" +" access (this is for devices that only provide the fb\n" +" all at once).\n" +"\n" +" If you do not supply a type \"map\" is assumed if\n" +" the file exists (see the next paragraphs for some\n" +" exceptions to this.)\n" "\n" " If string is \"setup:cmd\", then the command \"cmd\"\n" " is run and the first line from it is read and used\n" @@ -2362,13 +2371,14 @@ void print_help(int mode) { " determining WxHxB, etc. These are often done as root\n" " so take care.\n" "\n" -" If the string begins with \"video\", see the video4linux\n" +" If the string begins with \"video\", see the VIDEO4LINUX\n" " discusion below where the device may be queried for\n" " (and possibly set) the framebuffer parameters.\n" "\n" -" If the strings begins with \"cons\", see the linux\n" -" console discussion below where the framebuffer device\n" -" is opened and keystrokes are inserted into the console.\n" +" If the string begins with \"cons\", \"/dev/fb\", or\n" +" \"fb\", see the LINUX CONSOLE discussion below where\n" +" the framebuffer device is opened and keystrokes (and\n" +" possibly mouse events) are inserted into the console.\n" "\n" " Optional suffixes are \":R/G/B\" and \"+O\" to specify\n" " red, green, and blue masks and an offset into the\n" @@ -2388,11 +2398,12 @@ void print_help(int mode) { "\n" " (see ipcs(1) and fbset(1) for the first two examples)\n" "\n" -" All user input is discarded by default (but see the\n" -" -pipeinput option). Most of the X11 (screen, keyboard,\n" -" mouse) options do not make sense and many will cause\n" -" this mode to crash, so please think twice before\n" -" setting or changing them in a running x11vnc.\n" +" In general all user input is discarded by default (see\n" +" the -pipeinput option for how to use a helper program\n" +" to insert). Most of the X11 (screen, keyboard, mouse)\n" +" options do not make sense and many will cause this\n" +" mode to crash, so please think twice before setting or\n" +" changing them in a running x11vnc.\n" "\n" " If you DO NOT want x11vnc to close the X DISPLAY in\n" " rawfb mode, prepend a \"+\" e.g. +file:/dev/fb0...\n" @@ -2411,13 +2422,13 @@ void print_help(int mode) { " SNAPFB_RAWFB_RESET=1 as well.\n" "\n" " If you want x11vnc to dynamically transform a 24bpp\n" -" rawfb to 32bpp (note that this will be slower) use\n" -" the -24to32 option. This would be useful for, say,\n" -" for a video camera that delivers the pixel data as\n" +" rawfb to 32bpp (note that this will be slower) also\n" +" supply the -24to32 option. This would be useful for,\n" +" say, a video camera that delivers the pixel data as\n" " 24bpp packed RGB. This is the default under \"video\"\n" " mode if the bpp is 24.\n" "\n" -" video4linux: on Linux some attempt is made to handle\n" +" VIDEO4LINUX: on Linux some attempt is made to handle\n" " video devices (webcams or TV tuners) automatically.\n" " The idea is the WxHxB will be extracted from the\n" " device itself. So if you do not supply \"@WxHxB...\n" @@ -2495,44 +2506,63 @@ void print_help(int mode) { "\n" " See the -pipeinput VID option below for a way to control\n" " the settings through the VNC Viewer via keystrokes.\n" +" As a shortcut, if the string begins \"Video..\" instead\n" +" of \"video..\" then -pipeinput VID is implied.\n" "\n" " As above, if you specify a \"@WxHxB...\" after the\n" " string they are used verbatim: the device\n" " is not queried for the current values. Otherwise the\n" " device will be queried.\n" "\n" -" Linux console: If the libvncserver LinuxVNC command is\n" -" on your system use that instead of the following method\n" -" because it will be faster and more accurate for Linux\n" -" text console.\n" +" LINUX CONSOLE: If the libvncserver LinuxVNC program\n" +" is on your system you may want to use that instead of\n" +" the following method because it will be faster and more\n" +" accurate for Linux text console.\n" "\n" " If the rawfb string begins with \"cons\" the framebuffer\n" " device /dev/fb0 is opened (this requires the appropriate\n" -" kernel modules) and so is /dev/tty0. The latter is\n" -" used to inject keystrokes (not all are supported,\n" -" but the basic ones are). You will need to be root to\n" -" inject keystrokes. /dev/tty0 refers to the active VT,\n" -" to indicate one explicitly, use \"cons2\", etc. using\n" -" the VT number. Note you can change VT remotely using\n" -" the chvt(1) command. Sometimes switching out and back\n" -" corrects the framebuffer. To skip injecting entirely\n" -" use \"consx\".\n" +" kernel modules to be installed) and so is /dev/tty0.\n" +" The latter is used to inject keystrokes (not all are\n" +" supported, but the basic ones are). You will need to\n" +" be root to inject keystrokes. /dev/tty0 refers to the\n" +" active VT, to indicate one explicitly, use \"cons2\",\n" +" etc. using the VT number.\n" +"\n" +" If the Linux version seems to be 2.6 or later and the\n" +" \"uinput\" module appears to be present, then the uinput\n" +" method will be used instead of /dev/ttyN. uinput allows\n" +" insertion of BOTH keystrokes and mouse input and so it\n" +" preferred when accessing graphical (e.g. QT-embedded)\n" +" linux console apps. See -pipeinput UINPUT below\n" +" for more information on this mode (you may want to\n" +" also use the -nodragging and -cursor none options).\n" +" Use \"cons0\", etc or -pipeinput CONS to force the\n" +" /dev/ttyN method.\n" +"\n" +" Note you can change VT remotely using the chvt(1)\n" +" command. Sometimes switching out and back corrects\n" +" the framebuffer state.\n" +"\n" +" To skip input injecting entirely use \"consx\".\n" "\n" " The strings \"console\", or \"/dev/fb0\" can be used\n" " instead of \"cons\". The latter can be used to specify\n" -" a different framebuffer device, e.g. /dev/fb1. If the\n" -" name is something nonstandard, use \"cons:/dev/foofb\"\n" +" a different framebuffer device, e.g. /dev/fb1. As a\n" +" shortcut the \"/dev/\" can be dropped. If the name is\n" +" something nonstandard, use \"cons:/dev/foofb\"\n" "\n" " If you do not want x11vnc to guess the framebuffer's\n" -" WxHxB and masks automatically, specify them with a\n" +" WxHxB and masks automatically (sometimes the kernel\n" +" given inaccurate information), specify them with a\n" " @WxHxB at the end of the string.\n" "\n" " Examples:\n" " -rawfb cons (same as -rawfb console)\n" " -rawfb /dev/fb0 (same)\n" " -rawfb cons3 (force /dev/tty3)\n" -" -rawfb consx (no keystrokes)\n" +" -rawfb consx (no keystrokes or mouse)\n" " -rawfb console:/dev/nonstd\n" +" -rawfb cons -pipeinput UINPUT:accel=1.5\n" "\n" "-freqtab file For use with \"-rawfb video\" for TV tuner devices to\n" " specify station frequencies. Instead of using the built\n" @@ -2561,6 +2591,8 @@ void print_help(int mode) { " value is stored in X11VNC_RAWFB_STR for the pipe command\n" " to use if it wants. Do 'env | grep X11VNC' for more.\n" "\n" +" Built-in pipeinput modes:\n" +"\n" " If cmd is \"VID\" and you are using the -rawfb for a\n" " video capture device, then an internal list of keyboard\n" " mappings is used to set parameters of the video.\n" @@ -2579,7 +2611,57 @@ void print_help(int mode) { "\n" " If cmd is \"CONS\" or \"CONSn\" where n is a Linux\n" " console number, then the linux console keystroke\n" -" insertion (see -rawfb cons) is performed.\n" +" insertion to /dev/ttyN (see -rawfb cons) is performed.\n" +"\n" +" If cmd begins with \"UINPUT\" then the Linux uinput\n" +" module is used to insert both keystroke and mouse events\n" +" to the Linux console (see -rawfb above). This usually\n" +" is the /dev/input/uinput device file (you may need to\n" +" create it with \"mknod /dev/input/uinput c 10 223\"\n" +" and insert the module with \"modprobe uinput\".\n" +"\n" +" The UINPUT mode currently only does US keyboards (a\n" +" scan code option may be added), and not all keysyms\n" +" are supported.\n" +"\n" +" You may want to use the options -cursor none and\n" +" -nodragging in this mode.\n" +"\n" +" Additional tuning options may be supplied via:\n" +" UINPUT:opt1,opt2,... (a comma separated list). If an\n" +" option begins with \"/\" it is taken as the uinput\n" +" device file.\n" +" \n" +" Which uinput is injected can be controlled by an option\n" +" string made of the characters \"K\", \"M\", and \"B\"\n" +" (see the -input option), e.g. \"KM\" allows keystroke\n" +" and motion but not button clicks.\n" +"\n" +" A UINPUT option of the form: accel=f, or accel=fx+fy\n" +" sets the mouse motion \"acceleration\". This is used\n" +" to correct raw mouse relative motion into how much the\n" +" application cursor moves (x11vnc has no control over\n" +" how the application interprets the raw mouse motions).\n" +" Typically the acceleration for an X display is 2 (see\n" +" xset \"m\" option). \"f\" is a floating point number,\n" +" e.g. 2.0. Use \"fx+fy\" if you need to supply different\n" +" corrections for x and y.\n" +"\n" +" Note: the default acceleration is 2.0 since it seems\n" +" both X and qt-embedded often use this value.\n" +"\n" +" Even with a correct accel setting the mouse position\n" +" will get out of sync (probably due to a mouse\n" +" \"threshold\" setting where the acceleration doe not\n" +" apply, set xset(1)). The option reset=N sets the number\n" +" of ms (default 500) after which the cursor is attempted\n" +" to be reset (by forcing the mouse to (0, 0) via small\n" +" increments and then back out to (x, y) in 1 jump), This\n" +" correction seems to be needed but can cause jerkiness\n" +" or unexpected behavior. Use reset=0 to disable.\n" +"\n" +" Example:\n" +" -pipeinput UINPUT:accel=1.0 -cursor none\n" "\n" "-gui [gui-opts] Start up a simple tcl/tk gui based on the the remote\n" " control options -remote/-query described below.\n" @@ -2907,6 +2989,8 @@ void print_help(int mode) { " reset_record reset RECORD extension (if avail.)\n" " pointer_mode:n set -pointer_mode to n. same as \"pm\"\n" " input_skip:n set -input_skip to n.\n" +" allinput enable use of -allinput mode.\n" +" noallinput disable use of -allinput mode.\n" " speeds:str set -speeds to str.\n" " wmdt:str set -wmdt to str.\n" " debug_pointer enable -debug_pointer, same as \"dp\"\n" @@ -2936,6 +3020,8 @@ void print_help(int mode) { " snapfb enable -snapfb mode.\n" " nosnapfb disable -snapfb mode.\n" " rawfb:str set -rawfb mode to \"str\".\n" +" uinput_accel:f set uinput_accel to f.\n" +" uinput_reset:n set uinput_reset to n ms.\n" " progressive:n set libvncserver -progressive slice\n" " height parameter to n.\n" " desktop:str set -desktop name to str for new clients.\n" @@ -3009,7 +3095,6 @@ void print_help(int mode) { " remote command, we hope the name makes it obvious what\n" " the returned value corresponds to (hint: the ext_*\n" " variables correspond to the presence of X extensions):\n" -"\n" " ans= stop quit exit shutdown ping blacken zero\n" " refresh reset close disconnect id sid waitmapped\n" " nowaitmapped clip flashcmap noflashcmap shiftcmap\n" @@ -3040,16 +3125,17 @@ void print_help(int mode) { " nodragging wireframe_mode wireframe wf nowireframe\n" " nowf wirecopyrect wcr nowirecopyrect nowcr scr_area\n" " scr_skip scr_inc scr_keys scr_term scr_keyrepeat\n" -" scr_parms scrollcopyrect scr noscrollcopyrect noscr\n" -" fixscreen noxrecord xrecord reset_record pointer_mode\n" -" pm input_skip input grabkbd nograbkbd grabptr\n" -" nograbptr client_input speeds wmdt debug_pointer dp\n" -" nodebug_pointer nodp debug_keyboard dk nodebug_keyboard\n" -" nodk deferupdate defer wait_ui wait_bog nowait_bog\n" -" slow_fb wait readtimeout nap nonap sb screen_blank\n" -" fbpm nofbpm fs gaps grow fuzz snapfb nosnapfb rawfb\n" -" progressive rfbport http nohttp httpport httpdir\n" -" enablehttpproxy noenablehttpproxy alwaysshared\n" +" scr_parms scrollcopyrect scr noscrollcopyrect\n" +" noscr fixscreen noxrecord xrecord reset_record\n" +" pointer_mode pm input_skip allinput noallinput input\n" +" grabkbd nograbkbd grabptr nograbptr client_input\n" +" speeds wmdt debug_pointer dp nodebug_pointer nodp\n" +" debug_keyboard dk nodebug_keyboard nodk deferupdate\n" +" defer wait_ui wait_bog nowait_bog slow_fb wait\n" +" readtimeout nap nonap sb screen_blank fbpm nofbpm\n" +" fs gaps grow fuzz snapfb nosnapfb rawfb uinput_accel\n" +" uinput_reset progressive rfbport http nohttp httpport\n" +" httpdir enablehttpproxy noenablehttpproxy alwaysshared\n" " noalwaysshared nevershared noalwaysshared dontdisconnect\n" " nodontdisconnect desktop debug_xevents nodebug_xevents\n" " debug_xevents debug_xdamage nodebug_xdamage\n" @@ -3074,7 +3160,6 @@ void print_help(int mode) { " mouse_x mouse_y bpp depth indexed_color dpy_x dpy_y\n" " wdpy_x wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y\n" " rfbauth passwd viewpasswd\n" -"\n" "-QD variable Just like -query variable, but returns the default\n" " value for that parameter (no running x11vnc server\n" " is consulted)\n" diff --git a/x11vnc/keyboard.c b/x11vnc/keyboard.c index b4ebdf7..eb51d6d 100644 --- a/x11vnc/keyboard.c +++ b/x11vnc/keyboard.c @@ -2461,6 +2461,7 @@ void get_allowed_input(rfbClientPtr client, allowed_input_t *input) { str = "KMBC"; } } +if (0) fprintf(stderr, "GAI: %s - %s\n", str, cd->input); while (*str) { if (*str == 'K') { @@ -2485,9 +2486,10 @@ static void pipe_keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { if (pipeinput_int == PIPEINPUT_VID) { v4l_key_command(down, keysym, client); - } - if (pipeinput_int == PIPEINPUT_CONS) { + } else if (pipeinput_int == PIPEINPUT_CONS) { console_key_command(down, keysym, client); + } else if (pipeinput_int == PIPEINPUT_UINPUT) { + uinput_key_command(down, keysym, client); } if (pipeinput_fh == NULL) { return; @@ -2495,7 +2497,7 @@ static void pipe_keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { if (! view_only) { get_allowed_input(client, &input); - if (input.motion || input.button) { + if (input.keystroke) { can_input = 1; /* XXX distinguish later */ } } diff --git a/x11vnc/linuxfb.c b/x11vnc/linuxfb.c index c190feb..0b3d0ee 100644 --- a/x11vnc/linuxfb.c +++ b/x11vnc/linuxfb.c @@ -6,6 +6,7 @@ #include "xinerama.h" #include "screen.h" #include "pointer.h" +#include "allowed_input_t.h" #if LIBVNCSERVER_HAVE_SYS_IOCTL_H #include @@ -21,7 +22,8 @@ void console_pointer_command(int mask, int x, int y, rfbClientPtr client); char *console_guess(char *str, int *fd) { char *q, *in = strdup(str); char *atparms = NULL, *file = NULL; - int tty = -1; + int do_input, have_uinput, tty = -1; + if (strstr(in, "/dev/fb") == in) { free(in); in = (char *) malloc(strlen("cons:") + strlen(str) + 1); @@ -67,22 +69,43 @@ char *console_guess(char *str, int *fd) { } rfbLog("console_guess: file is %s\n", file); - if (!strcmp(in, "cons") || !strcmp(in, "console")) { + do_input = 1; + if (pipeinput_str) { + have_uinput = 0; + do_input = 0; + } else { + have_uinput = check_uinput(); + } + + if (!strcmp(in, "consx") || !strcmp(in, "consolex")) { + do_input = 0; + } else if (!strcmp(in, "cons") || !strcmp(in, "console")) { /* current active VT: */ - tty = 0; + if (! have_uinput) { + tty = 0; + } } else { int n; if (sscanf(in, "cons%d", &n) == 1) { tty = n; + have_uinput = 0; } else if (sscanf(in, "console%d", &n) != 1) { tty = n; + have_uinput = 0; } } - if (tty >=0 && tty < 64) { - if (pipeinput_str == NULL) { + + if (do_input) { + if (tty >=0 && tty < 64) { pipeinput_str = (char *) malloc(10); sprintf(pipeinput_str, "CONS%d", tty); - rfbLog("console_guess: file pipeinput %s\n", pipeinput_str); + rfbLog("console_guess: file pipeinput %s\n", + pipeinput_str); + initialize_pipeinput(); + } else if (have_uinput) { + pipeinput_str = strdup("UINPUT"); + rfbLog("console_guess: file pipeinput %s\n", + pipeinput_str); initialize_pipeinput(); } } @@ -143,10 +166,20 @@ char *console_guess(char *str, int *fd) { void console_key_command(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { static int control = 0, alt = 0; + allowed_input_t input; + if (debug_keyboard) fprintf(stderr, "console_key_command: %d %s\n", (int) keysym, down ? "down" : "up"); + if (pipeinput_cons_fd < 0) { return; } + if (view_only) { + return; + } + get_allowed_input(client, &input); + if (! input.keystroke) { + return; + } /* From LinuxVNC.c: */ if (keysym == XK_Control_L || keysym == XK_Control_R) { @@ -250,6 +283,7 @@ void console_key_command(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { } void console_pointer_command(int mask, int x, int y, rfbClientPtr client) { + /* do not forget viewonly perms */ if (mask || x || y || client) {} } diff --git a/x11vnc/options.c b/x11vnc/options.c index 5e60627..1cfb5be 100644 --- a/x11vnc/options.c +++ b/x11vnc/options.c @@ -290,6 +290,7 @@ int naptile = 4; /* tile change threshold per poll to take a nap */ int napfac = 4; /* time = napfac*waitms, cut load with extra waits */ int napmax = 1500; /* longest nap in ms. */ int ui_skip = 10; /* see watchloop. negative means ignore input */ +int all_input = 0; #if LIBVNCSERVER_HAVE_FBPM diff --git a/x11vnc/options.h b/x11vnc/options.h index 059db27..5537ac8 100644 --- a/x11vnc/options.h +++ b/x11vnc/options.h @@ -219,6 +219,7 @@ extern int naptile; extern int napfac; extern int napmax; extern int ui_skip; +extern int all_input; extern int watch_fbpm; diff --git a/x11vnc/params.h b/x11vnc/params.h index 2a9ea0b..504304a 100644 --- a/x11vnc/params.h +++ b/x11vnc/params.h @@ -35,8 +35,11 @@ #define MAXN 256 -#define PIPEINPUT_NONE 0x0 -#define PIPEINPUT_VID 0x1 -#define PIPEINPUT_CONS 0x2 +#define PIPEINPUT_NONE 0x0 +#define PIPEINPUT_VID 0x1 +#define PIPEINPUT_CONS 0x2 +#define PIPEINPUT_UINPUT 0x3 + +#define MAX_BUTTONS 5 #endif /* _X11VNC_PARAMS_H */ diff --git a/x11vnc/pointer.c b/x11vnc/pointer.c index a5896cb..5bbda83 100644 --- a/x11vnc/pointer.c +++ b/x11vnc/pointer.c @@ -43,7 +43,6 @@ typedef struct ptrremap { #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD MUTEX(pointerMutex); #endif -#define MAX_BUTTONS 5 #define MAX_BUTTON_EVENTS 50 static prtremap_t pointer_map[MAX_BUTTONS+1][MAX_BUTTON_EVENTS]; @@ -522,9 +521,10 @@ static void pipe_pointer(int mask, int x, int y, rfbClientPtr client) { if (pipeinput_int == PIPEINPUT_VID) { v4l_pointer_command(mask, x, y, client); - } - if (pipeinput_int == PIPEINPUT_CONS) { + } else if (pipeinput_int == PIPEINPUT_CONS) { console_pointer_command(mask, x, y, client); + } else if (pipeinput_int == PIPEINPUT_UINPUT) { + uinput_pointer_command(mask, x, y, client); } if (pipeinput_fh == NULL) { return; @@ -536,6 +536,7 @@ static void pipe_pointer(int mask, int x, int y, rfbClientPtr client) { can_input = 1; /* XXX distinguish later */ } } + if (cd) { uid = cd->uid; } @@ -594,6 +595,7 @@ void pointer(int mask, int x, int y, rfbClientPtr client) { if (mask >= 0) { got_pointer_calls++; } + get_allowed_input(client, &input); if (debug_pointer && mask >= 0) { static int show_motion = -1; @@ -631,7 +633,7 @@ void pointer(int mask, int x, int y, rfbClientPtr client) { y = nfix(y, dpy_y); } - if (pipeinput_fh != NULL && mask >= 0) { + if ((pipeinput_fh != NULL || pipeinput_int) && mask >= 0) { pipe_pointer(mask, x, y, client); if (! pipeinput_tee) { if (! view_only || raw_fb) { /* raw_fb hack */ @@ -639,7 +641,7 @@ void pointer(int mask, int x, int y, rfbClientPtr client) { got_keyboard_input++; last_pointer_client = client; } - if (view_only && raw_fb) { + if (input.motion) { /* raw_fb hack track button state */ button_mask_prev = button_mask; button_mask = mask; @@ -659,7 +661,6 @@ void pointer(int mask, int x, int y, rfbClientPtr client) { * mask = -1 is a special case call from scan_for_updates() * to flush the event queue; there is no real pointer event. */ - get_allowed_input(client, &input); if (! input.motion && ! input.button) { return; } @@ -863,7 +864,7 @@ void pointer(int mask, int x, int y, rfbClientPtr client) { } void initialize_pipeinput(void) { - char *p; + char *p = NULL; if (pipeinput_fh != NULL) { rfbLog("closing pipeinput stream: %p\n", pipeinput_fh); @@ -882,7 +883,11 @@ void initialize_pipeinput(void) { } /* look for options: tee, reopen, ... */ - p = strchr(pipeinput_str, ':'); + if (strstr(pipeinput_str, "UINPUT") == pipeinput_str) { + ; + } else { + p = strchr(pipeinput_str, ':'); + } if (p != NULL) { char *str, *opt, *q; int got = 0; @@ -919,8 +924,7 @@ if (0) fprintf(stderr, "initialize_pipeinput: %s -- %s\n", pipeinput_str, p); if (!strcmp(p, "VID")) { pipeinput_int = PIPEINPUT_VID; return; - } - if (strstr(p, "CONS") == p) { + } else if (strstr(p, "CONS") == p) { int tty = 0, n; char dev[32]; if (sscanf(p, "CONS%d", &n) == 1) { @@ -940,6 +944,14 @@ if (0) fprintf(stderr, "initialize_pipeinput: %s -- %s\n", pipeinput_str, p); rfbLogPerror("open"); } return; + } else if (strstr(p, "UINPUT") == p) { + char *q = strchr(p, ':'); + if (q) { + parse_uinput_str(q+1); + } + pipeinput_int = PIPEINPUT_UINPUT; + initialize_uinput(); + return; } set_child_info(); @@ -990,16 +1002,16 @@ if (0) fprintf(stderr, "initialize_pipeinput: %s -- %s\n", pipeinput_str, p); "# It can be:\n" "#\n" "# None (nothing to report)\n" -"# ButtonPress-N (this event will cause button-1 to be pressed) \n" -"# ButtonRelease-N (this event will cause button-1 to be released) \n" +"# ButtonPress-N (this event will cause button-N to be pressed) \n" +"# ButtonRelease-N (this event will cause button-N to be released) \n" "#\n" "# if two more more buttons change state in one event they are listed\n" "# separated by commas.\n" "#\n" "# One might parse a Pointer line with:\n" "#\n" -"# int client, x, y, mask; char *hint;\n" -"# sscanf(line, \"Pointer %d %d %d %s\", &client, &x, &y, &mask, &hint);\n" +"# int client, x, y, mask; char hint[100];\n" +"# sscanf(line, \"Pointer %d %d %d %d %s\", &client, &x, &y, &mask, hint);\n" "#\n" "#\n" "# Keysym events (keyboard presses and releases) come in the form:\n" @@ -1023,8 +1035,8 @@ if (0) fprintf(stderr, "initialize_pipeinput: %s -- %s\n", pipeinput_str, p); "#\n" "# One might parse a Keysym line with:\n" "#\n" -"# int client, down, keysym; char *name, *hint;\n" -"# sscanf(line, \"Keysym %d %d %s %s\", &client, &down, &keysym, &name, &hint);\n" +"# int client, down, keysym; char name[100], hint[100];\n" +"# sscanf(line, \"Keysym %d %d %d %s %s\", &client, &down, &keysym, name, hint);\n" "#\n" "# The value is currently just None, KeyPress, or KeyRelease.\n" "#\n" @@ -1041,6 +1053,20 @@ if (0) fprintf(stderr, "initialize_pipeinput: %s -- %s\n", pipeinput_str, p); "# info will be enough for most purposes (having identical keyboards on\n" "# both sides helps).\n" "#\n" +"# Parsing example for perl:\n" +"#\n" +"# while (<>) {\n" +"# chomp;\n" +"# if (/^Pointer/) {\n" +"# my ($p, $client, $x, $y, $mask, $hint) = split(' ', $_, 6);\n" +"# do_pointer($client, $x, $y, $mask, $hint);\n" +"# } elsif (/^Keysym/) {\n" +"# my ($k, $client, $down, $keysym, $name, $hint) = split(' ', $_, 6);\n" +"# do_keysym($client, $down, $keysym, $name, $hint);\n" +"# }\n" +"# }\n" +"#\n" +"#\n" "# Here comes your stream. The following token will always indicate the\n" "# end of this informational text:\n" "# END_OF_TOP\n" diff --git a/x11vnc/remote.c b/x11vnc/remote.c index 78148fd..9666796 100644 --- a/x11vnc/remote.c +++ b/x11vnc/remote.c @@ -24,6 +24,7 @@ #include "keyboard.h" #include "selection.h" #include "unixpw.h" +#include "uinput.h" int send_remote_cmd(char *cmd, int query, int wait); int do_remote_query(char *remote_cmd, char *query_cmd, int remote_sync, @@ -3029,6 +3030,21 @@ char *process_remote_cmd(char *cmd, int stringonly) { rfbLog("remote_cmd: setting input_skip %d\n", is); ui_skip = is; + } else if (!strcmp(p, "allinput")) { + if (query) { + snprintf(buf, bufn, "ans=%s:%d", p, all_input); + goto qry; + } + all_input = 1; + rfbLog("enabled allinput\n"); + } else if (!strcmp(p, "noallinput")) { + if (query) { + snprintf(buf, bufn, "ans=%s:%d", p, !all_input); + goto qry; + } + all_input = 0; + rfbLog("disabled allinput\n"); + } else if (strstr(p, "input") == p) { int doit = 1; COLON_CHECK("input:") @@ -3436,6 +3452,28 @@ char *process_remote_cmd(char *cmd, int stringonly) { do_new_fb(1); raw_fb_back_to_X = 0; + } else if (strstr(p, "uinput_accel") == p) { + COLON_CHECK("uinput_accel:") + if (query) { + snprintf(buf, bufn, "ans=%s%s%s", p, co, + NONUL(get_uinput_accel())); + goto qry; + } + p += strlen("uinput_accel:"); + rfbLog("set_uinput_accel: %s\n", p); + set_uinput_accel(p); + + } else if (strstr(p, "uinput_reset") == p) { + COLON_CHECK("uinput_reset:") + p += strlen("uinput_reset:"); + if (query) { + snprintf(buf, bufn, "ans=%s%s%d", p, co, + get_uinput_reset()); + goto qry; + } + rfbLog("set_uinput_reset: %s\n", p); + set_uinput_reset(atoi(p)); + } else if (strstr(p, "progressive") == p) { int f; COLON_CHECK("progressive:") diff --git a/x11vnc/screen.c b/x11vnc/screen.c index a309c5c..876cef4 100644 --- a/x11vnc/screen.c +++ b/x11vnc/screen.c @@ -574,10 +574,12 @@ void set_raw_fb_params(int restore) { } } else { /* Normal case: */ - if (! view_only) { +#if 0 + if (! view_only && ! pipeinput_str) { if (! quiet) rfbLog(" rawfb: setting view_only\n"); view_only = 1; } +#endif if (watch_selection) { if (! quiet) rfbLog(" rawfb: turning off " "watch_selection\n"); @@ -609,10 +611,6 @@ void set_raw_fb_params(int restore) { } multiple_cursors_mode = strdup("arrow"); } - if (0 && use_snapfb) { - if (! quiet) rfbLog(" rawfb: turning off use_snapfb\n"); - use_snapfb = 0; - } if (using_shm) { if (! quiet) rfbLog(" rawfb: turning off using_shm\n"); using_shm = 0; @@ -963,7 +961,8 @@ if (db) fprintf(stderr, "initialize_raw_fb reset\n"); rawfb_dev_video = 1; } else if (strstr(str, "dev/video")) { rawfb_dev_video = 1; - } else if (strstr(str, "cons") == str || strstr(str, "/dev/fb") == str) { + } else if (strstr(str, "cons") == str || strstr(str, "fb") == str || + strstr(str, "/dev/fb") == str) { char *str2 = console_guess(str, &raw_fb_fd); if (str2 == NULL) { rfbLog("console_guess failed for: %s\n", str); diff --git a/x11vnc/tkx11vnc b/x11vnc/tkx11vnc index 10dbb50..adffad6 100755 --- a/x11vnc/tkx11vnc +++ b/x11vnc/tkx11vnc @@ -178,6 +178,8 @@ Screen visual: rawfb: pipeinput: + uinput_accel: + uinput_reset: 24to32 =GAL LOFF @@ -317,6 +319,7 @@ Permissions Tuning =D-C:0,1,2,3,4 pointer_mode: input_skip: + allinput =D nodragging -- D speeds: diff --git a/x11vnc/tkx11vnc.h b/x11vnc/tkx11vnc.h index b4f9232..c657ab6 100644 --- a/x11vnc/tkx11vnc.h +++ b/x11vnc/tkx11vnc.h @@ -189,6 +189,8 @@ char gui_code[] = ""; " visual:\n" " rawfb:\n" " pipeinput:\n" +" uinput_accel:\n" +" uinput_reset:\n" " 24to32\n" " =GAL LOFF\n" "\n" @@ -328,6 +330,7 @@ char gui_code[] = ""; "Tuning\n" " =D-C:0,1,2,3,4 pointer_mode:\n" " input_skip:\n" +" allinput\n" " =D nodragging\n" " -- D\n" " speeds:\n" diff --git a/x11vnc/uinput.c b/x11vnc/uinput.c new file mode 100644 index 0000000..1c3f1b2 --- /dev/null +++ b/x11vnc/uinput.c @@ -0,0 +1,1097 @@ +/* -- uinput.c -- */ + +#include "x11vnc.h" +#include "cleanup.h" +#include "scan.h" +#include "xinerama.h" +#include "screen.h" +#include "pointer.h" +#include "allowed_input_t.h" + +#if LIBVNCSERVER_HAVE_SYS_IOCTL_H +#if LIBVNCSERVER_HAVE_LINUX_INPUT_H +#if LIBVNCSERVER_HAVE_LINUX_UINPUT_H +#define UINPUT_OK +#endif +#endif +#endif + +#ifdef UINPUT_OK +#include +#include +#include +#endif + +int check_uinput(void); +int initialize_uinput(void); +int set_uinput_accel(char *str); +void set_uinput_reset(int ms); +char *get_uinput_accel(); +int get_uinput_reset(); +void parse_uinput_str(char *str); +void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client); +void uinput_key_command(int down, int keysym, rfbClientPtr client); + +static void set_uinput_accel_xy(double fx, double fy); +static void shutdown_uinput(void); +static void ptr_move(int dx, int dy); +static void ptr_rel(int dx, int dy); +static void button_click(int down, int btn); +static int lookup_code(int keysym); + +static int fd = -1; +static int db = 1; +static int bmask = 0; + +static char *injectable = NULL; +static char *uinput_dev = NULL; + +static char *devs[] = { + "/dev/misc/uinput", + "/dev/input/uinput", + "/dev/uinput", + NULL +}; + + +/* + * User may need to do: + modprode uinput + mknod /dev/input/uinput c 10 223 + */ + +int check_uinput(void) { + int i; +#ifndef UINPUT_OK + return 0; +#else + if (UT.release) { + int maj, min; + /* guard against linux 2.4 */ + if (sscanf(UT.release, "%d.%d.", &maj, &min) == 2) { + if (maj < 2) { + return 0; + } else if (maj == 2) { + if (min < 6) { + return 0; + } + } + } + } + fd = -1; + i = 0; + while (devs[i] != NULL) { + if ( (fd = open(devs[i++], O_RDWR)) >= 0) { + break; + } + } + if (fd < 0) { + return 0; + } + close(fd); + fd = -1; + return 1; +#endif +} + +static void shutdown_uinput(void) { +#ifdef UINPUT_OK + ioctl(fd, UI_DEV_DESTROY); +#endif +} + +int initialize_uinput(void) { +#ifndef UINPUT_OK + return 0; +#else + int i; + struct uinput_user_dev udev; + + if (fd >= 0) { + shutdown_uinput(); + close(fd); + fd = -1; + } + + if (uinput_dev) { + fd = open(uinput_dev, O_RDWR); + rfbLog("initialize_uinput: using: %s %d\n", uinput_dev, fd); + } else { + i = 0; + while (devs[i] != NULL) { + if ( (fd = open(devs[i], O_RDWR)) >= 0) { + rfbLog("initialize_uinput: using: %s %d\n", + devs[i], fd); + break; + } + i++; + } + } + if (fd < 0) { + rfbLog("initialize_uinput: could not open an uinput device.\n"); + rfbLogPerror("open"); + clean_up_exit(1); + } + + memset(&udev, 0, sizeof(udev)); + + strncpy(udev.name, "x11vnc injector", UINPUT_MAX_NAME_SIZE); + + udev.id.bustype = BUS_USB; /* Matters? */ + udev.id.version = 4; + + ioctl(fd, UI_SET_EVBIT, EV_REL); + ioctl(fd, UI_SET_RELBIT, REL_X); + ioctl(fd, UI_SET_RELBIT, REL_Y); + + ioctl(fd, UI_SET_EVBIT, EV_KEY); + + for (i=0; i < 256; i++) { + ioctl(fd, UI_SET_KEYBIT, i); + } + + ioctl(fd, UI_SET_KEYBIT, BTN_MOUSE); + ioctl(fd, UI_SET_KEYBIT, BTN_LEFT); + ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE); + ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT); + ioctl(fd, UI_SET_KEYBIT, BTN_FORWARD); + ioctl(fd, UI_SET_KEYBIT, BTN_BACK); + + write(fd, &udev, sizeof(udev)); + + if (ioctl(fd, UI_DEV_CREATE) != 0) { + rfbLog("ioctl(fd, UI_DEV_CREATE) failed.\n"); + rfbLogPerror("ioctl"); + close(fd); + clean_up_exit(1); + } + return 1; +#endif +} + +static double fudge_x = 0.5; /* accel=2.0 */ +static double fudge_y = 0.5; + +static double resid_x = 0.0; +static double resid_y = 0.0; + +static double zero_delay = 0.5; + +static void set_uinput_accel_xy(double fx, double fy) { + fudge_x = 1.0/fx; + fudge_y = 1.0/fy; + rfbLog("set_uinput_accel: fx=%.5f fy=%.5f\n", fx, fy); + rfbLog("set_uinput_accel: ix=%.5f iy=%.5f\n", fudge_x, fudge_y); +} + +static char *uinput_accel_str = NULL; + +int set_uinput_accel(char *str) { + double fx, fy; + rfbLog("set_uinput_accel: str=%s\n", str); + if (sscanf(str, "%lf+%lf", &fx, &fy) == 2) { + set_uinput_accel_xy(fx, fy); + } else if (sscanf(str, "%lf", &fx) == 1) { + set_uinput_accel_xy(fx, fx); + } else { + rfbLog("invalid UINPUT accel= option: %s\n", str); + return 0; + } + if (uinput_accel_str) { + free(uinput_accel_str); + } + uinput_accel_str = strdup(str); + return 1; +} + +void set_uinput_reset(int ms) { + zero_delay = (double) ms/1000.; + rfbLog("set_uinput_reset: %d\n", ms); +} + +char *get_uinput_accel(void) { + return uinput_accel_str; +} +int get_uinput_reset(void) { + return (int) (1000 * zero_delay); +} + +void parse_uinput_str(char *in) { + char *p, *q, *str = strdup(in); + + if (injectable) { + free(injectable); + injectable = strdup("KMB"); + } + + p = strtok(str, ","); + while (p) { + if (p[0] == '/') { + if (uinput_dev) { + free(uinput_dev); + } + uinput_dev = strdup(p); + } else if (strstr(p, "accel=") == p) { + double fx, fy; + q = p + strlen("accel="); + if (! set_uinput_accel(q)) { + clean_up_exit(1); + } + + } else if (strstr(p, "reset=") == p) { + int n = atoi(p + strlen("reset=")); + set_uinput_reset(n); + } else if (strpbrk(p, "KMB") == p) { + if (injectable) { + free(injectable); + } + injectable = strdup(p); + } else { + rfbLog("invalid UINPUT option: %s\n", p); + clean_up_exit(1); + } + p = strtok(NULL, ","); + } + free(str); +} + +static void ptr_move(int dx, int dy) { +#ifdef UINPUT_OK + struct input_event ev; + + if (injectable && strchr(injectable, 'M') == NULL) { + return; + } +if (0) fprintf(stderr, "ptr_move: %d %d\n", dx, dy); + + memset(&ev, 0, sizeof(ev)); + + gettimeofday(&ev.time, NULL); + ev.type = EV_REL; + ev.code = REL_X; + ev.value = dx; + write(fd, &ev, sizeof(ev)); + + ev.type = EV_REL; + ev.code = REL_Y; + ev.value = dy; + write(fd, &ev, sizeof(ev)); + + ev.type = EV_SYN; + ev.code = SYN_REPORT; + ev.value = 0; + write(fd, &ev, sizeof(ev)); +#endif +} + +static void ptr_rel(int dx, int dy) { + int dxf, dyf; + + dxf = (int) (fudge_x * (double) dx); + dyf = (int) (fudge_y * (double) dy); + + if (db > 1) fprintf(stderr, "old dx dy: %d %d\n", dx, dy); + if (db > 1) fprintf(stderr, "new dx dy: %d %d\n", dxf, dyf); + + ptr_move(dxf, dyf); + + resid_x += fudge_x * (double) dx - dxf; + resid_y += fudge_y * (double) dy - dyf; + + if (resid_x < -1.0 || resid_x > 1.0 || resid_y < -1.0 || resid_y > 1.0) { + dxf = 0; + dyf = 0; + if (resid_x > 1.0) { + dxf = (int) resid_x; + } else if (resid_x < -1.0) { + dxf = -((int) (-resid_x)); + } + resid_x -= dxf; + if (resid_y > 1.0) { + dyf = (int) resid_y; + } else if (resid_y < -1.0) { + dyf = -((int) (-resid_y)); + } + resid_y -= dyf; + ptr_move(dxf, dyf); + } +} + +static void button_click(int down, int btn) { +#ifdef UINPUT_OK + struct input_event ev; + + if (injectable && strchr(injectable, 'B') == NULL) { + return; + } + + if (db) fprintf(stderr, "down %d btn %d\n", down, btn); + + memset(&ev, 0, sizeof(ev)); + gettimeofday(&ev.time, NULL); + ev.type = EV_KEY; + ev.value = down; + + if (btn == 1) { + ev.code = BTN_LEFT; + } else if (btn == 2) { + ev.code = BTN_MIDDLE; + } else if (btn == 3) { + ev.code = BTN_RIGHT; + } else if (btn == 4) { + ev.code = BTN_FORWARD; + } else if (btn == 5) { + ev.code = BTN_BACK; + } else { + return; + } + + write(fd, &ev, sizeof(ev)); + + ev.type = EV_SYN; + ev.code = SYN_REPORT; + ev.value = 0; + write(fd, &ev, sizeof(ev)); + +#endif +} + + +void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) { + static int last_x = -1, last_y = -1, last_mask = -1; + static double last_zero = 0.0; + allowed_input_t input; + + if (db) fprintf(stderr, "uinput_pointer_command: %d %d - %d\n", x, y, mask); + + if (view_only) { + return; + } + get_allowed_input(client, &input); + + if (!bmask && dnow() >= last_zero + zero_delay && input.motion) { + static int first = 1; + + if (zero_delay > 0.0 || first) { + /* try to push it to 0,0 */ + int tx = fudge_x * last_x; + int ty = fudge_y * last_y; + int bigjump = 1; + + if (bigjump) { + ptr_move(-tx, -ty); + ptr_move(-tx, -ty); + } else { + int i, step, n = 20; + step = dpy_x / n; + if (step < 100) step = 100; + for (i=0; i < n; i++) { + ptr_move(-step, -step); + } + for (i=0; i < n; i++) { + ptr_move(-1, -1); + } + } + if (db) fprintf(stderr, "uinput_pointer_command: reset\n"); + + /* rest a bit for system to absorb the change */ + usleep(30*1000); + + /* now jump back out */ + ptr_rel(x, y); + + last_x = x; + last_y = y; + resid_x = 0.0; + resid_y = 0.0; + + first = 0; + } + last_zero = dnow(); + } + + if (input.motion) { + if (x != last_x || y != last_y) { + ptr_rel(x - last_x, y - last_y); + last_x = x; + last_y = y; + } + } + + if (! input.button) { + return; + } + + if (last_mask < 0) { + last_mask = mask; + } + +#if 0 +fprintf(stderr, "mask: %s\n", bitprint(mask, 16)); +fprintf(stderr, "bmask: %s\n", bitprint(bmask, 16)); +fprintf(stderr, "last_mask: %s\n", bitprint(last_mask, 16)); +fprintf(stderr, "button_mask: %s\n", bitprint(button_mask, 16)); +#endif + + if (mask != last_mask) { + int i; + for (i=1; i <= MAX_BUTTONS; i++) { + int down, b = 1 << (i-1); + if ( (last_mask & b) == (mask & b)) { + continue; + } + if (mask & b) { + down = 1; + } else { + down = 0; + } + button_click(down, i); + } + last_mask = mask; + } + bmask = mask; +} + +void uinput_key_command(int down, int keysym, rfbClientPtr client) { +#ifdef UINPUT_OK + struct input_event ev; + int scancode; + allowed_input_t input; + + if (injectable && strchr(injectable, 'K') == NULL) { + return; + } + if (view_only) { + return; + } + get_allowed_input(client, &input); + if (! input.keystroke) { + return; + } + + scancode = lookup_code(keysym); + + if (scancode < 0) { + return; + } + if (db) fprintf(stderr, "uinput_key_command: %d -> %d\n", keysym, scancode); + + memset(&ev, 0, sizeof(ev)); + gettimeofday(&ev.time, NULL); + ev.type = EV_KEY; + ev.code = (unsigned char) scancode; + ev.value = down; + + write(fd, &ev, sizeof(ev)); + + ev.type = EV_SYN; + ev.code = SYN_REPORT; + ev.value = 0; + write(fd, &ev, sizeof(ev)); +#endif +} + +static int lookup_code(int keysym) { + + if (keysym == NoSymbol) { + return -1; + } + + switch(keysym) { +#ifdef UINPUT_OK + case XK_Escape: return KEY_ESC; + case XK_1: return KEY_1; + case XK_2: return KEY_2; + case XK_3: return KEY_3; + case XK_4: return KEY_4; + case XK_5: return KEY_5; + case XK_6: return KEY_6; + case XK_7: return KEY_7; + case XK_8: return KEY_8; + case XK_9: return KEY_9; + case XK_0: return KEY_0; + case XK_exclam: return KEY_1; + case XK_at: return KEY_2; + case XK_numbersign: return KEY_3; + case XK_dollar: return KEY_4; + case XK_percent: return KEY_5; + case XK_asciicircum: return KEY_6; + case XK_ampersand: return KEY_7; + case XK_asterisk: return KEY_8; + case XK_parenleft: return KEY_9; + case XK_parenright: return KEY_0; + case XK_minus: return KEY_MINUS; + case XK_underscore: return KEY_MINUS; + case XK_equal: return KEY_EQUAL; + case XK_plus: return KEY_EQUAL; + case XK_BackSpace: return KEY_BACKSPACE; + case XK_Tab: return KEY_TAB; + case XK_q: return KEY_Q; + case XK_Q: return KEY_Q; + case XK_w: return KEY_W; + case XK_W: return KEY_W; + case XK_e: return KEY_E; + case XK_E: return KEY_E; + case XK_r: return KEY_R; + case XK_R: return KEY_R; + case XK_t: return KEY_T; + case XK_T: return KEY_T; + case XK_y: return KEY_Y; + case XK_Y: return KEY_Y; + case XK_u: return KEY_U; + case XK_U: return KEY_U; + case XK_i: return KEY_I; + case XK_I: return KEY_I; + case XK_o: return KEY_O; + case XK_O: return KEY_O; + case XK_p: return KEY_P; + case XK_P: return KEY_P; + case XK_braceleft: return KEY_LEFTBRACE; + case XK_braceright: return KEY_RIGHTBRACE; + case XK_bracketleft: return KEY_LEFTBRACE; + case XK_bracketright: return KEY_RIGHTBRACE; + case XK_Return: return KEY_ENTER; + case XK_Control_L: return KEY_LEFTCTRL; + case XK_a: return KEY_A; + case XK_A: return KEY_A; + case XK_s: return KEY_S; + case XK_S: return KEY_S; + case XK_d: return KEY_D; + case XK_D: return KEY_D; + case XK_f: return KEY_F; + case XK_F: return KEY_F; + case XK_g: return KEY_G; + case XK_G: return KEY_G; + case XK_h: return KEY_H; + case XK_H: return KEY_H; + case XK_j: return KEY_J; + case XK_J: return KEY_J; + case XK_k: return KEY_K; + case XK_K: return KEY_K; + case XK_l: return KEY_L; + case XK_L: return KEY_L; + case XK_semicolon: return KEY_SEMICOLON; + case XK_colon: return KEY_SEMICOLON; + case XK_apostrophe: return KEY_APOSTROPHE; + case XK_quotedbl: return KEY_APOSTROPHE; + case XK_grave: return KEY_GRAVE; + case XK_asciitilde: return KEY_GRAVE; + case XK_Shift_L: return KEY_LEFTSHIFT; + case XK_backslash: return KEY_BACKSLASH; + case XK_bar: return KEY_BACKSLASH; + case XK_z: return KEY_Z; + case XK_Z: return KEY_Z; + case XK_x: return KEY_X; + case XK_X: return KEY_X; + case XK_c: return KEY_C; + case XK_C: return KEY_C; + case XK_v: return KEY_V; + case XK_V: return KEY_V; + case XK_b: return KEY_B; + case XK_B: return KEY_B; + case XK_n: return KEY_N; + case XK_N: return KEY_N; + case XK_m: return KEY_M; + case XK_M: return KEY_M; + case XK_comma: return KEY_COMMA; + case XK_less: return KEY_COMMA; + case XK_period: return KEY_DOT; + case XK_greater: return KEY_DOT; + case XK_slash: return KEY_SLASH; + case XK_question: return KEY_SLASH; + case XK_Shift_R: return KEY_RIGHTSHIFT; + case XK_KP_Multiply: return KEY_KPASTERISK; + case XK_Alt_L: return KEY_LEFTALT; + case XK_space: return KEY_SPACE; + case XK_Caps_Lock: return KEY_CAPSLOCK; + case XK_F1: return KEY_F1; + case XK_F2: return KEY_F2; + case XK_F3: return KEY_F3; + case XK_F4: return KEY_F4; + case XK_F5: return KEY_F5; + case XK_F6: return KEY_F6; + case XK_F7: return KEY_F7; + case XK_F8: return KEY_F8; + case XK_F9: return KEY_F9; + case XK_F10: return KEY_F10; + case XK_Num_Lock: return KEY_NUMLOCK; + case XK_Scroll_Lock: return KEY_SCROLLLOCK; + case XK_KP_7: return KEY_KP7; + case XK_KP_8: return KEY_KP8; + case XK_KP_9: return KEY_KP9; + case XK_KP_Subtract: return KEY_KPMINUS; + case XK_KP_4: return KEY_KP4; + case XK_KP_5: return KEY_KP5; + case XK_KP_6: return KEY_KP6; + case XK_KP_Add: return KEY_KPPLUS; + case XK_KP_1: return KEY_KP1; + case XK_KP_2: return KEY_KP2; + case XK_KP_3: return KEY_KP3; + case XK_KP_0: return KEY_KP0; + case XK_KP_Decimal: return KEY_KPDOT; + case XK_F13: return KEY_F13; + case XK_F11: return KEY_F11; + case XK_F12: return KEY_F12; + case XK_F14: return KEY_F14; + case XK_F15: return KEY_F15; + case XK_F16: return KEY_F16; + case XK_F17: return KEY_F17; + case XK_F18: return KEY_F18; + case XK_F19: return KEY_F19; + case XK_F20: return KEY_F20; + case XK_KP_Enter: return KEY_KPENTER; + case XK_Control_R: return KEY_RIGHTCTRL; + case XK_KP_Divide: return KEY_KPSLASH; + case XK_Sys_Req: return KEY_SYSRQ; + case XK_Alt_R: return KEY_RIGHTALT; + case XK_Linefeed: return KEY_LINEFEED; + case XK_Home: return KEY_HOME; + case XK_Up: return KEY_UP; + case XK_Page_Up: return KEY_PAGEUP; + case XK_Left: return KEY_LEFT; + case XK_Right: return KEY_RIGHT; + case XK_End: return KEY_END; + case XK_Down: return KEY_DOWN; + case XK_Page_Down: return KEY_PAGEDOWN; + case XK_Insert: return KEY_INSERT; + case XK_Delete: return KEY_DELETE; + case XK_KP_Equal: return KEY_KPEQUAL; + case XK_Pause: return KEY_PAUSE; + case XK_F21: return KEY_F21; + case XK_F22: return KEY_F22; + case XK_F23: return KEY_F23; + case XK_F24: return KEY_F24; + case XK_KP_Separator: return KEY_KPCOMMA; + case XK_Meta_L: return KEY_LEFTMETA; + case XK_Meta_R: return KEY_RIGHTMETA; + case XK_Multi_key: return KEY_COMPOSE; +#endif + default: return -1; + } +} + +#if 0 + +From /usr/include/linux/input.h + +We maintain it here since it is such a painful mess. + +Here is a little script to make it easier: + +#!/usr/bin/perl +while (<>) { + $_ =~ s/-XK_/XK_/; + next unless /^XK_/; + chomp; + if (/^(\S+)(\s+)(\S+)/) { + $a = $1; + $t = $2; + $b = $3; + print "\tcase $a:${t}return $b;\n"; + if ($a =~ /XK_[a-z]$/) { + $a = uc($a); + print "\tcase $a:${t}return $b;\n"; + } + } +} + +This only handles us kbd, we would need a kbd database in general... + +XK_Escape KEY_ESC +XK_1 KEY_1 +XK_2 KEY_2 +XK_3 KEY_3 +XK_4 KEY_4 +XK_5 KEY_5 +XK_6 KEY_6 +XK_7 KEY_7 +XK_8 KEY_8 +XK_9 KEY_9 +XK_0 KEY_0 +-XK_exclam KEY_1 +-XK_at KEY_2 +-XK_numbersign KEY_3 +-XK_dollar KEY_4 +-XK_percent KEY_5 +-XK_asciicircum KEY_6 +-XK_ampersand KEY_7 +-XK_asterisk KEY_8 +-XK_parenleft KEY_9 +-XK_parenright KEY_0 +XK_minus KEY_MINUS +-XK_underscore KEY_MINUS +XK_equal KEY_EQUAL +-XK_plus KEY_EQUAL +XK_BackSpace KEY_BACKSPACE +XK_Tab KEY_TAB +XK_q KEY_Q +XK_w KEY_W +XK_e KEY_E +XK_r KEY_R +XK_t KEY_T +XK_y KEY_Y +XK_u KEY_U +XK_i KEY_I +XK_o KEY_O +XK_p KEY_P +XK_braceleft KEY_LEFTBRACE +XK_braceright KEY_RIGHTBRACE +-XK_bracketleft KEY_LEFTBRACE +-XK_bracketright KEY_RIGHTBRACE +XK_Return KEY_ENTER +XK_Control_L KEY_LEFTCTRL +XK_a KEY_A +XK_s KEY_S +XK_d KEY_D +XK_f KEY_F +XK_g KEY_G +XK_h KEY_H +XK_j KEY_J +XK_k KEY_K +XK_l KEY_L +XK_semicolon KEY_SEMICOLON +-XK_colon KEY_SEMICOLON +XK_apostrophe KEY_APOSTROPHE +-XK_quotedbl KEY_APOSTROPHE +XK_grave KEY_GRAVE +-XK_asciitilde KEY_GRAVE +XK_Shift_L KEY_LEFTSHIFT +XK_backslash KEY_BACKSLASH +-XK_bar KEY_BACKSLASH +XK_z KEY_Z +XK_x KEY_X +XK_c KEY_C +XK_v KEY_V +XK_b KEY_B +XK_n KEY_N +XK_m KEY_M +XK_comma KEY_COMMA +-XK_less KEY_COMMA +XK_period KEY_DOT +-XK_greater KEY_DOT +XK_slash KEY_SLASH +-XK_question KEY_SLASH +XK_Shift_R KEY_RIGHTSHIFT +XK_KP_Multiply KEY_KPASTERISK +XK_Alt_L KEY_LEFTALT +XK_space KEY_SPACE +XK_Caps_Lock KEY_CAPSLOCK +XK_F1 KEY_F1 +XK_F2 KEY_F2 +XK_F3 KEY_F3 +XK_F4 KEY_F4 +XK_F5 KEY_F5 +XK_F6 KEY_F6 +XK_F7 KEY_F7 +XK_F8 KEY_F8 +XK_F9 KEY_F9 +XK_F10 KEY_F10 +XK_Num_Lock KEY_NUMLOCK +XK_Scroll_Lock KEY_SCROLLLOCK +XK_KP_7 KEY_KP7 +XK_KP_8 KEY_KP8 +XK_KP_9 KEY_KP9 +XK_KP_Subtract KEY_KPMINUS +XK_KP_4 KEY_KP4 +XK_KP_5 KEY_KP5 +XK_KP_6 KEY_KP6 +XK_KP_Add KEY_KPPLUS +XK_KP_1 KEY_KP1 +XK_KP_2 KEY_KP2 +XK_KP_3 KEY_KP3 +XK_KP_0 KEY_KP0 +XK_KP_Decimal KEY_KPDOT +NoSymbol KEY_103RD +XK_F13 KEY_F13 +NoSymbol KEY_102ND +XK_F11 KEY_F11 +XK_F12 KEY_F12 +XK_F14 KEY_F14 +XK_F15 KEY_F15 +XK_F16 KEY_F16 +XK_F17 KEY_F17 +XK_F18 KEY_F18 +XK_F19 KEY_F19 +XK_F20 KEY_F20 +XK_KP_Enter KEY_KPENTER +XK_Control_R KEY_RIGHTCTRL +XK_KP_Divide KEY_KPSLASH +XK_Sys_Req KEY_SYSRQ +XK_Alt_R KEY_RIGHTALT +XK_Linefeed KEY_LINEFEED +XK_Home KEY_HOME +XK_Up KEY_UP +XK_Page_Up KEY_PAGEUP +XK_Left KEY_LEFT +XK_Right KEY_RIGHT +XK_End KEY_END +XK_Down KEY_DOWN +XK_Page_Down KEY_PAGEDOWN +XK_Insert KEY_INSERT +XK_Delete KEY_DELETE +NoSymbol KEY_MACRO +NoSymbol KEY_MUTE +NoSymbol KEY_VOLUMEDOWN +NoSymbol KEY_VOLUMEUP +NoSymbol KEY_POWER +XK_KP_Equal KEY_KPEQUAL +NoSymbol KEY_KPPLUSMINUS +XK_Pause KEY_PAUSE +XK_F21 KEY_F21 +XK_F22 KEY_F22 +XK_F23 KEY_F23 +XK_F24 KEY_F24 +XK_KP_Separator KEY_KPCOMMA +XK_Meta_L KEY_LEFTMETA +XK_Meta_R KEY_RIGHTMETA +XK_Multi_key KEY_COMPOSE + +NoSymbol KEY_STOP +NoSymbol KEY_AGAIN +NoSymbol KEY_PROPS +NoSymbol KEY_UNDO +NoSymbol KEY_FRONT +NoSymbol KEY_COPY +NoSymbol KEY_OPEN +NoSymbol KEY_PASTE +NoSymbol KEY_FIND +NoSymbol KEY_CUT +NoSymbol KEY_HELP +NoSymbol KEY_MENU +NoSymbol KEY_CALC +NoSymbol KEY_SETUP +NoSymbol KEY_SLEEP +NoSymbol KEY_WAKEUP +NoSymbol KEY_FILE +NoSymbol KEY_SENDFILE +NoSymbol KEY_DELETEFILE +NoSymbol KEY_XFER +NoSymbol KEY_PROG1 +NoSymbol KEY_PROG2 +NoSymbol KEY_WWW +NoSymbol KEY_MSDOS +NoSymbol KEY_COFFEE +NoSymbol KEY_DIRECTION +NoSymbol KEY_CYCLEWINDOWS +NoSymbol KEY_MAIL +NoSymbol KEY_BOOKMARKS +NoSymbol KEY_COMPUTER +NoSymbol KEY_BACK +NoSymbol KEY_FORWARD +NoSymbol KEY_CLOSECD +NoSymbol KEY_EJECTCD +NoSymbol KEY_EJECTCLOSECD +NoSymbol KEY_NEXTSONG +NoSymbol KEY_PLAYPAUSE +NoSymbol KEY_PREVIOUSSONG +NoSymbol KEY_STOPCD +NoSymbol KEY_RECORD +NoSymbol KEY_REWIND +NoSymbol KEY_PHONE +NoSymbol KEY_ISO +NoSymbol KEY_CONFIG +NoSymbol KEY_HOMEPAGE +NoSymbol KEY_REFRESH +NoSymbol KEY_EXIT +NoSymbol KEY_MOVE +NoSymbol KEY_EDIT +NoSymbol KEY_SCROLLUP +NoSymbol KEY_SCROLLDOWN +NoSymbol KEY_KPLEFTPAREN +NoSymbol KEY_KPRIGHTPAREN + +NoSymbol KEY_INTL1 +NoSymbol KEY_INTL2 +NoSymbol KEY_INTL3 +NoSymbol KEY_INTL4 +NoSymbol KEY_INTL5 +NoSymbol KEY_INTL6 +NoSymbol KEY_INTL7 +NoSymbol KEY_INTL8 +NoSymbol KEY_INTL9 +NoSymbol KEY_LANG1 +NoSymbol KEY_LANG2 +NoSymbol KEY_LANG3 +NoSymbol KEY_LANG4 +NoSymbol KEY_LANG5 +NoSymbol KEY_LANG6 +NoSymbol KEY_LANG7 +NoSymbol KEY_LANG8 +NoSymbol KEY_LANG9 + +NoSymbol KEY_PLAYCD +NoSymbol KEY_PAUSECD +NoSymbol KEY_PROG3 +NoSymbol KEY_PROG4 +NoSymbol KEY_SUSPEND +NoSymbol KEY_CLOSE +NoSymbol KEY_PLAY +NoSymbol KEY_FASTFORWARD +NoSymbol KEY_BASSBOOST +NoSymbol KEY_PRINT +NoSymbol KEY_HP +NoSymbol KEY_CAMERA +NoSymbol KEY_SOUND +NoSymbol KEY_QUESTION +NoSymbol KEY_EMAIL +NoSymbol KEY_CHAT +NoSymbol KEY_SEARCH +NoSymbol KEY_CONNECT +NoSymbol KEY_FINANCE +NoSymbol KEY_SPORT +NoSymbol KEY_SHOP +NoSymbol KEY_ALTERASE +NoSymbol KEY_CANCEL +NoSymbol KEY_BRIGHTNESSDOWN +NoSymbol KEY_BRIGHTNESSUP +NoSymbol KEY_MEDIA + +NoSymbol KEY_UNKNOWN +NoSymbol +NoSymbol BTN_MISC +NoSymbol BTN_0 +NoSymbol BTN_1 +NoSymbol BTN_2 +NoSymbol BTN_3 +NoSymbol BTN_4 +NoSymbol BTN_5 +NoSymbol BTN_6 +NoSymbol BTN_7 +NoSymbol BTN_8 +NoSymbol BTN_9 +NoSymbol +NoSymbol BTN_MOUSE +NoSymbol BTN_LEFT +NoSymbol BTN_RIGHT +NoSymbol BTN_MIDDLE +NoSymbol BTN_SIDE +NoSymbol BTN_EXTRA +NoSymbol BTN_FORWARD +NoSymbol BTN_BACK +NoSymbol BTN_TASK +NoSymbol +NoSymbol BTN_JOYSTICK +NoSymbol BTN_TRIGGER +NoSymbol BTN_THUMB +NoSymbol BTN_THUMB2 +NoSymbol BTN_TOP +NoSymbol BTN_TOP2 +NoSymbol BTN_PINKIE +NoSymbol BTN_BASE +NoSymbol BTN_BASE2 +NoSymbol BTN_BASE3 +NoSymbol BTN_BASE4 +NoSymbol BTN_BASE5 +NoSymbol BTN_BASE6 +NoSymbol BTN_DEAD + +NoSymbol BTN_GAMEPAD +NoSymbol BTN_A +NoSymbol BTN_B +NoSymbol BTN_C +NoSymbol BTN_X +NoSymbol BTN_Y +NoSymbol BTN_Z +NoSymbol BTN_TL +NoSymbol BTN_TR +NoSymbol BTN_TL2 +NoSymbol BTN_TR2 +NoSymbol BTN_SELECT +NoSymbol BTN_START +NoSymbol BTN_MODE +NoSymbol BTN_THUMBL +NoSymbol BTN_THUMBR + +NoSymbol BTN_DIGI +NoSymbol BTN_TOOL_PEN +NoSymbol BTN_TOOL_RUBBER +NoSymbol BTN_TOOL_BRUSH +NoSymbol BTN_TOOL_PENCIL +NoSymbol BTN_TOOL_AIRBRUSH +NoSymbol BTN_TOOL_FINGER +NoSymbol BTN_TOOL_MOUSE +NoSymbol BTN_TOOL_LENS +NoSymbol BTN_TOUCH +NoSymbol BTN_STYLUS +NoSymbol BTN_STYLUS2 +NoSymbol BTN_TOOL_DOUBLETAP +NoSymbol BTN_TOOL_TRIPLETAP + +NoSymbol BTN_WHEEL +NoSymbol BTN_GEAR_DOWN +NoSymbol BTN_GEAR_UP + +NoSymbol KEY_OK +NoSymbol KEY_SELECT +NoSymbol KEY_GOTO +NoSymbol KEY_CLEAR +NoSymbol KEY_POWER2 +NoSymbol KEY_OPTION +NoSymbol KEY_INFO +NoSymbol KEY_TIME +NoSymbol KEY_VENDOR +NoSymbol KEY_ARCHIVE +NoSymbol KEY_PROGRAM +NoSymbol KEY_CHANNEL +NoSymbol KEY_FAVORITES +NoSymbol KEY_EPG +NoSymbol KEY_PVR +NoSymbol KEY_MHP +NoSymbol KEY_LANGUAGE +NoSymbol KEY_TITLE +NoSymbol KEY_SUBTITLE +NoSymbol KEY_ANGLE +NoSymbol KEY_ZOOM +NoSymbol KEY_MODE +NoSymbol KEY_KEYBOARD +NoSymbol KEY_SCREEN +NoSymbol KEY_PC +NoSymbol KEY_TV +NoSymbol KEY_TV2 +NoSymbol KEY_VCR +NoSymbol KEY_VCR2 +NoSymbol KEY_SAT +NoSymbol KEY_SAT2 +NoSymbol KEY_CD +NoSymbol KEY_TAPE +NoSymbol KEY_RADIO +NoSymbol KEY_TUNER +NoSymbol KEY_PLAYER +NoSymbol KEY_TEXT +NoSymbol KEY_DVD +NoSymbol KEY_AUX +NoSymbol KEY_MP3 +NoSymbol KEY_AUDIO +NoSymbol KEY_VIDEO +NoSymbol KEY_DIRECTORY +NoSymbol KEY_LIST +NoSymbol KEY_MEMO +NoSymbol KEY_CALENDAR +NoSymbol KEY_RED +NoSymbol KEY_GREEN +NoSymbol KEY_YELLOW +NoSymbol KEY_BLUE +NoSymbol KEY_CHANNELUP +NoSymbol KEY_CHANNELDOWN +NoSymbol KEY_FIRST +NoSymbol KEY_LAST +NoSymbol KEY_AB +NoSymbol KEY_NEXT +NoSymbol KEY_RESTART +NoSymbol KEY_SLOW +NoSymbol KEY_SHUFFLE +NoSymbol KEY_BREAK +NoSymbol KEY_PREVIOUS +NoSymbol KEY_DIGITS +NoSymbol KEY_TEEN +NoSymbol KEY_TWEN + +NoSymbol KEY_DEL_EOL +NoSymbol KEY_DEL_EOS +NoSymbol KEY_INS_LINE +NoSymbol KEY_DEL_LINE +NoSymbol KEY_MAX + +#endif + + diff --git a/x11vnc/uinput.h b/x11vnc/uinput.h new file mode 100644 index 0000000..ba45f22 --- /dev/null +++ b/x11vnc/uinput.h @@ -0,0 +1,18 @@ +#ifndef _X11VNC_UINPUT_H +#define _X11VNC_UINPUT_H + +/* -- uinput.h -- */ + +extern int check_uinput(void); +extern int initialize_uinput(void); +extern int set_uinput_accel(char *str); +extern void set_uinput_reset(int ms); +extern char *get_uinput_accel(); +extern int get_uinput_reset(); +extern void parse_uinput_str(char *str); +extern void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client); +extern void uinput_key_command(int down, int keysym, rfbClientPtr client); + + + +#endif /* _X11VNC_UINPUT_H */ diff --git a/x11vnc/util.c b/x11vnc/util.c index aa0fb79..2f9aa0f 100644 --- a/x11vnc/util.c +++ b/x11vnc/util.c @@ -446,7 +446,24 @@ void rfbCFD(long usec) { } if (! use_threads) { - rfbCheckFds(screen, usec); + if (0 && all_input) { + static int cnt = 0; + int f = 1; + while (rfbCheckFds(screen, usec) > 0) { + if (f) { + cnt++; + f = 0; + } + fprintf(stderr, "-%d", cnt); + } + } else { + if (all_input) { + screen->handleEventsEagerly = TRUE; + } else { + screen->handleEventsEagerly = FALSE; + } + rfbCheckFds(screen, usec); + } } if (unixpw && unixpw_in_progress && !uip0) { diff --git a/x11vnc/v4l.c b/x11vnc/v4l.c index 9209a3f..6a945ff 100644 --- a/x11vnc/v4l.c +++ b/x11vnc/v4l.c @@ -6,6 +6,7 @@ #include "xinerama.h" #include "screen.h" #include "connections.h" +#include "allowed_input_t.h" #if LIBVNCSERVER_HAVE_LINUX_VIDEODEV_H #if LIBVNCSERVER_HAVE_SYS_IOCTL_H @@ -556,12 +557,22 @@ static void v4l_fmt(char *fmt) { } void v4l_key_command(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { + allowed_input_t input; + if (raw_fb_fd < 0) { return; } if (! down) { return; } + if (view_only) { + return; + } + get_allowed_input(client, &input); + if (! input.keystroke) { + return; + } + if (keysym == XK_b) { v4l_br(-1); } else if (keysym == XK_B) { @@ -608,6 +619,7 @@ void v4l_key_command(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { void v4l_pointer_command(int mask, int x, int y, rfbClientPtr client) { + /* do not forget viewonly perms */ if (mask || x || y || client) {} } diff --git a/x11vnc/x11vnc.1 b/x11vnc/x11vnc.1 index 6da11a4..89cadc4 100644 --- a/x11vnc/x11vnc.1 +++ b/x11vnc/x11vnc.1 @@ -2,7 +2,7 @@ .TH X11VNC "1" "July 2006" "x11vnc " "User Commands" .SH NAME x11vnc - allow VNC connections to real X11 displays - version: 0.8.2, lastmod: 2006-07-04 + version: 0.8.2, lastmod: 2006-07-08 .SH SYNOPSIS .B x11vnc [OPTION]... @@ -2569,6 +2569,11 @@ read n user input events before scanning display. n < 0 means to act as though there is always user input. Default: 10 .PP +\fB-allinput\fR +.IP +Have x11vnc read and process all available client input +before proceeding. +.PP \fB-speeds\fR \fIrd,bw,lat\fR .IP x11vnc tries to estimate some speed parameters that @@ -2794,17 +2799,23 @@ memory object specified in \fIstring\fR. For shared memory segments string is of the form: "shm:N@WxHxB" which specifies a shmid N and framebuffer Width, Height, and Bits -per pixel. To memory map +per pixel. +.IP +For file polling to memory map .IR mmap (2) a file use: -"map:/path/to/a/file@WxHxB". If there is trouble -with mmap, use "file:/..." for slower +"map:/path/to/a/file@WxHxB", with WxHxB as above. +"mmap:..." is the same. If there is trouble with mmap, +use "file:/..." for slower .IR lseek (2) -based -reading. Use "snap:..." to imply \fB-snapfb\fR mode and the -"file:" access (this is for devices that only provide -the fb all at once). If you do not supply a type "map" -is assumed if the file exists. +based reading. +Use "snap:..." to imply \fB-snapfb\fR mode and the "file:" +access (this is for devices that only provide the fb +all at once). +.IP +If you do not supply a type "map" is assumed if +the file exists (see the next paragraphs for some +exceptions to this.) .IP If string is "setup:cmd", then the command "cmd" is run and the first line from it is read and used @@ -2812,13 +2823,14 @@ as \fIstring\fR. This allows initializing the device, determining WxHxB, etc. These are often done as root so take care. .IP -If the string begins with "video", see the video4linux +If the string begins with "video", see the VIDEO4LINUX discusion below where the device may be queried for (and possibly set) the framebuffer parameters. .IP -If the strings begins with "cons", see the linux -console discussion below where the framebuffer device -is opened and keystrokes are inserted into the console. +If the string begins with "cons", "/dev/fb", or +"fb", see the LINUX CONSOLE discussion below where +the framebuffer device is opened and keystrokes (and +possibly mouse events) are inserted into the console. .IP Optional suffixes are ":R/G/B" and "+O" to specify red, green, and blue masks and an offset into the @@ -2847,11 +2859,12 @@ and .IR fbset (1) for the first two examples) .IP -All user input is discarded by default (but see the -\fB-pipeinput\fR option). Most of the X11 (screen, keyboard, -mouse) options do not make sense and many will cause -this mode to crash, so please think twice before -setting or changing them in a running x11vnc. +In general all user input is discarded by default (see +the \fB-pipeinput\fR option for how to use a helper program +to insert). Most of the X11 (screen, keyboard, mouse) +options do not make sense and many will cause this +mode to crash, so please think twice before setting or +changing them in a running x11vnc. .IP If you DO NOT want x11vnc to close the X DISPLAY in rawfb mode, prepend a "+" e.g. +file:/dev/fb0... @@ -2870,13 +2883,13 @@ snapfb snapshot, set the environment variable: SNAPFB_RAWFB_RESET=1 as well. .IP If you want x11vnc to dynamically transform a 24bpp -rawfb to 32bpp (note that this will be slower) use -the \fB-24to32\fR option. This would be useful for, say, -for a video camera that delivers the pixel data as +rawfb to 32bpp (note that this will be slower) also +supply the \fB-24to32\fR option. This would be useful for, +say, a video camera that delivers the pixel data as 24bpp packed RGB. This is the default under "video" mode if the bpp is 24. .IP -video4linux: on Linux some attempt is made to handle +VIDEO4LINUX: on Linux some attempt is made to handle video devices (webcams or TV tuners) automatically. The idea is the WxHxB will be extracted from the device itself. So if you do not supply "@WxHxB... @@ -2956,46 +2969,64 @@ all of the above settings. .IP See the \fB-pipeinput\fR VID option below for a way to control the settings through the VNC Viewer via keystrokes. +As a shortcut, if the string begins "Video.." instead +of "video.." then \fB-pipeinput\fR VID is implied. .IP As above, if you specify a "@WxHxB..." after the string they are used verbatim: the device is not queried for the current values. Otherwise the device will be queried. .IP -Linux console: If the libvncserver LinuxVNC command is -on your system use that instead of the following method -because it will be faster and more accurate for Linux -text console. +LINUX CONSOLE: If the libvncserver LinuxVNC program +is on your system you may want to use that instead of +the following method because it will be faster and more +accurate for Linux text console. .IP If the rawfb string begins with "cons" the framebuffer device /dev/fb0 is opened (this requires the appropriate -kernel modules) and so is /dev/tty0. The latter is -used to inject keystrokes (not all are supported, -but the basic ones are). You will need to be root to -inject keystrokes. /dev/tty0 refers to the active VT, -to indicate one explicitly, use "cons2", etc. using -the VT number. Note you can change VT remotely using -the +kernel modules to be installed) and so is /dev/tty0. +The latter is used to inject keystrokes (not all are +supported, but the basic ones are). You will need to +be root to inject keystrokes. /dev/tty0 refers to the +active VT, to indicate one explicitly, use "cons2", +etc. using the VT number. +.IP +If the Linux version seems to be 2.6 or later and the +"uinput" module appears to be present, then the uinput +method will be used instead of /dev/ttyN. uinput allows +insertion of BOTH keystrokes and mouse input and so it +preferred when accessing graphical (e.g. QT-embedded) +linux console apps. See \fB-pipeinput\fR UINPUT below +for more information on this mode (you may want to +also use the \fB-nodragging\fR and \fB-cursor\fR none options). +Use "cons0", etc or \fB-pipeinput\fR CONS to force the +/dev/ttyN method. +.IP +Note you can change VT remotely using the .IR chvt (1) -command. Sometimes switching out and back -corrects the framebuffer. To skip injecting entirely -use "consx". +command. Sometimes switching out and back corrects +the framebuffer state. +.IP +To skip input injecting entirely use "consx". .IP The strings "console", or "/dev/fb0" can be used instead of "cons". The latter can be used to specify -a different framebuffer device, e.g. /dev/fb1. If the -name is something nonstandard, use "cons:/dev/foofb" +a different framebuffer device, e.g. /dev/fb1. As a +shortcut the "/dev/" can be dropped. If the name is +something nonstandard, use "cons:/dev/foofb" .IP If you do not want x11vnc to guess the framebuffer's -WxHxB and masks automatically, specify them with a +WxHxB and masks automatically (sometimes the kernel +given inaccurate information), specify them with a @WxHxB at the end of the string. .IP Examples: \fB-rawfb\fR cons (same as \fB-rawfb\fR console) \fB-rawfb\fR /dev/fb0 (same) \fB-rawfb\fR cons3 (force /dev/tty3) -\fB-rawfb\fR consx (no keystrokes) +\fB-rawfb\fR consx (no keystrokes or mouse) \fB-rawfb\fR console:/dev/nonstd +\fB-rawfb\fR cons \fB-pipeinput\fR UINPUT:accel=1.5 .PP \fB-freqtab\fR \fIfile\fR .IP @@ -3028,6 +3059,8 @@ To facilitate this, if \fB-rawfb\fR is in effect then the value is stored in X11VNC_RAWFB_STR for the pipe command to use if it wants. Do 'env | grep X11VNC' for more. .IP +Built-in pipeinput modes: +.IP If cmd is "VID" and you are using the \fB-rawfb\fR for a video capture device, then an internal list of keyboard mappings is used to set parameters of the video. @@ -3046,7 +3079,59 @@ GREY respectively. See \fB-rawfb\fR video for details. .IP If cmd is "CONS" or "CONSn" where n is a Linux console number, then the linux console keystroke -insertion (see \fB-rawfb\fR cons) is performed. +insertion to /dev/ttyN (see \fB-rawfb\fR cons) is performed. +.IP +If cmd begins with "UINPUT" then the Linux uinput +module is used to insert both keystroke and mouse events +to the Linux console (see \fB-rawfb\fR above). This usually +is the /dev/input/uinput device file (you may need to +create it with "mknod /dev/input/uinput c 10 223" +and insert the module with "modprobe uinput". +.IP +The UINPUT mode currently only does US keyboards (a +scan code option may be added), and not all keysyms +are supported. +.IP +You may want to use the options \fB-cursor\fR none and +\fB-nodragging\fR in this mode. +.IP +Additional tuning options may be supplied via: +UINPUT:opt1,opt2,... (a comma separated list). If an +option begins with "/" it is taken as the uinput +device file. +.IP +Which uinput is injected can be controlled by an option +string made of the characters "K", "M", and "B" +(see the \fB-input\fR option), e.g. "KM" allows keystroke +and motion but not button clicks. +.IP +A UINPUT option of the form: accel=f, or accel=fx+fy +sets the mouse motion "acceleration". This is used +to correct raw mouse relative motion into how much the +application cursor moves (x11vnc has no control over +how the application interprets the raw mouse motions). +Typically the acceleration for an X display is 2 (see +xset "m" option). "f" is a floating point number, +e.g. 2.0. Use "fx+fy" if you need to supply different +corrections for x and y. +.IP +Note: the default acceleration is 2.0 since it seems +both X and qt-embedded often use this value. +.IP +Even with a correct accel setting the mouse position +will get out of sync (probably due to a mouse +"threshold" setting where the acceleration doe not +apply, set +.IR xset (1) +). The option reset=N sets the number +of ms (default 500) after which the cursor is attempted +to be reset (by forcing the mouse to (0, 0) via small +increments and then back out to (x, y) in 1 jump), This +correction seems to be needed but can cause jerkiness +or unexpected behavior. Use reset=0 to disable. +.IP +Example: +\fB-pipeinput\fR UINPUT:accel=1.0 \fB-cursor\fR none .PP \fB-gui\fR \fI[gui-opts]\fR .IP @@ -3526,6 +3611,10 @@ pointer_mode:n set \fB-pointer_mode\fR to n. same as "pm" .IP input_skip:n set \fB-input_skip\fR to n. .IP +allinput enable use of \fB-allinput\fR mode. +.IP +noallinput disable use of \fB-allinput\fR mode. +.IP speeds:str set \fB-speeds\fR to str. .IP wmdt:str set \fB-wmdt\fR to str. @@ -3584,6 +3673,10 @@ nosnapfb disable \fB-snapfb\fR mode. .IP rawfb:str set \fB-rawfb\fR mode to "str". .IP +uinput_accel:f set uinput_accel to f. +.IP +uinput_reset:n set uinput_reset to n ms. +.IP progressive:n set libvncserver \fB-progressive\fR slice height parameter to n. .IP @@ -3703,7 +3796,6 @@ names that do not correspond to an x11vnc option or remote command, we hope the name makes it obvious what the returned value corresponds to (hint: the ext_* variables correspond to the presence of X extensions): -.IP ans= stop quit exit shutdown ping blacken zero refresh reset close disconnect id sid waitmapped nowaitmapped clip flashcmap noflashcmap shiftcmap @@ -3734,16 +3826,17 @@ xwarp noxwarppointer noxwarp buttonmap dragging nodragging wireframe_mode wireframe wf nowireframe nowf wirecopyrect wcr nowirecopyrect nowcr scr_area scr_skip scr_inc scr_keys scr_term scr_keyrepeat -scr_parms scrollcopyrect scr noscrollcopyrect noscr -fixscreen noxrecord xrecord reset_record pointer_mode -pm input_skip input grabkbd nograbkbd grabptr -nograbptr client_input speeds wmdt debug_pointer dp -nodebug_pointer nodp debug_keyboard dk nodebug_keyboard -nodk deferupdate defer wait_ui wait_bog nowait_bog -slow_fb wait readtimeout nap nonap sb screen_blank -fbpm nofbpm fs gaps grow fuzz snapfb nosnapfb rawfb -progressive rfbport http nohttp httpport httpdir -enablehttpproxy noenablehttpproxy alwaysshared +scr_parms scrollcopyrect scr noscrollcopyrect +noscr fixscreen noxrecord xrecord reset_record +pointer_mode pm input_skip allinput noallinput input +grabkbd nograbkbd grabptr nograbptr client_input +speeds wmdt debug_pointer dp nodebug_pointer nodp +debug_keyboard dk nodebug_keyboard nodk deferupdate +defer wait_ui wait_bog nowait_bog slow_fb wait +readtimeout nap nonap sb screen_blank fbpm nofbpm +fs gaps grow fuzz snapfb nosnapfb rawfb uinput_accel +uinput_reset progressive rfbport http nohttp httpport +httpdir enablehttpproxy noenablehttpproxy alwaysshared noalwaysshared nevershared noalwaysshared dontdisconnect nodontdisconnect desktop debug_xevents nodebug_xevents debug_xevents debug_xdamage nodebug_xdamage diff --git a/x11vnc/x11vnc.c b/x11vnc/x11vnc.c index 047858c..ba6154c 100644 --- a/x11vnc/x11vnc.c +++ b/x11vnc/x11vnc.c @@ -2073,6 +2073,10 @@ int main(int argc, char* argv[]) { CHECK_ARGC ui_skip = atoi(argv[++i]); if (! ui_skip) ui_skip = 1; + } else if (!strcmp(arg, "-allinput")) { + all_input = 1; + } else if (!strcmp(arg, "-noallinput")) { + all_input = 0; } else if (!strcmp(arg, "-speeds")) { CHECK_ARGC speeds_str = strdup(argv[++i]); diff --git a/x11vnc/x11vnc_defs.c b/x11vnc/x11vnc_defs.c index d95a33c..42a4370 100644 --- a/x11vnc/x11vnc_defs.c +++ b/x11vnc/x11vnc_defs.c @@ -15,7 +15,7 @@ int xtrap_base_event_type = 0; int xdamage_base_event_type = 0; /* date +'lastmod: %Y-%m-%d' */ -char lastmod[] = "0.8.2 lastmod: 2006-07-04"; +char lastmod[] = "0.8.2 lastmod: 2006-07-08"; /* X display info */