Commit 0afa1da8 authored by runge's avatar runge

x11vnc: improve uinput heuristics so button clicks work on qt-embedded.

parent 07952847
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -454,7 +454,7 @@ void print_help(int mode) {
" and last line be \"__BEGIN_VIEWONLY__\" to have 2\n"
" full-access passwords)\n"
"\n"
#ifndef REL81
#ifndef REL8x
"-unixpw [list] Use Unix username and password authentication. x11vnc\n"
" uses the su(1) program to verify the user's password.\n"
" [list] is an optional comma separated list of allowed\n"
......@@ -2562,7 +2562,7 @@ void print_help(int mode) {
" -rawfb cons3 (force /dev/tty3)\n"
" -rawfb consx (no keystrokes or mouse)\n"
" -rawfb console:/dev/nonstd\n"
" -rawfb cons -pipeinput UINPUT:accel=1.5\n"
" -rawfb cons -pipeinput UINPUT:accel=4.0\n"
"\n"
"-freqtab file For use with \"-rawfb video\" for TV tuner devices to\n"
" specify station frequencies. Instead of using the built\n"
......@@ -2640,28 +2640,30 @@ void print_help(int mode) {
" A UINPUT option of the form: accel=f, or accel=fx+fy\n"
" sets the mouse motion \"acceleration\". This is used\n"
" to correct raw mouse relative motion into how much the\n"
" application cursor moves (x11vnc has no control over\n"
" how the application interprets the raw mouse motions).\n"
" Typically the acceleration for an X display is 2 (see\n"
" xset \"m\" option). \"f\" is a floating point number,\n"
" e.g. 2.0. Use \"fx+fy\" if you need to supply different\n"
" corrections for x and y.\n"
" application cursor moves (x11vnc has no control over,\n"
" or knowledge of how the windowing application interprets\n"
" the raw mouse motions). Typically the acceleration\n"
" for an X display is 2 (see xset \"m\" option). \"f\"\n"
" is a floating point number, e.g. 3.0. Use \"fx+fy\"\n"
" if you need to supply different corrections for x and y.\n"
"\n"
" Note: the default acceleration is 2.0 since it seems\n"
" both X and qt-embedded often use this value.\n"
" both X and qt-embedded often (but not always) use\n"
" this value.\n"
"\n"
" Even with a correct accel setting the mouse position\n"
" will get out of sync (probably due to a mouse\n"
" \"threshold\" setting where the acceleration doe not\n"
" apply, set xset(1)). The option reset=N sets the number\n"
" of ms (default 500) after which the cursor is attempted\n"
" to be reset (by forcing the mouse to (0, 0) via small\n"
" increments and then back out to (x, y) in 1 jump), This\n"
" correction seems to be needed but can cause jerkiness\n"
" or unexpected behavior. Use reset=0 to disable.\n"
" apply, set xset(1)). The option reset=N sets the\n"
" number of ms (default 500) after which the cursor is\n"
" attempted to be reset (by forcing the mouse to (0,\n"
" 0) via small increments and then back out to (x, y)\n"
" in 1 jump), This correction seems to be needed but can\n"
" cause jerkiness or unexpected behavior with menus, etc.\n"
" Use reset=0 to disable.\n"
"\n"
" Example:\n"
" -pipeinput UINPUT:accel=1.0 -cursor none\n"
" -pipeinput UINPUT:accel=4.0 -cursor none\n"
"\n"
"-gui [gui-opts] Start up a simple tcl/tk gui based on the the remote\n"
" control options -remote/-query described below.\n"
......
......@@ -4005,7 +4005,7 @@ char *process_remote_cmd(char *cmd, int stringonly) {
snprintf(buf, bufn, "aro=%s:%d", p, no_external_cmds);
} else if (!strcmp(p, "passwdfile")) {
snprintf(buf, bufn, "aro=%s:%s", p, NONUL(passwdfile));
#ifndef REL81
#ifndef REL8x
} else if (!strcmp(p, "unixpw")) {
snprintf(buf, bufn, "aro=%s:%d", p, unixpw);
} else if (!strcmp(p, "unixpw_nis")) {
......
......@@ -15,7 +15,7 @@
#endif
#endif
#ifdef REL81
#ifdef REL8x
#undef SSLCMDS
#endif
......
......@@ -20,7 +20,7 @@
#endif
#endif
#ifdef REL81
#ifdef REL8x
#undef FORK_OK
#undef LIBVNCSERVER_HAVE_LIBSSL
#define LIBVNCSERVER_HAVE_LIBSSL 0
......
......@@ -32,6 +32,9 @@ void parse_uinput_str(char *str);
void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client);
void uinput_key_command(int down, int keysym, rfbClientPtr client);
static void 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);
......@@ -94,6 +97,45 @@ int check_uinput(void) {
#endif
}
static int key_pressed[256];
static int key_ismod[256];
static void init_key_tracker(void) {
int i;
for (i = 0; i < 256; i++) {
key_pressed[i] = 0;
key_ismod[i] = 0;
}
i = lookup_code(XK_Shift_L); if (0<=i && i<256) key_ismod[i] = 1;
i = lookup_code(XK_Shift_R); if (0<=i && i<256) key_ismod[i] = 1;
i = lookup_code(XK_Control_L); if (0<=i && i<256) key_ismod[i] = 1;
i = lookup_code(XK_Control_R); if (0<=i && i<256) key_ismod[i] = 1;
i = lookup_code(XK_Alt_L); if (0<=i && i<256) key_ismod[i] = 1;
i = lookup_code(XK_Alt_R); if (0<=i && i<256) key_ismod[i] = 1;
i = lookup_code(XK_Meta_L); if (0<=i && i<256) key_ismod[i] = 1;
i = lookup_code(XK_Meta_R); if (0<=i && i<256) key_ismod[i] = 1;
}
static int mod_is_down(void) {
int i;
for (i = 0; i < 256; i++) {
if (key_pressed[i] && key_ismod[i]) {
return 1;
}
}
return 0;
}
static int key_is_down(void) {
int i;
for (i = 0; i < 256; i++) {
if (key_pressed[i]) {
return 1;
}
}
return 0;
}
static void shutdown_uinput(void) {
#ifdef UINPUT_OK
ioctl(fd, UI_DEV_DESTROY);
......@@ -112,6 +154,8 @@ int initialize_uinput(void) {
close(fd);
fd = -1;
}
init_key_tracker();
if (uinput_dev) {
fd = open(uinput_dev, O_RDWR);
......@@ -176,6 +220,7 @@ static double resid_x = 0.0;
static double resid_y = 0.0;
static double zero_delay = 0.5;
static double last_button_click = 0.0;
static void set_uinput_accel_xy(double fx, double fy) {
fudge_x = 1.0/fx;
......@@ -353,6 +398,8 @@ static void button_click(int down, int btn) {
ev.value = 0;
write(fd, &ev, sizeof(ev));
last_button_click = dnow();
#endif
}
......@@ -361,6 +408,8 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) {
static int last_x = -1, last_y = -1, last_mask = -1;
static double last_zero = 0.0;
allowed_input_t input;
int do_reset;
double now;
if (db) fprintf(stderr, "uinput_pointer_command: %d %d - %d\n", x, y, mask);
......@@ -369,13 +418,31 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) {
}
get_allowed_input(client, &input);
if (!bmask && dnow() >= last_zero + zero_delay && input.motion) {
now = dnow();
do_reset = 1;
if (mask || bmask) {
do_reset = 0; /* do not do reset if moust button down */
} else if (! input.motion) {
do_reset = 0;
} else if (now < last_zero + zero_delay) {
do_reset = 0;
}
if (do_reset) {
if (mod_is_down()) {
do_reset = 0;
} else if (now < last_button_click + 0.25) {
do_reset = 0;
}
}
if (do_reset) {
static int first = 1;
if (zero_delay > 0.0 || first) {
/* try to push it to 0,0 */
int tx = fudge_x * last_x;
int ty = fudge_y * last_y;
int tx = fudge_x * last_x + 40;
int ty = fudge_y * last_y + 40;
int bigjump = 1;
if (bigjump) {
......@@ -399,6 +466,7 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) {
/* now jump back out */
ptr_rel(x, y);
if (0) usleep(10*1000);
last_x = x;
last_y = y;
......@@ -488,6 +556,10 @@ void uinput_key_command(int down, int keysym, rfbClientPtr client) {
ev.code = SYN_REPORT;
ev.value = 0;
write(fd, &ev, sizeof(ev));
if (0 <= scancode < 256) {
key_pressed[scancode] = down ? 1 : 0;
}
#endif
}
......
......@@ -51,7 +51,7 @@ extern char *crypt(const char*, const char *);
#define IS_BSD
#endif
#ifdef REL81
#ifdef REL8x
#undef UNIXPW_SU
#undef UNIXPW_CRYPT
#endif
......
......@@ -2,7 +2,7 @@
.TH X11VNC "1" "July 2006" "x11vnc " "User Commands"
.SH NAME
x11vnc - allow VNC connections to real X11 displays
version: 0.8.2, lastmod: 2006-07-08
version: 0.8.2, lastmod: 2006-07-09
.SH SYNOPSIS
.B x11vnc
[OPTION]...
......@@ -3026,7 +3026,7 @@ Examples:
\fB-rawfb\fR cons3 (force /dev/tty3)
\fB-rawfb\fR consx (no keystrokes or mouse)
\fB-rawfb\fR console:/dev/nonstd
\fB-rawfb\fR cons \fB-pipeinput\fR UINPUT:accel=1.5
\fB-rawfb\fR cons \fB-pipeinput\fR UINPUT:accel=4.0
.PP
\fB-freqtab\fR \fIfile\fR
.IP
......@@ -3108,30 +3108,32 @@ and motion but not button clicks.
A UINPUT option of the form: accel=f, or accel=fx+fy
sets the mouse motion "acceleration". This is used
to correct raw mouse relative motion into how much the
application cursor moves (x11vnc has no control over
how the application interprets the raw mouse motions).
Typically the acceleration for an X display is 2 (see
xset "m" option). "f" is a floating point number,
e.g. 2.0. Use "fx+fy" if you need to supply different
corrections for x and y.
application cursor moves (x11vnc has no control over,
or knowledge of how the windowing application interprets
the raw mouse motions). Typically the acceleration
for an X display is 2 (see xset "m" option). "f"
is a floating point number, e.g. 3.0. Use "fx+fy"
if you need to supply different corrections for x and y.
.IP
Note: the default acceleration is 2.0 since it seems
both X and qt-embedded often use this value.
both X and qt-embedded often (but not always) use
this value.
.IP
Even with a correct accel setting the mouse position
will get out of sync (probably due to a mouse
"threshold" setting where the acceleration doe not
apply, set
.IR xset (1)
). The option reset=N sets the number
of ms (default 500) after which the cursor is attempted
to be reset (by forcing the mouse to (0, 0) via small
increments and then back out to (x, y) in 1 jump), This
correction seems to be needed but can cause jerkiness
or unexpected behavior. Use reset=0 to disable.
). The option reset=N sets the
number of ms (default 500) after which the cursor is
attempted to be reset (by forcing the mouse to (0,
0) via small increments and then back out to (x, y)
in 1 jump), This correction seems to be needed but can
cause jerkiness or unexpected behavior with menus, etc.
Use reset=0 to disable.
.IP
Example:
\fB-pipeinput\fR UINPUT:accel=1.0 \fB-cursor\fR none
\fB-pipeinput\fR UINPUT:accel=4.0 \fB-cursor\fR none
.PP
\fB-gui\fR \fI[gui-opts]\fR
.IP
......
......@@ -1642,7 +1642,7 @@ int main(int argc, char* argv[]) {
CHECK_ARGC
passwdfile = strdup(argv[++i]);
got_passwdfile = 1;
#ifndef REL81
#ifndef REL8x
} else if (strstr(arg, "-unixpw") == arg) {
unixpw = 1;
if (strstr(arg, "-unixpw_nis")) {
......
......@@ -118,7 +118,7 @@
#define PASSWD_UNLESS_NOPW 0
#endif
#define noREL81
#define noREL8x
/*
* Beginning of support for small binary footprint build for embedded
......
......@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0;
int xdamage_base_event_type = 0;
/* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.8.2 lastmod: 2006-07-08";
char lastmod[] = "0.8.2 lastmod: 2006-07-09";
/* X display info */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment