From 365a22c63cb292ea494f39ebc48a37e322e5eb14 Mon Sep 17 00:00:00 2001 From: runge Date: Tue, 21 Dec 2010 12:04:02 -0500 Subject: x11vnc: touchscreen uinput support and Java viewer mousewheel support. See x11vnc/ChangeLog for rest. --- classes/ssl/SignedUltraViewerSSL.jar | Bin 112724 -> 113117 bytes classes/ssl/SignedVncViewer.jar | Bin 88791 -> 89208 bytes classes/ssl/UltraViewerSSL.jar | Bin 109640 -> 110040 bytes classes/ssl/VncViewer.jar | Bin 85809 -> 86228 bytes classes/ssl/ss_vncviewer | 12 + ...-vncviewer-cursor-colors+no-tab-traversal.patch | 62 +- .../tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch | 169 ++- classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch | 123 +- prepare_x11vnc_dist.sh | 4 +- x11vnc/8to24.c | 8 +- x11vnc/ChangeLog | 16 + x11vnc/Makefile.am | 2 +- x11vnc/README | 549 ++++--- x11vnc/RELEASE-NOTES | 1553 ++++++++++++++++++++ x11vnc/appshare.c | 8 +- x11vnc/cleanup.c | 3 + x11vnc/gui.c | 8 +- x11vnc/help.c | 186 ++- x11vnc/keyboard.c | 24 +- x11vnc/keyboard.h | 2 +- x11vnc/linuxfb.c | 1 + x11vnc/macosx.c | 1 + x11vnc/macosxCG.c | 4 + x11vnc/misc/Makefile.am | 2 +- x11vnc/misc/README | 4 + x11vnc/misc/qt_tslib_inject.pl | 1064 ++++++++++++++ x11vnc/misc/uinput.pl | 946 ++++++++++++ x11vnc/pointer.c | 10 +- x11vnc/remote.c | 42 +- x11vnc/scan.c | 12 +- x11vnc/screen.c | 24 +- x11vnc/sslhelper.c | 15 +- x11vnc/ssltools.h | 53 +- x11vnc/uinput.c | 401 ++++- x11vnc/uinput.h | 1 + x11vnc/unixpw.c | 10 +- x11vnc/user.c | 1 + x11vnc/util.h | 4 +- x11vnc/v4l.c | 18 +- x11vnc/x11vnc.1 | 193 ++- x11vnc/x11vnc.c | 38 +- x11vnc/x11vnc.h | 2 + x11vnc/x11vnc_defs.c | 2 +- x11vnc/xevents.c | 1 + x11vnc/xevents.h | 1 + x11vnc/xrecord.c | 6 +- x11vnc/xrecord.h | 2 +- x11vnc/xwrappers.c | 44 +- 48 files changed, 5200 insertions(+), 431 deletions(-) create mode 100644 x11vnc/RELEASE-NOTES create mode 100755 x11vnc/misc/qt_tslib_inject.pl create mode 100755 x11vnc/misc/uinput.pl diff --git a/classes/ssl/SignedUltraViewerSSL.jar b/classes/ssl/SignedUltraViewerSSL.jar index eccb9b9..6c18737 100644 Binary files a/classes/ssl/SignedUltraViewerSSL.jar and b/classes/ssl/SignedUltraViewerSSL.jar differ diff --git a/classes/ssl/SignedVncViewer.jar b/classes/ssl/SignedVncViewer.jar index f0d8bfa..95c0b0b 100644 Binary files a/classes/ssl/SignedVncViewer.jar and b/classes/ssl/SignedVncViewer.jar differ diff --git a/classes/ssl/UltraViewerSSL.jar b/classes/ssl/UltraViewerSSL.jar index 1791a09..45259fd 100644 Binary files a/classes/ssl/UltraViewerSSL.jar and b/classes/ssl/UltraViewerSSL.jar differ diff --git a/classes/ssl/VncViewer.jar b/classes/ssl/VncViewer.jar index 46d59d0..9453c6f 100644 Binary files a/classes/ssl/VncViewer.jar and b/classes/ssl/VncViewer.jar differ diff --git a/classes/ssl/ss_vncviewer b/classes/ssl/ss_vncviewer index 4f42bd5..7e793ff 100755 --- a/classes/ssl/ss_vncviewer +++ b/classes/ssl/ss_vncviewer @@ -2964,6 +2964,10 @@ if [ "X$use_ssh" = "X1" ]; then fi echo "ssh_pid='$pssh'"; echo if [ "X$use_sshssl" = "X" -a "X$getport" = "X" ]; then + if [ "X$SSVNC_EXTRA_COMMAND" != "X" ]; then + (sh -c "$SSVNC_EXTRA_COMMAND") & + echo "($SSVNC_EXTRA_COMMAND) &"; echo + fi echo "Running viewer:" trap "final" 0 2 15 @@ -3334,6 +3338,10 @@ if [ "X$direct_connect" != "X" ]; then echo "T sleep $SSVNC_EXTRA_SLEEP" sleep $SSVNC_EXTRA_SLEEP fi + if [ "X$SSVNC_EXTRA_COMMAND" != "X" ]; then + (sh -c "$SSVNC_EXTRA_COMMAND") & + echo "($SSVNC_EXTRA_COMMAND) &"; echo + fi if [ "X$reverse" = "X" ]; then hostdisp="$host:$disp" if [ "X$SSVNC_ULTRA_DSM" != "X" ]; then @@ -3568,6 +3576,10 @@ if [ "X$SSVNC_EXTRA_SLEEP" != "X" ]; then echo "sleep $SSVNC_EXTRA_SLEEP" sleep $SSVNC_EXTRA_SLEEP fi +if [ "X$SSVNC_EXTRA_COMMAND" != "X" ]; then + (sh -c "$SSVNC_EXTRA_COMMAND") & + echo "($SSVNC_EXTRA_COMMAND) &"; echo +fi if [ "X$reverse" = "X" ]; then if [ "X$NEED_VENCRYPT_VIEWER_BRIDGE" = "X1" -a "X$ptmp" != "X" ] ; then diff --git a/classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-tab-traversal.patch b/classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-tab-traversal.patch index db611af..bc10f3c 100644 --- a/classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-tab-traversal.patch +++ b/classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-cursor-colors+no-tab-traversal.patch @@ -1,6 +1,6 @@ --- vnc_javasrc.orig/VncCanvas.java 2004-10-10 02:15:54.000000000 -0400 -+++ vnc_javasrc/VncCanvas.java 2006-03-27 22:34:02.000000000 -0500 -@@ -28,6 +28,7 @@ ++++ vnc_javasrc/VncCanvas.java 2010-11-30 21:01:15.000000000 -0500 +@@ -28,13 +28,14 @@ import java.lang.*; import java.util.zip.*; @@ -8,6 +8,14 @@ // // VncCanvas is a subclass of Canvas which draws a VNC desktop on it. + // + + class VncCanvas extends Canvas +- implements KeyListener, MouseListener, MouseMotionListener { ++ implements KeyListener, MouseListener, MouseMotionListener, MouseWheelListener { + + VncViewer viewer; + RfbProto rfb; @@ -81,6 +82,20 @@ cm8 = new DirectColorModel(8, 7, (7 << 3), (3 << 6)); cm24 = new DirectColorModel(24, 0xFF0000, 0x00FF00, 0x0000FF); @@ -29,7 +37,53 @@ colors = new Color[256]; for (int i = 0; i < 256; i++) colors[i] = new Color(cm8.getRGB(i)); -@@ -1387,9 +1402,9 @@ +@@ -169,6 +184,7 @@ + inputEnabled = true; + addMouseListener(this); + addMouseMotionListener(this); ++ addMouseWheelListener(this); + if (viewer.showControls) { + viewer.buttonPanel.enableRemoteAccessControls(true); + } +@@ -177,6 +193,7 @@ + inputEnabled = false; + removeMouseListener(this); + removeMouseMotionListener(this); ++ removeMouseWheelListener(this); + if (viewer.showControls) { + viewer.buttonPanel.enableRemoteAccessControls(false); + } +@@ -1190,6 +1207,9 @@ + public void mouseDragged(MouseEvent evt) { + processLocalMouseEvent(evt, true); + } ++ public void mouseWheelMoved(MouseWheelEvent evt) { ++ processLocalMouseWheelEvent(evt); ++ } + + public void processLocalKeyEvent(KeyEvent evt) { + if (viewer.rfb != null && rfb.inNormalProtocol) { +@@ -1221,6 +1241,19 @@ + evt.consume(); + } + ++ public void processLocalMouseWheelEvent(MouseWheelEvent evt) { ++ if (viewer.rfb != null && rfb.inNormalProtocol) { ++ synchronized(rfb) { ++ try { ++ rfb.writeWheelEvent(evt); ++ } catch (Exception e) { ++ e.printStackTrace(); ++ } ++ rfb.notify(); ++ } ++ } ++ } ++ + public void processLocalMouseEvent(MouseEvent evt, boolean moved) { + if (viewer.rfb != null && rfb.inNormalProtocol) { + if (moved) { +@@ -1387,9 +1420,9 @@ result = cm8.getRGB(pixBuf[i]); } else { result = 0xFF000000 | @@ -42,7 +96,7 @@ } } else { result = 0; // Transparent pixel -@@ -1403,9 +1418,9 @@ +@@ -1403,9 +1436,9 @@ result = cm8.getRGB(pixBuf[i]); } else { result = 0xFF000000 | diff --git a/classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch b/classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch index fb77d33..801234a 100644 --- a/classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch +++ b/classes/ssl/tightvnc-1.3dev7_javasrc-vncviewer-ssl.patch @@ -1,4 +1,4 @@ -diff -x VncCanvas.java -Naur vnc_javasrc.orig/Makefile vnc_javasrc/Makefile +diff -Naur vnc_javasrc.orig/Makefile vnc_javasrc/Makefile --- vnc_javasrc.orig/Makefile 2004-03-04 08:34:25.000000000 -0500 +++ vnc_javasrc/Makefile 2010-05-18 20:56:26.000000000 -0400 @@ -4,6 +4,7 @@ @@ -44,9 +44,9 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/Makefile vnc_javasrc/Makefile export:: $(CLASSES) $(ARCHIVE) $(PAGES) @$(ExportJavaClasses) -diff -x VncCanvas.java -Naur vnc_javasrc.orig/RfbProto.java vnc_javasrc/RfbProto.java +diff -Naur vnc_javasrc.orig/RfbProto.java vnc_javasrc/RfbProto.java --- vnc_javasrc.orig/RfbProto.java 2004-03-04 08:34:25.000000000 -0500 -+++ vnc_javasrc/RfbProto.java 2010-03-27 17:58:37.000000000 -0400 ++++ vnc_javasrc/RfbProto.java 2010-11-30 22:05:12.000000000 -0500 @@ -199,7 +199,21 @@ host = h; port = p; @@ -79,7 +79,46 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/RfbProto.java vnc_javasrc/RfbProto } serverMajor = (b[4] - '0') * 100 + (b[5] - '0') * 10 + (b[6] - '0'); -@@ -992,6 +1006,19 @@ +@@ -892,6 +906,38 @@ + final static int ALT_MASK = InputEvent.ALT_MASK; + + ++ void writeWheelEvent(MouseWheelEvent evt) throws IOException { ++ ++ eventBufLen = 0; ++ ++ int x = evt.getX(); ++ int y = evt.getY(); ++ ++ if (x < 0) x = 0; ++ if (y < 0) y = 0; ++ ++ int ptrmask; ++ ++ int clicks = evt.getWheelRotation(); ++ System.out.println("writeWheelEvent: clicks: " + clicks); ++ if (clicks > 0) { ++ ptrmask = 16; ++ } else if (clicks < 0) { ++ ptrmask = 8; ++ } else { ++ return; ++ } ++ ++ eventBuf[eventBufLen++] = (byte) PointerEvent; ++ eventBuf[eventBufLen++] = (byte) ptrmask; ++ eventBuf[eventBufLen++] = (byte) ((x >> 8) & 0xff); ++ eventBuf[eventBufLen++] = (byte) (x & 0xff); ++ eventBuf[eventBufLen++] = (byte) ((y >> 8) & 0xff); ++ eventBuf[eventBufLen++] = (byte) (y & 0xff); ++ ++ os.write(eventBuf, 0, eventBufLen); ++ } ++ + // + // Write a pointer event message. We may need to send modifier key events + // around it to set the correct modifier state. +@@ -992,6 +1038,19 @@ boolean down = (evt.getID() == KeyEvent.KEY_PRESSED); int key; @@ -99,7 +138,7 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/RfbProto.java vnc_javasrc/RfbProto if (evt.isActionKey()) { // -@@ -1025,6 +1052,13 @@ +@@ -1025,6 +1084,13 @@ return; } @@ -113,7 +152,7 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/RfbProto.java vnc_javasrc/RfbProto } else { // -@@ -1036,6 +1070,7 @@ +@@ -1036,6 +1102,7 @@ key = keyChar; @@ -121,7 +160,7 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/RfbProto.java vnc_javasrc/RfbProto if (key < 0x20) { if (evt.isControlDown()) { key += 0x60; -@@ -1121,6 +1156,16 @@ +@@ -1121,6 +1188,16 @@ int oldModifiers = 0; void writeModifierKeyEvents(int newModifiers) { @@ -138,7 +177,7 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/RfbProto.java vnc_javasrc/RfbProto if ((newModifiers & CTRL_MASK) != (oldModifiers & CTRL_MASK)) writeKeyEvent(0xffe3, (newModifiers & CTRL_MASK) != 0); -diff -x VncCanvas.java -Naur vnc_javasrc.orig/SSLSocketToMe.java vnc_javasrc/SSLSocketToMe.java +diff -Naur vnc_javasrc.orig/SSLSocketToMe.java vnc_javasrc/SSLSocketToMe.java --- vnc_javasrc.orig/SSLSocketToMe.java 1969-12-31 19:00:00.000000000 -0500 +++ vnc_javasrc/SSLSocketToMe.java 2010-07-10 19:18:06.000000000 -0400 @@ -0,0 +1,2067 @@ @@ -2209,7 +2248,119 @@ diff -x VncCanvas.java -Naur vnc_javasrc.orig/SSLSocketToMe.java vnc_javasrc/SSL + private Base64Coder() {} + +} -diff -x VncCanvas.java -Naur vnc_javasrc.orig/VncViewer.java vnc_javasrc/VncViewer.java +diff -Naur vnc_javasrc.orig/VncCanvas.java vnc_javasrc/VncCanvas.java +--- vnc_javasrc.orig/VncCanvas.java 2004-10-10 02:15:54.000000000 -0400 ++++ vnc_javasrc/VncCanvas.java 2010-11-30 21:01:15.000000000 -0500 +@@ -28,13 +28,14 @@ + import java.lang.*; + import java.util.zip.*; + ++import java.util.Collections; + + // + // VncCanvas is a subclass of Canvas which draws a VNC desktop on it. + // + + class VncCanvas extends Canvas +- implements KeyListener, MouseListener, MouseMotionListener { ++ implements KeyListener, MouseListener, MouseMotionListener, MouseWheelListener { + + VncViewer viewer; + RfbProto rfb; +@@ -81,6 +82,20 @@ + cm8 = new DirectColorModel(8, 7, (7 << 3), (3 << 6)); + cm24 = new DirectColorModel(24, 0xFF0000, 0x00FF00, 0x0000FF); + ++ // kludge to not show any Java cursor in the canvas since we are ++ // showing the soft cursor (should be a user setting...) ++ Cursor dot = Toolkit.getDefaultToolkit().createCustomCursor( ++ Toolkit.getDefaultToolkit().createImage(new byte[4]), new Point(0,0), ++ "dot"); ++ this.setCursor(dot); ++ ++ // while we are at it... get rid of the keyboard traversals that ++ // make it so we can't type a Tab character: ++ this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, ++ Collections.EMPTY_SET); ++ this.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, ++ Collections.EMPTY_SET); ++ + colors = new Color[256]; + for (int i = 0; i < 256; i++) + colors[i] = new Color(cm8.getRGB(i)); +@@ -169,6 +184,7 @@ + inputEnabled = true; + addMouseListener(this); + addMouseMotionListener(this); ++ addMouseWheelListener(this); + if (viewer.showControls) { + viewer.buttonPanel.enableRemoteAccessControls(true); + } +@@ -177,6 +193,7 @@ + inputEnabled = false; + removeMouseListener(this); + removeMouseMotionListener(this); ++ removeMouseWheelListener(this); + if (viewer.showControls) { + viewer.buttonPanel.enableRemoteAccessControls(false); + } +@@ -1190,6 +1207,9 @@ + public void mouseDragged(MouseEvent evt) { + processLocalMouseEvent(evt, true); + } ++ public void mouseWheelMoved(MouseWheelEvent evt) { ++ processLocalMouseWheelEvent(evt); ++ } + + public void processLocalKeyEvent(KeyEvent evt) { + if (viewer.rfb != null && rfb.inNormalProtocol) { +@@ -1221,6 +1241,19 @@ + evt.consume(); + } + ++ public void processLocalMouseWheelEvent(MouseWheelEvent evt) { ++ if (viewer.rfb != null && rfb.inNormalProtocol) { ++ synchronized(rfb) { ++ try { ++ rfb.writeWheelEvent(evt); ++ } catch (Exception e) { ++ e.printStackTrace(); ++ } ++ rfb.notify(); ++ } ++ } ++ } ++ + public void processLocalMouseEvent(MouseEvent evt, boolean moved) { + if (viewer.rfb != null && rfb.inNormalProtocol) { + if (moved) { +@@ -1387,9 +1420,9 @@ + result = cm8.getRGB(pixBuf[i]); + } else { + result = 0xFF000000 | +- (pixBuf[i * 4 + 1] & 0xFF) << 16 | +- (pixBuf[i * 4 + 2] & 0xFF) << 8 | +- (pixBuf[i * 4 + 3] & 0xFF); ++ (pixBuf[i * 4 + 2] & 0xFF) << 16 | ++ (pixBuf[i * 4 + 1] & 0xFF) << 8 | ++ (pixBuf[i * 4 + 0] & 0xFF); + } + } else { + result = 0; // Transparent pixel +@@ -1403,9 +1436,9 @@ + result = cm8.getRGB(pixBuf[i]); + } else { + result = 0xFF000000 | +- (pixBuf[i * 4 + 1] & 0xFF) << 16 | +- (pixBuf[i * 4 + 2] & 0xFF) << 8 | +- (pixBuf[i * 4 + 3] & 0xFF); ++ (pixBuf[i * 4 + 2] & 0xFF) << 16 | ++ (pixBuf[i * 4 + 1] & 0xFF) << 8 | ++ (pixBuf[i * 4 + 0] & 0xFF); + } + } else { + result = 0; // Transparent pixel +diff -Naur vnc_javasrc.orig/VncViewer.java vnc_javasrc/VncViewer.java --- vnc_javasrc.orig/VncViewer.java 2004-03-04 08:34:25.000000000 -0500 +++ vnc_javasrc/VncViewer.java 2010-03-27 17:57:04.000000000 -0400 @@ -29,6 +29,7 @@ diff --git a/classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch b/classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch index 224d825..3309860 100644 --- a/classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch +++ b/classes/ssl/ultravnc-102-JavaViewer-ssl-etc.patch @@ -1685,7 +1685,7 @@ diff -Naur JavaViewer.orig/OptionsFrame.java JavaViewer/OptionsFrame.java choices[shareDesktopIndex].select("Yes"); diff -Naur JavaViewer.orig/RfbProto.java JavaViewer/RfbProto.java --- JavaViewer.orig/RfbProto.java 2006-05-24 15:14:40.000000000 -0400 -+++ JavaViewer/RfbProto.java 2010-03-27 17:59:56.000000000 -0400 ++++ JavaViewer/RfbProto.java 2010-11-30 22:13:58.000000000 -0500 @@ -31,6 +31,7 @@ import java.net.Socket; import java.util.*; @@ -2662,7 +2662,45 @@ diff -Naur JavaViewer.orig/RfbProto.java JavaViewer/RfbProto.java os.write(b); // } -@@ -1610,6 +1971,21 @@ +@@ -1506,6 +1867,37 @@ + final static int META_MASK = InputEvent.META_MASK; + final static int ALT_MASK = InputEvent.ALT_MASK; + ++ void writeWheelEvent(MouseWheelEvent evt) throws IOException { ++ eventBufLen = 0; ++ ++ int x = evt.getX(); ++ int y = evt.getY(); ++ ++ if (x < 0) x = 0; ++ if (y < 0) y = 0; ++ ++ int ptrmask; ++ ++ int clicks = evt.getWheelRotation(); ++ System.out.println("writeWheelEvent: clicks: " + clicks); ++ if (clicks > 0) { ++ ptrmask = 16; ++ } else if (clicks < 0) { ++ ptrmask = 8; ++ } else { ++ return; ++ } ++ ++ eventBuf[eventBufLen++] = (byte) PointerEvent; ++ eventBuf[eventBufLen++] = (byte) ptrmask; ++ eventBuf[eventBufLen++] = (byte) ((x >> 8) & 0xff); ++ eventBuf[eventBufLen++] = (byte) (x & 0xff); ++ eventBuf[eventBufLen++] = (byte) ((y >> 8) & 0xff); ++ eventBuf[eventBufLen++] = (byte) (y & 0xff); ++ ++ os.write(eventBuf, 0, eventBufLen); ++ } ++ + // + // Write a pointer event message. We may need to send modifier key events + // around it to set the correct modifier state. +@@ -1610,6 +2002,21 @@ boolean down = (evt.getID() == KeyEvent.KEY_PRESSED); @@ -2684,7 +2722,7 @@ diff -Naur JavaViewer.orig/RfbProto.java JavaViewer/RfbProto.java int key; if (evt.isActionKey()) { -@@ -1685,6 +2061,9 @@ +@@ -1685,6 +2092,9 @@ default : return; } @@ -2694,7 +2732,7 @@ diff -Naur JavaViewer.orig/RfbProto.java JavaViewer/RfbProto.java } else { -@@ -1794,6 +2173,16 @@ +@@ -1794,6 +2204,16 @@ int oldModifiers = 0; void writeModifierKeyEvents(int newModifiers) { @@ -4784,18 +4822,31 @@ diff -Naur JavaViewer.orig/SSLSocketToMe.java JavaViewer/SSLSocketToMe.java +} diff -Naur JavaViewer.orig/VncCanvas.java JavaViewer/VncCanvas.java --- JavaViewer.orig/VncCanvas.java 2005-11-21 18:50:18.000000000 -0500 -+++ JavaViewer/VncCanvas.java 2007-05-31 15:33:20.000000000 -0400 -@@ -27,6 +27,9 @@ ++++ JavaViewer/VncCanvas.java 2010-11-30 22:57:50.000000000 -0500 +@@ -27,6 +27,13 @@ import java.lang.*; import java.util.zip.*; +// begin runge/x11vnc +import java.util.Collections; ++// end runge/x11vnc ++ ++// begin runge/x11vnc ++// all the MouseWheel stuff below. +// end runge/x11vnc // // VncCanvas is a subclass of Canvas which draws a VNC desktop on it. -@@ -85,6 +88,22 @@ +@@ -34,7 +41,7 @@ + + class VncCanvas + extends Canvas +- implements KeyListener, MouseListener, MouseMotionListener { ++ implements KeyListener, MouseListener, MouseMotionListener, MouseWheelListener { + + VncViewer viewer; + RfbProto rfb; +@@ -85,6 +92,22 @@ cm24 = new DirectColorModel(24, 0xFF0000, 0x00FF00, 0x0000FF); @@ -4818,7 +4869,23 @@ diff -Naur JavaViewer.orig/VncCanvas.java JavaViewer/VncCanvas.java colors = new Color[256]; // sf@2005 - Now Default for (int i = 0; i < 256; i++) -@@ -202,6 +221,9 @@ +@@ -186,6 +209,7 @@ + inputEnabled = true; + addMouseListener(this); + addMouseMotionListener(this); ++ addMouseWheelListener(this); + if (viewer.showControls) { + viewer.buttonPanel.enableRemoteAccessControls(true); + } +@@ -193,6 +217,7 @@ + inputEnabled = false; + removeMouseListener(this); + removeMouseMotionListener(this); ++ removeMouseWheelListener(this); + if (viewer.showControls) { + viewer.buttonPanel.enableRemoteAccessControls(false); + } +@@ -202,6 +227,9 @@ public void setPixelFormat() throws IOException { // sf@2005 - Adding more color modes @@ -4828,7 +4895,7 @@ diff -Naur JavaViewer.orig/VncCanvas.java JavaViewer/VncCanvas.java if (viewer.options.eightBitColors > 0) { viewer.options.oldEightBitColors = viewer.options.eightBitColors; -@@ -237,6 +259,9 @@ +@@ -237,6 +265,9 @@ } else { @@ -4838,7 +4905,7 @@ diff -Naur JavaViewer.orig/VncCanvas.java JavaViewer/VncCanvas.java rfb.writeSetPixelFormat( 32, 24, -@@ -376,12 +401,14 @@ +@@ -376,12 +407,14 @@ // Start/stop session recording if necessary. viewer.checkRecordingStatus(); @@ -4859,7 +4926,7 @@ diff -Naur JavaViewer.orig/VncCanvas.java JavaViewer/VncCanvas.java // // main dispatch loop -@@ -390,6 +417,9 @@ +@@ -390,6 +423,9 @@ while (true) { // Read message type from the server. int msgType = rfb.readServerMessageType(); @@ -4869,7 +4936,37 @@ diff -Naur JavaViewer.orig/VncCanvas.java JavaViewer/VncCanvas.java // Process the message depending on its type. switch (msgType) { -@@ -1532,9 +1562,14 @@ +@@ -1332,6 +1368,9 @@ + public void mouseDragged(MouseEvent evt) { + processLocalMouseEvent(evt, true); + } ++ public void mouseWheelMoved(MouseWheelEvent evt) { ++ processLocalMouseWheelEvent(evt); ++ } + + public void processLocalKeyEvent(KeyEvent evt) { + if (viewer.rfb != null && rfb.inNormalProtocol) { +@@ -1367,6 +1406,19 @@ + evt.consume(); + } + ++ public void processLocalMouseWheelEvent(MouseWheelEvent evt) { ++ if (viewer.rfb != null && rfb.inNormalProtocol) { ++ synchronized(rfb) { ++ try { ++ rfb.writeWheelEvent(evt); ++ } catch (Exception e) { ++ e.printStackTrace(); ++ } ++ rfb.notify(); ++ } ++ } ++ } ++ + public void processLocalMouseEvent(MouseEvent evt, boolean moved) { + if (viewer.rfb != null && rfb.inNormalProtocol) { + if (moved) { +@@ -1532,9 +1584,14 @@ else { result = @@ -4887,7 +4984,7 @@ diff -Naur JavaViewer.orig/VncCanvas.java JavaViewer/VncCanvas.java } } else { result = 0; // Transparent pixel -@@ -1565,9 +1600,14 @@ +@@ -1565,9 +1622,14 @@ else { result = diff --git a/prepare_x11vnc_dist.sh b/prepare_x11vnc_dist.sh index 2f6fec1..d72100d 100644 --- a/prepare_x11vnc_dist.sh +++ b/prepare_x11vnc_dist.sh @@ -19,7 +19,7 @@ sed -e "s/LibVNCServer, [^,)]*\([(,]\)*/x11vnc, $VERSION\1/g" \ mv Makefile.am Makefile.am.LibVNCServer -echo "EXTRA_DIST=tightvnc-1.3dev5-vncviewer-alpha-cursor.patch README.LibVNCServer" > Makefile.am +echo "EXTRA_DIST=tightvnc-1.3dev5-vncviewer-alpha-cursor.patch RELEASE-NOTES README.LibVNCServer" > Makefile.am echo "" >> Makefile.am echo "if HAVE_SYSTEM_LIBVNCSERVER" >> Makefile.am echo "SUBDIRS=x11vnc classes" >> Makefile.am @@ -41,6 +41,7 @@ sed -e "s/^SUBDIRS.*$/#SUBDIRS=libvncserver libvncclient x11vnc classes/" \ mv README README.LibVNCServer cp x11vnc/README ./README +cp x11vnc/RELEASE-NOTES ./RELEASE-NOTES cat LibVNCServer.spec.in | \ sed -e "s/Johannes.Schindelin@gmx.de/runge@karlrunge.com/gi" \ @@ -134,4 +135,5 @@ make x11vnc-${VERSION}.tar.gz for f in configure.ac Makefile.am x11vnc/Makefile.am libvncserver/Makefile.am libvncclient/Makefile.am classes/Makefile.am classes/ssl/Makefile.am acinclude.m4 README; do mv -f $f.LibVNCServer $f done +rm -f ./RELEASE-NOTES diff --git a/x11vnc/8to24.c b/x11vnc/8to24.c index 75ab68a..30c3da2 100644 --- a/x11vnc/8to24.c +++ b/x11vnc/8to24.c @@ -720,7 +720,7 @@ static int check_depth_win(Window win, Window top, XWindowAttributes *attr) { if (store_it) { int i, j = -1, none = -1, nomap = -1; - int new = 0; + int newc = 0; if (attr->map_state == IsViewable) { /* count the visible ones: */ multivis_count++; @@ -754,7 +754,7 @@ if (db24 > 1) fprintf(stderr, "multivis: 0x%lx %d\n", win, attr->depth); } else if (none >= 0) { /* put it in the first None slot */ j = none; - new = 1; + newc = 1; } else if (nomap >=0) { /* put it in the first unmapped slot */ j = nomap; @@ -791,8 +791,8 @@ if (db24 > 1) fprintf(stderr, "multivis: STORE 0x%lx j: %3d ms: %d dep=%d\n", wi windows_8bpp[j].x = x; windows_8bpp[j].y = y; - if (new || now_vis) { -if (db24) fprintf(stderr, "new/now_vis: 0x%lx %d/%d\n", win, new, now_vis); + if (newc || now_vis) { +if (db24) fprintf(stderr, "new/now_vis: 0x%lx %d/%d\n", win, newc, now_vis); /* mark it immediately if a new one: */ X_UNLOCK; /* dont forget the giant lock */ mark_rect_as_modified(x, y, x + attr->width, diff --git a/x11vnc/ChangeLog b/x11vnc/ChangeLog index 8eb44c7..7ed6f78 100644 --- a/x11vnc/ChangeLog +++ b/x11vnc/ChangeLog @@ -1,3 +1,19 @@ +2010-12-21 Karl Runge + * x11vnc: Add RELEASE-NOTES. Call shutdown_uinput() when exiting. + Free some minor memory. Do not use GetMainDevice() on macosx. + Add utility scripts qt_tslib_inject.pl and uinput.pl. Option + -ungrabboth (not useful.) X11VNC_SB_FACTOR -sb user tweak. + X11VNC_REFLECT_{bitsPerSample,samplesPerPixel,bytesPerPixel} + for -reflect vncclient. Fix minor fd leaks. For -create mode + preserve LC_ALL; FIND_DISPLAY_NO_VT_FIND, FIND_DISPLAY_NO_LSOF, + and X11VNC_CREATE_LC_ALL_C_OK. Speed up -find and -create scripts + for large installations. Enable direct event input modes to + bypass uinput. TSLIB support for uinput touchscreens. Handle + pressure events on touchscreens. User can set X11VNC_UINPUT_BUS + and X11VNC_UINPUT_VERSION. Allow Tab switch in -create login: + prompt. Fix bug in setting bpp for -rawfb. Java viewers now + handle mousewheel events. No vars named new. + 2010-09-10 Karl Runge * x11vnc: update classes/ssl jars, patches, and script. update prepare_x11vnc_dist.sh to 0.9.13. Makefile.am no top_srcdir diff --git a/x11vnc/Makefile.am b/x11vnc/Makefile.am index 163f930..32f0978 100644 --- a/x11vnc/Makefile.am +++ b/x11vnc/Makefile.am @@ -16,7 +16,7 @@ desktopdir = $(datadir)/applications desktop_DATA = x11vnc.desktop man_MANS=x11vnc.1 -EXTRA_DIST=ChangeLog README tkx11vnc $(man_MANS) $(desktop_DATA) +EXTRA_DIST=ChangeLog README RELEASE-NOTES tkx11vnc $(man_MANS) $(desktop_DATA) if CYGIPC LD_CYGIPC=-lcygipc diff --git a/x11vnc/README b/x11vnc/README index 8666aad..310ec36 100644 --- a/x11vnc/README +++ b/x11vnc/README @@ -2,7 +2,7 @@ Copyright (C) 2002-2010 Karl J. Runge All rights reserved. -x11vnc README file Date: Fri Sep 10 12:29:36 EDT 2010 +x11vnc README file Date: Tue Dec 21 11:45:35 EST 2010 The following information is taken from these URLs: @@ -241,7 +241,7 @@ to: http://www.karlrunge.com/x11vnc/faq.html#faq-singleclick * Have x11vnc (0.9.3 or later) available to run on the remote host (i.e. in $PATH.) * Download and unpack a SSVNC bundle (1.0.19 or later, e.g. - ssvnc_no_windows-1.0.23.tar.gz) on the Viewer-side machine. + ssvnc_no_windows-1.0.28.tar.gz) on the Viewer-side machine. * Start the SSVNC Terminal Services mode GUI: ./ssvnc/bin/tsvnc * Enter your remote username@hostname (e.g. fred@far-away.east) in the "VNC Terminal Server" entry. @@ -909,10 +909,43 @@ make Here are some features that will appear in the 0.9.13 release: - * Coming Soon! - - - Here are some features that appeared in the 0.9.12 release: + * Improved support for non-X11 touchscreen devices (e.g. handheld or + cell phone) via Linux uinput input injection. Additional tuning + parameters are added. TSLIB touchscreen calibration is supported. + Tested on Qtmoko Neo Freerunner. A tool, misc/uinput.pl, is + provided to diagnose uinput behavior on new devices. The env. + vars. X11VNC_UINPUT_BUS and X11VNC_UINPUT_VERSION are available if + leaving them unset does not work. + * The Linux uinput non-X11 input injection can now be bypassed: + events can be directly written to the /dev/input/event devices + specified by the user (direct_abs=..., etc.) A -pipeinput input + injection helper script, misc/qt_tslib_inject.pl is provided as a + tweakable non-builtin direct input injection method. + * The list of new uinput parameters for the above two features is: + pressure, tslib_cal, touch_always, dragskip, btn_touch; + direct_rel, direct_abs, direct_btn, direct_key. + * The included SSL enabled Java VNC Viewers now handle Mouse Wheel + events. + * miscellaneous new features and changes: In -reflect mode, the + libvncclient connection can now have the pixel format modified via + the environment variables X11VNC_REFLECT_bitsPerSample, + X11VNC_REFLECT_samplesPerPixel, and X11VNC_REFLECT_bytesPerPixel + * In -create mode the following environment variables are added to + fine tune the behavior: FIND_DISPLAY_NO_LSOF: do not use lsof(1) + to try to determine the Linux VT, FIND_DISPLAY_NO_VT_FIND: do not + try to determine the Linux VT at all, X11VNC_CREATE_LC_ALL_C_OK: + do not bother undoing the setting LC_ALL=C that the create_display + script sets. The performance of the -create script has been + improved for large installations (100's of user sessions on one + machine.) + * In -unixpw mode, one can now Tab from login: to Password. + * An environment variable, X11VNC_SB_FACTOR, allows one to scale the + -sb screenblank sleep time from the default 2 secs. + * Documented that -grabkbd is no longer working with some/most + window managers (it can prevent resizing and menu posting.) + + + Here are some features that appeared in the 0.9.12 release (Sep/2010): * One can now specify the maximum number of displays that can be created in -create mode via the env. var. X11VNC_CREATE_MAX_DISPLAYS @@ -922,7 +955,7 @@ make killed by the display manager. * A compile time bug is fixed so that configuring using --with-system-libvncserver pointing to LibVNCServer 0.9.7 works - again. A bug from forced used of Xdefs.h is worked around. + again. A bug from forced use of Xdefs.h is worked around. Here are some features that appeared in the 0.9.11 release (Aug/2010): @@ -2028,56 +2061,63 @@ http://www.karlrunge.com/x11vnc/faq.html: Q-114: Can I export via VNC a Webcam or TV tuner framebuffer using x11vnc? - Q-115: Can I connect via VNC to a Qt-embedded/Qtopia application - running on my handheld or PC using the Linux console framebuffer (i.e. - not X11)? + Q-115: Can I connect via VNC to a Qt-embedded/Qt-enhanced/Qtopia + application running on my handheld, cell phone, or PC using the Linux + console framebuffer (i.e. not X11)? - Q-116: Now that non-X11 devices can be exported via VNC using x11vnc, + Q-116: How do I inject touch screen input into an + Qt-embedded/Qt-enhanced/Qtopia cell phone such as openmoko/qtmoko Neo + Freerunner? + + Q-117: Now that non-X11 devices can be exported via VNC using x11vnc, can I build it with no dependencies on X11 header files and libraries? - Q-117: Does x11vnc support Mac OS X Aqua/Quartz displays natively + Q-118: How do I cross compile x11vnc for a different architecture than + my Linux i386 or amd64 PC? + + Q-119: Does x11vnc support Mac OS X Aqua/Quartz displays natively (i.e. no X11 involved)? - Q-118: Can x11vnc be used as a VNC reflector/repeater to improve + Q-120: Can x11vnc be used as a VNC reflector/repeater to improve performance for the case of a large number of simultaneous VNC viewers (e.g. classroom broadcasting or a large demo)? - Q-119: Can x11vnc be used during a Linux, Solaris, etc. system + Q-121: Can x11vnc be used during a Linux, Solaris, etc. system Installation so the Installation can be done remotely? [Misc: Clipboard, File Transfer/Sharing, Printing, Sound, Beeps, Thanks, etc.] - Q-120: Does the Clipboard/Selection get transferred between the + Q-122: Does the Clipboard/Selection get transferred between the vncviewer and the X display? - Q-121: Can I use x11vnc to record a Shock Wave Flash (or other format) + Q-123: Can I use x11vnc to record a Shock Wave Flash (or other format) video of my desktop, e.g. to record a tutorial or demo? - Q-122: Can I transfer files back and forth with x11vnc? + Q-124: Can I transfer files back and forth with x11vnc? - Q-123: Which UltraVNC extensions are supported? + Q-125: Which UltraVNC extensions are supported? - Q-124: Can x11vnc emulate UltraVNC's Single Click helpdesk mode for + Q-126: Can x11vnc emulate UltraVNC's Single Click helpdesk mode for Unix? I.e. something very simple for a naive user to initiate a reverse vnc connection from their Unix desktop to a helpdesk operator's VNC Viewer. - Q-125: Can I (temporarily) mount my local (viewer-side) Windows/Samba + Q-127: Can I (temporarily) mount my local (viewer-side) Windows/Samba File share on the machine where x11vnc is running? - Q-126: Can I redirect CUPS print jobs from the remote desktop where + Q-128: Can I redirect CUPS print jobs from the remote desktop where x11vnc is running to a printer on my local (viewer-side) machine? - Q-127: How can I hear the sound (audio) from the remote applications + Q-129: How can I hear the sound (audio) from the remote applications on the desktop I am viewing via x11vnc? - Q-128: Why don't I hear the "Beeps" in my X session (e.g. when typing + Q-130: Why don't I hear the "Beeps" in my X session (e.g. when typing tput bel in an xterm)? - Q-129: Does x11vnc work with IPv6? + Q-131: Does x11vnc work with IPv6? - Q-130: Thanks for your program or for your help! Can I make a + Q-132: Thanks for your program or for your help! Can I make a donation? _________________________________________________________________ @@ -7884,9 +7924,9 @@ minal #2) x11vnc.) - Q-115: Can I connect via VNC to a Qt-embedded/Qtopia application - running on my handheld or PC using the Linux console framebuffer (i.e. - not X11)? + Q-115: Can I connect via VNC to a Qt-embedded/Qt-enhanced/Qtopia + application running on my handheld, cell phone, or PC using the Linux + console framebuffer (i.e. not X11)? Yes, the basic method for this is the -rawfb scheme where the Linux console framebuffer (usually /dev/fb0) is polled and the uinput driver @@ -7945,10 +7985,50 @@ minal #2) Update: We are finding some setups like Qtopia on the IPAQ do not allow mouse input via uinput. Please help us debug this problem by trying x11vnc on your device and letting us know what does and does - not work. - - - Q-116: Now that non-X11 devices can be exported via VNC using x11vnc, + not work. See the next FAQ for a possible workaround for touchscreens. + + + Q-116: How do I inject touch screen input into an + Qt-embedded/Qt-enhanced/Qtopia cell phone such as openmoko/qtmoko Neo + Freerunner? + + The qtmoko project does not use X11 for the graphical display. + Unfortunately the Linux uinput method described in the previous FAQ + does not work because Qt is using TSLIB (touch screen library) to + process the input and it only reads from one device (often + /dev/input/event1) and not from the new UINPUT device that x11vnc + creates (under -pipeinput UINPUT) + + So something else needs to be done. It was discovered that by simply + writing the touchscreen events directly to /dev/input/event1 then + input can be injected into the system. There is no x11vnc builtin mode + for this yet (until we understand it better), but there is a working + script provided in x11vnc/misc/qt_tslib_inject.pl. So one could use it + this way for example: + x11vnc ... -rawfb console -pipeinput path/to/qt_tslib_inject.pl -env INJECT_O +PTIONS=clickonly,cal=/etc/pointercal + + Read the script for how to enable other options and what the above + options mean (e.g. /etc/pointercal contains TSLIB's calibration + parameters and are necessary to achieve accurate pointing.) + + The x11vnc/misc/qt_tslib_inject.pl script can potentially be modified + to handle other devices where the uinput method fails. It could also + be modified to create 'hot keys', etc. + + Please let us know how things go if you try this out; there is much to + learn about synthetic input injection in handhelds and cell phones. As + we learn more we can develop a builtin x11vnc mode for this sort of + injection. + + Update Dec/2010: There is experimental built-in UINPUT support in the + x11vnc development tarball for qtmoko with touchpad managed by tslib. + See -pipeinput UINPUT for more info. Here is an example: + x11vnc -rawfb console -pipeinput UINPUT:touch,tslib_cal=/etc/pointercal,dire +ct_abs=/dev/input/event1,nouinput,dragskip=3 + + + Q-117: Now that non-X11 devices can be exported via VNC using x11vnc, can I build it with no dependencies on X11 header files and libraries? Yes, as of Jul/2006 x11vnc enables building for -rawfb only support. @@ -7962,7 +8042,40 @@ minal #2) know what you did. - Q-117: Does x11vnc support Mac OS X Aqua/Quartz displays natively + Q-118: How do I cross compile x11vnc for a different architecture than + my Linux i386 or amd64 PC? + + You will need a cross-compiling toolchain. Perhaps your distro + provides these or you can find a HOWTO for your distro. We found a + nice one at qtmoko.org for building armel binaries on Debian Linux + i386 machines. It includes most of the libraries that x11vnc needs. We + use that example here. + + We ran this script to set PATH, configure, and build: +#!/bin/sh + +# toolchain from: qtmoko-debian-toolchain-armv4t-eabi.tar.gz + +export PATH=/opt/toolchains/arm920t-eabi/bin:$PATH + +env CC=arm-linux-gcc ./configure --host=arm-linux --without-avahi + +make + +arm-linux-strip ./x11vnc/x11vnc +ls -l ./x11vnc/x11vnc + + Note we had to include --without-avahi due to lack of + libavahi-client.so.3 supplied by the toolchain we used. One would need + to add it if it was desired on the target machine. We also stripped + the binary to make it smaller. + + For an embedded system one may also want to add --without-x if the + embedded system does not use X11 and the -rawfb mechanism must be + used. + + + Q-119: Does x11vnc support Mac OS X Aqua/Quartz displays natively (i.e. no X11 involved)? Yes, since Nov/2006 in the development tree (x11vnc-0.8.4 tarball) @@ -8086,7 +8199,7 @@ ONLY do that for Mac OS X 10.5.x and NOT for 10.6.x (which doesn't need it anyway). - Q-118: Can x11vnc be used as a VNC reflector/repeater to improve + Q-120: Can x11vnc be used as a VNC reflector/repeater to improve performance for the case of a large number of simultaneous VNC viewers (e.g. classroom broadcasting or a large demo)? @@ -8195,7 +8308,7 @@ need it anyway). us know what you did. A really nice thing would be some sort of auto-discovery of your repeater, etc... - Q-119: Can x11vnc be used during a Linux, Solaris, etc. system + Q-121: Can x11vnc be used during a Linux, Solaris, etc. system Installation so the Installation can be done remotely? This can be done, but it doesn't always work because it depends on how @@ -8288,7 +8401,7 @@ need it anyway). [Misc: Clipboard, File Transfer/Sharing, Printing, Sound, Beeps, Thanks, etc.] - Q-120: Does the Clipboard/Selection get transferred between the + Q-122: Does the Clipboard/Selection get transferred between the vncviewer and the X display? As of Jan/2004 x11vnc supports the "CutText" part of the RFB (aka VNC) @@ -8342,7 +8455,7 @@ need it anyway). cutbuffers. - Q-121: Can I use x11vnc to record a Shock Wave Flash (or other format) + Q-123: Can I use x11vnc to record a Shock Wave Flash (or other format) video of my desktop, e.g. to record a tutorial or demo? Yes, it is possible with a number of tools that record VNC and @@ -8354,7 +8467,7 @@ need it anyway). parameters should be applied to x11vnc to speed up its polling for this sort of application, e.g. "-wait 10 -defer 10". - Q-122: Can I transfer files back and forth with x11vnc? + Q-124: Can I transfer files back and forth with x11vnc? As of Oct/2005 and May/2006 x11vnc enables, respectively, the TightVNC and UltraVNC file transfer implementations that were added to @@ -8402,7 +8515,7 @@ need it anyway). control you will probably be foiled by the "-rfbversion 3.6" issue. - Q-123: Which UltraVNC extensions are supported? + Q-125: Which UltraVNC extensions are supported? Some of them are supported. To get UltraVNC Viewers to attempt to use these extensions you will need to supply this option to x11vnc: @@ -8432,7 +8545,7 @@ need it anyway). ultravnc_repeater.pl - Q-124: Can x11vnc emulate UltraVNC's Single Click helpdesk mode for + Q-126: Can x11vnc emulate UltraVNC's Single Click helpdesk mode for Unix? I.e. something very simple for a naive user to initiate a reverse vnc connection from their Unix desktop to a helpdesk operator's VNC Viewer. @@ -8670,7 +8783,7 @@ connect = localhost:5501 You will find the details here. - Q-125: Can I (temporarily) mount my local (viewer-side) Windows/Samba + Q-127: Can I (temporarily) mount my local (viewer-side) Windows/Samba File share on the machine where x11vnc is running? You will have to use an external network redirection for this. @@ -8720,7 +8833,7 @@ d,ip=127.0.0.1,port=1139 Sep 2006 it is there for testing.) - Q-126: Can I redirect CUPS print jobs from the remote desktop where + Q-128: Can I redirect CUPS print jobs from the remote desktop where x11vnc is running to a printer on my local (viewer-side) machine? You will have to use an external network redirection for this. @@ -8812,7 +8925,7 @@ d,ip=127.0.0.1,port=1139 Sep 2006 it is there for testing.) - Q-127: How can I hear the sound (audio) from the remote applications + Q-129: How can I hear the sound (audio) from the remote applications on the desktop I am viewing via x11vnc? You will have to use an external network audio mechanism for this. @@ -8913,7 +9026,7 @@ or: provide (as of Sep/2006 it is there for testing.) - Q-128: Why don't I hear the "Beeps" in my X session (e.g. when typing + Q-130: Why don't I hear the "Beeps" in my X session (e.g. when typing tput bel in an xterm)? As of Dec/2003 "Beep" XBell events are tracked by default. The X @@ -8926,7 +9039,7 @@ or: redirector such as esd. - Q-129: Does x11vnc work with IPv6? + Q-131: Does x11vnc work with IPv6? Update: as of Apr/2010 in the 0.9.10 x11vnc development tarball, there is now built-in support for IPv6 (128 bit internet addresses.) See the @@ -9025,7 +9138,7 @@ or: Contributions: - Q-130: Thanks for your program or for your help! Can I make a + Q-132: Thanks for your program or for your help! Can I make a donation? Please do (any amount is appreciated; very few have donated) and thank @@ -12172,7 +12285,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.9.13 lastmod: 2010-09-10 +x11vnc: allow VNC connections to real X11 displays. 0.9.13 lastmod: 2010-12-20 x11vnc options: -display disp -auth file -N @@ -12193,83 +12306,83 @@ x11vnc options: -vncconnect -novncconnect -allow host1[,host2..] -localhost -listen6 str -nolookup -input string -grabkbd -grabptr - -grabalways -viewpasswd string -passwdfile filename - -showrfbauth filename -unixpw [list] -unixpw_nis [list] - -unixpw_cmd cmd -find -finddpy - -listdpy -findauth [disp] -create - -xdummy -xvnc -xvnc_redirect - -xdummy_xvfb -create_xsrv str -svc - -svc_xdummy -svc_xvnc -svc_xdummy_xvfb - -xdmsvc -sshxdmsvc -unixpw_system_greeter - -redirect port -display WAIT:... -vencrypt mode - -anontls mode -sslonly -dhparams file - -nossl -ssl [pem] -ssltimeout n - -sslnofail -ssldir dir -sslverify path - -sslCRL path -sslGenCA [dir] -sslGenCert type name - -sslEncKey pem -sslCertInfo pem -sslDelCert pem - -sslScripts -stunnel [pem] -stunnel3 [pem] - -enc cipher:keyfile -https [port] -httpsredir [port] - -http_oneport -ssh user@host:disp -usepw - -storepasswd pass file -nopw -accept string - -afteraccept string -gone string -users list - -noshm -flipbyteorder -onetile - -solid [color] -blackout string -xinerama - -noxinerama -xtrap -xrandr [mode] - -rotate string -padgeom WxH -o logfile - -flag file -rmflag file -rc filename - -norc -env VAR=VALUE -prog /path/to/x11vnc - -h, -help -?, -opts -V, -version - -license -dbg -q, -quiet - -v, -verbose -bg -modtweak - -nomodtweak -xkb -noxkb - -capslock -skip_lockkeys -noskip_lockkeys - -skip_keycodes string -sloppy_keys -skip_dups - -noskip_dups -add_keysyms -noadd_keysyms - -clear_mods -clear_keys -clear_all - -remap string -norepeat -repeat - -nofb -nobell -nosel - -noprimary -nosetprimary -noclipboard - -nosetclipboard -seldir string -cursor [mode] - -nocursor -cursor_drag -arrow n - -noxfixes -alphacut n -alphafrac fraction - -alpharemove -noalphablend -nocursorshape - -cursorpos -nocursorpos -xwarppointer - -noxwarppointer -always_inject -buttonmap string - -nodragging -ncache n -ncache_cr - -ncache_no_moveraise -ncache_no_dtchange -ncache_no_rootpixmap - -ncache_keep_anims -ncache_old_wm -ncache_pad n - -debug_ncache -wireframe [str] -nowireframe - -nowireframelocal -wirecopyrect mode -nowirecopyrect - -debug_wireframe -scrollcopyrect mode -noscrollcopyrect - -scr_area n -scr_skip list -scr_inc list - -scr_keys list -scr_term list -scr_keyrepeat lo-hi - -scr_parms string -fixscreen string -debug_scroll - -noxrecord -grab_buster -nograb_buster - -debug_grabs -debug_sel -pointer_mode n - -input_skip n -allinput -input_eagerly - -speeds rd,bw,lat -wmdt string -debug_pointer - -debug_keyboard -defer time -wait time - -extra_fbur n -wait_ui factor -setdefer n - -nowait_bog -slow_fb time -xrefresh time - -nap -nonap -sb time - -readtimeout n -ping n -nofbpm - -fbpm -nodpms -dpms - -forcedpms -clientdpms -noserverdpms - -noultraext -chatwindow -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 -macnodim - -macnosleep -macnosaver -macnowait - -macwheel n -macnoswap -macnoresize - -maciconanim n -macmenu -macuskbd - -gui [gui-opts] -remote command -query variable - -QD variable -sync -query_retries str - -remote_prefix str -noremote -yesremote - -unsafe -safer -privremote - -nocmds -allowedcmds list -deny_all - + -ungrabboth -grabalways -viewpasswd string + -passwdfile filename -showrfbauth filename -unixpw [list] + -unixpw_nis [list] -unixpw_cmd cmd -find + -finddpy -listdpy -findauth [disp] + -create -xdummy -xvnc + -xvnc_redirect -xdummy_xvfb -create_xsrv str + -svc -svc_xdummy -svc_xvnc + -svc_xdummy_xvfb -xdmsvc -sshxdmsvc + -unixpw_system_greeter -redirect port -display WAIT:... + -vencrypt mode -anontls mode -sslonly + -dhparams file -nossl -ssl [pem] + -ssltimeout n -sslnofail -ssldir dir + -sslverify path -sslCRL path -sslGenCA [dir] + -sslGenCert type name -sslEncKey pem -sslCertInfo pem + -sslDelCert pem -sslScripts -stunnel [pem] + -stunnel3 [pem] -enc cipher:keyfile -https [port] + -httpsredir [port] -http_oneport -ssh user@host:disp + -usepw -storepasswd pass file -nopw + -accept string -afteraccept string -gone string + -users list -noshm -flipbyteorder + -onetile -solid [color] -blackout string + -xinerama -noxinerama -xtrap + -xrandr [mode] -rotate string -padgeom WxH + -o logfile -flag file -rmflag file + -rc filename -norc -env VAR=VALUE + -prog /path/to/x11vnc -h, -help -?, -opts + -V, -version -license -dbg + -q, -quiet -v, -verbose -bg + -modtweak -nomodtweak -xkb + -noxkb -capslock -skip_lockkeys + -noskip_lockkeys -skip_keycodes string -sloppy_keys + -skip_dups -noskip_dups -add_keysyms + -noadd_keysyms -clear_mods -clear_keys + -clear_all -remap string -norepeat + -repeat -nofb -nobell + -nosel -noprimary -nosetprimary + -noclipboard -nosetclipboard -seldir string + -cursor [mode] -nocursor -cursor_drag + -arrow n -noxfixes -alphacut n + -alphafrac fraction -alpharemove -noalphablend + -nocursorshape -cursorpos -nocursorpos + -xwarppointer -noxwarppointer -always_inject + -buttonmap string -nodragging -ncache n + -ncache_cr -ncache_no_moveraise -ncache_no_dtchange + -ncache_no_rootpixmap -ncache_keep_anims -ncache_old_wm + -ncache_pad n -debug_ncache -wireframe [str] + -nowireframe -nowireframelocal -wirecopyrect mode + -nowirecopyrect -debug_wireframe -scrollcopyrect mode + -noscrollcopyrect -scr_area n -scr_skip list + -scr_inc list -scr_keys list -scr_term list + -scr_keyrepeat lo-hi -scr_parms string -fixscreen string + -debug_scroll -noxrecord -grab_buster + -nograb_buster -debug_grabs -debug_sel + -pointer_mode n -input_skip n -allinput + -input_eagerly -speeds rd,bw,lat -wmdt string + -debug_pointer -debug_keyboard -defer time + -wait time -extra_fbur n -wait_ui factor + -setdefer n -nowait_bog -slow_fb time + -xrefresh time -nap -nonap + -sb time -readtimeout n -ping n + -nofbpm -fbpm -nodpms + -dpms -forcedpms -clientdpms + -noserverdpms -noultraext -chatwindow + -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 + -macnodim -macnosleep -macnosaver + -macnowait -macwheel n -macnoswap + -macnoresize -maciconanim n -macmenu + -macuskbd -gui [gui-opts] -remote command + -query variable -QD variable -sync + -query_retries str -remote_prefix str -noremote + -yesremote -unsafe -safer + -privremote -nocmds -allowedcmds list + -deny_all LibVNCServer options: -rfbport port TCP port for RFB protocol @@ -12303,7 +12416,7 @@ libvncserver-tight-extension options: % x11vnc -help -x11vnc: allow VNC connections to real X11 displays. 0.9.13 lastmod: 2010-09-10 +x11vnc: allow VNC connections to real X11 displays. 0.9.13 lastmod: 2010-12-20 (type "x11vnc -opts" to just list the options.) @@ -13085,6 +13198,12 @@ Options: Some degree of cooperation from the person at the display is assumed. This is intended for remote help-desk or educational usage modes. + + Note: on some recent (12/2010) X servers and/or + desktops, -grabkbd no longer works: it prevents the + window manager from resizing windows and similar things. + Try -ungrabboth below (might not work.) + -grabptr As -grabkbd, but for the mouse pointer using XGrabPointer(3X11). Unfortunately due to the way the X server works, the mouse can still be moved around by the @@ -13094,6 +13213,11 @@ Options: act on the local user's input. Again, some degree of cooperation from the person at the display is assumed. +-ungrabboth Whenever there is any input (either keyboard or + pointer), ungrab *both* the keyboard and the pointer + while injecting the synthetic input. This is to allow + window managers, etc. a chance to grab. + -grabalways Apply both -grabkbd and -grabptr even when no VNC viewers are connected. If you only want one of them, use the -R remote control to turn the other back on, @@ -13639,6 +13763,15 @@ Options: xauth extract - $DISPLAY" + NOTE: As specified in the previous paragraph, you can + supply your own WAIT:cmd=... program or script, BUT + there are two very useful *BUILT-IN* ones: FINDDISPLAY + (alias -find above) and FINDCREATEDISPLAY (alias -create + above.) Most people use these instead of creating + their own script. Read the following (especially the + BUILT-IN modes sections) to see how to configure these + two useful builtin -display WAIT: modes. + In the case of -unixpw (and -unixpw_nis only if x11vnc is running as root), then the cmd= command is run as the user who just authenticated via the login and @@ -13670,6 +13803,11 @@ Options: your long "login:" line press the Up arrow once (before typing anything else). + Most of these colon options only apply to the builtin + FINDDISPLAY and FINDCREATEDISPLAY modes, but note + that they are passed to the extrenal command in the + environment as well and so could be used. + In the login panel, press F1 to get a list of the available options that you can add after the username. @@ -13703,23 +13841,19 @@ Options: and the user put "geom=1600x1200" in his ~/.x11vnc_create file. - To troubleshoot the FINDCREATEDISPLAY mechanism, - set the following env. var. to an output log file, - e.g -env CREATE_DISPLAY_OUTPUT=/tmp/mydebug.txt - To disable the option setting set the environment variable X11VNC_NO_UNIXPW_OPTS=1 before starting x11vnc. To set any other options, the user can use the gui (x11vnc -gui connect) or the remote control method (x11vnc -R opt:val) during his VNC session. - The combination of -display WAIT:cmd=... and -unixpw - allows automatic pairing of an unix authenticated VNC - user with his desktop. This could be very useful on - SunRays and also any system where multiple users share - a given machine. The user does not need to remember - special ports or passwords set up for his desktop - and VNC. + So we see the combination of -display WAIT:cmd=... and + -unixpw allows automatic pairing of an unix + authenticated VNC user with his desktop. This could + be very useful on SunRays and also any system where + multiple users share a given machine. The user does + not need to remember special ports or passwords set up + for his desktop and VNC. A nice way to use WAIT:cmd=... is out of inetd(8) (it automatically forks a new x11vnc for each user). @@ -13731,13 +13865,15 @@ Options: process that will not switch, but it is only encoding and decoding the encrypted stream at that point. - Automatic Finding of User X Sessions: + BUILT-IN modes: + + -- Automatic Finding of User X Sessions -- As a special case, WAIT:cmd=FINDDISPLAY will run a script that works on most Unixes to determine a user's DISPLAY variable and xauthority data (see who(1)). - The option "-find" is an alias for this mode. + NOTE: The option "-find" is an alias for this mode. To have this default script printed to stdout (e.g. for customization) run with WAIT:cmd=FINDDISPLAY-print To @@ -13781,7 +13917,12 @@ Options: X11VNC_SKIP_DISPLAY=all then all display finding fails as if you set X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 (below.) - Automatic Creation of User X Sessions: + On some systems lsof(1) can be very slow. Set the + env. var. FIND_DISPLAY_NO_LSOF=1 to skip using lsof to + try to find the Linux VT the X server is running on. + set FIND_DISPLAY_NO_VT_FIND=1 to avoid looking at all. + + -- Automatic Creation of User X Sessions -- An interesting option is WAIT:cmd=FINDCREATEDISPLAY that is like FINDDISPLAY in that is uses the same method @@ -13790,13 +13931,19 @@ Options: for the user. This is the only time x11vnc tries to actually start up an X server. - The option "-create" is an alias for this mode. + NOTE: The option "-create" is an alias for this mode. It will start looking for an open display number at :20 Override via X11VNC_CREATE_STARTING_DISPLAY_NUMBER=n By default 80 X displays are allowed (i.e. going to :99) Override via X11VNC_CREATE_MAX_DISPLAYS=n + For its heuristics, the create display script sets + LC_ALL=C so that command output is uniform. By default + it will try to restore LC_ALL right before starting the + user session. However, if you don't mind it keeping + LC_ALL=C set the env. var.: X11VNC_CREATE_LC_ALL_C_OK=1 + By default FINDCREATEDISPLAY will try Xvfb and then Xdummy: @@ -13823,6 +13970,10 @@ Options: it to terminate (or kill the X server process if all else fails). + To troubleshoot the FINDCREATEDISPLAY mechanism, + set the following env. var. to an output log file, + e.g -env CREATE_DISPLAY_OUTPUT=/tmp/mydebug.txt + So this is a somewhat odd mode for x11vnc in that it will start up and poll virtual X servers! This can be used from, say, inetd(8) to provide a means of @@ -16302,6 +16453,7 @@ t -sb time Time in seconds after NO activity (e.g. screen blank) to really throttle down the screen polls (i.e. sleep for about 1.5 secs). Use 0 to disable. Default: 60 + Set the env. var. X11VNC_SB_FACTOR to scale it. -readtimeout n Set LibVNCServer rfbMaxClientWait to n seconds. On slow links that take a long time to paint the first @@ -16749,18 +16901,19 @@ er using the 'console_guess' string printed at startup, be sure to indicate the snap: method. - uinput: If the Linux version appears to be 2.6 or - later and the "uinput" module appears to be present - (modprobe uinput), 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 will have to use -pipeinput if you - want to tweak any UINPUT parameters. You may also want - to also use the -nodragging and -cursor none options. - Use "console0", etc or -pipeinput CONSOLE to force - the /dev/ttyN method. + uinput: If the Linux version appears to be 2.6 + or later and the "uinput" module appears to be + present (modprobe uinput), 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. It also provides more accurate + keystroke insertion. See -pipeinput UINPUT below for + more information on this mode; you will have to use + -pipeinput if you want to tweak any UINPUT parameters. + You may also want to also use the -nodragging and + -cursor none options. Use "console0", etc or + -pipeinput CONSOLE to force the /dev/ttyN method. Note you can change the Linux VT remotely using the chvt(1) command to make the one you want be the active @@ -16800,7 +16953,11 @@ er to improve performance in the case of many (e.g. > 10) simultaneous VNC viewers, and you try a divide and conquer scheme to reduce bandwidth and improve - responsiveness. + responsiveness. (However, another user found this mode + useful to export a demo display through a slow link: + then multiple demo viewers connected to the reflecting + x11vnc on the fast side of the link, and so avoided + all of the demo viewers going through the slow link.) For example, if there will be 64 simultaneous VNC viewers this can lead to a lot of redundant VNC traffic @@ -16831,6 +16988,13 @@ er to "file:path_to_file" to indicate a file containing the password as its first line. + To set the pixel format that x11vnc requests as a VNC + CLIENT set the env. vars: X11VNC_REFLECT_bitsPerSample + X11VNC_REFLECT_samplesPerPixel, and + X11VNC_REFLECT_bytesPerPixel; the defaults are 8, 3, 4. + 2, 3, 1 would give a low color mode. See the function + rfbGetClient() in libvncclient for more info. + The VNC HOST mode implies -shared. Use -noshared as a subsequent cmdline option to disable sharing. @@ -16893,7 +17057,8 @@ er The UINPUT mode currently only does US keyboards (a scan code option may be added), and not all keysyms - are supported. + are supported. But it is probably more accurate than + the "CONSOLE" method. You may want to use the options -cursor none and -nodragging in this mode. @@ -16933,16 +17098,6 @@ er cause jerkiness or unexpected behavior with menus, etc. Use reset=0 to disable. - If the uinput device has an absolute pointer (as opposed - to a normal mouse that is a relative pointer) you can - specify the option "abs". Note that a touchpad - on a laptop is an absolute device to some degree. - This (usually) avoids all the problems with mouse - acceleration. If x11vnc has trouble deducing the size - of the device, use "abs=WxH". Furthermore, if the - device is a touchscreen (assumed to have an absolute - pointer) use "touch" or "touch=WxH". - If you set the env. var X11VNC_UINPUT_THRESHOLDS then the thresh=n mode will be enabled. It is currently not working well. If |dx| <= thresh and |dy| < thresh @@ -16952,8 +17107,70 @@ er Example: -pipeinput UINPUT:accel=4.0 -cursor none - You can also set the env. var X11VNC_UINPUT_DEBUG=1 or - higher to get debugging output for UINPUT mode. + If the uinput device has an absolute pointer (as opposed + to a normal mouse that is a relative pointer) you can + specify the option "abs". Note that a touchpad + on a laptop is an absolute device to some degree. + This (usually) avoids all the problems with mouse + acceleration. If x11vnc has trouble deducing the + size of the device, use "abs=WxH". Furthermore, + if the device is a touchscreen (assumed to have an + absolute pointer) use "touch" or "touch=WxH". + For touchscreens, when a mouse button is pressed, + a pressure increase is injected, and when the button + is released a pressure of zero is injected. + + If touch has been set, use "touch_always=1" to + indicate whenever the mouse moves with no button + pressed, a touch event of zero pressure should be + sent anyway. Also use "btn_touch=1" to indicate a + BTN_TOUCH keystroke press or release should be sent + instead of a pressure change. Set "dragskip=n" to + skip n dragged mouse touches (with pressure applied) + before injecting one. To indicate the pressure that + should be sent when there is a button click for a + touchscreen device, specify pressure=n, e.g. n=5. The + default is n=1. + + If a touch screen is being used ("touch" above) + and it is having its input processed by tslib, you can + specify the tslib calibration file via tslib_cal=. + For example, tslib_cal=/etc/pointercal. To get accurate + or even usable positioning this is required when tslib + is in use. + + The Linux uinput mechanism can be bypassed and one can + write input events DIRECTLY to the devices instead. + To do this, specify one or more of the following + for the input classes: direct_rel= + direct_abs= direct_btn= or + direct_key=. The file is usually + something like /dev/input/event1 but you can specify + any device file or pipe. You must specify each one + of the above classes even if they correspond to the + same device file (rel/abs and btn are often the same.) + Look at the file /proc/bus/input/devices to get an idea + what is available and the device filenames. Note: + The /dev/input/mouse* devices do not seem to work, + use the corresponding /dev/input/event* file instead. + Any input class not directly specified as above will be + handled via the uinput mechanism. To disable creating a + uinput device (and thereby discarding unhandled input), + specify "nouinput". + + Examples: + + -pipeinput UINPUT:direct_abs=/dev/input/event1 + + this was used on a qtmoko Neo freerunner (armel): + + -pipeinput UINPUT:touch,tslib_cal=/etc/pointercal, + direct_abs=/dev/input/event1,nouinput,dragskip=4 + + (where the long line has been split into two.) + + You can set the env. var X11VNC_UINPUT_DEBUG=1 or higher + to get debugging output for UINPUT mode. -macnodim For the native MacOSX server, disable dimming. -macnosleep For the native MacOSX server, disable display sleep. diff --git a/x11vnc/RELEASE-NOTES b/x11vnc/RELEASE-NOTES new file mode 100644 index 0000000..0d5c4b9 --- /dev/null +++ b/x11vnc/RELEASE-NOTES @@ -0,0 +1,1553 @@ + +x11vnc 0.9.13 2010-12-20 + +New in the 0.9.13 x11vnc release: + + Improved support for non-X11 touchscreen devices (e.g. handheld or + cell phone) via Linux uinput input injection. Additional + tuning parameters are added. TSLIB touchscreen calibration + is supported. Tested on Qtmoko Neo Freerunner. + + A tool, misc/uinput.pl, is provided to diagnose uinput + behavior on new devices. + + The env. vars. X11VNC_UINPUT_BUS and X11VNC_UINPUT_VERSION + are available if leaving them unset does not work. + + The Linux uinput non-X11 input injection can now be bypassed: + events can be directly written to the /dev/input/event + devices specified by the user (direct_abs=..., etc.) + + A -pipeinput input injection helper script, + misc/qt_tslib_inject.pl is provided as a tweakable + non-builtin direct input injection method. + + The list of new uinput parameters for the above two features is: + pressure, tslib_cal, touch_always, dragskip, btn_touch; + direct_rel, direct_abs, direct_btn, direct_key. + + The included SSL enabled Java VNC Viewers now handle Mouse + Wheel events. + + + miscellaneous new features and changes: + + In -reflect mode, the libvncclient connection can now have + the pixel format modified via the environment + variables X11VNC_REFLECT_bitsPerSample, + X11VNC_REFLECT_samplesPerPixel, and + X11VNC_REFLECT_bytesPerPixel + + In -create mode the following environment variables are added + to fine tune the behavior: FIND_DISPLAY_NO_LSOF: + do not use lsof(1) to try to determine the Linux VT, + FIND_DISPLAY_NO_VT_FIND: do not try to determine the + Linux VT at all, X11VNC_CREATE_LC_ALL_C_OK: do not bother + undoing the setting LC_ALL=C that the create_display + script sets. The performance of the -create script + has been improved for large installations (100's of + user sessions on one machine.) + + In -unixpw mode, one can now Tab from login: to Password. + + An environment variable, X11VNC_SB_FACTOR, allows one to scale + the -sb screenblank sleep time from the default 2 secs. + + In -rawfb mode, a bug is fixed in setting the number of bits + per pixel. + + Documented that -grabkbd is no longer working with some/most + window managers (it can prevent resizing and menu posting.) + + The macosx deprecated interface GetMainDevice() call is removed. + Compile with -DX11VNC_MACOSX_USE_GETMAINDEVICE if needed + for an old macosx version... + + Miscellaneous code cleanup. + +----------------------------------------------------------------------------- + + +x11vnc 0.9.12 2010-09-10 + +New in the 0.9.12 x11vnc release: + + One can now specify the maximum number of displays + that can be created in -create mode via the + env. var. X11VNC_CREATE_MAX_DISPLAYS + + The X11VNC_NO_LIMIT_SHM env. var. is added to skip any + automatic shared memory reduction. + + The kdm display manager is now detected when trying not to get + killed by the display manager. + + miscellaneous new features and changes: + + A compile error is fixed when using --with-system-libvncserver + pointing to LibVNCServer 0.9.7. + + -nevershared -forever usage mode is documented. + + Old SuSE broken thread local storage is documented. + + x11vnc exit cases are documented. + + A compile bug from forced use of Xdefs.h is worked around. + + +----------------------------------------------------------------------------- + + +x11vnc 0.9.11 2010-08-08 + +New in the 0.9.11 x11vnc release: + + The source tree is synchronized with the most recent libvncclient + (this only affects -reflect mode.) The build is fixed + for incompatibilities when using an external LibVNCServer + (e.g. ./configure --with-system-libvncserver...) + + The SSL enabled Java VNC Viewer Makefile has been modified so + that the jar files that are built are compatible back + to Java 1.4. + + In -reflect mode cursor position updates are now handled + correctly. + + In -create/-unixpw mode, the env. var. FD_USERPREFS may be set + to a filename in the user's home directory that includes + default username:options values (so the options do not + need to be typed every time at the login prompt.) + + miscellaneous new features and changes: + + An option -always_inject is provided: Even if there is no + displacement (dx = dy = 0) for a VNC mouse event force + the pointer to the indicated x,y position anyway. + + New java viewer debugging and workaround applet parameters: + debugKeyboard mapF5_to_atsign forbid_Ctrl_Alt + + You can set X11VNC_AVAHI_NAME, X11VNC_AVAHI_HOST, and/or + X11VNC_AVAHI_PORT environment variables to override the + default values. For example: -env X11VNC_AVAHI_NAME=wally + + When opening the X11 display extra XAUTHLOCALHOSTNAME settings + are attempted. + + +----------------------------------------------------------------------------- + + +x11vnc 0.9.10 2010-05-03 + +New in the 0.9.10 x11vnc release: + + IPv6 is now supported for all usage modes: forward and reverse + connections, SSL and unencrypted, etc. + + The included SSL enabled Java VNC viewer applet now supports + Chained SSL Certificates (x11vnc -ssl always has.) + The applet autodects x11vnc and set GET=1 for faster + connecting via HTTPS. + + A demo CGI script 'desktop.cgi' shows how to create an + SSL encrypted, multi-user x11vnc web login desktop + service. The user logs into a secure web site and gets + his/her own virtual desktop and his browser accesses it + with the SSL Java VNC Viewer applet. + + A serverCert Java Viewer applet parameter is provided. + Use an authenticated HTTPS browser connection to set + this parameter (the user could set it locally too.) + The onetimekey tool has -certonly option for this scheme. + + The Xdummy script (use Xorg 'dummy' driver instead of Xvfb) + no longer requires being run as root. + + + miscellaneous new features and changes: + + In the Java viewer applet, debugCerts and debugKeyboard parameters + are provided. The debugging output of the applet is more + readable. Some corner-case bugs (e.g. socket exceptions) + are now handled gracefully. Parameters forbid_Ctrl_Alt + and mapF5_to_atsign are added. + + The amount of time to wait for HTTPS applet downloads to finish + can be set in env. var. X11VNC_HTTPS_DOWNLOAD_WAIT_TIME. + + The -xkb mode is automatically enabled if there are more than + 4 keysyms per key. + + -coe is now an alias for -connect_or_exit. + + The -input_eagerly option enables this LibVNCServer feature + (it is like -allinput.) + + The "%" unix password verification tricks for the -unixpw + option are now documented. They also run a command + in UNIXPW_CMD. + + In -create (-svc, etc.) modes, a warning is printed out if Xvfb + cannot be found. Xvfb '+kb' option is checked for. + The -env CREATE_DISPLAY_OUTPUT=/tmp/mydebug.txt debugging + option is documented. Try to preserve user's PATH + if possible. + + In XDMCP connection mode, a test for GDM listening only + on IPv6 (::1) is performed. The interface can also be + specified via FD_XDMCP_IF. + + The example scripts connect_switch, ultravnc_repeater.pl, inet6to4 + have settings to let them run reliably for long times + as daemons. They also support IPv6. + + IPv6 notes: for some very esoteric cases (e.g. -chatwindow) + IPv4 localhost may be required for local IPC. A demo + transition tool 'inet6to4' is also included (can be + used for other apps.) x11vnc options related to IPv6: + -listen6, -6, -no6, -noipv4, -noipv6, and -connect, + -proxy. + + Use STUNNEL_LISTEN in -stunnel mode to have it listen on a + particular interface. Also STUNNEL_PROG. + + New remote control query options: pointer_x, pointer_y, + pointer_same, pointer_root, and pointer_mask. A demo + script using them misc/panner.pl is provided. + + Remote control change of -clip option will not create new + framebuffer if the size has not changed (for panner.pl) + + The X11VNC_DISABLE_SSL_CLIENT_MODE env. var. can be set to + disable SSL client role in reverse connections. This + means the VNC viewer side must be in SSL client role. + UltraVNC repeater operation can benefit from this. + + The SSL_INIT_TIMEOUT is increased to 1 hour if 'repeater' + is detected in a reverse connect string. + + The X property X11VNC_TRAP_XRANDR can be set on a desktop to + force x11vnc to use the -xrandr screen size change + trapping code. + + The -sslScripts option prints out the SSL certificate management + scripts. + + Suggest '-auth guess' and '-findauth' if X connection fails. + + The TightVNC sercurity type (TightVNC features enabler) now + works for RFB version 3.8. + + RECORD scroll detection is now working with the new gtk/gdk scroll + mechanism. Set X11VNC_SCROLL_MUST_EQUAL to disable. + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.9.9 2009-12-21 + + + +New in the 0.9.9 x11vnc release: + + A new option -findauth runs the FINDDISPLAY script that applies + heuristics to try to determine the correct XAUTHORITY + file. The use of '-auth guess' will use the XAUTHORITY + that -findauth reveals. This can be handy in with + the lastest GDM where the ability to store cookies in + ~/.Xauthority has been removed. + + If x11vnc is running as root (e.g. inetd or XDM/GDM/KDM) + the FD_XDM=1 mode will be tried if the above -findauth + or '-auth guess' command fails; it will find the + correct XAUTHORITY for the given display (this works for + XDM/GDM/KDM if the login greeter panel is up or if someone + has already logged into an X session.) You can also + set -env FD_XDM=1 to force it to be done on the first try. + + The -unixpw_system_greeter option, when used in combined + unixpw and XDMCP FINDCREATEDISPLAY mode (e.g. -xdmsvc), + enables the user to press Escape to jump directly to the + XDM/GDM/KDM login greeter screen. This way the user + avoids entering his unix password twice at X session + creation time. For subseqent logins to the same session, + he uses the regular x11vnc unixpw "login:" prompt. Also, + the unixpw login panel now has a short help displayed + if the user presses 'F1' that lists the options. + + The -appshare option enables simple application sharing based on + the -id/-sid mechanism. Every new toplevel window that + the application creates induces a new viewer window via + a reverse connection. The -id/-sid and -connect options + are required. Run 'x11vnc -appshare -help' for more info. + + Heuristics are applied to try to determine if the X display + is currently in a Display Manager Greeter Login panel + (e.g. GDM.) If so, x11vnc's creation of any windows and + use of XFIXES are delayed. + + This is to try to avoid x11vnc being killed after the user + logs in if the GDM KillInitClients=true is in effect. + So one no longer needs to set KillInitClients=false in + gdm.conf. Note that in recent GDM the KillInitClients + option has been removed. + + Also delayed is the use of the XFIXES cursor fetching + functionality; this avoids an Xorg bug that causes Xorg + to crash right after the user logs in. + + x11vnc now tries to be more aggressive in keeping up with VNC + client's framebuffer update requests. Some broken VNC + clients continuously spray these requests at VNC servers + (regardless of whether they have received any updates + or not.) The -extra_fbur option allows one to fine tune + the setting. + + The "-display WAIT:cmd=...", -find, -create modes now work + correctly for the user-supplied login program scheme + "-unixpw_cmd ...", as long as the login program supports + running commands specified in the environment variable + "RFB_UNIXPW_CMD_RUN" as the logged-in user. The mode + "-unixpw_nis ..." has also been made more consistent. + The username option "tag=..." can be used to set FD_TAG. + + The -stunnel option (like -ssl but uses stunnel as an external + helper program) now works with the -ssl "SAVE" and "TMP" + special certificate names. The -sslverify and -sslCRL + options now work correctly in -stunnel mode. Single port + HTTPS connections are also supported for this mode. + + The remote control command -R can be used to instruct x11vnc + to resend its most recent copy of the Clipboard, + Primary, or Cutbuffer selections: "x11vnc -R + resend_clipboard", "x11vnc -R resend_primary", and + "x11vnc -R resend_cutbuffer". + + miscellaneous new features and changes: + + The fonts in the GUI (-gui) can now by set via environment + variables, e.g. -env X11VNC_FONT_BOLD='Helvetica -16 bold' + and -env X11VNC_FONT_FIXED='Courier -14'. + + The value of the -timeout option is now also used for the timing + out of reverse connections. The -timeout exit will + occur if no client has made it to normal operating state + (instead of merely trying to connect.) + + One can add extra URL parameters to the HTTPS (-ssl) urls + via X11VNC_EXTRA_HTTPS_PARAMS without needing to edit + index.vnc. E.g.: -env X11VNC_EXTRA_HTTPS_PARAMS='?GET=1' + + One can make the libvncserver HTTP (non-SSL) server listen on + localhost: -env X11VNC_HTTP_LISTEN_LOCALHOST=1 (this way + only the single-port VNC+HTTPS is exposed to the network.) + + Warnings are printed out at startup if $DISPLAY appears to + start with "localhost:" (SSH X11 forwarding) or + "hostname:" (remote X display; will fail w/o -noshm) + + The -solid option now uses the DBUS_SESSION_BUS_ADDRESS env. var + if available. The -solid option now works in xfce. + If available, the dbus_launch(1) will be used in + FINDCREATEDISPLAY for gnome sessions. + + The bcx_xattach remote control command was added to facilitate + xattach and x2x desktop cursor switching. Other new + remote control commands: grab_state, ping:mystring, + grablocal, resend_cutbuffer, resend_clipboard, + resend_primary, keycode, keysym, fakebuttonevent, + ptr, sleep, get_xprop, set_xprop, wininfo, pointer_pos, + mouse_xy, noop, guess_dbus, DIRECT:query. Remote control + scripting, -query_retries, and -remote_prefix were + also added. + + In -rawfb mode the X display will not be opened at all unless + the -rawfb string is prefixed with '+' or -display + was specified on the cmdline. + + For multiple, separate x11vnc instances on the same X display, + one can rename the X11VNC_REMOTE, X11VNC_TICKER, and + VNC_CONNECT property names to unique ones. + + The -showrfbauth option prints out the VNC rfbauth password. + + The XDAMAGE mechanism is now automatically disabled for a + period of time if a game or screensaver generates too + many XDAMAGE rectangles per second. This avoids the X11 + event queue from soaking up too much memory. + + x11vnc does not switch on server autorepeat if any keys are + pressed down to work around a recent Xorg server and/or + gnome bug where the key will never stop repeating. + + Thse list of current clients is kept more up-to-date in the + tkx11vnc gui. Bugs in the gui setpass mode have been + fixed. + + Threads stability is further improved. See under the -threads + option help info about -env X11VNC_THREADS_NEW_FB_SLEEP=ms + + There is an experimental workaround: "-env X11VNC_WATCH_DX_DY=1" + that tries to avoid problems with poorly constructed + menu themes that place the initial position of the mouse + cursor inside a menu item's active zone. + + The crypt(3) function is now declared inside the x11vnc code on + all platforms (not just Linux). To disable this, set + CPPFLAGS='-DDO_NOT_DECLARE_CRYPT' while configuring. + (crypt is declared to avoid problems with header files.) + + Error reasons are printed for -storepasswd failures. + + Two scripts are added to x11vnc/misc: connect_switch and + ultravnc_repeater.pl + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + + + +----------------------------------------------------------------------------- + + +x11vnc 0.9.8 2009-07-08 + + +New in the 0.9.8 x11vnc release: + + Better reliability for the Java Viewer applet when connecting + through a Web Proxy via HTTPS. A proxy hostname + and port can be specified via applet parameters. + Proxy Authentication via Auth-Basic is supported. + More x11vnc printout in -ssl is provided to help + troubleshoot this mode and other ssl connections. + + Stability improvements to -threads mode. Running x11vnc this + way is more reliable now. Threaded operation sometimes + gives better interactive response and faster updates. The + threaded mode now supports multiple VNC viewers using + the same VNC encoding (some only on Linux or enabled + at build time.) The threaded mode can also yield + a performance enhancement in the many client case + (e.g. class-room broadcast.) We have tested with 30 to + 50 simultaneous clients. See also -reflect. + + + miscellaneous new features and changes: + + x11vnc automatically tries to work around an Xorg server bug + involving infinitely repeating keys when turning off key + repeating. Use -repeat if the automatic workaround fails. + Also, the environment variable X11VNC_IDLE_TIMEOUT + (seconds) is provided. + + In -reflect mode the environment variable X11VNC_REFLECT_PASSWORD + is provided. + + The -clip mode works under -rawfb. + + The -nounixpw option can disable unixpw mode if an earlier option + enables it (e.g. -svc). + + Scroll detection is skipped for windows with 'OpenOffice' in + their name. + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.9.7 2009-03-31 + + +New in the 0.9.7 x11vnc release: + + Basic support for building with VirtualGL's TurboVNC (an + enhanced TightVNC for fast LAN high framerate usage) + encoding and TightVNC modifications. More info: + http://www.karlrunge.com/x11vnc/faq.html#faq-turbovnc + and x11vnc/misc/turbovnc/README. + + The -ncache_cr option has been fixed and so in -ncache mode + smooth opaque window motions are now work correctly. Try + it out to see how smooth it is even on a slow link. + + Support for Linux text consoles (virtual terminals, e.g. 1-6) + is provided via, e.g., 'x11vnc -rawfb vt2' (for virtual + terminal #2). + + This is like LinuxVNC (i.e. text only), it avoids using + /dev/fb and uses /dev/vcsaN instead (the '-rawfb console' + mode uses /dev/fb.) With /dev/vcsaN the text terminal + is accessible even it if is not the currently active one. + + The -rawfb option now supports framebuffers with bits per pixel + less than 8 (e.g. 4 or 1 bpp.) + + Reverse connections now work in Anonymous Diffie Hellman SSL/TLS + mode. Reverse connections also work for VeNCrypt and + ANONTLS modes. + + + miscellaneous new features and changes: + + The included SSL enabled UltraVNC java viewer now has a + configurable [Home] entry in the drives drop down menu. + + In the -create, -svc, etc. modes one can now specify a + range of X displays to ignore in X11VNC_SKIP_DISPLAY. + Improvements and bugfixes were made to the find_display + and create_display scripts. FD_EXTRA option is provided. + + The '-rawfb video' option finds the video device file more + carefully. + + The -rmflag option allows a new way to indicate to other + applications that x11vnc has started. + + All of the java applet parameters are now documented in + the classes/ssl/README file. + + There is now a "sendbell" remote control command. + + A one-time -padgeom once:WxH mode is added. + + Improvements to the CUPS Terminal Services helper mode. + + If the X display cannot be opened normally then the env. var. + XAUTHLOCALHOSTNAME=localhost is tried. + + Bugfix for selection transfer to a now non-existent X window + (Thunderbird can cause this.) Related, the env. variable + LIBXCB_ALLOW_SLOPPY_LOCK is now set by default. + + Bugfix for -8to24 mode due to nonstandard indexed color support. + + The libvncserver and x11vnc autoconf/automake settings have + been improved. + + libXrandr include file is now found on Solaris. + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.9.6 2008-12-10 + + +New in the 0.9.6 x11vnc release: + + x11vnc's SSL encryption is extended to support the VeNCrypt and + TLS (older; vino) SSL/TLS security type extensions to VNC. + + Anonymous Diffie-Hellman key exchange (-ssl ANON) and Certificate + Revocation List support (-sslCRL) is added to the SSL + encryption mode. + + The Java viewer applet can now be served up through the VNC port + (5900) in addition to the normal HTTP port (5800) via + the -http_oneport option. Previously this only worked + for SSL connections and HTTPS. + + The "-rfbport PROMPT" mode presents a simple gui for the user + to select a port for the x11vnc service and a few other + settings. This enables a menu entry for naive users + that is included in x11vnc.desktop. + + If x11vnc is not built with the Avahi Zeroconf library an external + helper program (avahi-publish or dns-sd on Mac OS X) + is used instead. + + miscellaneous new features and changes: + + The default mode for '-ssl' is now the '-ssl SAVE' mode; i.e. + the generated certificate is saved and reused in + subsequent sessions rather than being discarded. + Use '-ssl TMP' recover the old way. This change made + to for it to be more likely that the VNC Viewer can save + the accepted cert for future authentications. + + The solid background color option works on the Mac OS X console. + + The -reopen option enables x11vnc to try to re connect to the X + display if GDM (or other display manager) kills it just + after the user logs in. + + The -dhparams option can be used to point to your own Diffie + Hellman parameters. + + The -setdefer option allows tuning how quickly updates will + be sent. Default setting tuned. + + The option -zeroconf is now an alias for -avahi/-mdns. + + In pipeinput mode, the pipe filehandle is now closed when + x11vnc exits. + + The -sshonly option turns off VeNCrypt and TLSVNC (vino) mod + leaving only the standard SSL (i.e. vncs://) + + For testing, the option -rand in an alias for -rawfb rand -nopw + + Minor tweaks to improve CUPS Print tunneling. + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.9.5 2008-10-24 + + +New in the 0.9.5 x11vnc release: + + Symmetric key encryption using the RC4, AES, Blowfish, and 3DES + ciphers is supported via the -enc cipher:keyfile option. + The SSVNC unix viewer 1.0.20 and later supports these + encryption methods. + + Server-side scaling can now have different scale factors along + the horizontal and vertical axes. E.g. -scale 1280x1024 + (same as -geometry 1280x1024) or -scale 0.8x0.75 + + The -chatwindow option allows a chat window to appear on the + X console during UltraVNC chats (requires the SSVNC + viewer package.) + + miscellaneous new features and changes: + + The HTTP Java viewer applet jar, classes/VncViewer.jar, has + been updated with an improved implementation based on + the code used by the classes/ssl applets. + + A description and instructions are now printed out when + X_ShmAttach fails if one tries to attach to a remote + $DISPLAY (i.e. $DISPLAY is on a different machine from + the machine x11vnc is running on; this often happens + with SSH X redirection, X terminal servers, etc). + + The -allow option now works correctly in -ssl mode. + + The -remap option now works on the MacOSX console. + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.9.4 2008-09-17 + + +New in the 0.9.4 x11vnc release: + + Reverse VNC connections (-connect and -connect_or_exit options) + work in the -find and -create X session FINDCREATEDISPLAY + modes. + + Reverse VNC connections (either normal or using SSL) can use a + Web Proxy, a SOCKS proxy, the UltraVNC repeater proxy, + an SSH connection, or even a CGI URL to make the outgoing + connection (-proxy option). Forward connections can + use the -ssh option to set up a reachable redirection. + + Support for the ZYWRLE encoding is added, this is the RealVNC ZRLE + encoding extended to do motion video and photo regions + more efficiently by way of a Wavelet based transformation. + + The session finding and creating modes (-find and -create) have + been improved to be more reliable and also provide a new + desktop types (xfce) and new service redirection options. + + Support for indexed colormaps (PseudoColor) with depths other + than 8 is provided (depths 1 to 16 now work). + + Java viewer applet source code is provided in the x11vnc 0.9.4 + tarball so now everything can be built from source. + + miscellaneous new features and changes: + + To unset Caps_Lock, Num_Lock and raise all keys in the X server + use -clear_all, or by remote control 'x11vnc -R clear_all' + + The -autoport option gives more control over the server port + range that probes. + + The -ping option can be used to help keep idle connections alive. + + The -finddpy and -listdpy utilities help to debug and configure + the -find, -create, and -display WAIT:... modes. + + Some automatic detection of screen resizes are handled even if + the -xrandr option is not supplied. + + The -advertise_truecolor option can workaround some VNC viewer + incompatibilities with PseudoColor. + + The option '-clip xinerama0' can be used to clip to the first + Xinerama sub-screen, etc. + + If a fast framebuffer read rate is detected the -wait and -defer + parameters are reduced to 10 and 15 msec, respectively. + + Pasting of the selection/clipboard into remote applications + (e.g. Java) is improved. + + Usage with dvorak keyboards is improved. The option -macuskbd is + available on MacOSX to use the original US keyboard code. + + Via a compiler option (-DENABLE_GRABLOCAL) one can use the + -grablocal n option to filter VNC client input if someone + at the console has done mouse or keyboard input n secs ago. + + The -sleepin option can now sleep a random amount of time between + min and max time delays (-sleepin min-max). + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.9.3 2007-10-04 + + +New in the 0.9.3 x11vnc release: + + This release provides client-side caching to improve interactive + response. Almost no VNC viewers implement caching which is why + VNC is slow compared to other remote graphics protocols. + + The x11vnc caching will work with any VNC viewer, but they will + not hide the pixmap cache region that is below the main desktop + (one must adjust the window manually). The SSVNC Unix VNC viewer, + however, automatically detects and hides the region. + + To enable caching, supply "-ncache n" to x11vnc, where the + number n, e.g. 10, indicates how much memory to devote to the + caching scheme. + + See http://www.karlrunge.com/x11vnc/#faq-client-caching + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.9.2 2007-06-18 + + +New in the 0.9.2 x11vnc release: + + A compile-time bug is fixed for when the OpenSSL library is not + available or --without-ssl is supplied; previously the + build would fail. + + One can configure x11vnc via "configure --with-system-libvncserver" + to use a system installed libvncserver library instead of + the one bundled in the release tarball. + + If UltraVNC file transfer or chat is detected, then VNC clients + are "pinged" more often to prevent these side channels + from becoming serviced too infrequently. + + In -unixpw mode in the username and password dialog no text will + be echoed if the first character sent is "Escape". This + enables a convenience feature in SSVNC to send the username + and password automatically. + + miscellaneous new features and changes: + + When building from the CVS tree --with-x11vnc must be supplied if + you want x11vnc to be built. The LibVNCServer release + tarball no longer contains the x11vnc source. + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.9.1 2007-05-24 + + +New in the 0.9.1 x11vnc release: + + A new Unix username identification scheme is provided when + SSL client certificates are used to authenticate VNC + viewers. The username is extracted from the 'Subject' + section of the cert. The option is "-users sslpeer=" + which, like "-users unixpw=" already does, will cause + a switch to the Unix user. This is useful for the + -find and -create options that try to find an existing + X session associated with the user or create a new one. + + The UltraVNC Java Viewer has been modified to support SSL + connections. Some bugs were also fixed and some + improvements added. A patch file and a compiled jar file + (UltraViewerSSL.jar and SignedUltraViewerSSL.jar in the + classes/ssl directory) are provided in the x11vnc package. + + For the -user option groups are now handled better by using + initgroups(3), or if finer control is needed one can + use: "-users user1.group1,..." + + When SSL client certification is being used and external login + programs are being used the env. var. RFB_SSL_CLIENT_CERT + is set to the clients certificate. Set X11VNC_SSLPEER_CN + to use the Common Name instead of the certificate email + address to find the unix username. + + miscellaneous new features and changes: + + The -wait and -defer defaults were lowered from 30 to 20 + milliseconds, set the values explicitly if this increases + the load too much for your liking. + + In -create mode where a Xvfb session is started, mwm was added + as a session type. setpgrp(2) is used for the spawned + process if available. The XKEYBOARD extension is + enabled (+kb, but it doesn't seem to always work). + TrueColor is forced to be the default visual (recent + Xvfb seem to choose DirectColor, this is likely a bug) + One can also force creating a new Xvfb by setting the + env. var. X11VNC_FINDDISPLAY_ALWAYS_FAILS (not exactly + clear what this would be used for). + + The WAITBG env. var. enables -display WAIT:... to take place in + the background. + + One can specify the X11VNC_SKIP_DISPLAY env. var. for a list of + displays to exclude in the FINDDISPLAY action. This can + also be specified via nd=... as a -unixpw login option. + + setsid() or setpgrp() is called for the external command spawned + by the -gone option (since it may be long lived, e.g. a + screen locker). + + The script "onetimekey" utility is provided in the classes/ssl + subdirectory that allows a (very long) string representing + a Client SSL certificate to be provided by the authenticating + client, or via https cgi script (e.g. after a web login). + + Some bugs were fixed in the libvncserver implementation of + UltraVNC file transfer. + + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.9 2007-04-18 + + +New in the 0.9 x11vnc release: + + VNC Service advertising via mDNS / ZeroConf / BonJour with the + Avahi client library. Enable via "-avahi". + + Implementations of UltraVNC's TextChat, SingleWindow, and + ServerInput extensions (requires ultravnc viewer or ssvnc + Unix viewer). They toggle the selection of a single window + (-id), and disable (friendly) user input and viewing + (monitor blank) at the VNC server. + + Short aliases "-find", "-create", "-svc", and "-xdmsvc" for + commonly used FINDCREATEDISPLAY usage modes (to find + the user's display or create one, etc). + + Reverse VNC connections (viewer listening) now work in SSL + (-ssl) mode. + + miscellaneous new features and changes: + + New options to control the Monitor power state and keyboard/mouse + grabbing: -forcedpms, -clientdpms, -noserverdpms, + and -grabalways. + + A simple way to emulate inetd(8) to some degree via the "-loopbg" + option. + + Monitor the accuracy of XDAMAGE and apply "-noxdamage" if it is + not working well. OpenGL applications like like beryl and + MythTv have been shown to make XDAMAGE not work properly. + + For Java SSL connections involving a router/firewall port + redirection, an option -httpsredir to spare the user + from needing to include PORT=NNN in the browser URL. + + A -sleepin n option to delay startup by n seconds to let redirs + and listening clients to get started. + + TightVNC file transfer is now off by default; enable via + -tightfilexfer + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.8.4 2007-02-01 + + +New in the 0.8.4 x11vnc release: + + Native Mac OS X Aqua/Quartz support. It exports the full + display (no X11 server, etc). + + This provides an alternative to OSXvnc; some activities + are faster (and see the client-side caching feature + -ncache in the 0.8.5 development version for more + speedups). + + x11vnc can act as a VNC reflector/repeater using the + "-reflect host:N" option. This is useful for large + classroom broadcasting or demos. You set up a number + of reflectors to spread the network and CPU load around + for better response. + + A new login mode: "-display WAIT:cmd=FINDCREATEDISPLAY -unixpw ..." + that will Create a new X session (Xvfb, Xdummy, or + Xorg) for the user if it cannot find the user's X + session display via the FINDDISPLAY method. It will + be re-found upon reconnection. + + This enables a simple "terminal services" mode based on + Unix username and password and where the user does not + have to memorize their VNC display number, etc. + + + miscellaneous new features and changes: + + Option -nodpms to avoid problems with programs like KDE's + kdesktop_lock that keep restarting the screen saver + every few seconds even with active VNC clients connected. + + The "-N" option couples the VNC Display number to the X Display + number. E.g. if your X DISPLAY is :2 then the VNC display + will be :2 (i.e. using port 5902). If that port is taken + x11vnc will exit. + + Wireframe copyrect detection for local user activity (e.g. someone + sitting at the physical display moving windows). You + can disable this with the -nowireframelocal option. + + To automatically fix the common mouse motion problem on XINERAMA + (multi-headed) displays, the -xwarppointer option is + enabled by default when XINERAMA is active. You can + disable this with the -noxwarppointer option. + + By default in -reflect mode -shared is implied (it makes sense), + use -noshared after the -reflect option to disable this. + + The -prog option lets you specify the full path (argv[0]) to + the program, in case it is spawned by inetd/tcpd and + cannot determine its path. The path is needed for the + -http option to guess the http classes directory. + + Usually not needed, but there are many options for tuning the + native Mac OS X mode: -macnodim -macnosleep -macnosaver + -macnowait -macwheel -macnoswap -macnoresize -maciconanim + -macmenu. + + An option -debug_xdamage has been added for debugging and profiling. + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.8.3 2006-11-13 + + +New in the 0.8.3 x11vnc release: + + The -ssl option provides SSL encryption and authentication + natively via the www.openssl.org library. One can use + from a simple self-signed certificate server certificate + up to full CA and client certificate authentication schemes. + + The -sslverify option allows for authenticating VNC clients via + their certificates in either -ssl or -stunnel modes. + + Certificate creation and management tools are provide in the + -sslGenCert, -sslGenCA, and related options. + + An SSL enabled Java applet VNC Viewer applet is provided in + classes/ssl/VncViewer.jar. + + The applet may also be loaded into the web + browser via HTTPS, i.e one can use the VNC port, + e.g. https://host:5900/ + + See our "Enhanced TightVNC Viewer" project, for native + SSL enabled viewers. + + The -unixpw option supports Unix username and password + authentication. The -ssl or -localhost and -stunnel + options (or detection of an SSH tunnel) are enforced in + this mode to prevent password sniffing. + + Coupling -unixpw with -display WAIT:cmd=FINDDISPLAY provides a + way to allow a user to login with their UNIX password + and have their display connected to automatically. + + Hooks are provided in the -unixpw_cmd and "-passwdfile cmd:,custom:..." + options to allow you to supply your own authentication + and password lookup programs (e.g. LDAP). + + The "-ultrafilexfer" alias is provided and improved UltraVNC + filetransfer rates have been achieved. + + The -rotate option enables you to rotate or reflect the screen + before exporting via VNC. This is intended for use on + handhelds and other devices where the rotation orientation + is not "natural". + + miscellaneous new features and changes: + + Similar to -ssl, the -stunnel option starts up a SSL tunnel server + stunnel (that must be installed separately on the system) + to allow only encrypted SSL connections from the network. + + Option -sslnofail to exit immediately if there are any SSL + connection failures. + + A simpler variant of -unixpw is the -unixpw_nis option that + works in environments where the encrypted passwords are + readable, e.g. NIS. + + x11vnc can be configured and built to not depend on X11 libraries + "./configure --without-x" for -rawfb only operation + (e.g. embedded linux console devices). + + Add -cursor_drag to change the mouse cursor during Drag and Drop, etc. + + Under the "-connect_or_exit host" option x11vnc will exit + immediately unless the reverse connection to host + succeeds. The "-rfbport 0" option disables TCP listening + for connections (useful for this mode). + + The "-rawfb rand" and "-rawfb none" options are useful for + testing automation scripts, etc., without requiring a + full desktop. + + Reduced spewing of information at startup, use "-verbose" (also + "-v") to turn it back on for debugging. + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.8.2 2006-07-13 + + +New in the 0.8.2 x11vnc release: + + Support for full mouse and keyboard input into the Linux + console framebuffer /dev/fb0 in -rawfb mode + (i.e. non-X11) by using the Linux "uinput" driver. + + This enables, for example, viewing and interacting + with Qt-embedded/Qtopia-Core apps on Linux-based + handhelds, etc. + + Options: -rawfb cons, -pipeinput UINPUT More info: + http://www.karlrunge.com/x11vnc/#faq-qt-embedded + + Extension of the display option: -display WAIT: + to delay x11vnc's opening of the X display + until a VNC client connects (useful built-in: + -display WAIT:cmd=FINDDISPLAY, to find a user's + display and Xauthority data). + + Options -grabkbd and -grabptr have x11vnc try to grab + the X display when VNC clients are connected to + prevent a (non-malicious) user at the physical X + display from performing keyboard or mouse input. + E.g. remote help-desk support. + + + miscellaneous new features and changes: + + -allowedcmds option to fine-tune which external commands + may be run by x11vnc, rather than shutting + them all off with -nocmds. + + -env VAR=VALUE convenience option to avoid the need of + setting environment variables before starting + x11vnc. + + -allinput option to enable libvncserver handleEventsEagerly + parameter (not clear it yields an improvement). + + -rawfb rand fun/testing option using /dev/urandom as a fb. + + -license, -copying, -warranty option. + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.8.1 2006-06-03 + +New in the 0.8.1 x11vnc release: + + Improved support for webcams and tv tuners with video4linux + /dev/video: see the "-rawfb video" and "-pipeinput VID" + options. (the latter gives a simple keyboard control + of a tv tuner; see also the -freqtab option for stations). + + FBPM support for hardware that provides framebuffer power + management (it needs to be disabled when vnc clients + are connected). + + The -usepw option will require x11vnc to use a password of + some sort or otherwise exit immediately. Put it in + your ~/.x11vncrc so you don't forget. + + The command "x11vnc -storepasswd" will prompt for a password + without echoing and save it in ~/.vnc/passwd + + The X CLIPBOARD selection is managed in addition to the + X PRIMARY selection. + + + miscellaneous new features and changes: + + Convenience option for accessing the Linux console: -rawfb cons + etc. (requires /dev/fb0 to be working). + + clipboard/cut-text input can now be managed on a per-client + basis. + + -capslock and -skip_lockkeys options can help make CapsLock work + better. + + The Xdummy wrapper script is included in the source tree. + + A mode "-gone popup" as been added. + + -24to32 option to avoid 24bpp problems. + + -xinerama is on by default. + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.8 2006-02-13 + + +New in the 0.8 x11vnc release: + + TightVNC file transfer support is enabled via the extension to + LibVNCServer added by Rohit Kumar. + + The -passwdfile option has been enhanced to handle any number + of full-access and view only passwords in an easy to + maintain format, and additional features. + + The -8to24 option enables multi-depth viewing on systems that do + not support -overlay. The 8bpp regions are transformed + to depth 24 TrueColor before exporting via VNC. + + The x11vnc source code has gone through a major reorganization. + The build has been enhanced and many bugs fixed. + + + miscellaneous new features and changes: + + -afteraccept option is like -accept however it enables running + a user supplied command after client authentication + has taken place. The RFB_* environment variables have + been extended. + -loop option will run x11vnc in an outer loop restarting each time + (useful for situations where the X server restarts often). + -slow_fb allows for slow polling for special purpose applications + (e.g. video). -blackout noptr,WxH+X+Y,... will prevent + the pointer from going into a blacked out region. + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help | less + +----------------------------------------------------------------------------- + + +x11vnc 0.7.2 2005-07-11 + + +New in the 0.7.2 x11vnc release: + + The X DAMAGE extension is supported to dramatically reduce + resource consumption when idle: often 20 times less; + and to pick up small changed regions more quickly. + + DAMAGE sends events indicating damaged (modified) screen + rectangles to x11vnc. These are used as hints to focus + the polling and also if the rectangle is below a size + threshold it is accepted unconditionally (i.e. dragged in + from the framebuffer). Tuning is possible with -xd_area. + + DAMAGE is available on recent Xorg servers and Solaris 10. + + -wireframe: Heuristics are used to guess when a window is being + moved or resized and during this period show only a + moving wireframe outline. Just like on video cards in + the 90's, remember? This is to avoid window "lurching" + when you move or resize one opaquely. + + Also, -wirecopyrect applies the VNC CopyRect encoding + for the moved window. Both are on by default, use + -nowireframe or -nowirecopyrect to disable (aka -nowf + and -nowcr). + + -scrollcopyrect: Sniff the X11 protocol via the RECORD extension + and to try to detect window scrolls (e.g. via scrollbar, + Up/Down arrow, etc). When detected, the VNC CopyRect + encoding is applied to the scrolled regions for a speedup. + + The contents of the scrolling window may only be + approximate while it is being scrolled: e.g. tearing, + bunching-up, etc. The heuristics will also miss scrolls + by certain toolkits or applications, so those will still + happen the slow way. To disable use -noscrollcopyrect + (aka -noscr). Tuning is also available, see the -help + entry. + + -listen: Makes x11vnc listen only on a single network interface. + -localhost now implies '-listen localhost'. + + -rawfb: Instead of polling an X server framebuffer, poll a raw + one (i.e. a mapped file or a shm segment). E.g. for + the linux framebuffer device: + + -rawfb map:/dev/fb0@1024x768x32 + + This is a bit out of x11vnc's scope but may have some + interesting applications. Perhaps /dev/video? + + -pipeinput: Pipe the VNC user's pointer and keyboard input events + to a helper program you provide. Two examples are in + misc/vcinject.pl and misc/slide.pl. Primarily intended + for use with -rawfb to somehow kludge-up user input, + but it can also be used by itself. + + Improvements for the magnification scaling case (e.g. -scale 2) + for use in low vision applications. It is faster and + no-blending :nb now works correctly. + + More safety measures are taken WRT remote-control in the + default mode. See the -unsafe, -safer, -privremote, + and -nocmds options. + + The GUI has been improved, and running with the options "-gui icon" + presents a small, simple gui instead of the full blown one, + and "-gui tray" attempts to embed the small icon in the + system tray. Use "-gui tray=setpass" to prompt for + session password creation at startup. + + + miscellaneous new features and changes: + + -xkb: a simple test is performed at startup to see if it is a + good idea to apply -xkb mode for the current keyboard + keymapping (i.e. if keysyms like !, @, [ are otherwise + unavailable). To disable use -noxkb. + ISO_Level3_Shift vs. Mode_switch: Set things up in -xkb mode to + prefer ISO_Level3_Shift over Mode_switch for modtweaking. + No override; let me know if this causes problems. + -add_keysyms is now the default, use -noadd_keysyms to disable. + the added keysyms are periodically deleted. + -remap DEAD: shorthand for mapping many "dead" keysyms to their + "un-dead" counterparts, e.g. grave -> dead_grave. For + some VNC viewers that are unable to send the dead keysym. + -skip_dups: skip impossible duplicate key events sent by some VNC + viewers. -noskip_dups to disable (currently off by default). + -sloppy_keys: try to handle sloppy keyboarding (esp. between + different language keyboards) where, say, Shift is released + before the key. + -norepeat N: ping-pong N times if something else on the desktop + restores key autorepeating (e.g. session startup). Default + 2. Also, If the VNC client is idle for 5 min. autorepeat + is restored. + -wait_ui: If there is very recent user input, cut the -wait sleep + time by the specified factor (default 2.0). + -nowait_bog: Detection is now in place to watch for polling "bogging + down" (e.g. lots of scrolling text from a long build in a + terminal) and to sleep more. Use -nowait_bog to disable. + -flag: write PORT=5900 to a flag file to aid wrapper scripts. + -http: try to guess what the -httpdir should be and if found + enable http listening. + -clip WxH+X+Y: only show the specified rectangle not the + entire screen. + cursors are now scaled by default under -scale, use -scale_cursor + to modify this behavior. + -arrow n: select from some different arrow cursors (ignored under + XFIXES cursor grabbing mode). + -nolookup: disable DNS lookups for broken environments. + -seldir: fine tune and debug selection transfer. + build-time customization macros: SHARED, FOREVER, NOREPEAT, + REMOTE_CONTROL, SMALL_FOOTPRINT, default passwd, etc. + see the top of the x11vnc.c for more info. + -xtrap: DEC-XTRAP extension is supported for legacy systems + with insufficient XTEST extension (X11R5). + -shiftcmap: for legacy systems with non-standard colormap values. + -noxrecord: do not use the RECORD extension for anything (currently + only -scrollcopyrect and grabserver watching use it). + -grab_buster: fork a helper thread to watch for XGrabServer deadlock + in x11vnc and break the grab. Under -scrollcopyrect there + is a small window where x11vnc is vulnerable to this deadlock. + -dbg: A "crash shell" with tips on debugging will be presented + instead of exiting when a fatal error occurs. + -fixscreen: periodically refresh the screen to get rid of painting + errors, etc. induced by new features, jpeg compression, etc. + -speeds: Tell x11vnc what the network and fb speeds are instead of + having it try to measure them. (these speeds are used by + various features, such as -wireframe, -scrollcopyrect, etc.). + -wmdt: set the window manager or desktop to spare x11vnc from guessing. + -readtimeout: set libvncserver's read timeout parameter, useful on + very slow links that take more than 20secs to paint + the whole screen. + -nopw: If you use x11vnc without a password it now prints out a + scary warning message. Use -nopw to disable the warning. + plugged X event leaks; periodically purge any remaining buildup. + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help + +----------------------------------------------------------------------------- + + +x11vnc 0.7.1 2005-02-24 + + +New in the 0.7.1 x11vnc release: + + Improved algorithm for approximating XFIXES cursors with + transparency (alpha channel). No more ugly black fuzz + around translucent cursors. Tuning parameters -alpha* + if it is still not right. + + Added mechanisms to handle XFIXES cursors with transparency + exactly (i.e. blend in the background). Works by default + under -nocursorshape updates, and also works under limited + circumstances for cursorshape updates if the VNC viewer + is patched (TightVNC viewer patch provided). + + -solid: to improve performance switch the background to a solid + color when clients are connected. Works on GNOME, KDE, + CDE, and classic X. + + -input: allows fine-tuning the type of allowed user input + (Keystroke, Mouse-motion, Button-click). Useful for + certain applications of x11vnc, e.g. demos. Also + per-client settings via -R input:xyz.. + + -users: enables switching to different users if started as root. + Please read the description for details. + + -gui ez: less daunting GUI with fewer options via '-gui ez' or + "Misc -> simple-gui" once started. + + miscellaneous new features and changes: + + -nap is now the default, use -nonap to disable. + -snapfb: snapshot h/w fb to RAM periodically, not clear how useful... + -timeout n: for use in certain applications, exit if no client + connects after n seconds. + -oa and -logappend for appending to logfiles. + -opts will just show the options w/o the long -help descriptions. + if you forget to set -display, it will beep and try :0 after a bit. + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help + +----------------------------------------------------------------------------- + + +x11vnc 0.7 2004-12-23 + + +New in the 0.7 x11vnc release: + + Support for the XFIXES X extension to show the exact mouse cursor + shape. Requires libXfixes. For approximate cursor + shapes also see: -cursor (none|arrow|X|some|most) + + -remote/-R: remote-control support: nearly every setting can be + changed dynamically without restarting x11vnc. For + example, "x11vnc -R shared", and "x11vnc -R scale:3/4" + will connect to a running x11vnc server to make it shared + and re-scaled, respectively. + + -gui: launches a simple tcl/tk GUI based on the remote control + function. Requires the tcl/tk "wish" program. + + -overlay: support for overlay/multi-depth (e.g. 24+8) visuals + on Solaris (SUN_OVL extension) and IRIX. + + -xrandr: support for the XRANDR (X Resize, Rotate and Reflection) + extension: if the screen changes size or rotates x11vnc + creates a new framebuffer to match it. Useful to have a VNC + Viewer that supports NewFBSize extension. (also -padgeom) + + -pointer_mode: Experimental pointer input handling schemes, + e.g.: "-pointer_mode 3" (similar to -nodragging) + + man page x11vnc.1 and README files created. + + miscellaneous new features and changes: + + -sb: set screen blank idle timeout + -nocursorshape: disable cursor shape VNC extension. + RFB_MODE = "accept" or "gone" passed to -accept/-gone commands. + -vncconnect is now the default. + -norepeat is now the default. + "-id pick" to pick a window via xwininfo for the -id option. + -sid option: like -id but crops root window instead. + Related to remote-control: -query, -noremote, -sync, + -deny_all, -safer, -unsafe. + + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help + +----------------------------------------------------------------------------- + + +x11vnc 0.6.2 2004-08-02 + +New in the 0.6.2 x11vnc release: + + -scale option for server side scaling (e.g. -scale 2/3). + + -storepasswd option to create VNC password files. + + ~/.x11vncrc simple config file support. + + -cursorpos now the default (send cursor position updates to clients + that understand them, disable with -nocursorpos) + + more connection info sent to the -accept and -gone commands. + + new keyboard related features: + + -modtweak is now the default (it automatically adjusts the modifier + keys state to send a Keysym properly, disable -nomodtweak) + this works around "ghost" keys like "< >" in XFree86. + + -xkb option to use XKEYBOARD extension for modtweak-ing to further + improve the accuracy of sending Keysyms between different + language keyboards. + + -skip_keycodes and -add_keysyms options to fine tune stubborn + keyboard differences. + + -norepeat option to turn off X server key autorepeat when clients + are connected (works around the repeated characters problem) + + -clear_mods and -clear_keys to send key release events at + startup and exit. + + removed options: + + -hints/-nohints: we now always use hints. + +For more information: + + http://www.karlrunge.com/x11vnc/ + http://www.karlrunge.com/x11vnc/x11vnc_opts.html + x11vnc -help + +----------------------------------------------------------------------------- + diff --git a/x11vnc/appshare.c b/x11vnc/appshare.c index fc3c29e..71cdf17 100644 --- a/x11vnc/appshare.c +++ b/x11vnc/appshare.c @@ -1358,7 +1358,7 @@ static void list_apps(void) { static int process_control(char *file, int check_clients) { int i, nnew = 0, seen[CMAX]; - char line[1024], *new[CMAX]; + char line[1024], *newctl[CMAX]; FILE *f; f = fopen(file, "r"); @@ -1481,7 +1481,7 @@ static int process_control(char *file, int check_clients) { if (idx >= 0) { seen[idx] = 1; } else { - new[nnew++] = strdup(q); + newctl[nnew++] = strdup(q); } } } @@ -1509,8 +1509,8 @@ static int process_control(char *file, int check_clients) { } continue; } - clients[free] = new[i]; - client(new[i], 1); + clients[free] = newctl[i]; + client(newctl[i], 1); } } return 1; diff --git a/x11vnc/cleanup.c b/x11vnc/cleanup.c index 4ecef42..232311c 100644 --- a/x11vnc/cleanup.c +++ b/x11vnc/cleanup.c @@ -50,6 +50,7 @@ so, delete this exception statement from your version. #include "screen.h" #include "xrecord.h" #include "xevents.h" +#include "uinput.h" /* * Exiting and error handling routines @@ -187,6 +188,8 @@ void clean_up_exit(int ret) { pipeinput_fh = NULL; } + shutdown_uinput(); + if (! dpy) { /* raw_rb hack */ if (rm_flagfile) { unlink(rm_flagfile); diff --git a/x11vnc/gui.c b/x11vnc/gui.c index e264385..6101adb 100644 --- a/x11vnc/gui.c +++ b/x11vnc/gui.c @@ -81,26 +81,26 @@ static Window tweak_tk_window_id(Window win) { return None; #else char *name = NULL; - Window parent, new; + Window parent, new_win; if (getenv("NO_TWEAK_TK_WINDOW_ID")) { return win; } /* hack for tk, does not report outermost window */ - new = win; + new_win = win; parent = parent_window(win, &name); if (parent && name != NULL) { lowercase(name); if (strstr(name, "wish") || strstr(name, "x11vnc")) { - new = parent; + new_win = parent; rfbLog("tray_embed: using parent: %s\n", name); } } if (name != NULL) { XFree_wr(name); } - return new; + return new_win; #endif /* NO_X11 */ } diff --git a/x11vnc/help.c b/x11vnc/help.c index 5eb80cc..c268b3f 100644 --- a/x11vnc/help.c +++ b/x11vnc/help.c @@ -848,6 +848,12 @@ void print_help(int mode) { " Some degree of cooperation from the person at the\n" " display is assumed. This is intended for remote\n" " help-desk or educational usage modes.\n" +"\n" +" Note: on some recent (12/2010) X servers and/or\n" +" desktops, -grabkbd no longer works: it prevents the\n" +" window manager from resizing windows and similar things.\n" +" Try -ungrabboth below (might not work.)\n" +"\n" "-grabptr As -grabkbd, but for the mouse pointer using\n" " XGrabPointer(3X11). Unfortunately due to the way the X\n" " server works, the mouse can still be moved around by the\n" @@ -857,6 +863,11 @@ void print_help(int mode) { " act on the local user's input. Again, some degree of\n" " cooperation from the person at the display is assumed.\n" "\n" +"-ungrabboth Whenever there is any input (either keyboard or\n" +" pointer), ungrab *both* the keyboard and the pointer\n" +" while injecting the synthetic input. This is to allow\n" +" window managers, etc. a chance to grab.\n" +"\n" "-grabalways Apply both -grabkbd and -grabptr even when no VNC\n" " viewers are connected. If you only want one of them,\n" " use the -R remote control to turn the other back on,\n" @@ -1412,6 +1423,15 @@ void print_help(int mode) { "\n" " xauth extract - $DISPLAY\"\n" "\n" +" NOTE: As specified in the previous paragraph, you can\n" +" supply your own WAIT:cmd=... program or script, BUT\n" +" there are two very useful *BUILT-IN* ones: FINDDISPLAY\n" +" (alias -find above) and FINDCREATEDISPLAY (alias -create\n" +" above.) Most people use these instead of creating\n" +" their own script. Read the following (especially the\n" +" BUILT-IN modes sections) to see how to configure these\n" +" two useful builtin -display WAIT: modes.\n" +"\n" " In the case of -unixpw (and -unixpw_nis only if x11vnc\n" " is running as root), then the cmd= command is run\n" " as the user who just authenticated via the login and\n" @@ -1443,6 +1463,11 @@ void print_help(int mode) { " your long \"login:\" line press the Up arrow once\n" " (before typing anything else).\n" "\n" +" Most of these colon options only apply to the builtin\n" +" FINDDISPLAY and FINDCREATEDISPLAY modes, but note\n" +" that they are passed to the extrenal command in the\n" +" environment as well and so could be used.\n" +"\n" " In the login panel, press F1 to get a list of the\n" " available options that you can add after the username.\n" "\n" @@ -1476,23 +1501,19 @@ void print_help(int mode) { " and the user put \"geom=1600x1200\" in his\n" " ~/.x11vnc_create file.\n" "\n" -" To troubleshoot the FINDCREATEDISPLAY mechanism,\n" -" set the following env. var. to an output log file,\n" -" e.g -env CREATE_DISPLAY_OUTPUT=/tmp/mydebug.txt\n" -"\n" " To disable the option setting set the environment\n" " variable X11VNC_NO_UNIXPW_OPTS=1 before starting x11vnc.\n" " To set any other options, the user can use the gui\n" " (x11vnc -gui connect) or the remote control method\n" " (x11vnc -R opt:val) during his VNC session.\n" "\n" -" The combination of -display WAIT:cmd=... and -unixpw\n" -" allows automatic pairing of an unix authenticated VNC\n" -" user with his desktop. This could be very useful on\n" -" SunRays and also any system where multiple users share\n" -" a given machine. The user does not need to remember\n" -" special ports or passwords set up for his desktop\n" -" and VNC.\n" +" So we see the combination of -display WAIT:cmd=... and\n" +" -unixpw allows automatic pairing of an unix\n" +" authenticated VNC user with his desktop. This could\n" +" be very useful on SunRays and also any system where\n" +" multiple users share a given machine. The user does\n" +" not need to remember special ports or passwords set up\n" +" for his desktop and VNC.\n" "\n" " A nice way to use WAIT:cmd=... is out of inetd(8)\n" " (it automatically forks a new x11vnc for each user).\n" @@ -1504,13 +1525,15 @@ void print_help(int mode) { " process that will not switch, but it is only encoding\n" " and decoding the encrypted stream at that point.\n" "\n" -" Automatic Finding of User X Sessions:\n" +" BUILT-IN modes:\n" +"\n" +" -- Automatic Finding of User X Sessions --\n" "\n" " As a special case, WAIT:cmd=FINDDISPLAY will run a\n" " script that works on most Unixes to determine a user's\n" " DISPLAY variable and xauthority data (see who(1)).\n" "\n" -" The option \"-find\" is an alias for this mode.\n" +" NOTE: The option \"-find\" is an alias for this mode.\n" "\n" " To have this default script printed to stdout (e.g. for\n" " customization) run with WAIT:cmd=FINDDISPLAY-print To\n" @@ -1553,7 +1576,12 @@ void print_help(int mode) { " X11VNC_SKIP_DISPLAY=all then all display finding fails\n" " as if you set X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 (below.)\n" "\n" -" Automatic Creation of User X Sessions:\n" +" On some systems lsof(1) can be very slow. Set the\n" +" env. var. FIND_DISPLAY_NO_LSOF=1 to skip using lsof to\n" +" try to find the Linux VT the X server is running on.\n" +" set FIND_DISPLAY_NO_VT_FIND=1 to avoid looking at all.\n" +"\n" +" -- Automatic Creation of User X Sessions --\n" "\n" " An interesting option is WAIT:cmd=FINDCREATEDISPLAY\n" " that is like FINDDISPLAY in that is uses the same method\n" @@ -1562,13 +1590,19 @@ void print_help(int mode) { " for the user. This is the only time x11vnc tries to\n" " actually start up an X server.\n" "\n" -" The option \"-create\" is an alias for this mode.\n" +" NOTE: The option \"-create\" is an alias for this mode.\n" "\n" " It will start looking for an open display number at :20\n" " Override via X11VNC_CREATE_STARTING_DISPLAY_NUMBER=n\n" " By default 80 X displays are allowed (i.e. going to :99)\n" " Override via X11VNC_CREATE_MAX_DISPLAYS=n\n" "\n" +" For its heuristics, the create display script sets\n" +" LC_ALL=C so that command output is uniform. By default\n" +" it will try to restore LC_ALL right before starting the\n" +" user session. However, if you don't mind it keeping\n" +" LC_ALL=C set the env. var.: X11VNC_CREATE_LC_ALL_C_OK=1\n" +"\n" " By default FINDCREATEDISPLAY will try Xvfb and then\n" " Xdummy:\n" "\n" @@ -1595,6 +1629,10 @@ void print_help(int mode) { " it to terminate (or kill the X server process if all\n" " else fails).\n" "\n" +" To troubleshoot the FINDCREATEDISPLAY mechanism,\n" +" set the following env. var. to an output log file,\n" +" e.g -env CREATE_DISPLAY_OUTPUT=/tmp/mydebug.txt\n" +"\n" " So this is a somewhat odd mode for x11vnc in that it\n" " will start up and poll virtual X servers! This can\n" " be used from, say, inetd(8) to provide a means of\n" @@ -4075,6 +4113,7 @@ void print_help(int mode) { "-sb time Time in seconds after NO activity (e.g. screen blank)\n" " to really throttle down the screen polls (i.e. sleep\n" " for about 1.5 secs). Use 0 to disable. Default: %d\n" +" Set the env. var. X11VNC_SB_FACTOR to scale it.\n" "\n" "-readtimeout n Set LibVNCServer rfbMaxClientWait to n seconds. On\n" " slow links that take a long time to paint the first\n" @@ -4520,18 +4559,19 @@ void print_help(int mode) { " using the 'console_guess' string printed at startup,\n" " be sure to indicate the snap: method.\n" "\n" -" uinput: If the Linux version appears to be 2.6 or\n" -" later and the \"uinput\" module appears to be present\n" -" (modprobe uinput), then the uinput method will be used\n" -" instead of /dev/ttyN. uinput allows insertion of BOTH\n" -" keystrokes and mouse input and so it preferred when\n" -" accessing graphical (e.g. QT-embedded) linux console\n" -" apps. See -pipeinput UINPUT below for more information\n" -" on this mode; you will have to use -pipeinput if you\n" -" want to tweak any UINPUT parameters. You may also want\n" -" to also use the -nodragging and -cursor none options.\n" -" Use \"console0\", etc or -pipeinput CONSOLE to force\n" -" the /dev/ttyN method.\n" +" uinput: If the Linux version appears to be 2.6\n" +" or later and the \"uinput\" module appears to be\n" +" present (modprobe uinput), then the uinput method\n" +" 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. It also provides more accurate\n" +" keystroke insertion. See -pipeinput UINPUT below for\n" +" more information on this mode; you will have to use\n" +" -pipeinput if you want to tweak any UINPUT parameters.\n" +" You may also want to also use the -nodragging and\n" +" -cursor none options. Use \"console0\", etc or\n" +" -pipeinput CONSOLE to force the /dev/ttyN method.\n" "\n" " Note you can change the Linux VT remotely using the\n" " chvt(1) command to make the one you want be the active\n" @@ -4571,7 +4611,11 @@ void print_help(int mode) { " to improve performance in the case of many (e.g. >\n" " 10) simultaneous VNC viewers, and you try a divide\n" " and conquer scheme to reduce bandwidth and improve\n" -" responsiveness.\n" +" responsiveness. (However, another user found this mode\n" +" useful to export a demo display through a slow link:\n" +" then multiple demo viewers connected to the reflecting\n" +" x11vnc on the fast side of the link, and so avoided\n" +" all of the demo viewers going through the slow link.)\n" "\n" " For example, if there will be 64 simultaneous VNC\n" " viewers this can lead to a lot of redundant VNC traffic\n" @@ -4602,6 +4646,13 @@ void print_help(int mode) { " to \"file:path_to_file\" to indicate a file containing\n" " the password as its first line.\n" "\n" +" To set the pixel format that x11vnc requests as a VNC\n" +" CLIENT set the env. vars: X11VNC_REFLECT_bitsPerSample\n" +" X11VNC_REFLECT_samplesPerPixel, and\n" +" X11VNC_REFLECT_bytesPerPixel; the defaults are 8, 3, 4.\n" +" 2, 3, 1 would give a low color mode. See the function\n" +" rfbGetClient() in libvncclient for more info.\n" +"\n" " The VNC HOST mode implies -shared. Use -noshared as\n" " a subsequent cmdline option to disable sharing.\n" "\n" @@ -4664,7 +4715,8 @@ void print_help(int mode) { "\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" +" are supported. But it is probably more accurate than\n" +" the \"CONSOLE\" method.\n" "\n" " You may want to use the options -cursor none and\n" " -nodragging in this mode.\n" @@ -4704,16 +4756,6 @@ void print_help(int mode) { " cause jerkiness or unexpected behavior with menus, etc.\n" " Use reset=0 to disable.\n" "\n" -" If the uinput device has an absolute pointer (as opposed\n" -" to a normal mouse that is a relative pointer) you can\n" -" specify the option \"abs\". Note that a touchpad\n" -" on a laptop is an absolute device to some degree.\n" -" This (usually) avoids all the problems with mouse\n" -" acceleration. If x11vnc has trouble deducing the size\n" -" of the device, use \"abs=WxH\". Furthermore, if the\n" -" device is a touchscreen (assumed to have an absolute\n" -" pointer) use \"touch\" or \"touch=WxH\".\n" -"\n" " If you set the env. var X11VNC_UINPUT_THRESHOLDS then\n" " the thresh=n mode will be enabled. It is currently\n" " not working well. If |dx| <= thresh and |dy| < thresh\n" @@ -4723,8 +4765,70 @@ void print_help(int mode) { " Example:\n" " -pipeinput UINPUT:accel=4.0 -cursor none\n" "\n" -" You can also set the env. var X11VNC_UINPUT_DEBUG=1 or\n" -" higher to get debugging output for UINPUT mode.\n" +" If the uinput device has an absolute pointer (as opposed\n" +" to a normal mouse that is a relative pointer) you can\n" +" specify the option \"abs\". Note that a touchpad\n" +" on a laptop is an absolute device to some degree.\n" +" This (usually) avoids all the problems with mouse\n" +" acceleration. If x11vnc has trouble deducing the\n" +" size of the device, use \"abs=WxH\". Furthermore,\n" +" if the device is a touchscreen (assumed to have an\n" +" absolute pointer) use \"touch\" or \"touch=WxH\".\n" +" For touchscreens, when a mouse button is pressed,\n" +" a pressure increase is injected, and when the button\n" +" is released a pressure of zero is injected.\n" +"\n" +" If touch has been set, use \"touch_always=1\" to\n" +" indicate whenever the mouse moves with no button\n" +" pressed, a touch event of zero pressure should be\n" +" sent anyway. Also use \"btn_touch=1\" to indicate a\n" +" BTN_TOUCH keystroke press or release should be sent\n" +" instead of a pressure change. Set \"dragskip=n\" to\n" +" skip n dragged mouse touches (with pressure applied)\n" +" before injecting one. To indicate the pressure that\n" +" should be sent when there is a button click for a\n" +" touchscreen device, specify pressure=n, e.g. n=5. The\n" +" default is n=1.\n" +"\n" +" If a touch screen is being used (\"touch\" above)\n" +" and it is having its input processed by tslib, you can\n" +" specify the tslib calibration file via tslib_cal=.\n" +" For example, tslib_cal=/etc/pointercal. To get accurate\n" +" or even usable positioning this is required when tslib\n" +" is in use.\n" +"\n" +" The Linux uinput mechanism can be bypassed and one can\n" +" write input events DIRECTLY to the devices instead.\n" +" To do this, specify one or more of the following\n" +" for the input classes: direct_rel=\n" +" direct_abs= direct_btn= or\n" +" direct_key=. The file is usually\n" +" something like /dev/input/event1 but you can specify\n" +" any device file or pipe. You must specify each one\n" +" of the above classes even if they correspond to the\n" +" same device file (rel/abs and btn are often the same.)\n" +" Look at the file /proc/bus/input/devices to get an idea\n" +" what is available and the device filenames. Note:\n" +" The /dev/input/mouse* devices do not seem to work,\n" +" use the corresponding /dev/input/event* file instead.\n" +" Any input class not directly specified as above will be\n" +" handled via the uinput mechanism. To disable creating a\n" +" uinput device (and thereby discarding unhandled input),\n" +" specify \"nouinput\".\n" +"\n" +" Examples:\n" +"\n" +" -pipeinput UINPUT:direct_abs=/dev/input/event1\n" +"\n" +" this was used on a qtmoko Neo freerunner (armel):\n" +"\n" +" -pipeinput UINPUT:touch,tslib_cal=/etc/pointercal,\n" +" direct_abs=/dev/input/event1,nouinput,dragskip=4\n" +"\n" +" (where the long line has been split into two.)\n" +"\n" +" You can set the env. var X11VNC_UINPUT_DEBUG=1 or higher\n" +" to get debugging output for UINPUT mode.\n" "\n" "-macnodim For the native MacOSX server, disable dimming. \n" "-macnosleep For the native MacOSX server, disable display sleep.\n" diff --git a/x11vnc/keyboard.c b/x11vnc/keyboard.c index 9e9e044..54ff70e 100644 --- a/x11vnc/keyboard.c +++ b/x11vnc/keyboard.c @@ -61,7 +61,7 @@ void check_add_keysyms(void); int add_keysym(KeySym keysym); void delete_added_keycodes(int bequiet); void initialize_remap(char *infile); -int sloppy_key_check(int key, rfbBool down, rfbKeySym keysym, int *new); +int sloppy_key_check(int key, rfbBool down, rfbKeySym keysym, int *new_kc); void switch_to_xkb_if_better(void); char *short_kmbcf(char *str); void initialize_allowed_input(void); @@ -518,7 +518,7 @@ int add_keysym(KeySym keysym) { for (kc = minkey+1; kc <= maxkey; kc++) { int i, j, didmsg = 0, is_empty = 1; char *str; - KeySym new[8]; + KeySym newks[8]; for (n=0; n < syms_per_keycode; n++) { if (keymap[ (kc-minkey) * syms_per_keycode + n] @@ -532,19 +532,19 @@ int add_keysym(KeySym keysym) { } for (i=0; i<8; i++) { - new[i] = NoSymbol; + newks[i] = NoSymbol; } if (add_keysyms == 2) { - new[0] = keysym; /* XXX remove me */ + newks[0] = keysym; /* XXX remove me */ } else { for(i=0; i < syms_per_keycode; i++) { - new[i] = keysym; + newks[i] = keysym; if (i >= 7) break; } } XChangeKeyboardMapping(dpy, kc, syms_per_keycode, - new, 1); + newks, 1); if (alltime_num >= alltime_len) { didmsg = 1; /* something weird */ @@ -584,7 +584,7 @@ static void delete_keycode(KeyCode kc, int bequiet) { #else int minkey, maxkey, syms_per_keycode, i; KeySym *keymap; - KeySym ksym, new[8]; + KeySym ksym, newks[8]; char *str; RAWFB_RET_VOID @@ -594,10 +594,10 @@ static void delete_keycode(KeyCode kc, int bequiet) { &syms_per_keycode); for (i=0; i<8; i++) { - new[i] = NoSymbol; + newks[i] = NoSymbol; } - XChangeKeyboardMapping(dpy, kc, syms_per_keycode, new, 1); + XChangeKeyboardMapping(dpy, kc, syms_per_keycode, newks, 1); if (! bequiet && ! quiet) { ksym = XKeycodeToKeysym(dpy, kc, 0); @@ -907,14 +907,14 @@ static int kc1_shift, kc1_control, kc1_caplock, kc1_alt; static int kc1_meta, kc1_numlock, kc1_super, kc1_hyper; static int kc1_mode_switch, kc1_iso_level3_shift, kc1_multi_key; -int sloppy_key_check(int key, rfbBool down, rfbKeySym keysym, int *new) { +int sloppy_key_check(int key, rfbBool down, rfbKeySym keysym, int *new_kc) { if (!sloppy_keys) { return 0; } RAWFB_RET(0) #if NO_X11 - if (!key || !down || !keysym || !new) {} + if (!key || !down || !keysym || !new_kc) {} return 0; #else @@ -958,7 +958,7 @@ int sloppy_key_check(int key, rfbBool down, rfbKeySym keysym, int *new) { "-> %d/0x%x (nmods: %d)\n", (int) key, (int) key, downkey, downkey, nmods_down); } - *new = downkey; + *new_kc = downkey; return 1; } } diff --git a/x11vnc/keyboard.h b/x11vnc/keyboard.h index e72cb86..39a1a89 100644 --- a/x11vnc/keyboard.h +++ b/x11vnc/keyboard.h @@ -48,7 +48,7 @@ extern void check_add_keysyms(void); extern int add_keysym(KeySym keysym); extern void delete_added_keycodes(int bequiet); extern void initialize_remap(char *infile); -extern int sloppy_key_check(int key, rfbBool down, rfbKeySym keysym, int *new); +extern int sloppy_key_check(int key, rfbBool down, rfbKeySym keysym, int *new_kc); extern void switch_to_xkb_if_better(void); extern char *short_kmbcf(char *str); extern void initialize_allowed_input(void); diff --git a/x11vnc/linuxfb.c b/x11vnc/linuxfb.c index f65a67d..1831c5f 100644 --- a/x11vnc/linuxfb.c +++ b/x11vnc/linuxfb.c @@ -265,6 +265,7 @@ char *console_guess(char *str, int *fd) { } else { sprintf(q, "map:%s@%s", file, atparms); } + free(atparms); return q; } diff --git a/x11vnc/macosx.c b/x11vnc/macosx.c index b3cff79..4b13528 100644 --- a/x11vnc/macosx.c +++ b/x11vnc/macosx.c @@ -241,6 +241,7 @@ char *macosx_console_guess(char *str, int *fd) { q = (char *) malloc(strlen("map:macosx:") + strlen(file) + 1 + strlen(atparms) + 1); sprintf(q, "map:macosx:%s@%s", file, atparms); + free(atparms); return q; } diff --git a/x11vnc/macosxCG.c b/x11vnc/macosxCG.c index 4f1fd0a..a465493 100644 --- a/x11vnc/macosxCG.c +++ b/x11vnc/macosxCG.c @@ -87,7 +87,9 @@ int dragum(void) { CGPoint loc; CGDirectDisplayID displayID2 = kCGDirectMainDisplay; +#ifdef X11VNC_MACOSX_USE_GETMAINDEVICE (void) GetMainDevice(); +#endif for (i=0; i< 50; i++) { usleep(1000*100); @@ -140,7 +142,9 @@ void macosxCG_init(void) { #endif displayID = kCGDirectMainDisplay; +#ifdef X11VNC_MACOSX_USE_GETMAINDEVICE (void) GetMainDevice(); +#endif CGSetLocalEventsSuppressionInterval(0.0); CGSetLocalEventsFilterDuringSupressionState( diff --git a/x11vnc/misc/Makefile.am b/x11vnc/misc/Makefile.am index 98a7511..e6a50aa 100644 --- a/x11vnc/misc/Makefile.am +++ b/x11vnc/misc/Makefile.am @@ -1,3 +1,3 @@ SUBDIRS = turbovnc DIST_SUBDIRS = turbovnc -EXTRA_DIST=README blockdpy.c dtVncPopup rx11vnc rx11vnc.pl shm_clear ranfb.pl slide.pl vcinject.pl x11vnc_loop Xdummy ultravnc_repeater.pl connect_switch panner.pl desktop.cgi inet6to4 +EXTRA_DIST=README blockdpy.c dtVncPopup rx11vnc rx11vnc.pl shm_clear ranfb.pl slide.pl vcinject.pl x11vnc_loop Xdummy ultravnc_repeater.pl connect_switch panner.pl desktop.cgi inet6to4 uinput.pl qt_tslib_inject.pl diff --git a/x11vnc/misc/README b/x11vnc/misc/README index f38616e..2ed1dff 100644 --- a/x11vnc/misc/README +++ b/x11vnc/misc/README @@ -26,6 +26,10 @@ x11vnc -pipeinput/-rawfb utilities: slide.pl amusing example using x11vnc -rawfb for jpeg slideshow. ranfb.pl example -rawfb setup:./ranfb.pl to set up a framebuffer. + uinput.pl test perl script for Linux uinput injection. + + qt_tslib_inject.pl touchscreen -pipeinput helper for tslib on qtmoko. + Misc. scripts: shm_clear list or remove orphaned shm slots from hard x11vnc crashes. diff --git a/x11vnc/misc/qt_tslib_inject.pl b/x11vnc/misc/qt_tslib_inject.pl new file mode 100755 index 0000000..d69d174 --- /dev/null +++ b/x11vnc/misc/qt_tslib_inject.pl @@ -0,0 +1,1064 @@ +#!/usr/bin/perl +# +# qt_tslib_inject.pl: +# +# touch screen input injection tool for use with x11vnc. +# +# example usage: +# +# x11vnc ... -rawfb console -pipeinput ./qt_tslib_inject_input.pl -env INJECT_OPTIONS=cal=/etc/pointercal +# +# See options below. +# +# tested on qtmoko (neo freerunner) with tslib. + +# +# Copyright (c) 2010 by Karl J. Runge +# +# qt_tslib_inject.pl is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# qt_tslib_inject.pl is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qt_tslib_inject.pl; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA +# or see . +# + +set_constants(); + +# one can set these env. vars. before running: + +# the device file to inject the events into: +# +$dev = $ENV{INJECT_DEV}; +$dev = "/dev/input/event1" unless $dev; + +# options, see below. useful: cal=/etc/pointercal +# +$options = $ENV{INJECT_OPTIONS}; +$options = '' unless $options ne ''; + +$debug = 0; # enable debugging output: +$pressure = 1; # level of touch pad pressure for click. +$btn_touch = 0; # send BTN_TOUCH on clicks instead of pressure changes. +$absalways = 0; # send a zero pressure absolute position event whenever mouse moves. +$dragskip = 0; # how often to skip injecting motion event while dragging. + +$a_xform = ''; # tslib's calibration coefficients. +@a = (); + +%keycmds = (); # user defined hotkeys to run external commands. + +# separate the options by comma, e.g. pressure=5,cal=/etc/pointercal + +if ($options =~ /absalways/i) { + # set to always send a zero pressure ABS event when mouse moves + $absalways = 1; +} +if ($options =~ /btn_touch/i) { + # send BTN_TOUCH on clicks. + $btn_touch = 1; +} +if ($options =~ /pressure=(\d+)/i) { + # level of touchpad pressure to use on a touch. + $pressure = $1; +} +if ($options =~ /dragskip=(\d+)/i) { + # when dragging with pressure, skip this many events. + $dragskip = $1; +} +if ($options =~ /cal=([^,]+)/i) { + # tslib's /etc/pointercal linear transform: + $a_xform = $1; + if (-f $a_xform) { + $a_xform = `head -n 1 '$a_xform'`; + chomp $a_xform; + $a_xform =~ s/^\s*//; + $a_xform =~ s/\s*$//; + } +} +if ($options =~ /keycmds=([^,]+)/i) { + # format: keysym1:command1+keysym2:command2+... + # e.g.: keycmds=F6:date+F7:'./x11vnc-0.9.10 -connect ./ctl.txt -R reset' + my $str = $1; + if (-f $str && open(F, "<$str")) { + $str = ''; + while () { + chomp; + $_ =~ s/^\s*//; + $_ =~ s/\s*$//; + next if /^#/; + next if $_ eq ""; + $str .= '+' if $str ne ''; + $str .= $_; + } + close F; + } + foreach my $part (split(/\+/, $str)) { + my ($key, $cmd) = split(/:/, $part, 2); + if ($key !~ /^\s*$/) { + $keycmds{$key} = $cmd; + } + } +} +if ($options =~ /debug=(\d+)/i) { + # debug printout + $debug = $1; +} elsif ($options =~ /debug/i) { + $debug = 1; +} + +# end of the top part that user should read and understand +# for setting options, etc. +###################################################################### + +$start = time(); + +# open the device for writing: +# +$modes = $O_WRONLY; +printf("open modes: 0x%x\n", $modes) if $debug; + +sysopen(FD, $dev, $modes) || die "$dev: $!"; + +my $curr_mask = 0; +my $curr_x = 0; +my $curr_y = 0; +my $down_count = 0; + +# read input events from x11vnc through STDIN: +# +while (<>) { + chomp; + if (/^Pointer/) { + my ($p, $client, $x, $y, $mask, $hint) = split(' ', $_, 6); + do_pointer($client, $x, $y, $mask, $hint); + } elsif (/^Keysym/) { + my ($k, $client, $down, $keysym, $name, $hint) = split(' ', $_, 6); + do_keysym($client, $down, $keysym, $name, $hint); + } +} + +close(FD); + +exit(0); + +sub do_keysym { + # qtmoko/neo does not support keystroke input. so these will be ignored. + # (one possibility would to be enable qtmoko to read from /dev/tty0. + # but the injection mechanism would need to be modified.) + my ($client, $down, $keysym, $name, $hint) = @_; + + $ENV{DO_KEYSYM} = "$client $down $keysym $name $hint"; + + # one could implement his own 'hot keys' here. + + # process any keycmds: + if (%keycmds && (exists $keycmds{$name} || exists $keycmds{ALL})) { + my $cmd = $keycmds{$name}; + if (!exists $keycmds{$name}) { + $cmd = $keycmds{ALL}; + print STDERR "keycmds: $name/ALL: running: $cmd\n"; + system("$cmd"); + } elsif ($down) { + print STDERR "keycmds: $name: running: $cmd\n"; + system("$cmd"); + } + return; + } + + $name = "XK_$name"; + my $nolookup = 0; + if (! exists $key_lookup{$name}) { + $nolookup = 1; + } elsif (! defined $key_lookup{$name}) { + $nolookup = 2; + } elsif ($key_lookup{$name} =~ /^\s*$/) { + $nolookup = 3; + } + if ($nolookup) { + print STDERR "do_keysym: key not implemented-$nolookup $down $keysym $name $hint.\n" if $debug; + return; + } + + print STDERR gettime() . " do_keysym: $name\n" if $debug; + do_key($key_lookup{$name}, $down); +} + +sub do_pointer { + my ($client, $x, $y, $mask, $hint) = @_; + my $x2 = $x; + my $y2 = $y; + if ($a_xform ne '') { + # this is tslib's /etc/pointercal format. + if (! @a) { + # -528 33408 -3417516 -44200 408 40292028 56541 + @a = split(' ', $a_xform); + foreach my $a (@a) { + $a += 0.0; + } + } + # this is the inverse of the tslib transformation: + # + $x2 = ( $a[4] * ($a[6] * $x - $a[2]) - $a[1] * ($a[6] * $y - $a[5]) ) + / ( $a[4] * $a[0] - $a[1] * $a[3]); + $y2 = ( $a[0] * ($a[6] * $y - $a[5]) - $a[3] * ($a[6] * $x - $a[2]) ) + / ( $a[4] * $a[0] - $a[1] * $a[3]); + $x2 = int($x2); + $y2 = int($y2); + } + + print STDERR gettime() . " do_pointer $x $y (=> $x2 $y2) $mask $hint.\n" if $debug; + + if (! $btn_touch) { + if ($curr_mask == 0 && $mask == 0) { + do_abs($x2, $y2, 0) if $absalways; + } elsif ($curr_mask == 0 && $mask != 0) { + do_abs($x2, $y2, $pressure); + $down_count = 0; + } elsif ($curr_mask != 0 && $mask == 0) { + do_abs($x2, $y2, 0); + } elsif ($curr_mask != 0 && $mask != 0) { + $down_count++; + if ($dragskip > 0) { + if ($down_count % $dragskip == 0) { + do_abs($x2, $y2, $pressure); + } else { + print STDERR "dragskip $down_count $dragskip\n" if $debug; + } + } else { + do_abs($x2, $y2, $pressure); + } + } + } else { + if ($curr_mask == 0 && $mask == 0) { + do_abs($x2, $y2, 0) if $absalways; + } elsif ($curr_mask == 0 && $mask != 0) { + do_abs($x2, $y2, 0); + do_btn($BTN_TOUCH, 1); + } elsif ($curr_mask != 0 && $mask == 0) { + do_abs($x2, $y2, 0); + do_btn($BTN_TOUCH, 0); + } elsif ($curr_mask != 0 && $mask != 0) { + ; + } + } + + $curr_mask = $mask; + $curr_x = $x2; + $curr_y = $y2; +} + +# struct input_event { +# struct timeval time; +# __u16 type; +# __u16 code; +# __s32 value; +# }; + +sub do_syn { + my $ev = gtod(); + $ev .= pack("S", $EV_SYN); + $ev .= pack("S", $SYN_REPORT); + $ev .= pack("i", 0); + print STDERR "do_syn EV_SYN\n" if $debug; + my $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_syn: $!\n"; + } +} + +sub do_key { + # not supported by qtmoko + my ($key, $down) = @_; + my $ev = gtod(); + $ev .= pack("S", $EV_KEY); + $ev .= pack("S", $key); + $ev .= pack("i", $down); + print STDERR "do_key $key $down\n" if $debug; + my $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_key: $!\n"; + } + do_syn(); +} + +sub do_btn { + # only BTN_TOUCH supported by qtmoko (but it seems to be ignored??) + my ($button, $down) = @_; + my $ev = gtod(); + $ev .= pack("S", $EV_KEY); + $ev .= pack("S", $button); + $ev .= pack("i", $down); + print STDERR "do_btn $button $down\n" if $debug; + my $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_btn: $!\n"; + } + do_syn(); +} + +sub do_abs { + # absolute method is the workhorse for the touchscreen. + my ($x, $y, $p) = @_; + my $ev = gtod(); + $ev .= pack("S", $EV_ABS); + $ev .= pack("S", $ABS_Y); + $ev .= pack("i", $y); + print STDERR "do_abs y=$y\n" if $debug; + my $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_abs: $!\n"; + } + $ev = gtod(); + $ev .= pack("S", $EV_ABS); + $ev .= pack("S", $ABS_X); + $ev .= pack("i", $x); + print STDERR "do_abs x=$x\n" if $debug; + $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_abs: $!\n"; + } + $ev = gtod(); + $ev .= pack("S", $EV_ABS); + $ev .= pack("S", $ABS_PRESSURE); + $ev .= pack("i", $p); + print STDERR "do_abs p=$p\n" if $debug; + $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_abs: $!\n"; + } + do_syn(); +} + +sub do_rel { + # not supported by qtmoko + my ($dx, $dy) = @_; + my $ev = gtod(); + $ev .= pack("S", $EV_REL); + $ev .= pack("S", $REL_Y); + $ev .= pack("i", $dy); + print STDERR "do_rel dy=$dy\n" if $debug; + my $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_rel: $!\n"; + } + $ev = gtod(); + $ev .= pack("S", $EV_REL); + $ev .= pack("S", $REL_X); + $ev .= pack("i", $dx); + print STDERR "do_rel dx=$dx\n"; + $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_rel: $!\n"; + } + do_syn(); +} + +sub gtod { + # 32 bit machines. TBD use perl module Time:HiRes. + $tv = ("\0" x 4) x 2; # assumes long is 4 bytes. should use pack. + $tz = ("\0" x 4) x 2; + syscall($linux_gettimeofday_syscall, $tv, $tz); + return $tv; +} + +sub gettime { + my $tv = gtod(); + my ($tv_sec, $tv_usec) = unpack("L2", $tv); + $tv_usec2 = sprintf("%8.6f", $tv_usec/1000000.0); + if ( $tv_usec2 =~ /^0\./ ) { + $tv_usec2 =~ s/^0\././; + $tv_sec = "$tv_sec$tv_usec2"; + } else { + $tv_sec = $tv_sec + ($tv_usec/1000000.0); + } + return sprintf("%.3f", $tv_sec - $start); +} + +sub fsleep { + my ($time) = @_; + select(undef, undef, undef, $time) if $time; +} + +sub set_constants { + +# from /usr/include/linux/uinput.h /usr/include/linux/input.h and x11vnc. + +# #define ABS_MAX 0x3f = 63 +# +# #define UINPUT_MAX_NAME_SIZE 80 +# +# struct input_id { +# __u16 bustype; +# __u16 vendor; +# __u16 product; +# __u16 version; +# }; +# +# struct uinput_user_dev { +# char name[UINPUT_MAX_NAME_SIZE]; +# struct input_id id; +# int ff_effects_max; +# int absmax[ABS_MAX + 1]; +# int absmin[ABS_MAX + 1]; +# int absfuzz[ABS_MAX + 1]; +# int absflat[ABS_MAX + 1]; +# }; +# #endif /* __UINPUT_H_ */ + +$EV_SYN = 0x00; +$EV_KEY = 0x01; +$EV_REL = 0x02; +$EV_ABS = 0x03; +$EV_MSC = 0x04; +$EV_SW = 0x05; +$EV_LED = 0x11; +$EV_SND = 0x12; +$EV_REP = 0x14; +$EV_FF = 0x15; +$EV_PWR = 0x16; +$EV_FF_STATUS = 0x17; +$EV_MAX = 0x1f; + +$ID_BUS = 0; +$ID_VENDOR = 1; +$ID_PRODUCT = 2; +$ID_VERSION = 3; + +$BUS_PCI = 0x01; +$BUS_ISAPNP = 0x02; +$BUS_USB = 0x03; +$BUS_HIL = 0x04; +$BUS_BLUETOOTH = 0x05; +$BUS_VIRTUAL = 0x06; + +$BUS_ISA = 0x10; +$BUS_I8042 = 0x11; +$BUS_XTKBD = 0x12; +$BUS_RS232 = 0x13; +$BUS_GAMEPORT = 0x14; +$BUS_PARPORT = 0x15; +$BUS_AMIGA = 0x16; +$BUS_ADB = 0x17; +$BUS_I2C = 0x18; +$BUS_HOST = 0x19; +$BUS_GSC = 0x1A; +$BUS_ATARI = 0x1B; + +$REL_X = 0x00; +$REL_Y = 0x01; +$REL_Z = 0x02; +$REL_RX = 0x03; +$REL_RY = 0x04; +$REL_RZ = 0x05; +$REL_HWHEEL = 0x06; +$REL_DIAL = 0x07; +$REL_WHEEL = 0x08; +$REL_MISC = 0x09; + +$ABS_X = 0x00; +$ABS_Y = 0x01; +$ABS_Z = 0x02; +$ABS_RX = 0x03; +$ABS_RY = 0x04; +$ABS_RZ = 0x05; +$ABS_THROTTLE = 0x06; +$ABS_RUDDER = 0x07; +$ABS_WHEEL = 0x08; +$ABS_GAS = 0x09; +$ABS_BRAKE = 0x0a; +$ABS_HAT0X = 0x10; +$ABS_HAT0Y = 0x11; +$ABS_HAT1X = 0x12; +$ABS_HAT1Y = 0x13; +$ABS_HAT2X = 0x14; +$ABS_HAT2Y = 0x15; +$ABS_HAT3X = 0x16; +$ABS_HAT3Y = 0x17; +$ABS_PRESSURE = 0x18; +$ABS_DISTANCE = 0x19; +$ABS_TILT_X = 0x1a; +$ABS_TILT_Y = 0x1b; +$ABS_TOOL_WIDTH = 0x1c; +$ABS_VOLUME = 0x20; +$ABS_MISC = 0x28; +$ABS_MT_TOUCH_MAJOR = 0x30; +$ABS_MT_TOUCH_MINOR = 0x31; +$ABS_MT_WIDTH_MAJOR = 0x32; +$ABS_MT_WIDTH_MINOR = 0x33; +$ABS_MT_ORIENTATION = 0x34; +$ABS_MT_POSITION_X = 0x35; +$ABS_MT_POSITION_Y = 0x36; +$ABS_MT_TOOL_TYPE = 0x37; +$ABS_MT_BLOB_ID = 0x38; +$ABS_MT_TRACKING_ID = 0x39; +#$ABS_MAX = 0x3f; + + +$BTN_MISC = 0x100; +$BTN_0 = 0x100; +$BTN_1 = 0x101; +$BTN_2 = 0x102; +$BTN_3 = 0x103; +$BTN_4 = 0x104; +$BTN_5 = 0x105; +$BTN_6 = 0x106; +$BTN_7 = 0x107; +$BTN_8 = 0x108; +$BTN_9 = 0x109; + +$BTN_MOUSE = 0x110; +$BTN_LEFT = 0x110; +$BTN_RIGHT = 0x111; +$BTN_MIDDLE = 0x112; +$BTN_SIDE = 0x113; +$BTN_EXTRA = 0x114; +$BTN_FORWARD = 0x115; +$BTN_BACK = 0x116; +$BTN_TASK = 0x117; + +$BTN_JOYSTICK = 0x120; +$BTN_TRIGGER = 0x120; +$BTN_THUMB = 0x121; +$BTN_THUMB2 = 0x122; +$BTN_TOP = 0x123; +$BTN_TOP2 = 0x124; +$BTN_PINKIE = 0x125; +$BTN_BASE = 0x126; +$BTN_BASE2 = 0x127; +$BTN_BASE3 = 0x128; +$BTN_BASE4 = 0x129; +$BTN_BASE5 = 0x12a; +$BTN_BASE6 = 0x12b; +$BTN_DEAD = 0x12f; + +$BTN_GAMEPAD = 0x130; +$BTN_A = 0x130; +$BTN_B = 0x131; +$BTN_C = 0x132; +$BTN_X = 0x133; +$BTN_Y = 0x134; +$BTN_Z = 0x135; +$BTN_TL = 0x136; +$BTN_TR = 0x137; +$BTN_TL2 = 0x138; +$BTN_TR2 = 0x139; +$BTN_SELECT = 0x13a; +$BTN_START = 0x13b; +$BTN_MODE = 0x13c; +$BTN_THUMBL = 0x13d; +$BTN_THUMBR = 0x13e; + +$BTN_DIGI = 0x140; +$BTN_TOOL_PEN = 0x140; +$BTN_TOOL_RUBBER = 0x141; +$BTN_TOOL_BRUSH = 0x142; +$BTN_TOOL_PENCIL = 0x143; +$BTN_TOOL_AIRBRUSH = 0x144; +$BTN_TOOL_FINGER = 0x145; +$BTN_TOOL_MOUSE = 0x146; +$BTN_TOOL_LENS = 0x147; +$BTN_TOUCH = 0x14a; +$BTN_STYLUS = 0x14b; +$BTN_STYLUS2 = 0x14c; +$BTN_TOOL_DOUBLETAP = 0x14d; +$BTN_TOOL_TRIPLETAP = 0x14e; + +$BTN_WHEEL = 0x150; +$BTN_GEAR_DOWN = 0x150; +$BTN_GEAR_UP = 0x151; + +$SYN_REPORT = 0; +$SYN_CONFIG = 1; +$SYN_MT_REPORT = 2; + +$KEY_RESERVED = 0; +$KEY_ESC = 1; +$KEY_1 = 2; +$KEY_2 = 3; +$KEY_3 = 4; +$KEY_4 = 5; +$KEY_5 = 6; +$KEY_6 = 7; +$KEY_7 = 8; +$KEY_8 = 9; +$KEY_9 = 10; +$KEY_0 = 11; +$KEY_MINUS = 12; +$KEY_EQUAL = 13; +$KEY_BACKSPACE = 14; +$KEY_TAB = 15; +$KEY_Q = 16; +$KEY_W = 17; +$KEY_E = 18; +$KEY_R = 19; +$KEY_T = 20; +$KEY_Y = 21; +$KEY_U = 22; +$KEY_I = 23; +$KEY_O = 24; +$KEY_P = 25; +$KEY_LEFTBRACE = 26; +$KEY_RIGHTBRACE = 27; +$KEY_ENTER = 28; +$KEY_LEFTCTRL = 29; +$KEY_A = 30; +$KEY_S = 31; +$KEY_D = 32; +$KEY_F = 33; +$KEY_G = 34; +$KEY_H = 35; +$KEY_J = 36; +$KEY_K = 37; +$KEY_L = 38; +$KEY_SEMICOLON = 39; +$KEY_APOSTROPHE = 40; +$KEY_GRAVE = 41; +$KEY_LEFTSHIFT = 42; +$KEY_BACKSLASH = 43; +$KEY_Z = 44; +$KEY_X = 45; +$KEY_C = 46; +$KEY_V = 47; +$KEY_B = 48; +$KEY_N = 49; +$KEY_M = 50; +$KEY_COMMA = 51; +$KEY_DOT = 52; +$KEY_SLASH = 53; +$KEY_RIGHTSHIFT = 54; +$KEY_KPASTERISK = 55; +$KEY_LEFTALT = 56; +$KEY_SPACE = 57; +$KEY_CAPSLOCK = 58; +$KEY_F1 = 59; +$KEY_F2 = 60; +$KEY_F3 = 61; +$KEY_F4 = 62; +$KEY_F5 = 63; +$KEY_F6 = 64; +$KEY_F7 = 65; +$KEY_F8 = 66; +$KEY_F9 = 67; +$KEY_F10 = 68; +$KEY_NUMLOCK = 69; +$KEY_SCROLLLOCK = 70; +$KEY_KP7 = 71; +$KEY_KP8 = 72; +$KEY_KP9 = 73; +$KEY_KPMINUS = 74; +$KEY_KP4 = 75; +$KEY_KP5 = 76; +$KEY_KP6 = 77; +$KEY_KPPLUS = 78; +$KEY_KP1 = 79; +$KEY_KP2 = 80; +$KEY_KP3 = 81; +$KEY_KP0 = 82; +$KEY_KPDOT = 83; +$KEY_103RD = 84; +$KEY_F13 = 85; +$KEY_102ND = 86; +$KEY_F11 = 87; +$KEY_F12 = 88; +$KEY_F14 = 89; +$KEY_F15 = 90; +$KEY_F16 = 91; +$KEY_F17 = 92; +$KEY_F18 = 93; +$KEY_F19 = 94; +$KEY_F20 = 95; +$KEY_KPENTER = 96; +$KEY_RIGHTCTRL = 97; +$KEY_KPSLASH = 98; +$KEY_SYSRQ = 99; +$KEY_RIGHTALT = 100; +$KEY_LINEFEED = 101; +$KEY_HOME = 102; +$KEY_UP = 103; +$KEY_PAGEUP = 104; +$KEY_LEFT = 105; +$KEY_RIGHT = 106; +$KEY_END = 107; +$KEY_DOWN = 108; +$KEY_PAGEDOWN = 109; +$KEY_INSERT = 110; +$KEY_DELETE = 111; +$KEY_MACRO = 112; +$KEY_MUTE = 113; +$KEY_VOLUMEDOWN = 114; +$KEY_VOLUMEUP = 115; +$KEY_POWER = 116; +$KEY_KPEQUAL = 117; +$KEY_KPPLUSMINUS = 118; +$KEY_PAUSE = 119; +$KEY_F21 = 120; +$KEY_F22 = 121; +$KEY_F23 = 122; +$KEY_F24 = 123; +$KEY_KPCOMMA = 124; +$KEY_LEFTMETA = 125; +$KEY_RIGHTMETA = 126; +$KEY_COMPOSE = 127; +$KEY_STOP = 128; +$KEY_AGAIN = 129; +$KEY_PROPS = 130; +$KEY_UNDO = 131; +$KEY_FRONT = 132; +$KEY_COPY = 133; +$KEY_OPEN = 134; +$KEY_PASTE = 135; +$KEY_FIND = 136; +$KEY_CUT = 137; +$KEY_HELP = 138; +$KEY_MENU = 139; +$KEY_CALC = 140; +$KEY_SETUP = 141; +$KEY_SLEEP = 142; +$KEY_WAKEUP = 143; +$KEY_FILE = 144; +$KEY_SENDFILE = 145; +$KEY_DELETEFILE = 146; +$KEY_XFER = 147; +$KEY_PROG1 = 148; +$KEY_PROG2 = 149; +$KEY_WWW = 150; +$KEY_MSDOS = 151; +$KEY_COFFEE = 152; +$KEY_DIRECTION = 153; +$KEY_CYCLEWINDOWS = 154; +$KEY_MAIL = 155; +$KEY_BOOKMARKS = 156; +$KEY_COMPUTER = 157; +$KEY_BACK = 158; +$KEY_FORWARD = 159; +$KEY_CLOSECD = 160; +$KEY_EJECTCD = 161; +$KEY_EJECTCLOSECD = 162; +$KEY_NEXTSONG = 163; +$KEY_PLAYPAUSE = 164; +$KEY_PREVIOUSSONG = 165; +$KEY_STOPCD = 166; +$KEY_RECORD = 167; +$KEY_REWIND = 168; +$KEY_PHONE = 169; +$KEY_ISO = 170; +$KEY_CONFIG = 171; +$KEY_HOMEPAGE = 172; +$KEY_REFRESH = 173; +$KEY_EXIT = 174; +$KEY_MOVE = 175; +$KEY_EDIT = 176; +$KEY_SCROLLUP = 177; +$KEY_SCROLLDOWN = 178; +$KEY_KPLEFTPAREN = 179; +$KEY_KPRIGHTPAREN = 180; +$KEY_INTL1 = 181; +$KEY_INTL2 = 182; +$KEY_INTL3 = 183; +$KEY_INTL4 = 184; +$KEY_INTL5 = 185; +$KEY_INTL6 = 186; +$KEY_INTL7 = 187; +$KEY_INTL8 = 188; +$KEY_INTL9 = 189; +$KEY_LANG1 = 190; +$KEY_LANG2 = 191; +$KEY_LANG3 = 192; +$KEY_LANG4 = 193; +$KEY_LANG5 = 194; +$KEY_LANG6 = 195; +$KEY_LANG7 = 196; +$KEY_LANG8 = 197; +$KEY_LANG9 = 198; +$KEY_PLAYCD = 200; +$KEY_PAUSECD = 201; +$KEY_PROG3 = 202; +$KEY_PROG4 = 203; +$KEY_SUSPEND = 205; +$KEY_CLOSE = 206; +$KEY_PLAY = 207; +$KEY_FASTFORWARD = 208; +$KEY_BASSBOOST = 209; +$KEY_PRINT = 210; +$KEY_HP = 211; +$KEY_CAMERA = 212; +$KEY_SOUND = 213; +$KEY_QUESTION = 214; +$KEY_EMAIL = 215; +$KEY_CHAT = 216; +$KEY_SEARCH = 217; +$KEY_CONNECT = 218; +$KEY_FINANCE = 219; +$KEY_SPORT = 220; +$KEY_SHOP = 221; +$KEY_ALTERASE = 222; +$KEY_CANCEL = 223; +$KEY_BRIGHTNESSDOWN = 224; +$KEY_BRIGHTNESSUP = 225; +$KEY_MEDIA = 226; +$KEY_UNKNOWN = 240; +$KEY_OK = 0x160; +$KEY_SELECT = 0x161; +$KEY_GOTO = 0x162; +$KEY_CLEAR = 0x163; +$KEY_POWER2 = 0x164; +$KEY_OPTION = 0x165; +$KEY_INFO = 0x166; +$KEY_TIME = 0x167; +$KEY_VENDOR = 0x168; +$KEY_ARCHIVE = 0x169; +$KEY_PROGRAM = 0x16a; +$KEY_CHANNEL = 0x16b; +$KEY_FAVORITES = 0x16c; +$KEY_EPG = 0x16d; +$KEY_PVR = 0x16e; +$KEY_MHP = 0x16f; +$KEY_LANGUAGE = 0x170; +$KEY_TITLE = 0x171; +$KEY_SUBTITLE = 0x172; +$KEY_ANGLE = 0x173; +$KEY_ZOOM = 0x174; +$KEY_MODE = 0x175; +$KEY_KEYBOARD = 0x176; +$KEY_SCREEN = 0x177; +$KEY_PC = 0x178; +$KEY_TV = 0x179; +$KEY_TV2 = 0x17a; +$KEY_VCR = 0x17b; +$KEY_VCR2 = 0x17c; +$KEY_SAT = 0x17d; +$KEY_SAT2 = 0x17e; +$KEY_CD = 0x17f; +$KEY_TAPE = 0x180; +$KEY_RADIO = 0x181; +$KEY_TUNER = 0x182; +$KEY_PLAYER = 0x183; +$KEY_TEXT = 0x184; +$KEY_DVD = 0x185; +$KEY_AUX = 0x186; +$KEY_MP3 = 0x187; +$KEY_AUDIO = 0x188; +$KEY_VIDEO = 0x189; +$KEY_DIRECTORY = 0x18a; +$KEY_LIST = 0x18b; +$KEY_MEMO = 0x18c; +$KEY_CALENDAR = 0x18d; +$KEY_RED = 0x18e; +$KEY_GREEN = 0x18f; +$KEY_YELLOW = 0x190; +$KEY_BLUE = 0x191; +$KEY_CHANNELUP = 0x192; +$KEY_CHANNELDOWN = 0x193; +$KEY_FIRST = 0x194; +$KEY_LAST = 0x195; +$KEY_AB = 0x196; +$KEY_NEXT = 0x197; +$KEY_RESTART = 0x198; +$KEY_SLOW = 0x199; +$KEY_SHUFFLE = 0x19a; +$KEY_BREAK = 0x19b; +$KEY_PREVIOUS = 0x19c; +$KEY_DIGITS = 0x19d; +$KEY_TEEN = 0x19e; +$KEY_TWEN = 0x19f; +$KEY_DEL_EOL = 0x1c0; +$KEY_DEL_EOS = 0x1c1; +$KEY_INS_LINE = 0x1c2; +$KEY_DEL_LINE = 0x1c3; +$KEY_MAX = 0x1ff; + + + $key_lookup{XK_Escape} = $KEY_ESC; + $key_lookup{XK_1} = $KEY_1; + $key_lookup{XK_2} = $KEY_2; + $key_lookup{XK_3} = $KEY_3; + $key_lookup{XK_4} = $KEY_4; + $key_lookup{XK_5} = $KEY_5; + $key_lookup{XK_6} = $KEY_6; + $key_lookup{XK_7} = $KEY_7; + $key_lookup{XK_8} = $KEY_8; + $key_lookup{XK_9} = $KEY_9; + $key_lookup{XK_0} = $KEY_0; + $key_lookup{XK_exclam} = $KEY_1; + $key_lookup{XK_at} = $KEY_2; + $key_lookup{XK_numbersign} = $KEY_3; + $key_lookup{XK_dollar} = $KEY_4; + $key_lookup{XK_percent} = $KEY_5; + $key_lookup{XK_asciicircum} = $KEY_6; + $key_lookup{XK_ampersand} = $KEY_7; + $key_lookup{XK_asterisk} = $KEY_8; + $key_lookup{XK_parenleft} = $KEY_9; + $key_lookup{XK_parenright} = $KEY_0; + $key_lookup{XK_minus} = $KEY_MINUS; + $key_lookup{XK_underscore} = $KEY_MINUS; + $key_lookup{XK_equal} = $KEY_EQUAL; + $key_lookup{XK_plus} = $KEY_EQUAL; + $key_lookup{XK_BackSpace} = $KEY_BACKSPACE; + $key_lookup{XK_Tab} = $KEY_TAB; + $key_lookup{XK_q} = $KEY_Q; + $key_lookup{XK_Q} = $KEY_Q; + $key_lookup{XK_w} = $KEY_W; + $key_lookup{XK_W} = $KEY_W; + $key_lookup{XK_e} = $KEY_E; + $key_lookup{XK_E} = $KEY_E; + $key_lookup{XK_r} = $KEY_R; + $key_lookup{XK_R} = $KEY_R; + $key_lookup{XK_t} = $KEY_T; + $key_lookup{XK_T} = $KEY_T; + $key_lookup{XK_y} = $KEY_Y; + $key_lookup{XK_Y} = $KEY_Y; + $key_lookup{XK_u} = $KEY_U; + $key_lookup{XK_U} = $KEY_U; + $key_lookup{XK_i} = $KEY_I; + $key_lookup{XK_I} = $KEY_I; + $key_lookup{XK_o} = $KEY_O; + $key_lookup{XK_O} = $KEY_O; + $key_lookup{XK_p} = $KEY_P; + $key_lookup{XK_P} = $KEY_P; + $key_lookup{XK_braceleft} = $KEY_LEFTBRACE; + $key_lookup{XK_braceright} = $KEY_RIGHTBRACE; + $key_lookup{XK_bracketleft} = $KEY_LEFTBRACE; + $key_lookup{XK_bracketright} = $KEY_RIGHTBRACE; + $key_lookup{XK_Return} = $KEY_ENTER; + $key_lookup{XK_Control_L} = $KEY_LEFTCTRL; + $key_lookup{XK_a} = $KEY_A; + $key_lookup{XK_A} = $KEY_A; + $key_lookup{XK_s} = $KEY_S; + $key_lookup{XK_S} = $KEY_S; + $key_lookup{XK_d} = $KEY_D; + $key_lookup{XK_D} = $KEY_D; + $key_lookup{XK_f} = $KEY_F; + $key_lookup{XK_F} = $KEY_F; + $key_lookup{XK_g} = $KEY_G; + $key_lookup{XK_G} = $KEY_G; + $key_lookup{XK_h} = $KEY_H; + $key_lookup{XK_H} = $KEY_H; + $key_lookup{XK_j} = $KEY_J; + $key_lookup{XK_J} = $KEY_J; + $key_lookup{XK_k} = $KEY_K; + $key_lookup{XK_K} = $KEY_K; + $key_lookup{XK_l} = $KEY_L; + $key_lookup{XK_L} = $KEY_L; + $key_lookup{XK_semicolon} = $KEY_SEMICOLON; + $key_lookup{XK_colon} = $KEY_SEMICOLON; + $key_lookup{XK_apostrophe} = $KEY_APOSTROPHE; + $key_lookup{XK_quotedbl} = $KEY_APOSTROPHE; + $key_lookup{XK_grave} = $KEY_GRAVE; + $key_lookup{XK_asciitilde} = $KEY_GRAVE; + $key_lookup{XK_Shift_L} = $KEY_LEFTSHIFT; + $key_lookup{XK_backslash} = $KEY_BACKSLASH; + $key_lookup{XK_bar} = $KEY_BACKSLASH; + $key_lookup{XK_z} = $KEY_Z; + $key_lookup{XK_Z} = $KEY_Z; + $key_lookup{XK_x} = $KEY_X; + $key_lookup{XK_X} = $KEY_X; + $key_lookup{XK_c} = $KEY_C; + $key_lookup{XK_C} = $KEY_C; + $key_lookup{XK_v} = $KEY_V; + $key_lookup{XK_V} = $KEY_V; + $key_lookup{XK_b} = $KEY_B; + $key_lookup{XK_B} = $KEY_B; + $key_lookup{XK_n} = $KEY_N; + $key_lookup{XK_N} = $KEY_N; + $key_lookup{XK_m} = $KEY_M; + $key_lookup{XK_M} = $KEY_M; + $key_lookup{XK_comma} = $KEY_COMMA; + $key_lookup{XK_less} = $KEY_COMMA; + $key_lookup{XK_period} = $KEY_DOT; + $key_lookup{XK_greater} = $KEY_DOT; + $key_lookup{XK_slash} = $KEY_SLASH; + $key_lookup{XK_question} = $KEY_SLASH; + $key_lookup{XK_Shift_R} = $KEY_RIGHTSHIFT; + $key_lookup{XK_KP_Multiply} = $KEY_KPASTERISK; + $key_lookup{XK_Alt_L} = $KEY_LEFTALT; + $key_lookup{XK_space} = $KEY_SPACE; + $key_lookup{XK_Caps_Lock} = $KEY_CAPSLOCK; + $key_lookup{XK_F1} = $KEY_F1; + $key_lookup{XK_F2} = $KEY_F2; + $key_lookup{XK_F3} = $KEY_F3; + $key_lookup{XK_F4} = $KEY_F4; + $key_lookup{XK_F5} = $KEY_F5; + $key_lookup{XK_F6} = $KEY_F6; + $key_lookup{XK_F7} = $KEY_F7; + $key_lookup{XK_F8} = $KEY_F8; + $key_lookup{XK_F9} = $KEY_F9; + $key_lookup{XK_F10} = $KEY_F10; + $key_lookup{XK_Num_Lock} = $KEY_NUMLOCK; + $key_lookup{XK_Scroll_Lock} = $KEY_SCROLLLOCK; + $key_lookup{XK_KP_7} = $KEY_KP7; + $key_lookup{XK_KP_8} = $KEY_KP8; + $key_lookup{XK_KP_9} = $KEY_KP9; + $key_lookup{XK_KP_Subtract} = $KEY_KPMINUS; + $key_lookup{XK_KP_4} = $KEY_KP4; + $key_lookup{XK_KP_5} = $KEY_KP5; + $key_lookup{XK_KP_6} = $KEY_KP6; + $key_lookup{XK_KP_Add} = $KEY_KPPLUS; + $key_lookup{XK_KP_1} = $KEY_KP1; + $key_lookup{XK_KP_2} = $KEY_KP2; + $key_lookup{XK_KP_3} = $KEY_KP3; + $key_lookup{XK_KP_0} = $KEY_KP0; + $key_lookup{XK_KP_Decimal} = $KEY_KPDOT; + $key_lookup{XK_F13} = $KEY_F13; + $key_lookup{XK_F11} = $KEY_F11; + $key_lookup{XK_F12} = $KEY_F12; + $key_lookup{XK_F14} = $KEY_F14; + $key_lookup{XK_F15} = $KEY_F15; + $key_lookup{XK_F16} = $KEY_F16; + $key_lookup{XK_F17} = $KEY_F17; + $key_lookup{XK_F18} = $KEY_F18; + $key_lookup{XK_F19} = $KEY_F19; + $key_lookup{XK_F20} = $KEY_F20; + $key_lookup{XK_KP_Enter} = $KEY_KPENTER; + $key_lookup{XK_Control_R} = $KEY_RIGHTCTRL; + $key_lookup{XK_KP_Divide} = $KEY_KPSLASH; + $key_lookup{XK_Sys_Req} = $KEY_SYSRQ; + $key_lookup{XK_Alt_R} = $KEY_RIGHTALT; + $key_lookup{XK_Linefeed} = $KEY_LINEFEED; + $key_lookup{XK_Home} = $KEY_HOME; + $key_lookup{XK_Up} = $KEY_UP; + $key_lookup{XK_Page_Up} = $KEY_PAGEUP; + $key_lookup{XK_Left} = $KEY_LEFT; + $key_lookup{XK_Right} = $KEY_RIGHT; + $key_lookup{XK_End} = $KEY_END; + $key_lookup{XK_Down} = $KEY_DOWN; + $key_lookup{XK_Page_Down} = $KEY_PAGEDOWN; + $key_lookup{XK_Insert} = $KEY_INSERT; + $key_lookup{XK_Delete} = $KEY_DELETE; + $key_lookup{XK_KP_Equal} = $KEY_KPEQUAL; + $key_lookup{XK_Pause} = $KEY_PAUSE; + $key_lookup{XK_F21} = $KEY_F21; + $key_lookup{XK_F22} = $KEY_F22; + $key_lookup{XK_F23} = $KEY_F23; + $key_lookup{XK_F24} = $KEY_F24; + $key_lookup{XK_KP_Separator} = $KEY_KPCOMMA; + $key_lookup{XK_Meta_L} = $KEY_LEFTMETA; + $key_lookup{XK_Meta_R} = $KEY_RIGHTMETA; + $key_lookup{XK_Multi_key} = $KEY_COMPOSE; + +$ABS_MAX = 63; + +$UI_DEV_CREATE = 0x5501; +$UI_DEV_DESTROY = 0x5502; +$UI_SET_EVBIT = 0x40045564; +$UI_SET_KEYBIT = 0x40045565; +$UI_SET_RELBIT = 0x40045566; +$UI_SET_ABSBIT = 0x40045567; + +# FIXME: time hires, etc. +$linux_gettimeofday_syscall = 78; + +$O_RDONLY = 00; +$O_WRONLY = 01; +$O_RDWR = 02; +$O_NDELAY = 04000; + +} diff --git a/x11vnc/misc/uinput.pl b/x11vnc/misc/uinput.pl new file mode 100755 index 0000000..9620140 --- /dev/null +++ b/x11vnc/misc/uinput.pl @@ -0,0 +1,946 @@ +#!/usr/bin/perl + +# This is a test injection script for Linux uinput. +# It can be handy working out / troubleshooting Linux uinput injection on a new device. + +# +# Copyright (c) 2010 by Karl J. Runge +# +# uinput.pl is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# uinput.pl is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with uinput.pl; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA +# or see . +# + +set_constants(); + +# options for what injection to handle: +$rel = 1; +$abs = 1; +$touch = 1; +$allkeys = 1; + +# these can be set via env: + +$WIDTH = $ENV{WIDTH}; +$WIDTH = 480 unless $WIDTH; +$HEIGHT = $ENV{HEIGHT}; +$HEIGHT = 640 unless $HEIGHT; +$DEV = $ENV{DEV}; +$DEV = "/dev/input/uinput" unless $DEV; + +# this fills in name and input type part of uinput_user_dev struct: + +$udev = "uinput.pl"; +$n = 80 - length($udev); +$udev .= "\0" x $n; + +$udev .= "\0" x 2; # bus +$udev .= "\0" x 2; # vendor +$udev .= "\0" x 2; # product +$udev .= "\0" x 2; # version + +$udev .= "\0" x 4; # ff_effects_max + +# this fills in the abs arrays: +# +foreach $type (qw(absmax absmin absfuzz absflat)) { + $n = $ABS_MAX + 1; + for ($j = 0; $j < $n; $j++) { + if ($abs && $type eq 'absmax' && $j == $ABS_X) { + $udev .= pack("i", $WIDTH-1); + } elsif ($abs && $type eq 'absmax' && $j == $ABS_Y) { + $udev .= pack("i", $HEIGHT-1); + } else { + $udev .= "\0" x 4; + } + } +} + +print "udev: ", length($udev) . " '$udev'\n"; + +$modes = $O_RDWR; +$modes = $O_WRONLY | $O_NDELAY; +printf("open modes: 0x%x\n", $modes); + +sysopen(FD, $DEV, $modes) || die "$DEV: $!"; + +if ($rel) { + io_ctl($UI_SET_EVBIT, $EV_REL); + io_ctl($UI_SET_RELBIT, $REL_X); + io_ctl($UI_SET_RELBIT, $REL_Y); +} + +io_ctl($UI_SET_EVBIT, $EV_KEY); + +io_ctl($UI_SET_EVBIT, $EV_SYN); + +for ($i=0; $i < 256; $i++) { + last unless $allkeys; + io_ctl($UI_SET_KEYBIT, $i); +} + +io_ctl($UI_SET_KEYBIT, $BTN_MOUSE); +io_ctl($UI_SET_KEYBIT, $BTN_LEFT); +io_ctl($UI_SET_KEYBIT, $BTN_MIDDLE); +io_ctl($UI_SET_KEYBIT, $BTN_RIGHT); +io_ctl($UI_SET_KEYBIT, $BTN_FORWARD); +io_ctl($UI_SET_KEYBIT, $BTN_BACK); + +if ($abs) { + io_ctl($UI_SET_KEYBIT, $BTN_TOUCH) if $touch; + io_ctl($UI_SET_EVBIT, $EV_ABS); + io_ctl($UI_SET_ABSBIT, $ABS_X); + io_ctl($UI_SET_ABSBIT, $ABS_Y); +} + +$ret = syswrite(FD, $udev, length($udev)); +print "syswrite: $ret\n"; + +io_ctl($UI_DEV_CREATE); +fsleep(0.25); + +# this should show our new virtual device: +# +system("cat /proc/bus/input/devices 1>&2"); +print STDERR "\n"; + +################################################# +# put in your various test injection events here: + +#do_key($KEY_A, 1, 0.1); +#do_key($KEY_A, 0, 0.1); + +#do_key($KEY_POWER, 1, 0.1); +#do_key($KEY_POWER, 0, 0.1); + +do_abs(118, 452, 0, 0.1); + +do_abs(110, 572, 1, 0.1); + +do_btn($BTN_TOUCH, 1, 0.1); +do_btn($BTN_TOUCH, 0, 0.1); + +do_btn($BTN_MOUSE, 1, 0.1); +do_btn($BTN_MOUSE, 0, 0.1); +################################################# + +fsleep(0.25); +io_ctl($UI_DEV_DESTROY); + +close(FD); + +exit(0); + +sub io_ctl { + my ($cmd, $val) = @_; + if (defined $val) { + my $ret = syscall($linux_ioctl_syscall, fileno(FD), $cmd, $val); + my $err = $!; $err = '' if $ret == 0; + print STDERR "io_ctl(FD, $cmd, $val) = $ret $err\n"; + } else { + my $ret = syscall($linux_ioctl_syscall, fileno(FD), $cmd); + my $err = $!; $err = '' if $ret == 0; + print STDERR "io_ctl(FD, $cmd) = $ret $err\n"; + } +} + +sub do_syn { + my $ev = gtod(); + $ev .= pack("S", $EV_SYN); + $ev .= pack("S", $SYN_REPORT); + $ev .= pack("i", 0); + print STDERR "do_syn EV_SYN\n"; + my $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_syn: $!\n"; + } +} + +sub do_key { + my ($key, $down, $sleep) = @_; + my $ev = gtod(); + $ev .= pack("S", $EV_KEY); + $ev .= pack("S", $key); + $ev .= pack("i", $down); + print STDERR "do_key $key $down\n"; + my $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_key: $!\n"; + } + do_syn(); + fsleep($sleep); + print STDERR "\n"; +} + +sub do_btn { + my ($button, $down, $sleep) = @_; + my $ev = gtod(); + $ev .= pack("S", $EV_KEY); + $ev .= pack("S", $button); + $ev .= pack("i", $down); + print STDERR "do_btn $button $down\n"; + my $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_btn: $!\n"; + } + do_syn(); + fsleep($sleep); + print STDERR "\n"; +} + +sub do_abs { + my ($x, $y, $p, $sleep) = @_; + my $ev = gtod(); + $ev .= pack("S", $EV_ABS); + $ev .= pack("S", $ABS_Y); + $ev .= pack("i", $y); + print STDERR "do_abs y=$y\n"; + my $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_abs: $!\n"; + } + $ev = gtod(); + $ev .= pack("S", $EV_ABS); + $ev .= pack("S", $ABS_X); + $ev .= pack("i", $x); + print STDERR "do_abs x=$x\n"; + $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_abs: $!\n"; + } + $ev = gtod(); + $ev .= pack("S", $EV_ABS); + $ev .= pack("S", $ABS_PRESSURE); + $ev .= pack("i", $p); + print STDERR "do_abs p=$p\n"; + $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_abs: $!\n"; + } + do_syn(); + fsleep($sleep); + print STDERR "\n"; +} + +sub do_rel { + my ($dx, $dy, $sleep) = @_; + my $ev = gtod(); + $ev .= pack("S", $EV_REL); + $ev .= pack("S", $REL_Y); + $ev .= pack("i", $dy); + print STDERR "do_rel dy=$dy\n"; + my $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_rel: $!\n"; + } + $ev = gtod(); + $ev .= pack("S", $EV_REL); + $ev .= pack("S", $REL_X); + $ev .= pack("i", $dx); + print STDERR "do_rel dx=$dx\n"; + $ret = syswrite(FD, $ev, length($ev)); + if (!defined $ret) { + print STDERR "do_rel: $!\n"; + } + do_syn(); + fsleep($sleep); + print STDERR "\n"; +} + +sub gtod { + $tv = ("\0" x 4) x 2; # assumes long is 4 bytes. FIXME: use pack. + $tz = ("\0" x 4) x 2; + syscall($linux_gettimeofday_syscall, $tv, $tz); + return $tv; +} + +sub fsleep { + my ($time) = @_; + select(undef, undef, undef, $time) if $time; +} + +sub set_constants { + +# from /usr/include/linux/uinput.h /usr/include/linux/input.h and x11vnc. + +# #define ABS_MAX 0x3f = 63 +# +# #define UINPUT_MAX_NAME_SIZE 80 +# +# struct input_id { +# __u16 bustype; +# __u16 vendor; +# __u16 product; +# __u16 version; +# }; +# +# struct uinput_user_dev { +# char name[UINPUT_MAX_NAME_SIZE]; +# struct input_id id; +# int ff_effects_max; +# int absmax[ABS_MAX + 1]; +# int absmin[ABS_MAX + 1]; +# int absfuzz[ABS_MAX + 1]; +# int absflat[ABS_MAX + 1]; +# }; +# #endif /* __UINPUT_H_ */ + +$EV_SYN = 0x00; +$EV_KEY = 0x01; +$EV_REL = 0x02; +$EV_ABS = 0x03; +$EV_MSC = 0x04; +$EV_SW = 0x05; +$EV_LED = 0x11; +$EV_SND = 0x12; +$EV_REP = 0x14; +$EV_FF = 0x15; +$EV_PWR = 0x16; +$EV_FF_STATUS = 0x17; +$EV_MAX = 0x1f; + +$ID_BUS = 0; +$ID_VENDOR = 1; +$ID_PRODUCT = 2; +$ID_VERSION = 3; + +$BUS_PCI = 0x01; +$BUS_ISAPNP = 0x02; +$BUS_USB = 0x03; +$BUS_HIL = 0x04; +$BUS_BLUETOOTH = 0x05; +$BUS_VIRTUAL = 0x06; + +$BUS_ISA = 0x10; +$BUS_I8042 = 0x11; +$BUS_XTKBD = 0x12; +$BUS_RS232 = 0x13; +$BUS_GAMEPORT = 0x14; +$BUS_PARPORT = 0x15; +$BUS_AMIGA = 0x16; +$BUS_ADB = 0x17; +$BUS_I2C = 0x18; +$BUS_HOST = 0x19; +$BUS_GSC = 0x1A; +$BUS_ATARI = 0x1B; + +$REL_X = 0x00; +$REL_Y = 0x01; +$REL_Z = 0x02; +$REL_RX = 0x03; +$REL_RY = 0x04; +$REL_RZ = 0x05; +$REL_HWHEEL = 0x06; +$REL_DIAL = 0x07; +$REL_WHEEL = 0x08; +$REL_MISC = 0x09; + +$ABS_X = 0x00; +$ABS_Y = 0x01; +$ABS_Z = 0x02; +$ABS_RX = 0x03; +$ABS_RY = 0x04; +$ABS_RZ = 0x05; +$ABS_THROTTLE = 0x06; +$ABS_RUDDER = 0x07; +$ABS_WHEEL = 0x08; +$ABS_GAS = 0x09; +$ABS_BRAKE = 0x0a; +$ABS_HAT0X = 0x10; +$ABS_HAT0Y = 0x11; +$ABS_HAT1X = 0x12; +$ABS_HAT1Y = 0x13; +$ABS_HAT2X = 0x14; +$ABS_HAT2Y = 0x15; +$ABS_HAT3X = 0x16; +$ABS_HAT3Y = 0x17; +$ABS_PRESSURE = 0x18; +$ABS_DISTANCE = 0x19; +$ABS_TILT_X = 0x1a; +$ABS_TILT_Y = 0x1b; +$ABS_TOOL_WIDTH = 0x1c; +$ABS_VOLUME = 0x20; +$ABS_MISC = 0x28; +$ABS_MT_TOUCH_MAJOR = 0x30; +$ABS_MT_TOUCH_MINOR = 0x31; +$ABS_MT_WIDTH_MAJOR = 0x32; +$ABS_MT_WIDTH_MINOR = 0x33; +$ABS_MT_ORIENTATION = 0x34; +$ABS_MT_POSITION_X = 0x35; +$ABS_MT_POSITION_Y = 0x36; +$ABS_MT_TOOL_TYPE = 0x37; +$ABS_MT_BLOB_ID = 0x38; +$ABS_MT_TRACKING_ID = 0x39; +#$ABS_MAX = 0x3f; + + +$BTN_MISC = 0x100; +$BTN_0 = 0x100; +$BTN_1 = 0x101; +$BTN_2 = 0x102; +$BTN_3 = 0x103; +$BTN_4 = 0x104; +$BTN_5 = 0x105; +$BTN_6 = 0x106; +$BTN_7 = 0x107; +$BTN_8 = 0x108; +$BTN_9 = 0x109; + +$BTN_MOUSE = 0x110; +$BTN_LEFT = 0x110; +$BTN_RIGHT = 0x111; +$BTN_MIDDLE = 0x112; +$BTN_SIDE = 0x113; +$BTN_EXTRA = 0x114; +$BTN_FORWARD = 0x115; +$BTN_BACK = 0x116; +$BTN_TASK = 0x117; + +$BTN_JOYSTICK = 0x120; +$BTN_TRIGGER = 0x120; +$BTN_THUMB = 0x121; +$BTN_THUMB2 = 0x122; +$BTN_TOP = 0x123; +$BTN_TOP2 = 0x124; +$BTN_PINKIE = 0x125; +$BTN_BASE = 0x126; +$BTN_BASE2 = 0x127; +$BTN_BASE3 = 0x128; +$BTN_BASE4 = 0x129; +$BTN_BASE5 = 0x12a; +$BTN_BASE6 = 0x12b; +$BTN_DEAD = 0x12f; + +$BTN_GAMEPAD = 0x130; +$BTN_A = 0x130; +$BTN_B = 0x131; +$BTN_C = 0x132; +$BTN_X = 0x133; +$BTN_Y = 0x134; +$BTN_Z = 0x135; +$BTN_TL = 0x136; +$BTN_TR = 0x137; +$BTN_TL2 = 0x138; +$BTN_TR2 = 0x139; +$BTN_SELECT = 0x13a; +$BTN_START = 0x13b; +$BTN_MODE = 0x13c; +$BTN_THUMBL = 0x13d; +$BTN_THUMBR = 0x13e; + +$BTN_DIGI = 0x140; +$BTN_TOOL_PEN = 0x140; +$BTN_TOOL_RUBBER = 0x141; +$BTN_TOOL_BRUSH = 0x142; +$BTN_TOOL_PENCIL = 0x143; +$BTN_TOOL_AIRBRUSH = 0x144; +$BTN_TOOL_FINGER = 0x145; +$BTN_TOOL_MOUSE = 0x146; +$BTN_TOOL_LENS = 0x147; +$BTN_TOUCH = 0x14a; +$BTN_STYLUS = 0x14b; +$BTN_STYLUS2 = 0x14c; +$BTN_TOOL_DOUBLETAP = 0x14d; +$BTN_TOOL_TRIPLETAP = 0x14e; + +$BTN_WHEEL = 0x150; +$BTN_GEAR_DOWN = 0x150; +$BTN_GEAR_UP = 0x151; + +$SYN_REPORT = 0; +$SYN_CONFIG = 1; +$SYN_MT_REPORT = 2; + +$KEY_RESERVED = 0; +$KEY_ESC = 1; +$KEY_1 = 2; +$KEY_2 = 3; +$KEY_3 = 4; +$KEY_4 = 5; +$KEY_5 = 6; +$KEY_6 = 7; +$KEY_7 = 8; +$KEY_8 = 9; +$KEY_9 = 10; +$KEY_0 = 11; +$KEY_MINUS = 12; +$KEY_EQUAL = 13; +$KEY_BACKSPACE = 14; +$KEY_TAB = 15; +$KEY_Q = 16; +$KEY_W = 17; +$KEY_E = 18; +$KEY_R = 19; +$KEY_T = 20; +$KEY_Y = 21; +$KEY_U = 22; +$KEY_I = 23; +$KEY_O = 24; +$KEY_P = 25; +$KEY_LEFTBRACE = 26; +$KEY_RIGHTBRACE = 27; +$KEY_ENTER = 28; +$KEY_LEFTCTRL = 29; +$KEY_A = 30; +$KEY_S = 31; +$KEY_D = 32; +$KEY_F = 33; +$KEY_G = 34; +$KEY_H = 35; +$KEY_J = 36; +$KEY_K = 37; +$KEY_L = 38; +$KEY_SEMICOLON = 39; +$KEY_APOSTROPHE = 40; +$KEY_GRAVE = 41; +$KEY_LEFTSHIFT = 42; +$KEY_BACKSLASH = 43; +$KEY_Z = 44; +$KEY_X = 45; +$KEY_C = 46; +$KEY_V = 47; +$KEY_B = 48; +$KEY_N = 49; +$KEY_M = 50; +$KEY_COMMA = 51; +$KEY_DOT = 52; +$KEY_SLASH = 53; +$KEY_RIGHTSHIFT = 54; +$KEY_KPASTERISK = 55; +$KEY_LEFTALT = 56; +$KEY_SPACE = 57; +$KEY_CAPSLOCK = 58; +$KEY_F1 = 59; +$KEY_F2 = 60; +$KEY_F3 = 61; +$KEY_F4 = 62; +$KEY_F5 = 63; +$KEY_F6 = 64; +$KEY_F7 = 65; +$KEY_F8 = 66; +$KEY_F9 = 67; +$KEY_F10 = 68; +$KEY_NUMLOCK = 69; +$KEY_SCROLLLOCK = 70; +$KEY_KP7 = 71; +$KEY_KP8 = 72; +$KEY_KP9 = 73; +$KEY_KPMINUS = 74; +$KEY_KP4 = 75; +$KEY_KP5 = 76; +$KEY_KP6 = 77; +$KEY_KPPLUS = 78; +$KEY_KP1 = 79; +$KEY_KP2 = 80; +$KEY_KP3 = 81; +$KEY_KP0 = 82; +$KEY_KPDOT = 83; +$KEY_103RD = 84; +$KEY_F13 = 85; +$KEY_102ND = 86; +$KEY_F11 = 87; +$KEY_F12 = 88; +$KEY_F14 = 89; +$KEY_F15 = 90; +$KEY_F16 = 91; +$KEY_F17 = 92; +$KEY_F18 = 93; +$KEY_F19 = 94; +$KEY_F20 = 95; +$KEY_KPENTER = 96; +$KEY_RIGHTCTRL = 97; +$KEY_KPSLASH = 98; +$KEY_SYSRQ = 99; +$KEY_RIGHTALT = 100; +$KEY_LINEFEED = 101; +$KEY_HOME = 102; +$KEY_UP = 103; +$KEY_PAGEUP = 104; +$KEY_LEFT = 105; +$KEY_RIGHT = 106; +$KEY_END = 107; +$KEY_DOWN = 108; +$KEY_PAGEDOWN = 109; +$KEY_INSERT = 110; +$KEY_DELETE = 111; +$KEY_MACRO = 112; +$KEY_MUTE = 113; +$KEY_VOLUMEDOWN = 114; +$KEY_VOLUMEUP = 115; +$KEY_POWER = 116; +$KEY_KPEQUAL = 117; +$KEY_KPPLUSMINUS = 118; +$KEY_PAUSE = 119; +$KEY_F21 = 120; +$KEY_F22 = 121; +$KEY_F23 = 122; +$KEY_F24 = 123; +$KEY_KPCOMMA = 124; +$KEY_LEFTMETA = 125; +$KEY_RIGHTMETA = 126; +$KEY_COMPOSE = 127; +$KEY_STOP = 128; +$KEY_AGAIN = 129; +$KEY_PROPS = 130; +$KEY_UNDO = 131; +$KEY_FRONT = 132; +$KEY_COPY = 133; +$KEY_OPEN = 134; +$KEY_PASTE = 135; +$KEY_FIND = 136; +$KEY_CUT = 137; +$KEY_HELP = 138; +$KEY_MENU = 139; +$KEY_CALC = 140; +$KEY_SETUP = 141; +$KEY_SLEEP = 142; +$KEY_WAKEUP = 143; +$KEY_FILE = 144; +$KEY_SENDFILE = 145; +$KEY_DELETEFILE = 146; +$KEY_XFER = 147; +$KEY_PROG1 = 148; +$KEY_PROG2 = 149; +$KEY_WWW = 150; +$KEY_MSDOS = 151; +$KEY_COFFEE = 152; +$KEY_DIRECTION = 153; +$KEY_CYCLEWINDOWS = 154; +$KEY_MAIL = 155; +$KEY_BOOKMARKS = 156; +$KEY_COMPUTER = 157; +$KEY_BACK = 158; +$KEY_FORWARD = 159; +$KEY_CLOSECD = 160; +$KEY_EJECTCD = 161; +$KEY_EJECTCLOSECD = 162; +$KEY_NEXTSONG = 163; +$KEY_PLAYPAUSE = 164; +$KEY_PREVIOUSSONG = 165; +$KEY_STOPCD = 166; +$KEY_RECORD = 167; +$KEY_REWIND = 168; +$KEY_PHONE = 169; +$KEY_ISO = 170; +$KEY_CONFIG = 171; +$KEY_HOMEPAGE = 172; +$KEY_REFRESH = 173; +$KEY_EXIT = 174; +$KEY_MOVE = 175; +$KEY_EDIT = 176; +$KEY_SCROLLUP = 177; +$KEY_SCROLLDOWN = 178; +$KEY_KPLEFTPAREN = 179; +$KEY_KPRIGHTPAREN = 180; +$KEY_INTL1 = 181; +$KEY_INTL2 = 182; +$KEY_INTL3 = 183; +$KEY_INTL4 = 184; +$KEY_INTL5 = 185; +$KEY_INTL6 = 186; +$KEY_INTL7 = 187; +$KEY_INTL8 = 188; +$KEY_INTL9 = 189; +$KEY_LANG1 = 190; +$KEY_LANG2 = 191; +$KEY_LANG3 = 192; +$KEY_LANG4 = 193; +$KEY_LANG5 = 194; +$KEY_LANG6 = 195; +$KEY_LANG7 = 196; +$KEY_LANG8 = 197; +$KEY_LANG9 = 198; +$KEY_PLAYCD = 200; +$KEY_PAUSECD = 201; +$KEY_PROG3 = 202; +$KEY_PROG4 = 203; +$KEY_SUSPEND = 205; +$KEY_CLOSE = 206; +$KEY_PLAY = 207; +$KEY_FASTFORWARD = 208; +$KEY_BASSBOOST = 209; +$KEY_PRINT = 210; +$KEY_HP = 211; +$KEY_CAMERA = 212; +$KEY_SOUND = 213; +$KEY_QUESTION = 214; +$KEY_EMAIL = 215; +$KEY_CHAT = 216; +$KEY_SEARCH = 217; +$KEY_CONNECT = 218; +$KEY_FINANCE = 219; +$KEY_SPORT = 220; +$KEY_SHOP = 221; +$KEY_ALTERASE = 222; +$KEY_CANCEL = 223; +$KEY_BRIGHTNESSDOWN = 224; +$KEY_BRIGHTNESSUP = 225; +$KEY_MEDIA = 226; +$KEY_UNKNOWN = 240; +$KEY_OK = 0x160; +$KEY_SELECT = 0x161; +$KEY_GOTO = 0x162; +$KEY_CLEAR = 0x163; +$KEY_POWER2 = 0x164; +$KEY_OPTION = 0x165; +$KEY_INFO = 0x166; +$KEY_TIME = 0x167; +$KEY_VENDOR = 0x168; +$KEY_ARCHIVE = 0x169; +$KEY_PROGRAM = 0x16a; +$KEY_CHANNEL = 0x16b; +$KEY_FAVORITES = 0x16c; +$KEY_EPG = 0x16d; +$KEY_PVR = 0x16e; +$KEY_MHP = 0x16f; +$KEY_LANGUAGE = 0x170; +$KEY_TITLE = 0x171; +$KEY_SUBTITLE = 0x172; +$KEY_ANGLE = 0x173; +$KEY_ZOOM = 0x174; +$KEY_MODE = 0x175; +$KEY_KEYBOARD = 0x176; +$KEY_SCREEN = 0x177; +$KEY_PC = 0x178; +$KEY_TV = 0x179; +$KEY_TV2 = 0x17a; +$KEY_VCR = 0x17b; +$KEY_VCR2 = 0x17c; +$KEY_SAT = 0x17d; +$KEY_SAT2 = 0x17e; +$KEY_CD = 0x17f; +$KEY_TAPE = 0x180; +$KEY_RADIO = 0x181; +$KEY_TUNER = 0x182; +$KEY_PLAYER = 0x183; +$KEY_TEXT = 0x184; +$KEY_DVD = 0x185; +$KEY_AUX = 0x186; +$KEY_MP3 = 0x187; +$KEY_AUDIO = 0x188; +$KEY_VIDEO = 0x189; +$KEY_DIRECTORY = 0x18a; +$KEY_LIST = 0x18b; +$KEY_MEMO = 0x18c; +$KEY_CALENDAR = 0x18d; +$KEY_RED = 0x18e; +$KEY_GREEN = 0x18f; +$KEY_YELLOW = 0x190; +$KEY_BLUE = 0x191; +$KEY_CHANNELUP = 0x192; +$KEY_CHANNELDOWN = 0x193; +$KEY_FIRST = 0x194; +$KEY_LAST = 0x195; +$KEY_AB = 0x196; +$KEY_NEXT = 0x197; +$KEY_RESTART = 0x198; +$KEY_SLOW = 0x199; +$KEY_SHUFFLE = 0x19a; +$KEY_BREAK = 0x19b; +$KEY_PREVIOUS = 0x19c; +$KEY_DIGITS = 0x19d; +$KEY_TEEN = 0x19e; +$KEY_TWEN = 0x19f; +$KEY_DEL_EOL = 0x1c0; +$KEY_DEL_EOS = 0x1c1; +$KEY_INS_LINE = 0x1c2; +$KEY_DEL_LINE = 0x1c3; +$KEY_MAX = 0x1ff; + + + $key_lookup{XK_Escape} = $KEY_ESC; + $key_lookup{XK_1} = $KEY_1; + $key_lookup{XK_2} = $KEY_2; + $key_lookup{XK_3} = $KEY_3; + $key_lookup{XK_4} = $KEY_4; + $key_lookup{XK_5} = $KEY_5; + $key_lookup{XK_6} = $KEY_6; + $key_lookup{XK_7} = $KEY_7; + $key_lookup{XK_8} = $KEY_8; + $key_lookup{XK_9} = $KEY_9; + $key_lookup{XK_0} = $KEY_0; + $key_lookup{XK_exclam} = $KEY_1; + $key_lookup{XK_at} = $KEY_2; + $key_lookup{XK_numbersign} = $KEY_3; + $key_lookup{XK_dollar} = $KEY_4; + $key_lookup{XK_percent} = $KEY_5; + $key_lookup{XK_asciicircum} = $KEY_6; + $key_lookup{XK_ampersand} = $KEY_7; + $key_lookup{XK_asterisk} = $KEY_8; + $key_lookup{XK_parenleft} = $KEY_9; + $key_lookup{XK_parenright} = $KEY_0; + $key_lookup{XK_minus} = $KEY_MINUS; + $key_lookup{XK_underscore} = $KEY_MINUS; + $key_lookup{XK_equal} = $KEY_EQUAL; + $key_lookup{XK_plus} = $KEY_EQUAL; + $key_lookup{XK_BackSpace} = $KEY_BACKSPACE; + $key_lookup{XK_Tab} = $KEY_TAB; + $key_lookup{XK_q} = $KEY_Q; + $key_lookup{XK_Q} = $KEY_Q; + $key_lookup{XK_w} = $KEY_W; + $key_lookup{XK_W} = $KEY_W; + $key_lookup{XK_e} = $KEY_E; + $key_lookup{XK_E} = $KEY_E; + $key_lookup{XK_r} = $KEY_R; + $key_lookup{XK_R} = $KEY_R; + $key_lookup{XK_t} = $KEY_T; + $key_lookup{XK_T} = $KEY_T; + $key_lookup{XK_y} = $KEY_Y; + $key_lookup{XK_Y} = $KEY_Y; + $key_lookup{XK_u} = $KEY_U; + $key_lookup{XK_U} = $KEY_U; + $key_lookup{XK_i} = $KEY_I; + $key_lookup{XK_I} = $KEY_I; + $key_lookup{XK_o} = $KEY_O; + $key_lookup{XK_O} = $KEY_O; + $key_lookup{XK_p} = $KEY_P; + $key_lookup{XK_P} = $KEY_P; + $key_lookup{XK_braceleft} = $KEY_LEFTBRACE; + $key_lookup{XK_braceright} = $KEY_RIGHTBRACE; + $key_lookup{XK_bracketleft} = $KEY_LEFTBRACE; + $key_lookup{XK_bracketright} = $KEY_RIGHTBRACE; + $key_lookup{XK_Return} = $KEY_ENTER; + $key_lookup{XK_Control_L} = $KEY_LEFTCTRL; + $key_lookup{XK_a} = $KEY_A; + $key_lookup{XK_A} = $KEY_A; + $key_lookup{XK_s} = $KEY_S; + $key_lookup{XK_S} = $KEY_S; + $key_lookup{XK_d} = $KEY_D; + $key_lookup{XK_D} = $KEY_D; + $key_lookup{XK_f} = $KEY_F; + $key_lookup{XK_F} = $KEY_F; + $key_lookup{XK_g} = $KEY_G; + $key_lookup{XK_G} = $KEY_G; + $key_lookup{XK_h} = $KEY_H; + $key_lookup{XK_H} = $KEY_H; + $key_lookup{XK_j} = $KEY_J; + $key_lookup{XK_J} = $KEY_J; + $key_lookup{XK_k} = $KEY_K; + $key_lookup{XK_K} = $KEY_K; + $key_lookup{XK_l} = $KEY_L; + $key_lookup{XK_L} = $KEY_L; + $key_lookup{XK_semicolon} = $KEY_SEMICOLON; + $key_lookup{XK_colon} = $KEY_SEMICOLON; + $key_lookup{XK_apostrophe} = $KEY_APOSTROPHE; + $key_lookup{XK_quotedbl} = $KEY_APOSTROPHE; + $key_lookup{XK_grave} = $KEY_GRAVE; + $key_lookup{XK_asciitilde} = $KEY_GRAVE; + $key_lookup{XK_Shift_L} = $KEY_LEFTSHIFT; + $key_lookup{XK_backslash} = $KEY_BACKSLASH; + $key_lookup{XK_bar} = $KEY_BACKSLASH; + $key_lookup{XK_z} = $KEY_Z; + $key_lookup{XK_Z} = $KEY_Z; + $key_lookup{XK_x} = $KEY_X; + $key_lookup{XK_X} = $KEY_X; + $key_lookup{XK_c} = $KEY_C; + $key_lookup{XK_C} = $KEY_C; + $key_lookup{XK_v} = $KEY_V; + $key_lookup{XK_V} = $KEY_V; + $key_lookup{XK_b} = $KEY_B; + $key_lookup{XK_B} = $KEY_B; + $key_lookup{XK_n} = $KEY_N; + $key_lookup{XK_N} = $KEY_N; + $key_lookup{XK_m} = $KEY_M; + $key_lookup{XK_M} = $KEY_M; + $key_lookup{XK_comma} = $KEY_COMMA; + $key_lookup{XK_less} = $KEY_COMMA; + $key_lookup{XK_period} = $KEY_DOT; + $key_lookup{XK_greater} = $KEY_DOT; + $key_lookup{XK_slash} = $KEY_SLASH; + $key_lookup{XK_question} = $KEY_SLASH; + $key_lookup{XK_Shift_R} = $KEY_RIGHTSHIFT; + $key_lookup{XK_KP_Multiply} = $KEY_KPASTERISK; + $key_lookup{XK_Alt_L} = $KEY_LEFTALT; + $key_lookup{XK_space} = $KEY_SPACE; + $key_lookup{XK_Caps_Lock} = $KEY_CAPSLOCK; + $key_lookup{XK_F1} = $KEY_F1; + $key_lookup{XK_F2} = $KEY_F2; + $key_lookup{XK_F3} = $KEY_F3; + $key_lookup{XK_F4} = $KEY_F4; + $key_lookup{XK_F5} = $KEY_F5; + $key_lookup{XK_F6} = $KEY_F6; + $key_lookup{XK_F7} = $KEY_F7; + $key_lookup{XK_F8} = $KEY_F8; + $key_lookup{XK_F9} = $KEY_F9; + $key_lookup{XK_F10} = $KEY_F10; + $key_lookup{XK_Num_Lock} = $KEY_NUMLOCK; + $key_lookup{XK_Scroll_Lock} = $KEY_SCROLLLOCK; + $key_lookup{XK_KP_7} = $KEY_KP7; + $key_lookup{XK_KP_8} = $KEY_KP8; + $key_lookup{XK_KP_9} = $KEY_KP9; + $key_lookup{XK_KP_Subtract} = $KEY_KPMINUS; + $key_lookup{XK_KP_4} = $KEY_KP4; + $key_lookup{XK_KP_5} = $KEY_KP5; + $key_lookup{XK_KP_6} = $KEY_KP6; + $key_lookup{XK_KP_Add} = $KEY_KPPLUS; + $key_lookup{XK_KP_1} = $KEY_KP1; + $key_lookup{XK_KP_2} = $KEY_KP2; + $key_lookup{XK_KP_3} = $KEY_KP3; + $key_lookup{XK_KP_0} = $KEY_KP0; + $key_lookup{XK_KP_Decimal} = $KEY_KPDOT; + $key_lookup{XK_F13} = $KEY_F13; + $key_lookup{XK_F11} = $KEY_F11; + $key_lookup{XK_F12} = $KEY_F12; + $key_lookup{XK_F14} = $KEY_F14; + $key_lookup{XK_F15} = $KEY_F15; + $key_lookup{XK_F16} = $KEY_F16; + $key_lookup{XK_F17} = $KEY_F17; + $key_lookup{XK_F18} = $KEY_F18; + $key_lookup{XK_F19} = $KEY_F19; + $key_lookup{XK_F20} = $KEY_F20; + $key_lookup{XK_KP_Enter} = $KEY_KPENTER; + $key_lookup{XK_Control_R} = $KEY_RIGHTCTRL; + $key_lookup{XK_KP_Divide} = $KEY_KPSLASH; + $key_lookup{XK_Sys_Req} = $KEY_SYSRQ; + $key_lookup{XK_Alt_R} = $KEY_RIGHTALT; + $key_lookup{XK_Linefeed} = $KEY_LINEFEED; + $key_lookup{XK_Home} = $KEY_HOME; + $key_lookup{XK_Up} = $KEY_UP; + $key_lookup{XK_Page_Up} = $KEY_PAGEUP; + $key_lookup{XK_Left} = $KEY_LEFT; + $key_lookup{XK_Right} = $KEY_RIGHT; + $key_lookup{XK_End} = $KEY_END; + $key_lookup{XK_Down} = $KEY_DOWN; + $key_lookup{XK_Page_Down} = $KEY_PAGEDOWN; + $key_lookup{XK_Insert} = $KEY_INSERT; + $key_lookup{XK_Delete} = $KEY_DELETE; + $key_lookup{XK_KP_Equal} = $KEY_KPEQUAL; + $key_lookup{XK_Pause} = $KEY_PAUSE; + $key_lookup{XK_F21} = $KEY_F21; + $key_lookup{XK_F22} = $KEY_F22; + $key_lookup{XK_F23} = $KEY_F23; + $key_lookup{XK_F24} = $KEY_F24; + $key_lookup{XK_KP_Separator} = $KEY_KPCOMMA; + $key_lookup{XK_Meta_L} = $KEY_LEFTMETA; + $key_lookup{XK_Meta_R} = $KEY_RIGHTMETA; + $key_lookup{XK_Multi_key} = $KEY_COMPOSE; + +$ABS_MAX = 63; + +$UI_DEV_CREATE = 0x5501; +$UI_DEV_DESTROY = 0x5502; +$UI_SET_EVBIT = 0x40045564; +$UI_SET_KEYBIT = 0x40045565; +$UI_SET_RELBIT = 0x40045566; +$UI_SET_ABSBIT = 0x40045567; + +# FIXME: time hires, etc. +$linux_gettimeofday_syscall = 78; + +$O_RDONLY = 00; +$O_WRONLY = 01; +$O_RDWR = 02; +$O_NDELAY = 04000; + +} diff --git a/x11vnc/pointer.c b/x11vnc/pointer.c index c57d2d7..f2995c3 100644 --- a/x11vnc/pointer.c +++ b/x11vnc/pointer.c @@ -620,24 +620,24 @@ static void pipe_pointer(int mask, int x, int y, rfbClientPtr client) { if (mask == button_mask) { strcat(hint, "None"); } else { - int i, old, new, m = 1, cnt = 0; + int i, old, newb, m = 1, cnt = 0; for (i=0; ihttpDir) { return; @@ -619,8 +619,8 @@ static void reset_httpport(int old, int new) { } } -static void reset_rfbport(int old, int new) { - int rp = new; +static void reset_rfbport(int old, int newp) { + int rp = newp; if (inetd) { rfbLog("reset_rfbport: cannot set rfbport: %d in inetd.\n", rp); @@ -2303,7 +2303,7 @@ char *process_remote_cmd(char *cmd, int stringonly) { * safe_remote_only but at least the command names * are fixed. */ - char *new; + char *newc; int doit = 1; COLON_CHECK("solid_color:") if (query) { @@ -2313,19 +2313,19 @@ char *process_remote_cmd(char *cmd, int stringonly) { } p += strlen("solid_color:"); if (*p != '\0') { - new = strdup(p); + newc = strdup(p); } else { - new = strdup(solid_default); + newc = strdup(solid_default); } - rfbLog("remote_cmd: solid %s -> %s\n", NONUL(solid_str), new); + rfbLog("remote_cmd: solid %s -> %s\n", NONUL(solid_str), newc); if (solid_str) { - if (!strcmp(solid_str, new)) { + if (!strcmp(solid_str, newc)) { doit = 0; } free(solid_str); } - solid_str = new; + solid_str = newc; use_solid_bg = 1; if (raw_fb && !macosx_console) set_raw_fb_params(0); @@ -4213,6 +4213,24 @@ char *process_remote_cmd(char *cmd, int stringonly) { rfbLog("enabled grab_ptr\n"); goto done; } + if (!strcmp(p, "ungrabboth")) { + if (query) { + snprintf(buf, bufn, "ans=%s:%d", p, ungrab_both); + goto qry; + } + ungrab_both = 1; + rfbLog("enabled ungrab_both\n"); + goto done; + } + if (!strcmp(p, "noungrabboth")) { + if (query) { + snprintf(buf, bufn, "ans=%s:%d", p, !ungrab_both); + goto qry; + } + ungrab_both = 0; + rfbLog("disabled ungrab_both\n"); + goto done; + } if (!strcmp(p, "nograbptr")) { int orig = grab_ptr; if (query) { diff --git a/x11vnc/scan.c b/x11vnc/scan.c index b8fa645..1fb7883 100644 --- a/x11vnc/scan.c +++ b/x11vnc/scan.c @@ -2961,7 +2961,17 @@ static void nap_check(int tile_cnt) { now = time(NULL); if (screen_blank > 0) { - int dt_ev, dt_fbu, ms = 2000; + int dt_ev, dt_fbu; + static int ms = 0; + if (ms == 0) { + ms = 2000; + if (getenv("X11VNC_SB_FACTOR")) { + ms = ms * atof(getenv("X11VNC_SB_FACTOR")); + } + if (ms <= 0) { + ms = 2000; + } + } /* if no activity, pause here for a second or so. */ dt_ev = (int) (now - last_event); diff --git a/x11vnc/screen.c b/x11vnc/screen.c index 6bada90..067d144 100644 --- a/x11vnc/screen.c +++ b/x11vnc/screen.c @@ -1461,7 +1461,19 @@ char *vnc_reflect_guess(char *str, char **raw_fb_addr) { char *str0 = strdup(str); if (client == NULL) { - client = rfbGetClient(8, 3, 4); + int bitsPerSample = 8; + int samplesPerPixel = 3; + int bytesPerPixel = 4; + char *s; + s = getenv("X11VNC_REFLECT_bitsPerSample"); + if (s) bitsPerSample = atoi(s); + s = getenv("X11VNC_REFLECT_samplesPerPixel"); + if (s) samplesPerPixel = atoi(s); + s = getenv("X11VNC_REFLECT_bytesPerPixel"); + if (s) bytesPerPixel = atoi(s); + rfbLog("rfbGetClient(bitsPerSample=%d, samplesPerPixel=%d, bytesPerPixel=%d)\n", + bitsPerSample, samplesPerPixel, bytesPerPixel); + client = rfbGetClient(bitsPerSample, samplesPerPixel, bytesPerPixel); } rfbLog("rawfb: %s\n", str); @@ -2086,16 +2098,16 @@ if (db) fprintf(stderr, "initialize_raw_fb reset\n"); /* hmmm, not following directions, see if map: applies */ struct stat sbuf; if (stat(str, &sbuf) == 0) { - char *new; + char *newstr; int len = strlen("map:") + strlen(str) + 1; rfbLog("no type prefix: %s\n", raw_fb_str); rfbLog(" but file exists, so assuming: map:%s\n", raw_fb_str); - new = (char *) malloc(len); - strcpy(new, "map:"); - strcat(new, str); + newstr = (char *) malloc(len); + strcpy(newstr, "map:"); + strcat(newstr, str); free(str); - str = new; + str = newstr; } } diff --git a/x11vnc/sslhelper.c b/x11vnc/sslhelper.c index ca5168f..7057615 100644 --- a/x11vnc/sslhelper.c +++ b/x11vnc/sslhelper.c @@ -125,17 +125,17 @@ char *get_saved_pem(char *save, int create) { sprintf(path, "%s/server%s.pem", cdir, s); if (stat(path, &sbuf) != 0) { - char *new = NULL; + char *new_name = NULL; if (create) { if (inetd || opts_bg) { set_env("GENCERT_NOPROMPT", "1"); } - new = create_tmp_pem(path, prompt); + new_name = create_tmp_pem(path, prompt); if (!getenv("X11VNC_SSL_NO_PASSPHRASE") && !inetd && !opts_bg) { - sslEncKey(new, 0); + sslEncKey(new_name, 0); } } - return new; + return new_name; } if (! quiet) { @@ -332,9 +332,12 @@ char *create_tmp_pem(char *pathin, int prompt) { sprintf(str, tmpl, C, L, OU, O, CN, EM); cnf_fd = mkstemp(cnf); + if (cnf_fd < 0) { + return NULL; + } pem_fd = mkstemp(pem); - - if (cnf_fd < 0 || pem_fd < 0) { + if (pem_fd < 0) { + close(cnf_fd); return NULL; } diff --git a/x11vnc/ssltools.h b/x11vnc/ssltools.h index 9c74d5f..6557a9b 100644 --- a/x11vnc/ssltools.h +++ b/x11vnc/ssltools.h @@ -847,15 +847,18 @@ char find_display[] = "prdpy () {\n" " d1=$1\n" " chvt0=\"\"\n" +" if [ \"X$FIND_DISPLAY_NO_VT_FIND\" != \"X\" ]; then\n" +" :\n" " # we can only do chvt on Linux:\n" -" if [ \"X$uname\" = \"XLinux\" ]; then\n" +" elif [ \"X$uname\" = \"XLinux\" ]; then\n" " d2=$d1\n" " d3=`echo \"$d2\" | sed -e 's/^.*:/:/' -e 's/\\..*$//'`\n" " d4=\"($d2|$d3)\"\n" "\n" " # vt is usually in X server line:\n" " #\n" -" vt=`ps wwwwwaux | grep X | egrep -v 'startx|xinit' | egrep \" $d4 \" | egrep ' vt([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -n 1`\n" +" ps_tmp=`ps wwaux | grep X`\n" +" vt=`echo \"$ps_tmp\" | grep X | egrep -v 'startx|xinit' | egrep \" $d4 \" | egrep ' vt([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -n 1`\n" "\n" " if [ \"X$vt\" != \"X\" ]; then\n" " # strip it out and add it.\n" @@ -865,7 +868,7 @@ char find_display[] = " fi\n" " else\n" " # otherwise look for tty:\n" -" vt=`ps wwwwwaux | grep X | egrep \" $d4 \" | egrep ' tty([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -n 1`\n" +" vt=`echo \"$ps_tmp\" | grep X | egrep \" $d4 \" | egrep ' tty([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -n 1`\n" " if [ \"X$vt\" != \"X\" ]; then\n" " vt=`echo \"$vt\" | sed -e 's/^.* tty\\([0-9][0-9]*\\) .*$/\\1/'`\n" " if echo \"$vt\" | grep '^[0-9][0-9]*$' > /dev/null; then\n" @@ -873,8 +876,12 @@ char find_display[] = " fi\n" " else\n" " # otherwise try lsof:\n" -" pvt=`ps wwwwwaux | grep X | egrep -v 'startx|xinit' | egrep \" $d4 \" | head -n 1 | awk '{print $2}'`\n" -" if [ \"X$pvt\" != \"X\" ]; then\n" +" pvt=`echo \"$ps_tmp\" | grep X | egrep -v 'startx|xinit' | egrep \" $d4 \" | head -n 1 | awk '{print $2}'`\n" +" if [ \"X$FIND_DISPLAY_NO_LSOF\" != \"X\" ]; then\n" +" if [ \"X$pvt\" != \"X\" ]; then\n" +" chvt0=\",XPID=$pvt\"\n" +" fi\n" +" elif [ \"X$pvt\" != \"X\" ]; then\n" " vt=`lsof -b -p \"$pvt\" 2>/dev/null | egrep '/dev/tty([789]|[1-9][0-9][0-9]*)$' | grep -v grep | head -n 1 | awk '{print $NF}' | sed -e 's,/dev/tty,,'`\n" " if echo \"$vt\" | grep '^[0-9][0-9]*$' > /dev/null; then\n" " chvt0=\",VT=$vt\"\n" @@ -902,9 +909,9 @@ char find_display[] = "if [ \"X$uname\" = \"XDarwin\" ]; then\n" " psout=`ps aux 2>/dev/null | grep -wv PID | grep -v grep`\n" "elif [ \"X$uname\" = \"XLinux\" -o \"X$is_bsd\" = \"X1\" ]; then\n" -" psout=`ps wwwaux 2>/dev/null | grep -wv PID | grep -v grep`\n" +" psout=`ps wwaux 2>/dev/null | grep -wv PID | grep -v grep`\n" "elif [ \"X$uname\" = \"XSunOS\" -a -x /usr/ucb/ps ]; then\n" -" psout=`/usr/ucb/ps wwwaux 2>/dev/null | grep -wv PID | grep -v grep`\n" +" psout=`/usr/ucb/ps wwaux 2>/dev/null | grep -wv PID | grep -v grep`\n" "else\n" " psout=`ps -ef 2>/dev/null | grep -wv PID | grep -v grep`\n" "fi\n" @@ -1192,6 +1199,8 @@ char find_display[] = "\n" "# try the items in the list:\n" "#\n" +"nsout_trim=`echo \"$nsout\" | grep \"/tmp/.X11-unix/\"`\n" +"#\n" "for p in $list\n" "do\n" " xa=`echo \"$p\" | awk -F, '{print $2}'`\n" @@ -1205,7 +1214,7 @@ char find_display[] = " # check for the local X11 files:\n" " xd=\"/tmp/.X11-unix/X$d\"\n" " if [ -r \"$xd\" -o -w \"$xd\" -o -x \"$xd\" ]; then\n" -" if echo \"$nsout\" | grep \"/tmp/.X11-unix/X$d[ ]*\\$\" > /dev/null; then\n" +" if echo \"$nsout_trim\" | grep \"/tmp/.X11-unix/X$d[ ]*\\$\" > /dev/null; then\n" " ok=1\n" " fi\n" " fi\n" @@ -1473,6 +1482,7 @@ char create_display[] = "COLUMNS=256\n" "export COLUMNS\n" "\n" +"LC_ALL_save=$LC_ALL\n" "LC_ALL=C\n" "export LC_ALL\n" "\n" @@ -1491,11 +1501,12 @@ char create_display[] = " if [ \"X$have_netstat\" != \"X\" ]; then\n" " nsout=`$have_netstat -an`\n" " fi\n" +" nsout_trim=`echo \"$nsout\" | grep \"/tmp/.X11-unix/\"`\n" " while [ $try -lt $sry ]\n" " do\n" " tlock=\"/tmp/.X${try}-lock\"\n" " if [ -r $tlock ]; then\n" -" if echo \"$nsout\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n" +" if echo \"$nsout_trim\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n" " :\n" " else\n" " pid=`head -n 1 $tlock 2>/dev/null | sed -e 's/[ ]//g' | grep '^[0-9][0-9]*$'`\n" @@ -1513,7 +1524,7 @@ char create_display[] = " fi\n" " fi\n" " if [ ! -f $tlock ]; then\n" -" if echo \"$nsout\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n" +" if echo \"$nsout_trim\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n" " :\n" " else\n" " n=$try\n" @@ -1829,6 +1840,16 @@ char create_display[] = " echo \"\" 1>&2\n" "}\n" "\n" +"put_back_LC_ALL() {\n" +" if [ \"X$X11VNC_CREATE_LC_ALL_C_OK\" = \"X\" ]; then\n" +" if [ \"X$LC_ALL_save\" = \"X\" ]; then\n" +" unset LC_ALL\n" +" else\n" +" LC_ALL=\"$LC_ALL_save\"\n" +" fi\n" +" fi\n" +"}\n" +"\n" "server() {\n" " authfile=`auth`\n" " sess=`findsession`\n" @@ -1894,6 +1915,7 @@ char create_display[] = " # ns=2\n" " #fi\n" "\n" +"\n" " if [ \"X$use_xdmcp_query\" = \"X1\" ]; then\n" " # we cannot use -nolisten tcp\n" " if [ \"X$FD_XDMCP_IF\" != \"X\" ]; then\n" @@ -1908,6 +1930,7 @@ char create_display[] = " lhost=localhost\n" " fi\n" " echo \"$* -once -query $lhost $FD_OPTS\" 1>&2\n" +" put_back_LC_ALL\n" " if [ \"X$have_root\" != \"X\" ]; then\n" " if [ -r $authfile ]; then\n" " $have_nohup $* -once -query $lhost -auth $authfile $FD_OPTS 1>&2 &\n" @@ -1932,6 +1955,7 @@ char create_display[] = " sxcmd=$have_startx\n" " fi\n" " echo \"$sxcmd $sess -- $* $nolisten -auth $authfile $FD_OPTS\" 1>&2\n" +" put_back_LC_ALL\n" " if [ \"X$have_root\" != \"X\" ]; then\n" " $sxcmd $sess -- $* $nolisten -auth $authfile $FD_OPTS 1>&2 &\n" " else\n" @@ -1947,6 +1971,7 @@ char create_display[] = " else\n" " # need to emulate startx/xinit ourselves...\n" " echo \"$* $nolisten -auth $authfile $FD_OPTS\" 1>&2\n" +" put_back_LC_ALL\n" " if [ \"X$have_root\" != \"X\" ]; then\n" " $have_nohup $* $nolisten -auth $authfile $FD_OPTS 1>&2 &\n" " pid=$!\n" @@ -1964,10 +1989,14 @@ char create_display[] = " $have_nohup sh -c \"(sleep 3; $sess)\" 1>&2 &\n" " fi\n" " fi\n" +"\n" +" LC_ALL=C\n" +" export LC_ALL\n" +"\n" " if uname | grep SunOS > /dev/null; then\n" -" $have_nohup sh -c \"(sleep 60; rm -f $rmf)\" 1>&2 &\n" +" $have_nohup sh -c \"(sleep 150; rm -f $rmf)\" 1>&2 &\n" " else\n" -" $have_nohup sh -c \"(sleep 60; rm -f $rmf $authfile)\" 1>&2 &\n" +" $have_nohup sh -c \"(sleep 150; rm -f $rmf $authfile)\" 1>&2 &\n" " fi\n" "\n" " t=0\n" diff --git a/x11vnc/uinput.c b/x11vnc/uinput.c index 2dfb9fe..92bd1d8 100644 --- a/x11vnc/uinput.c +++ b/x11vnc/uinput.c @@ -63,6 +63,7 @@ so, delete this exception statement from your version. int check_uinput(void); int initialize_uinput(void); +void shutdown_uinput(void); int set_uinput_accel(char *str); int set_uinput_thresh(char *str); void set_uinput_reset(int ms); @@ -83,20 +84,29 @@ static void init_key_tracker(void); static int mod_is_down(void); static int key_is_down(void); 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 = 0; +static int direct_rel_fd = -1; +static int direct_abs_fd = -1; +static int direct_btn_fd = -1; +static int direct_key_fd = -1; static int bmask = 0; +static int db = 0; static char *injectable = NULL; static char *uinput_dev = NULL; +static char *tslib_cal = NULL; +static double a[7]; static int uinput_touchscreen = 0; static int uinput_abs = 0; +static int btn_touch = 0; +static int dragskip = 0; +static int touch_always = 0; +static int touch_pressure = 1; static int abs_x = 0, abs_y = 0; static char *devs[] = { @@ -106,6 +116,13 @@ static char *devs[] = { NULL }; +#ifndef O_NDELAY +#ifdef O_NONBLOCK +#define O_NDELAY O_NONBLOCK +#else +#define O_NDELAY 0 +#endif +#endif /* * User may need to do: @@ -137,7 +154,7 @@ int check_uinput(void) { fd = -1; i = 0; while (devs[i] != NULL) { - if ( (fd = open(devs[i++], O_RDWR)) >= 0) { + if ( (fd = open(devs[i++], O_WRONLY | O_NDELAY)) >= 0) { break; } } @@ -190,39 +207,187 @@ static int key_is_down(void) { return 0; } -static void shutdown_uinput(void) { +void shutdown_uinput(void) { #ifdef UINPUT_OK - ioctl(fd, UI_DEV_DESTROY); + if (fd >= 0) { + if (db) { + rfbLog("shutdown_uinput called on fd=%d\n", fd); + } + ioctl(fd, UI_DEV_DESTROY); + close(fd); + fd = -1; + } + + /* close direct injection files too: */ + if (direct_rel_fd >= 0) close(direct_rel_fd); + if (direct_abs_fd >= 0) close(direct_abs_fd); + if (direct_btn_fd >= 0) close(direct_btn_fd); + if (direct_key_fd >= 0) close(direct_key_fd); + direct_rel_fd = -1; + direct_abs_fd = -1; + direct_btn_fd = -1; + direct_key_fd = -1; +#endif +} + +/* +grep BUS_ /usr/include/linux/input.h | awk '{print $2}' | perl -e 'while (<>) {chomp; print "#ifdef $_\n\t\tif(!strcmp(s, \"$_\"))\tudev.id.bustype = $_\n#endif\n"}' + */ +static int get_bustype(char *s) { +#ifdef UINPUT_OK + + if (!s) return 0; + +#ifdef BUS_PCI + if(!strcmp(s, "BUS_PCI")) return BUS_PCI; +#endif +#ifdef BUS_ISAPNP + if(!strcmp(s, "BUS_ISAPNP")) return BUS_ISAPNP; +#endif +#ifdef BUS_USB + if(!strcmp(s, "BUS_USB")) return BUS_USB; +#endif +#ifdef BUS_HIL + if(!strcmp(s, "BUS_HIL")) return BUS_HIL; +#endif +#ifdef BUS_BLUETOOTH + if(!strcmp(s, "BUS_BLUETOOTH")) return BUS_BLUETOOTH; +#endif +#ifdef BUS_VIRTUAL + if(!strcmp(s, "BUS_VIRTUAL")) return BUS_VIRTUAL; +#endif +#ifdef BUS_ISA + if(!strcmp(s, "BUS_ISA")) return BUS_ISA; +#endif +#ifdef BUS_I8042 + if(!strcmp(s, "BUS_I8042")) return BUS_I8042; +#endif +#ifdef BUS_XTKBD + if(!strcmp(s, "BUS_XTKBD")) return BUS_XTKBD; +#endif +#ifdef BUS_RS232 + if(!strcmp(s, "BUS_RS232")) return BUS_RS232; +#endif +#ifdef BUS_GAMEPORT + if(!strcmp(s, "BUS_GAMEPORT")) return BUS_GAMEPORT; +#endif +#ifdef BUS_PARPORT + if(!strcmp(s, "BUS_PARPORT")) return BUS_PARPORT; +#endif +#ifdef BUS_AMIGA + if(!strcmp(s, "BUS_AMIGA")) return BUS_AMIGA; #endif +#ifdef BUS_ADB + if(!strcmp(s, "BUS_ADB")) return BUS_ADB; +#endif +#ifdef BUS_I2C + if(!strcmp(s, "BUS_I2C")) return BUS_I2C; +#endif +#ifdef BUS_HOST + if(!strcmp(s, "BUS_HOST")) return BUS_HOST; +#endif +#ifdef BUS_GSC + if(!strcmp(s, "BUS_GSC")) return BUS_GSC; +#endif +#ifdef BUS_ATARI + if(!strcmp(s, "BUS_ATARI")) return BUS_ATARI; +#endif + if (atoi(s) > 0) { + return atoi(s); + } + +#endif + return 0; +} + +static void load_tslib_cal(void) { + FILE *f; + char line[1024], *p; + int i; + + /* /etc/pointercal -528 33408 -3417516 -44200 408 40292028 56541 */ + + /* this is the identity transformation: */ + a[0] = 1.0; + a[1] = 0.0; + a[2] = 0.0; + a[3] = 0.0; + a[4] = 1.0; + a[5] = 0.0; + a[6] = 1.0; + + if (tslib_cal == NULL) { + return; + } + + rfbLog("load_tslib_cal: reading %s\n", tslib_cal); + f = fopen(tslib_cal, "r"); + if (f == NULL) { + rfbLogPerror("load_tslib_cal: fopen"); + clean_up_exit(1); + } + + if (fgets(line, sizeof(line), f) == NULL) { + rfbLogPerror("load_tslib_cal: fgets"); + clean_up_exit(1); + } + fclose(f); + + p = strtok(line, " \t"); + i = 0; + while (p) { + a[i] = (double) atoi(p); + rfbLog("load_tslib_cal: a[%d] %.3f\n", i, a[i]); + p = strtok(NULL, " \t"); + i++; + if (i >= 7) { + break; + } + } + if (i != 7) { + rfbLog("load_tslib_cal: invalid tslib file format: i=%d %s\n", + i, tslib_cal); + clean_up_exit(1); + } } + int initialize_uinput(void) { #ifndef UINPUT_OK return 0; #else int i; + char *s; struct uinput_user_dev udev; if (fd >= 0) { shutdown_uinput(); - close(fd); - fd = -1; } + fd = -1; if (getenv("X11VNC_UINPUT_DEBUG")) { db = atoi(getenv("X11VNC_UINPUT_DEBUG")); rfbLog("set uinput debug to: %d\n", db); } + if (tslib_cal) { + load_tslib_cal(); + } + init_key_tracker(); if (uinput_dev) { - fd = open(uinput_dev, O_RDWR); - rfbLog("initialize_uinput: using: %s %d\n", uinput_dev, fd); + if (!strcmp(uinput_dev, "nouinput")) { + rfbLog("initialize_uinput: not creating uinput device.\n"); + return 1; + } else { + fd = open(uinput_dev, O_WRONLY | O_NDELAY); + 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) { + if ( (fd = open(devs[i], O_WRONLY | O_NDELAY)) >= 0) { rfbLog("initialize_uinput: using: %s %d\n", devs[i], fd); break; @@ -233,15 +398,29 @@ int initialize_uinput(void) { if (fd < 0) { rfbLog("initialize_uinput: could not open an uinput device.\n"); rfbLogPerror("open"); - clean_up_exit(1); + if (direct_rel_fd < 0 && direct_abs_fd < 0 && direct_btn_fd < 0 && direct_key_fd < 0) { + clean_up_exit(1); + } + return 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; + s = getenv("X11VNC_UINPUT_BUS"); + if (s) { + udev.id.bustype = get_bustype(s); + } else if (0) { + udev.id.bustype = BUS_USB; + } + + s = getenv("X11VNC_UINPUT_VERSION"); + if (s) { + udev.id.version = atoi(s); + } else if (0) { + udev.id.version = 4; + } ioctl(fd, UI_SET_EVBIT, EV_REL); ioctl(fd, UI_SET_RELBIT, REL_X); @@ -249,6 +428,8 @@ int initialize_uinput(void) { ioctl(fd, UI_SET_EVBIT, EV_KEY); + ioctl(fd, UI_SET_EVBIT, EV_SYN); + for (i=0; i < 256; i++) { ioctl(fd, UI_SET_KEYBIT, i); } @@ -289,6 +470,23 @@ int initialize_uinput(void) { set_uinput_accel_xy(1.0, 1.0); } + if (db) { + rfbLog(" udev.name: %s\n", udev.name); + rfbLog(" udev.id.bustype: %d\n", udev.id.bustype); + rfbLog(" udev.id.vendor: %d\n", udev.id.vendor); + rfbLog(" udev.id.product: %d\n", udev.id.product); + rfbLog(" udev.id.version: %d\n", udev.id.version); + rfbLog(" udev.ff_effects_max: %d\n", udev.ff_effects_max); + rfbLog(" udev.absmin[ABS_X]: %d\n", udev.absmin[ABS_X]); + rfbLog(" udev.absmax[ABS_X]: %d\n", udev.absmax[ABS_X]); + rfbLog(" udev.absfuzz[ABS_X]: %d\n", udev.absfuzz[ABS_X]); + rfbLog(" udev.absflat[ABS_X]: %d\n", udev.absflat[ABS_X]); + rfbLog(" udev.absmin[ABS_Y]: %d\n", udev.absmin[ABS_Y]); + rfbLog(" udev.absmax[ABS_Y]: %d\n", udev.absmax[ABS_Y]); + rfbLog(" udev.absfuzz[ABS_Y]: %d\n", udev.absfuzz[ABS_Y]); + rfbLog(" udev.absflat[ABS_Y]: %d\n", udev.absflat[ABS_Y]); + } + write(fd, &udev, sizeof(udev)); if (ioctl(fd, UI_DEV_CREATE) != 0) { @@ -408,6 +606,11 @@ void parse_uinput_str(char *in) { uinput_abs = 0; abs_x = abs_y = 0; + if (tslib_cal) { + free(tslib_cal); + tslib_cal = NULL; + } + p = strtok(str, ","); while (p) { if (p[0] == '/') { @@ -415,6 +618,11 @@ void parse_uinput_str(char *in) { free(uinput_dev); } uinput_dev = strdup(p); + } else if (strstr(p, "nouinput") == p) { + if (uinput_dev) { + free(uinput_dev); + } + uinput_dev = strdup(p); } else if (strstr(p, "accel=") == p) { q = p + strlen("accel="); if (! set_uinput_accel(q)) { @@ -435,6 +643,12 @@ void parse_uinput_str(char *in) { free(injectable); } injectable = strdup(p); + } else if (strstr(p, "touch_always=") == p) { + touch_always = atoi(p + strlen("touch_always=")); + } else if (strstr(p, "btn_touch=") == p) { + btn_touch = atoi(p + strlen("btn_touch=")); + } else if (strstr(p, "dragskip=") == p) { + dragskip = atoi(p + strlen("dragskip=")); } else if (strstr(p, "touch") == p) { int gw, gh; q = strchr(p, '='); @@ -452,7 +666,38 @@ void parse_uinput_str(char *in) { abs_x = gw; abs_y = gh; } - + } else if (strstr(p, "pressure=") == p) { + touch_pressure = atoi(p + strlen("pressure=")); + } else if (strstr(p, "direct_rel=") == p) { + direct_rel_fd = open(p+strlen("direct_rel="), O_WRONLY); + if (direct_rel_fd < 0) { + rfbLogPerror("uinput: direct_rel open"); + } else { + rfbLog("uinput: opened: %s fd=%d\n", p, direct_rel_fd); + } + } else if (strstr(p, "direct_abs=") == p) { + direct_abs_fd = open(p+strlen("direct_abs="), O_WRONLY); + if (direct_abs_fd < 0) { + rfbLogPerror("uinput: direct_abs open"); + } else { + rfbLog("uinput: opened: %s fd=%d\n", p, direct_abs_fd); + } + } else if (strstr(p, "direct_btn=") == p) { + direct_btn_fd = open(p+strlen("direct_btn="), O_WRONLY); + if (direct_btn_fd < 0) { + rfbLogPerror("uinput: direct_btn open"); + } else { + rfbLog("uinput: opened: %s fd=%d\n", p, direct_btn_fd); + } + } else if (strstr(p, "direct_key=") == p) { + direct_key_fd = open(p+strlen("direct_key="), O_WRONLY); + if (direct_key_fd < 0) { + rfbLogPerror("uinput: direct_key open"); + } else { + rfbLog("uinput: opened: %s fd=%d\n", p, direct_key_fd); + } + } else if (strstr(p, "tslib_cal=") == p) { + tslib_cal = strdup(p+strlen("tslib_cal=")); } else { rfbLog("invalid UINPUT option: %s\n", p); clean_up_exit(1); @@ -465,6 +710,7 @@ void parse_uinput_str(char *in) { static void ptr_move(int dx, int dy) { #ifdef UINPUT_OK struct input_event ev; + int d = direct_rel_fd < 0 ? fd : direct_rel_fd; if (injectable && strchr(injectable, 'M') == NULL) { return; @@ -472,29 +718,45 @@ static void ptr_move(int dx, int dy) { memset(&ev, 0, sizeof(ev)); + if (db) fprintf(stderr, "ptr_move(%d, %d) fd=%d\n", dx, dy, d); + gettimeofday(&ev.time, NULL); ev.type = EV_REL; ev.code = REL_Y; ev.value = dy; - write(fd, &ev, sizeof(ev)); + write(d, &ev, sizeof(ev)); ev.type = EV_REL; ev.code = REL_X; ev.value = dx; - write(fd, &ev, sizeof(ev)); + write(d, &ev, sizeof(ev)); ev.type = EV_SYN; ev.code = SYN_REPORT; ev.value = 0; - write(fd, &ev, sizeof(ev)); + write(d, &ev, sizeof(ev)); #else if (!dx || !dy) {} #endif } -static void ptr_abs(int x, int y) { +static void apply_tslib(int *x, int *y) { + double x1 = *x, y1 = *y, x2, y2; + + /* this is the inverse of the tslib linear transform: */ + x2 = (a[4] * (a[6] * x1 - a[2]) - a[1] * (a[6] * y1 - a[5]))/(a[4]*a[0] - a[1]*a[3]); + y2 = (a[0] * (a[6] * y1 - a[5]) - a[3] * (a[6] * x1 - a[2]))/(a[4]*a[0] - a[1]*a[3]); + + *x = (int) x2; + *y = (int) y2; +} + + +static void ptr_abs(int x, int y, int p) { #ifdef UINPUT_OK struct input_event ev; + int x0, y0; + int d = direct_abs_fd < 0 ? fd : direct_abs_fd; if (injectable && strchr(injectable, 'M') == NULL) { return; @@ -502,23 +764,37 @@ static void ptr_abs(int x, int y) { memset(&ev, 0, sizeof(ev)); - if (db) fprintf(stderr, "ptr_abs(%d, %d)\n", x, y); + x0 = x; + y0 = y; + + if (tslib_cal) { + apply_tslib(&x, &y); + } + + if (db) fprintf(stderr, "ptr_abs(%d, %d => %d %d, p=%d) fd=%d\n", x0, y0, x, y, p, d); gettimeofday(&ev.time, NULL); ev.type = EV_ABS; ev.code = ABS_Y; ev.value = y; - write(fd, &ev, sizeof(ev)); + write(d, &ev, sizeof(ev)); ev.type = EV_ABS; ev.code = ABS_X; ev.value = x; - write(fd, &ev, sizeof(ev)); + write(d, &ev, sizeof(ev)); + + if (p >= 0) { + ev.type = EV_ABS; + ev.code = ABS_PRESSURE; + ev.value = p; + write(d, &ev, sizeof(ev)); + } ev.type = EV_SYN; ev.code = SYN_REPORT; ev.value = 0; - write(fd, &ev, sizeof(ev)); + write(d, &ev, sizeof(ev)); #else if (!x || !y) {} #endif @@ -658,7 +934,7 @@ static void ptr_rel(int dx, int dy) { resid_y -= dyf; if (db > 1) fprintf(stderr, "*%s resid: dx dy: %d %d %f %f\n", accel > 1 ? "*" : " ", dxf, dyf, resid_x, resid_y); -if (0) {usleep(100*1000)}; +if (0) {usleep(100*1000) ;} ptr_move(dxf, dyf); } } @@ -667,12 +943,13 @@ if (0) {usleep(100*1000)}; static void button_click(int down, int btn) { #ifdef UINPUT_OK struct input_event ev; + int d = direct_btn_fd < 0 ? fd : direct_btn_fd; if (injectable && strchr(injectable, 'B') == NULL) { return; } - if (db) fprintf(stderr, "button_click: btn %d %s\n", btn, down ? "down" : "up"); + if (db) fprintf(stderr, "button_click: btn %d %s fd=%d\n", btn, down ? "down" : "up", d); memset(&ev, 0, sizeof(ev)); gettimeofday(&ev.time, NULL); @@ -696,12 +973,12 @@ static void button_click(int down, int btn) { return; } - write(fd, &ev, sizeof(ev)); + write(d, &ev, sizeof(ev)); ev.type = EV_SYN; ev.code = SYN_REPORT; ev.value = 0; - write(fd, &ev, sizeof(ev)); + write(d, &ev, sizeof(ev)); last_button_click = dnow(); #else @@ -756,15 +1033,6 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) { do_reset = 1; } if (uinput_abs) { -#if 0 - /* this is a bad idea... need to do something else */ - if (do_reset) { - ptr_abs(dpy_x, dpy_y); - usleep(10*1000); - ptr_abs(x, y); - usleep(10*1000); - } -#endif do_reset = 0; } @@ -849,7 +1117,7 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) { } else { ptr_rel(x, y); } - if (1) {usleep(10*1000)}; + if (1) {usleep(10*1000) ;} last_x = x; last_y = y; @@ -863,8 +1131,10 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) { if (input.motion) { if (x != last_x || y != last_y) { - if (uinput_abs) { - ptr_abs(x, y); + if (uinput_touchscreen) { + ; + } else if (uinput_abs) { + ptr_abs(x, y, -1); } else { ptr_rel(x - last_x, y - last_y); } @@ -888,7 +1158,46 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) { fprintf(stderr, "button_mask: %s\n", bitprint(button_mask, 16)); } - if (mask != last_mask) { + if (uinput_touchscreen) { + if (!btn_touch) { + static int down_count = 0; + int p = touch_pressure >=0 ? touch_pressure : 0; + if (!last_mask && !mask) { + if (touch_always) { + ptr_abs(last_x, last_y, 0); + } + } else if (!last_mask && mask) { + ptr_abs(last_x, last_y, p); + down_count = 0; + } else if (last_mask && !mask) { + ptr_abs(last_x, last_y, 0); + } else if (last_mask && mask) { + down_count++; + if (dragskip > 0) { + if (down_count % dragskip == 0) { + ptr_abs(last_x, last_y, p); + } + } else { + ptr_abs(last_x, last_y, p); + } + } + } else { + if (!last_mask && !mask) { + if (touch_always) { + ptr_abs(last_x, last_y, 0); + } + } else if (!last_mask && mask) { + ptr_abs(last_x, last_y, 0); + button_click(1, 0); + } else if (last_mask && !mask) { + ptr_abs(last_x, last_y, 0); + button_click(0, 0); + } else if (last_mask && mask) { + ; + } + } + last_mask = mask; + } else if (mask != last_mask) { int i; for (i=1; i <= MAX_BUTTONS; i++) { int down, b = 1 << (i-1); @@ -902,6 +1211,9 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) { } button_click(down, i); } + if (mask && uinput_abs && touch_pressure >= 0) { + ptr_abs(last_x, last_y, touch_pressure); + } last_mask = mask; } bmask = mask; @@ -912,6 +1224,7 @@ void uinput_key_command(int down, int keysym, rfbClientPtr client) { struct input_event ev; int scancode; allowed_input_t input; + int d = direct_key_fd < 0 ? fd : direct_key_fd; if (injectable && strchr(injectable, 'K') == NULL) { return; @@ -929,7 +1242,7 @@ void uinput_key_command(int down, int keysym, rfbClientPtr client) { if (scancode < 0) { return; } - if (db) fprintf(stderr, "uinput_key_command: %d -> %d %s\n", keysym, scancode, down ? "down" : "up"); + if (db) fprintf(stderr, "uinput_key_command: %d -> %d %s fd=%d\n", keysym, scancode, down ? "down" : "up", d); memset(&ev, 0, sizeof(ev)); gettimeofday(&ev.time, NULL); @@ -937,12 +1250,12 @@ void uinput_key_command(int down, int keysym, rfbClientPtr client) { ev.code = (unsigned char) scancode; ev.value = down; - write(fd, &ev, sizeof(ev)); + write(d, &ev, sizeof(ev)); ev.type = EV_SYN; ev.code = SYN_REPORT; ev.value = 0; - write(fd, &ev, sizeof(ev)); + write(d, &ev, sizeof(ev)); if (0 <= scancode && scancode < 256) { key_pressed[scancode] = down ? 1 : 0; @@ -952,6 +1265,10 @@ void uinput_key_command(int down, int keysym, rfbClientPtr client) { #endif } +#if 0 + grep 'case XK_' x0vnc.c | sed -e 's/case /$key_lookup{/' -e 's/:/}/' -e 's/return /= $/' +#endif + static int lookup_code(int keysym) { if (keysym == NoSymbol) { diff --git a/x11vnc/uinput.h b/x11vnc/uinput.h index 01e8708..346e97c 100644 --- a/x11vnc/uinput.h +++ b/x11vnc/uinput.h @@ -37,6 +37,7 @@ so, delete this exception statement from your version. extern int check_uinput(void); extern int initialize_uinput(void); +extern void shutdown_uinput(void); extern int set_uinput_accel(char *str); extern int set_uinput_thresh(char *str); extern void set_uinput_reset(int ms); diff --git a/x11vnc/unixpw.c b/x11vnc/unixpw.c index b610fa9..ccdb195 100644 --- a/x11vnc/unixpw.c +++ b/x11vnc/unixpw.c @@ -565,6 +565,12 @@ char *get_pty_ptmx(int *fd_p) { ioctl(fd, TIOCFLUSH, (char *) 0); #endif + if (strlen(slave) > sizeof(slave_str)/2) { + rfbLog("get_pty_ptmx: slave string length too long.\n"); + close(fd); + return NULL; + } + strcpy(slave_str, slave); *fd_p = fd; return slave_str; @@ -1743,7 +1749,7 @@ void unixpw_keystroke(rfbBool down, rfbKeySym keysym, int init) { down ? "down":"up ", keysym, keystr); } - if (keysym == XK_Return || keysym == XK_Linefeed) { + if (keysym == XK_Return || keysym == XK_Linefeed || keysym == XK_Tab) { /* let "up" pass down below for Return case */ if (down) { return; @@ -1866,7 +1872,7 @@ void unixpw_keystroke(rfbBool down, rfbKeySym keysym, int init) { return; } - if (keysym == XK_Return || keysym == XK_Linefeed) { + if (keysym == XK_Return || keysym == XK_Linefeed || keysym == XK_Tab) { char pw[] = "Password: "; if (down) { diff --git a/x11vnc/user.c b/x11vnc/user.c index e9028ba..f09fbb9 100644 --- a/x11vnc/user.c +++ b/x11vnc/user.c @@ -2769,6 +2769,7 @@ if (db) fprintf(stderr, "\n"); clean_up_exit(1); } n = fread(line2, 1, 16384, p); + pclose(p); } if (tmp_fd >= 0) { unlink(tmp); diff --git a/x11vnc/util.h b/x11vnc/util.h index 64c9f76..55585cf 100644 --- a/x11vnc/util.h +++ b/x11vnc/util.h @@ -96,8 +96,8 @@ extern struct timeval _mysleep; ((KeySym)(keysym) != XK_Caps_Lock) && ((KeySym)(keysym) != XK_Shift_Lock))) /* - * Not sure why... but when threaded we have to mutex our X11 calls to - * avoid XIO crashes. + * When threaded we have to mutex our X11 calls to avoid XIO crashes + * due to callbacks. */ #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD extern MUTEX(x11Mutex); diff --git a/x11vnc/v4l.c b/x11vnc/v4l.c index 84bfd08..86c33a6 100644 --- a/x11vnc/v4l.c +++ b/x11vnc/v4l.c @@ -434,23 +434,23 @@ static void apply_settings(char *dev, char *settings, int *fd) { static double dval = 0.05; static int v4l1_dpct(int old, int d) { - int new, max = V4L1_MAX; + int newval, max = V4L1_MAX; /* -1 and 1 are special cases for "small increments" */ if (d == -1) { - new = old - (int) (dval * max); + newval = old - (int) (dval * max); } else if (d == 1) { - new = old + (int) (dval * max); + newval = old + (int) (dval * max); } else { - new = (d * max)/100; + newval = (d * max)/100; } - if (new < 0) { - new = 0; + if (newval < 0) { + newval = 0; } - if (new > max) { - new = max; + if (newval > max) { + newval = max; } - return new; + return newval; } static void v4l_requery(void) { diff --git a/x11vnc/x11vnc.1 b/x11vnc/x11vnc.1 index cfab152..8a92433 100644 --- a/x11vnc/x11vnc.1 +++ b/x11vnc/x11vnc.1 @@ -1,8 +1,8 @@ .\" This file was automatically generated from x11vnc -help output. -.TH X11VNC "1" "September 2010" "x11vnc " "User Commands" +.TH X11VNC "1" "December 2010" "x11vnc " "User Commands" .SH NAME x11vnc - allow VNC connections to real X11 displays - version: 0.9.13, lastmod: 2010-09-10 + version: 0.9.13, lastmod: 2010-12-20 .SH SYNOPSIS .B x11vnc [OPTION]... @@ -925,6 +925,11 @@ server with them, grabbing the keyboard himself, etc. Some degree of cooperation from the person at the display is assumed. This is intended for remote help-desk or educational usage modes. +.IP +Note: on some recent (12/2010) X servers and/or +desktops, \fB-grabkbd\fR no longer works: it prevents the +window manager from resizing windows and similar things. +Try \fB-ungrabboth\fR below (might not work.) .PP \fB-grabptr\fR .IP @@ -940,6 +945,13 @@ for resizes, etc, will act on the local user's input. Again, some degree of cooperation from the person at the display is assumed. .PP +\fB-ungrabboth\fR +.IP +Whenever there is any input (either keyboard or +pointer), ungrab *both* the keyboard and the pointer +while injecting the synthetic input. This is to allow +window managers, etc. a chance to grab. +.PP \fB-grabalways\fR .IP Apply both \fB-grabkbd\fR and \fB-grabptr\fR even when no VNC @@ -1569,6 +1581,15 @@ xauthority data for the display. For example; .IP xauth extract - $DISPLAY" .IP +NOTE: As specified in the previous paragraph, you can +supply your own WAIT:cmd=... program or script, BUT +there are two very useful *BUILT-IN* ones: FINDDISPLAY +(alias \fB-find\fR above) and FINDCREATEDISPLAY (alias \fB-create\fR +above.) Most people use these instead of creating +their own script. Read the following (especially the +BUILT-IN modes sections) to see how to configure these +two useful builtin \fB-display\fR WAIT: modes. +.IP In the case of \fB-unixpw\fR (and \fB-unixpw_nis\fR only if x11vnc is running as root), then the cmd= command is run as the user who just authenticated via the login and @@ -1600,6 +1621,11 @@ type and enter your password incorrectly, to retrieve your long "login:" line press the Up arrow once (before typing anything else). .IP +Most of these colon options only apply to the builtin +FINDDISPLAY and FINDCREATEDISPLAY modes, but note +that they are passed to the extrenal command in the +environment as well and so could be used. +.IP In the login panel, press F1 to get a list of the available options that you can add after the username. .IP @@ -1633,23 +1659,19 @@ prompt. For example \fB-env\fR FD_USERPREFS=.x11vnc_create and the user put "geom=1600x1200" in his ~/.x11vnc_create file. .IP -To troubleshoot the FINDCREATEDISPLAY mechanism, -set the following env. var. to an output log file, -e.g \fB-env\fR CREATE_DISPLAY_OUTPUT=/tmp/mydebug.txt -.IP To disable the option setting set the environment variable X11VNC_NO_UNIXPW_OPTS=1 before starting x11vnc. To set any other options, the user can use the gui (x11vnc \fB-gui\fR connect) or the remote control method (x11vnc \fB-R\fR opt:val) during his VNC session. .IP -The combination of \fB-display\fR WAIT:cmd=... and \fB-unixpw\fR -allows automatic pairing of an unix authenticated VNC -user with his desktop. This could be very useful on -SunRays and also any system where multiple users share -a given machine. The user does not need to remember -special ports or passwords set up for his desktop -and VNC. +So we see the combination of \fB-display\fR WAIT:cmd=... and +\fB-unixpw\fR allows automatic pairing of an unix +authenticated VNC user with his desktop. This could +be very useful on SunRays and also any system where +multiple users share a given machine. The user does +not need to remember special ports or passwords set up +for his desktop and VNC. .IP A nice way to use WAIT:cmd=... is out of .IR inetd (8) @@ -1662,7 +1684,9 @@ the user as well. Note: there will be a 2nd SSL helper process that will not switch, but it is only encoding and decoding the encrypted stream at that point. .IP -Automatic Finding of User X Sessions: +BUILT-IN modes: +.IP +\fB--\fR Automatic Finding of User X Sessions \fB--\fR .IP As a special case, WAIT:cmd=FINDDISPLAY will run a script that works on most Unixes to determine a user's @@ -1670,7 +1694,7 @@ DISPLAY variable and xauthority data (see .IR who (1) ). .IP -The option "\fB-find\fR" is an alias for this mode. +NOTE: The option "\fB-find\fR" is an alias for this mode. .IP To have this default script printed to stdout (e.g. for customization) run with WAIT:cmd=FINDDISPLAY-print To @@ -1715,7 +1739,14 @@ using "+" instead of "," If "nd=all" or you set X11VNC_SKIP_DISPLAY=all then all display finding fails as if you set X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 (below.) .IP -Automatic Creation of User X Sessions: +On some systems +.IR lsof (1) +can be very slow. Set the +env. var. FIND_DISPLAY_NO_LSOF=1 to skip using lsof to +try to find the Linux VT the X server is running on. +set FIND_DISPLAY_NO_VT_FIND=1 to avoid looking at all. +.IP +\fB--\fR Automatic Creation of User X Sessions \fB--\fR .IP An interesting option is WAIT:cmd=FINDCREATEDISPLAY that is like FINDDISPLAY in that is uses the same method @@ -1724,13 +1755,19 @@ find one it will try to *start* up an X server session for the user. This is the only time x11vnc tries to actually start up an X server. .IP -The option "\fB-create\fR" is an alias for this mode. +NOTE: The option "\fB-create\fR" is an alias for this mode. .IP It will start looking for an open display number at :20 Override via X11VNC_CREATE_STARTING_DISPLAY_NUMBER=n By default 80 X displays are allowed (i.e. going to :99) Override via X11VNC_CREATE_MAX_DISPLAYS=n .IP +For its heuristics, the create display script sets +LC_ALL=C so that command output is uniform. By default +it will try to restore LC_ALL right before starting the +user session. However, if you don't mind it keeping +LC_ALL=C set the env. var.: X11VNC_CREATE_LC_ALL_C_OK=1 +.IP By default FINDCREATEDISPLAY will try Xvfb and then Xdummy: .IP @@ -1757,6 +1794,10 @@ The user must exit the X session in the usual way for it to terminate (or kill the X server process if all else fails). .IP +To troubleshoot the FINDCREATEDISPLAY mechanism, +set the following env. var. to an output log file, +e.g \fB-env\fR CREATE_DISPLAY_OUTPUT=/tmp/mydebug.txt +.IP So this is a somewhat odd mode for x11vnc in that it will start up and poll virtual X servers! This can be used from, say, @@ -4614,6 +4655,7 @@ Default: take naps Time in seconds after NO activity (e.g. screen blank) to really throttle down the screen polls (i.e. sleep for about 1.5 secs). Use 0 to disable. Default: 60 +Set the env. var. X11VNC_SB_FACTOR to scale it. .PP \fB-readtimeout\fR \fIn\fR .IP @@ -5129,18 +5171,19 @@ do not prefer the default 16bpp set RAWFB_VCSA_BPP to using the 'console_guess' string printed at startup, be sure to indicate the snap: method. .IP -uinput: If the Linux version appears to be 2.6 or -later and the "uinput" module appears to be present -(modprobe uinput), 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 will have to use \fB-pipeinput\fR if you -want to tweak any UINPUT parameters. You may also want -to also use the \fB-nodragging\fR and \fB-cursor\fR none options. -Use "console0", etc or \fB-pipeinput\fR CONSOLE to force -the /dev/ttyN method. +uinput: If the Linux version appears to be 2.6 +or later and the "uinput" module appears to be +present (modprobe uinput), 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. It also provides more accurate +keystroke insertion. See \fB-pipeinput\fR UINPUT below for +more information on this mode; you will have to use +\fB-pipeinput\fR if you want to tweak any UINPUT parameters. +You may also want to also use the \fB-nodragging\fR and +\fB-cursor\fR none options. Use "console0", etc or +\fB-pipeinput\fR CONSOLE to force the /dev/ttyN method. .IP Note you can change the Linux VT remotely using the .IR chvt (1) @@ -5181,7 +5224,11 @@ This mode is really only of use if you are trying to improve performance in the case of many (e.g. > 10) simultaneous VNC viewers, and you try a divide and conquer scheme to reduce bandwidth and improve -responsiveness. +responsiveness. (However, another user found this mode +useful to export a demo display through a slow link: +then multiple demo viewers connected to the reflecting +x11vnc on the fast side of the link, and so avoided +all of the demo viewers going through the slow link.) .IP For example, if there will be 64 simultaneous VNC viewers this can lead to a lot of redundant VNC traffic @@ -5212,6 +5259,13 @@ the password needed to log into the vnc host server, or to "file:path_to_file" to indicate a file containing the password as its first line. .IP +To set the pixel format that x11vnc requests as a VNC +CLIENT set the env. vars: X11VNC_REFLECT_bitsPerSample +X11VNC_REFLECT_samplesPerPixel, and +X11VNC_REFLECT_bytesPerPixel; the defaults are 8, 3, 4. +2, 3, 1 would give a low color mode. See the function +rfbGetClient() in libvncclient for more info. +.IP The VNC HOST mode implies \fB-shared.\fR Use \fB-noshared\fR as a subsequent cmdline option to disable sharing. .PP @@ -5278,7 +5332,8 @@ 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. +are supported. But it is probably more accurate than +the "CONSOLE" method. .IP You may want to use the options \fB-cursor\fR none and \fB-nodragging\fR in this mode. @@ -5320,16 +5375,6 @@ in 1 jump), This correction seems to be needed but can cause jerkiness or unexpected behavior with menus, etc. Use reset=0 to disable. .IP -If the uinput device has an absolute pointer (as opposed -to a normal mouse that is a relative pointer) you can -specify the option "abs". Note that a touchpad -on a laptop is an absolute device to some degree. -This (usually) avoids all the problems with mouse -acceleration. If x11vnc has trouble deducing the size -of the device, use "abs=WxH". Furthermore, if the -device is a touchscreen (assumed to have an absolute -pointer) use "touch" or "touch=WxH". -.IP If you set the env. var X11VNC_UINPUT_THRESHOLDS then the thresh=n mode will be enabled. It is currently not working well. If |dx| <= thresh and |dy| < thresh @@ -5339,8 +5384,70 @@ no acceleration is applied. Use "thresh=+n" |dx| + Example: \fB-pipeinput\fR UINPUT:accel=4.0 \fB-cursor\fR none .IP -You can also set the env. var X11VNC_UINPUT_DEBUG=1 or -higher to get debugging output for UINPUT mode. +If the uinput device has an absolute pointer (as opposed +to a normal mouse that is a relative pointer) you can +specify the option "abs". Note that a touchpad +on a laptop is an absolute device to some degree. +This (usually) avoids all the problems with mouse +acceleration. If x11vnc has trouble deducing the +size of the device, use "abs=WxH". Furthermore, +if the device is a touchscreen (assumed to have an +absolute pointer) use "touch" or "touch=WxH". +For touchscreens, when a mouse button is pressed, +a pressure increase is injected, and when the button +is released a pressure of zero is injected. +.IP +If touch has been set, use "touch_always=1" to +indicate whenever the mouse moves with no button +pressed, a touch event of zero pressure should be +sent anyway. Also use "btn_touch=1" to indicate a +BTN_TOUCH keystroke press or release should be sent +instead of a pressure change. Set "dragskip=n" to +skip n dragged mouse touches (with pressure applied) +before injecting one. To indicate the pressure that +should be sent when there is a button click for a +touchscreen device, specify pressure=n, e.g. n=5. The +default is n=1. +.IP +If a touch screen is being used ("touch" above) +and it is having its input processed by tslib, you can +specify the tslib calibration file via tslib_cal=. +For example, tslib_cal=/etc/pointercal. To get accurate +or even usable positioning this is required when tslib +is in use. +.IP +The Linux uinput mechanism can be bypassed and one can +write input events DIRECTLY to the devices instead. +To do this, specify one or more of the following +for the input classes: direct_rel= +direct_abs= direct_btn= or +direct_key=. The file is usually +something like /dev/input/event1 but you can specify +any device file or pipe. You must specify each one +of the above classes even if they correspond to the +same device file (rel/abs and btn are often the same.) +Look at the file /proc/bus/input/devices to get an idea +what is available and the device filenames. Note: +The /dev/input/mouse* devices do not seem to work, +use the corresponding /dev/input/event* file instead. +Any input class not directly specified as above will be +handled via the uinput mechanism. To disable creating a +uinput device (and thereby discarding unhandled input), +specify "nouinput". +.IP +Examples: +.IP +\fB-pipeinput\fR UINPUT:direct_abs=/dev/input/event1 +.IP +this was used on a qtmoko Neo freerunner (armel): +.IP +\fB-pipeinput\fR UINPUT:touch,tslib_cal=/etc/pointercal, +direct_abs=/dev/input/event1,nouinput,dragskip=4 +.IP +(where the long line has been split into two.) +.IP +You can set the env. var X11VNC_UINPUT_DEBUG=1 or higher +to get debugging output for UINPUT mode. .PP \fB-macnodim\fR .IP diff --git a/x11vnc/x11vnc.c b/x11vnc/x11vnc.c index 3f965e2..d427f32 100644 --- a/x11vnc/x11vnc.c +++ b/x11vnc/x11vnc.c @@ -1065,6 +1065,7 @@ static void check_rcfile(int argc, char **argv) { if (! home) { norc = 1; } else { + memset(rcfile, 0, sizeof(rcfile)); strncpy(rcfile, home, 500); free(home); @@ -1394,6 +1395,7 @@ static void quick_pw(char *str) { if(fgets(tmp, 1024, in) == NULL) { exit(2); } + fclose(in); q = strdup(tmp); } else { q = strdup(str+1); @@ -2574,6 +2576,10 @@ int main(int argc, char* argv[]) { grab_ptr = 1; continue; } + if (!strcmp(arg, "-ungrabboth")) { + ungrab_both = 1; + continue; + } if (!strcmp(arg, "-grabalways")) { grab_kbd = 1; grab_ptr = 1; @@ -4274,7 +4280,7 @@ int main(int argc, char* argv[]) { char *pstr = "%VNCDISPLAY"; if (strstr(logfile, pstr)) { char *h = this_host(); - char *s, *q, *new; + char *s, *q, *newlog; int n, p = got_rfbport_val; /* we don't really know the port yet... so guess */ if (p < 0) { @@ -4293,23 +4299,23 @@ int main(int argc, char* argv[]) { n++; q = t+1; } - new = (char *) malloc(strlen(logfile) + n * strlen(pstr)); - new[0] = '\0'; + newlog = (char *) malloc(strlen(logfile) + n * strlen(pstr)); + newlog[0] = '\0'; q = logfile; while (1) { char *t = strstr(q, pstr); if (!t) { - strcat(new, q); + strcat(newlog, q); break; } - strncat(new, q, t - q); - strcat(new, s); + strncat(newlog, q, t - q); + strcat(newlog, s); q = t + strlen(pstr); } - logfile = new; + logfile = newlog; if (!quiet && !got_inetd) { - rfbLog("Expanded logfile to '%s'\n", new); + rfbLog("Expanded logfile to '%s'\n", newlog); } free(s); @@ -4317,7 +4323,7 @@ int main(int argc, char* argv[]) { pstr = "%HOME"; if (strstr(logfile, pstr)) { char *h = get_home_dir(); - char *s, *q, *new; + char *s, *q, *newlog; s = (char *) malloc(strlen(h) + 32); sprintf(s, "%s", h); @@ -4329,23 +4335,23 @@ int main(int argc, char* argv[]) { n++; q = t+1; } - new = (char *) malloc(strlen(logfile) + n * strlen(pstr)); - new[0] = '\0'; + newlog = (char *) malloc(strlen(logfile) + n * strlen(pstr)); + newlog[0] = '\0'; q = logfile; while (1) { char *t = strstr(q, pstr); if (!t) { - strcat(new, q); + strcat(newlog, q); break; } - strncat(new, q, t - q); - strcat(new, s); + strncat(newlog, q, t - q); + strcat(newlog, s); q = t + strlen(pstr); } - logfile = new; + logfile = newlog; if (!quiet && !got_inetd) { - rfbLog("Expanded logfile to '%s'\n", new); + rfbLog("Expanded logfile to '%s'\n", newlog); } free(s); } diff --git a/x11vnc/x11vnc.h b/x11vnc/x11vnc.h index 8d69543..3299109 100644 --- a/x11vnc/x11vnc.h +++ b/x11vnc/x11vnc.h @@ -133,6 +133,8 @@ so, delete this exception statement from your version. * -DPOLL_8TO24_DELAY=N * -DDEBUG_XEVENTS=1 enable printout for X events. * + * -DX11VNC_MACOSX_USE_GETMAINDEVICE use deprecated GetMainDevice on macosx + * * Set these in CPPFLAGS before running configure. E.g.: * * % env CPPFLAGS="-DFOREVER -DREMOTE_CONTROL=0" ./configure diff --git a/x11vnc/x11vnc_defs.c b/x11vnc/x11vnc_defs.c index fc6215b..ae048ee 100644 --- a/x11vnc/x11vnc_defs.c +++ b/x11vnc/x11vnc_defs.c @@ -47,7 +47,7 @@ int xtrap_base_event_type = 0; int xdamage_base_event_type = 0; /* date +'lastmod: %Y-%m-%d' */ -char lastmod[] = "0.9.13 lastmod: 2010-09-10"; +char lastmod[] = "0.9.13 lastmod: 2010-12-20"; /* X display info */ diff --git a/x11vnc/xevents.c b/x11vnc/xevents.c index 2fc122d..72b6515 100644 --- a/x11vnc/xevents.c +++ b/x11vnc/xevents.c @@ -57,6 +57,7 @@ int grab_buster = 0; int grab_kbd = 0; int grab_ptr = 0; int grab_always = 0; +int ungrab_both = 0; int grab_local = 0; int sync_tod_delay = 20; diff --git a/x11vnc/xevents.h b/x11vnc/xevents.h index dbdddde..5b8bdce 100644 --- a/x11vnc/xevents.h +++ b/x11vnc/xevents.h @@ -39,6 +39,7 @@ extern int grab_buster; extern int grab_kbd; extern int grab_ptr; extern int grab_always; +extern int ungrab_both; extern int grab_local; extern int sync_tod_delay; diff --git a/x11vnc/xrecord.c b/x11vnc/xrecord.c index 4f79dce..87e15b9 100644 --- a/x11vnc/xrecord.c +++ b/x11vnc/xrecord.c @@ -73,7 +73,7 @@ void initialize_xrecord(void); void zerodisp_xrecord(void); void shutdown_xrecord(void); int xrecord_skip_keysym(rfbKeySym keysym); -int xrecord_skip_button(int new, int old); +int xrecord_skip_button(int newb, int old); int xrecord_scroll_keysym(rfbKeySym keysym); void check_xrecord_reset(int force); void xrecord_watch(int start, int setby); @@ -410,9 +410,9 @@ int xrecord_skip_keysym(rfbKeySym keysym) { return 0; } -int xrecord_skip_button(int new, int old) { +int xrecord_skip_button(int new_button, int old) { /* unused vars warning: */ - if (new || old) {} + if (new_button || old) {} return 0; } diff --git a/x11vnc/xrecord.h b/x11vnc/xrecord.h index cee660d..2c1e2d7 100644 --- a/x11vnc/xrecord.h +++ b/x11vnc/xrecord.h @@ -60,7 +60,7 @@ extern void initialize_xrecord(void); extern void zerodisp_xrecord(void); extern void shutdown_xrecord(void); extern int xrecord_skip_keysym(rfbKeySym keysym); -extern int xrecord_skip_button(int new, int old); +extern int xrecord_skip_button(int newb, int old); extern int xrecord_scroll_keysym(rfbKeySym keysym); extern void check_xrecord_reset(int force); extern void xrecord_watch(int start, int setby); diff --git a/x11vnc/xwrappers.c b/x11vnc/xwrappers.c index 667957e..bb73565 100644 --- a/x11vnc/xwrappers.c +++ b/x11vnc/xwrappers.c @@ -347,7 +347,15 @@ XImage *XCreateImage_wr(Display *disp, Visual *visual, unsigned int depth, xi = (XImage *) malloc(sizeof(XImage)); memset(xi, 0, sizeof(XImage)); xi->depth = depth; - xi->bits_per_pixel = (depth == 24) ? 32 : depth; + if (depth >= 24) { + xi->bits_per_pixel = 32; + } else if (depth > 16) { + xi->bits_per_pixel = 24; + } else if (depth > 8) { + xi->bits_per_pixel = 16; + } else { + xi->bits_per_pixel = 8; + } xi->format = format; xi->xoffset = offset; xi->data = data; @@ -706,7 +714,7 @@ void copy_raw_fb(XImage *dest, int x, int y, unsigned int w, unsigned int h) { src = snap->data + snap->bytes_per_line*y + pixelsize*x; dst = dest->data; -if (db) fprintf(stderr, "snap->bytes_per_line: %d, dest->bytes_per_line: %d, w: %d h: %d dpy_x: %d wdpy_x: %d cdpy_x: %d\n", snap->bytes_per_line, dest->bytes_per_line, w, h, dpy_x, wdpy_x, cdpy_x); +if (db) fprintf(stderr, "snap->bytes_per_line: %d, dest->bytes_per_line: %d, w: %d h: %d dpy_x: %d wdpy_x: %d cdpy_x: %d bpp: %d pixelsize: %d\n", snap->bytes_per_line, dest->bytes_per_line, w, h, dpy_x, wdpy_x, cdpy_x, bpp, pixelsize); for (line = 0; line < h; line++) { memcpy(dst, src, w * pixelsize); @@ -725,7 +733,7 @@ if (db) fprintf(stderr, "snap->bytes_per_line: %d, dest->bytes_per_line: %d, w: src = raw_fb_addr + raw_fb_offset + bpl*y + pixelsize*x; dst = dest->data; -if (db) fprintf(stderr, "bpl: %d, dest->bytes_per_line: %d, w: %d h: %d dpy_x: %d wdpy_x: %d cdpy_x: %d\n", bpl, dest->bytes_per_line, w, h, dpy_x, wdpy_x, cdpy_x); +if (db) fprintf(stderr, "bpl: %d, dest->bytes_per_line: %d, w: %d h: %d dpy_x: %d wdpy_x: %d cdpy_x: %d bpp: %d pixelsize: %d\n", bpl, dest->bytes_per_line, w, h, dpy_x, wdpy_x, cdpy_x, bpp, pixelsize); for (line = 0; line < h; line++) { memcpy(dst, src, w * pixelsize); @@ -878,6 +886,7 @@ void XTRAP_FakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down, void XTestFakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down, unsigned long delay) { static int first = 1; + int regrab = 0; RAWFB_RET_VOID @@ -903,11 +912,16 @@ void XTestFakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down, if (grab_kbd) { XUngrabKeyboard(dpy, CurrentTime); + regrab = 1; + } + if (grab_ptr && ungrab_both) { + XUngrabPointer(dpy, CurrentTime); + regrab = 1; } if (xtrap_input) { XTRAP_FakeKeyEvent_wr(dpy, key, down, delay); - if (grab_kbd) { + if (regrab) { adjust_grabs(1, 1); } return; @@ -923,7 +937,7 @@ void XTestFakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down, } #if LIBVNCSERVER_HAVE_XTEST XTestFakeKeyEvent(dpy, key, down, delay); - if (grab_kbd) { + if (regrab) { adjust_grabs(1, 1); } if (debug_keyboard) { @@ -964,6 +978,7 @@ void XTRAP_FakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press, void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press, unsigned long delay) { + int regrab = 0; RAWFB_RET_VOID #if NO_X11 @@ -974,11 +989,16 @@ void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press, if (grab_ptr) { XUngrabPointer(dpy, CurrentTime); + regrab = 1; + } + if (grab_kbd && ungrab_both) { + XUngrabKeyboard(dpy, CurrentTime); + regrab = 1; } if (xtrap_input) { XTRAP_FakeButtonEvent_wr(dpy, button, is_press, delay); - if (grab_ptr) { + if (regrab) { adjust_grabs(1, 1); } return; @@ -995,7 +1015,7 @@ void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press, #if LIBVNCSERVER_HAVE_XTEST XTestFakeButtonEvent(dpy, button, is_press, delay); #endif - if (grab_ptr) { + if (regrab) { adjust_grabs(1, 1); } #endif /* NO_X11 */ @@ -1029,6 +1049,7 @@ void XTRAP_FakeMotionEvent_wr(Display* dpy, int screen, int x, int y, void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y, unsigned long delay) { + int regrab = 0; RAWFB_RET_VOID #if NO_X11 @@ -1039,11 +1060,16 @@ void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y, if (grab_ptr) { XUngrabPointer(dpy, CurrentTime); + regrab = 1; + } + if (grab_kbd && ungrab_both) { + XUngrabKeyboard(dpy, CurrentTime); + regrab = 1; } if (xtrap_input) { XTRAP_FakeMotionEvent_wr(dpy, screen, x, y, delay); - if (grab_ptr) { + if (regrab) { adjust_grabs(1, 1); } return; @@ -1056,7 +1082,7 @@ void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y, #if LIBVNCSERVER_HAVE_XTEST XTestFakeMotionEvent(dpy, screen, x, y, delay); #endif - if (grab_ptr) { + if (regrab) { adjust_grabs(1, 1); } #endif /* NO_X11 */ -- cgit v1.2.1