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

pull/1/head
runge 18 years ago
parent 079528470d
commit 0afa1da8cc

File diff suppressed because it is too large Load Diff

@ -454,7 +454,7 @@ void print_help(int mode) {
" and last line be \"__BEGIN_VIEWONLY__\" to have 2\n" " and last line be \"__BEGIN_VIEWONLY__\" to have 2\n"
" full-access passwords)\n" " full-access passwords)\n"
"\n" "\n"
#ifndef REL81 #ifndef REL8x
"-unixpw [list] Use Unix username and password authentication. x11vnc\n" "-unixpw [list] Use Unix username and password authentication. x11vnc\n"
" uses the su(1) program to verify the user's password.\n" " uses the su(1) program to verify the user's password.\n"
" [list] is an optional comma separated list of allowed\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 cons3 (force /dev/tty3)\n"
" -rawfb consx (no keystrokes or mouse)\n" " -rawfb consx (no keystrokes or mouse)\n"
" -rawfb console:/dev/nonstd\n" " -rawfb console:/dev/nonstd\n"
" -rawfb cons -pipeinput UINPUT:accel=1.5\n" " -rawfb cons -pipeinput UINPUT:accel=4.0\n"
"\n" "\n"
"-freqtab file For use with \"-rawfb video\" for TV tuner devices to\n" "-freqtab file For use with \"-rawfb video\" for TV tuner devices to\n"
" specify station frequencies. Instead of using the built\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" " A UINPUT option of the form: accel=f, or accel=fx+fy\n"
" sets the mouse motion \"acceleration\". This is used\n" " sets the mouse motion \"acceleration\". This is used\n"
" to correct raw mouse relative motion into how much the\n" " to correct raw mouse relative motion into how much the\n"
" application cursor moves (x11vnc has no control over\n" " application cursor moves (x11vnc has no control over,\n"
" how the application interprets the raw mouse motions).\n" " or knowledge of how the windowing application interprets\n"
" Typically the acceleration for an X display is 2 (see\n" " the raw mouse motions). Typically the acceleration\n"
" xset \"m\" option). \"f\" is a floating point number,\n" " for an X display is 2 (see xset \"m\" option). \"f\"\n"
" e.g. 2.0. Use \"fx+fy\" if you need to supply different\n" " is a floating point number, e.g. 3.0. Use \"fx+fy\"\n"
" corrections for x and y.\n" " if you need to supply different corrections for x and y.\n"
"\n" "\n"
" Note: the default acceleration is 2.0 since it seems\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" "\n"
" Even with a correct accel setting the mouse position\n" " Even with a correct accel setting the mouse position\n"
" will get out of sync (probably due to a mouse\n" " will get out of sync (probably due to a mouse\n"
" \"threshold\" setting where the acceleration doe not\n" " \"threshold\" setting where the acceleration doe not\n"
" apply, set xset(1)). The option reset=N sets the number\n" " apply, set xset(1)). The option reset=N sets the\n"
" of ms (default 500) after which the cursor is attempted\n" " number of ms (default 500) after which the cursor is\n"
" to be reset (by forcing the mouse to (0, 0) via small\n" " attempted to be reset (by forcing the mouse to (0,\n"
" increments and then back out to (x, y) in 1 jump), This\n" " 0) via small increments and then back out to (x, y)\n"
" correction seems to be needed but can cause jerkiness\n" " in 1 jump), This correction seems to be needed but can\n"
" or unexpected behavior. Use reset=0 to disable.\n" " cause jerkiness or unexpected behavior with menus, etc.\n"
" Use reset=0 to disable.\n"
"\n" "\n"
" Example:\n" " Example:\n"
" -pipeinput UINPUT:accel=1.0 -cursor none\n" " -pipeinput UINPUT:accel=4.0 -cursor none\n"
"\n" "\n"
"-gui [gui-opts] Start up a simple tcl/tk gui based on the the remote\n" "-gui [gui-opts] Start up a simple tcl/tk gui based on the the remote\n"
" control options -remote/-query described below.\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); snprintf(buf, bufn, "aro=%s:%d", p, no_external_cmds);
} else if (!strcmp(p, "passwdfile")) { } else if (!strcmp(p, "passwdfile")) {
snprintf(buf, bufn, "aro=%s:%s", p, NONUL(passwdfile)); snprintf(buf, bufn, "aro=%s:%s", p, NONUL(passwdfile));
#ifndef REL81 #ifndef REL8x
} else if (!strcmp(p, "unixpw")) { } else if (!strcmp(p, "unixpw")) {
snprintf(buf, bufn, "aro=%s:%d", p, unixpw); snprintf(buf, bufn, "aro=%s:%d", p, unixpw);
} else if (!strcmp(p, "unixpw_nis")) { } else if (!strcmp(p, "unixpw_nis")) {

@ -15,7 +15,7 @@
#endif #endif
#endif #endif
#ifdef REL81 #ifdef REL8x
#undef SSLCMDS #undef SSLCMDS
#endif #endif

@ -20,7 +20,7 @@
#endif #endif
#endif #endif
#ifdef REL81 #ifdef REL8x
#undef FORK_OK #undef FORK_OK
#undef LIBVNCSERVER_HAVE_LIBSSL #undef LIBVNCSERVER_HAVE_LIBSSL
#define LIBVNCSERVER_HAVE_LIBSSL 0 #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_pointer_command(int mask, int x, int y, rfbClientPtr client);
void uinput_key_command(int down, int keysym, 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 set_uinput_accel_xy(double fx, double fy);
static void shutdown_uinput(void); static void shutdown_uinput(void);
static void ptr_move(int dx, int dy); static void ptr_move(int dx, int dy);
@ -94,6 +97,45 @@ int check_uinput(void) {
#endif #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) { static void shutdown_uinput(void) {
#ifdef UINPUT_OK #ifdef UINPUT_OK
ioctl(fd, UI_DEV_DESTROY); ioctl(fd, UI_DEV_DESTROY);
@ -112,6 +154,8 @@ int initialize_uinput(void) {
close(fd); close(fd);
fd = -1; fd = -1;
} }
init_key_tracker();
if (uinput_dev) { if (uinput_dev) {
fd = open(uinput_dev, O_RDWR); fd = open(uinput_dev, O_RDWR);
@ -176,6 +220,7 @@ static double resid_x = 0.0;
static double resid_y = 0.0; static double resid_y = 0.0;
static double zero_delay = 0.5; static double zero_delay = 0.5;
static double last_button_click = 0.0;
static void set_uinput_accel_xy(double fx, double fy) { static void set_uinput_accel_xy(double fx, double fy) {
fudge_x = 1.0/fx; fudge_x = 1.0/fx;
@ -353,6 +398,8 @@ static void button_click(int down, int btn) {
ev.value = 0; ev.value = 0;
write(fd, &ev, sizeof(ev)); write(fd, &ev, sizeof(ev));
last_button_click = dnow();
#endif #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 int last_x = -1, last_y = -1, last_mask = -1;
static double last_zero = 0.0; static double last_zero = 0.0;
allowed_input_t input; allowed_input_t input;
int do_reset;
double now;
if (db) fprintf(stderr, "uinput_pointer_command: %d %d - %d\n", x, y, mask); 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); 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; static int first = 1;
if (zero_delay > 0.0 || first) { if (zero_delay > 0.0 || first) {
/* try to push it to 0,0 */ /* try to push it to 0,0 */
int tx = fudge_x * last_x; int tx = fudge_x * last_x + 40;
int ty = fudge_y * last_y; int ty = fudge_y * last_y + 40;
int bigjump = 1; int bigjump = 1;
if (bigjump) { if (bigjump) {
@ -399,6 +466,7 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) {
/* now jump back out */ /* now jump back out */
ptr_rel(x, y); ptr_rel(x, y);
if (0) usleep(10*1000);
last_x = x; last_x = x;
last_y = y; last_y = y;
@ -488,6 +556,10 @@ void uinput_key_command(int down, int keysym, rfbClientPtr client) {
ev.code = SYN_REPORT; ev.code = SYN_REPORT;
ev.value = 0; ev.value = 0;
write(fd, &ev, sizeof(ev)); write(fd, &ev, sizeof(ev));
if (0 <= scancode < 256) {
key_pressed[scancode] = down ? 1 : 0;
}
#endif #endif
} }

@ -51,7 +51,7 @@ extern char *crypt(const char*, const char *);
#define IS_BSD #define IS_BSD
#endif #endif
#ifdef REL81 #ifdef REL8x
#undef UNIXPW_SU #undef UNIXPW_SU
#undef UNIXPW_CRYPT #undef UNIXPW_CRYPT
#endif #endif

@ -2,7 +2,7 @@
.TH X11VNC "1" "July 2006" "x11vnc " "User Commands" .TH X11VNC "1" "July 2006" "x11vnc " "User Commands"
.SH NAME .SH NAME
x11vnc - allow VNC connections to real X11 displays 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 .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
@ -3026,7 +3026,7 @@ Examples:
\fB-rawfb\fR cons3 (force /dev/tty3) \fB-rawfb\fR cons3 (force /dev/tty3)
\fB-rawfb\fR consx (no keystrokes or mouse) \fB-rawfb\fR consx (no keystrokes or mouse)
\fB-rawfb\fR console:/dev/nonstd \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 .PP
\fB-freqtab\fR \fIfile\fR \fB-freqtab\fR \fIfile\fR
.IP .IP
@ -3108,30 +3108,32 @@ and motion but not button clicks.
A UINPUT option of the form: accel=f, or accel=fx+fy A UINPUT option of the form: accel=f, or accel=fx+fy
sets the mouse motion "acceleration". This is used sets the mouse motion "acceleration". This is used
to correct raw mouse relative motion into how much the to correct raw mouse relative motion into how much the
application cursor moves (x11vnc has no control over application cursor moves (x11vnc has no control over,
how the application interprets the raw mouse motions). or knowledge of how the windowing application interprets
Typically the acceleration for an X display is 2 (see the raw mouse motions). Typically the acceleration
xset "m" option). "f" is a floating point number, for an X display is 2 (see xset "m" option). "f"
e.g. 2.0. Use "fx+fy" if you need to supply different is a floating point number, e.g. 3.0. Use "fx+fy"
corrections for x and y. if you need to supply different corrections for x and y.
.IP .IP
Note: the default acceleration is 2.0 since it seems 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 .IP
Even with a correct accel setting the mouse position Even with a correct accel setting the mouse position
will get out of sync (probably due to a mouse will get out of sync (probably due to a mouse
"threshold" setting where the acceleration doe not "threshold" setting where the acceleration doe not
apply, set apply, set
.IR xset (1) .IR xset (1)
). The option reset=N sets the number ). The option reset=N sets the
of ms (default 500) after which the cursor is attempted number of ms (default 500) after which the cursor is
to be reset (by forcing the mouse to (0, 0) via small attempted to be reset (by forcing the mouse to (0,
increments and then back out to (x, y) in 1 jump), This 0) via small increments and then back out to (x, y)
correction seems to be needed but can cause jerkiness in 1 jump), This correction seems to be needed but can
or unexpected behavior. Use reset=0 to disable. cause jerkiness or unexpected behavior with menus, etc.
Use reset=0 to disable.
.IP .IP
Example: Example:
\fB-pipeinput\fR UINPUT:accel=1.0 \fB-cursor\fR none \fB-pipeinput\fR UINPUT:accel=4.0 \fB-cursor\fR none
.PP .PP
\fB-gui\fR \fI[gui-opts]\fR \fB-gui\fR \fI[gui-opts]\fR
.IP .IP

@ -1642,7 +1642,7 @@ int main(int argc, char* argv[]) {
CHECK_ARGC CHECK_ARGC
passwdfile = strdup(argv[++i]); passwdfile = strdup(argv[++i]);
got_passwdfile = 1; got_passwdfile = 1;
#ifndef REL81 #ifndef REL8x
} else if (strstr(arg, "-unixpw") == arg) { } else if (strstr(arg, "-unixpw") == arg) {
unixpw = 1; unixpw = 1;
if (strstr(arg, "-unixpw_nis")) { if (strstr(arg, "-unixpw_nis")) {

@ -118,7 +118,7 @@
#define PASSWD_UNLESS_NOPW 0 #define PASSWD_UNLESS_NOPW 0
#endif #endif
#define noREL81 #define noREL8x
/* /*
* Beginning of support for small binary footprint build for embedded * 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; int xdamage_base_event_type = 0;
/* date +'lastmod: %Y-%m-%d' */ /* 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 */ /* X display info */

Loading…
Cancel
Save