Deleted Added
full compact
moused.c (233090) moused.c (240891)
1/**
2 ** Copyright (c) 1995 Michael Smith, All rights reserved.
3 **
4 ** Redistribution and use in source and binary forms, with or without
5 ** modification, are permitted provided that the following conditions
6 ** are met:
7 ** 1. Redistributions of source code must retain the above copyright
8 ** notice, this list of conditions and the following disclaimer as

--- 31 unchanged lines hidden (view full) ---

40 **
41 ** The mouse interface functions are derived closely from the mouse
42 ** handler in the XFree86 X server. Many thanks to the XFree86 people
43 ** for their great work!
44 **
45 **/
46
47#include <sys/cdefs.h>
1/**
2 ** Copyright (c) 1995 Michael Smith, All rights reserved.
3 **
4 ** Redistribution and use in source and binary forms, with or without
5 ** modification, are permitted provided that the following conditions
6 ** are met:
7 ** 1. Redistributions of source code must retain the above copyright
8 ** notice, this list of conditions and the following disclaimer as

--- 31 unchanged lines hidden (view full) ---

40 **
41 ** The mouse interface functions are derived closely from the mouse
42 ** handler in the XFree86 X server. Many thanks to the XFree86 people
43 ** for their great work!
44 **
45 **/
46
47#include <sys/cdefs.h>
48__FBSDID("$FreeBSD: head/usr.sbin/moused/moused.c 233090 2012-03-17 16:40:15Z hselasky $");
48__FBSDID("$FreeBSD: head/usr.sbin/moused/moused.c 240891 2012-09-24 17:13:33Z hselasky $");
49
50#include <sys/param.h>
51#include <sys/consio.h>
52#include <sys/mouse.h>
53#include <sys/socket.h>
54#include <sys/stat.h>
55#include <sys/time.h>
56#include <sys/un.h>

--- 346 unchanged lines hidden (view full) ---

403 int rate; /* report rate */
404 int resolution; /* MOUSE_RES_XXX or a positive number */
405 int zmap[4]; /* MOUSE_{X|Y}AXIS or a button number */
406 int wmode; /* wheel mode button number */
407 int mfd; /* mouse file descriptor */
408 int cfd; /* /dev/consolectl file descriptor */
409 int mremsfd; /* mouse remote server file descriptor */
410 int mremcfd; /* mouse remote client file descriptor */
49
50#include <sys/param.h>
51#include <sys/consio.h>
52#include <sys/mouse.h>
53#include <sys/socket.h>
54#include <sys/stat.h>
55#include <sys/time.h>
56#include <sys/un.h>

--- 346 unchanged lines hidden (view full) ---

403 int rate; /* report rate */
404 int resolution; /* MOUSE_RES_XXX or a positive number */
405 int zmap[4]; /* MOUSE_{X|Y}AXIS or a button number */
406 int wmode; /* wheel mode button number */
407 int mfd; /* mouse file descriptor */
408 int cfd; /* /dev/consolectl file descriptor */
409 int mremsfd; /* mouse remote server file descriptor */
410 int mremcfd; /* mouse remote client file descriptor */
411 int is_removable; /* set if device is removable, like USB */
411 long clickthreshold; /* double click speed in msec */
412 long button2timeout; /* 3 button emulation timeout */
413 mousehw_t hw; /* mouse device hardware information */
414 mousemode_t mode; /* protocol information */
415 float accelx; /* Acceleration in the X axis */
416 float accely; /* Acceleration in the Y axis */
417 float expoaccel; /* Exponential acceleration */
418 float expoffset; /* Movement offset for exponential accel. */

--- 10 unchanged lines hidden (view full) ---

429 .rate = 0,
430 .resolution = MOUSE_RES_UNKNOWN,
431 .zmap = { 0, 0, 0, 0 },
432 .wmode = 0,
433 .mfd = -1,
434 .cfd = -1,
435 .mremsfd = -1,
436 .mremcfd = -1,
412 long clickthreshold; /* double click speed in msec */
413 long button2timeout; /* 3 button emulation timeout */
414 mousehw_t hw; /* mouse device hardware information */
415 mousemode_t mode; /* protocol information */
416 float accelx; /* Acceleration in the X axis */
417 float accely; /* Acceleration in the Y axis */
418 float expoaccel; /* Exponential acceleration */
419 float expoffset; /* Movement offset for exponential accel. */

--- 10 unchanged lines hidden (view full) ---

430 .rate = 0,
431 .resolution = MOUSE_RES_UNKNOWN,
432 .zmap = { 0, 0, 0, 0 },
433 .wmode = 0,
434 .mfd = -1,
435 .cfd = -1,
436 .mremsfd = -1,
437 .mremcfd = -1,
438 .is_removable = 0,
437 .clickthreshold = DFLT_CLICKTHRESHOLD,
438 .button2timeout = DFLT_BUTTON2TIMEOUT,
439 .accelx = 1.0,
440 .accely = 1.0,
441 .expoaccel = 1.0,
442 .expoffset = 1.0,
443 .remainx = 0.0,
444 .remainy = 0.0,

--- 120 unchanged lines hidden (view full) ---

565static int gtco_digipad(u_char, mousestatus_t *);
566
567int
568main(int argc, char *argv[])
569{
570 int c;
571 int i;
572 int j;
439 .clickthreshold = DFLT_CLICKTHRESHOLD,
440 .button2timeout = DFLT_BUTTON2TIMEOUT,
441 .accelx = 1.0,
442 .accely = 1.0,
443 .expoaccel = 1.0,
444 .expoffset = 1.0,
445 .remainx = 0.0,
446 .remainy = 0.0,

--- 120 unchanged lines hidden (view full) ---

567static int gtco_digipad(u_char, mousestatus_t *);
568
569int
570main(int argc, char *argv[])
571{
572 int c;
573 int i;
574 int j;
573 static int retry;
574
575 for (i = 0; i < MOUSE_MAXBUTTON; ++i)
576 mstate[i] = &bstate[i];
577
578 while ((c = getopt(argc, argv, "3A:C:DE:F:HI:L:PRS:T:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
579 switch(c) {
580
581 case '3':

--- 289 unchanged lines hidden (view full) ---

871
872 default:
873 if (rodent.portname)
874 break;
875 warnx("no port name specified");
876 usage();
877 }
878
575
576 for (i = 0; i < MOUSE_MAXBUTTON; ++i)
577 mstate[i] = &bstate[i];
578
579 while ((c = getopt(argc, argv, "3A:C:DE:F:HI:L:PRS:T:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
580 switch(c) {
581
582 case '3':

--- 289 unchanged lines hidden (view full) ---

872
873 default:
874 if (rodent.portname)
875 break;
876 warnx("no port name specified");
877 usage();
878 }
879
879 retry = 1;
880 if (strncmp(rodent.portname, "/dev/ums", 8) == 0) {
881 retry = 5;
882 }
880 if (strncmp(rodent.portname, "/dev/ums", 8) == 0)
881 rodent.is_removable = 1;
883
884 for (;;) {
885 if (setjmp(env) == 0) {
886 signal(SIGHUP, hup);
887 signal(SIGINT , cleanup);
888 signal(SIGQUIT, cleanup);
889 signal(SIGTERM, cleanup);
890 signal(SIGUSR1, pause_mouse);
882
883 for (;;) {
884 if (setjmp(env) == 0) {
885 signal(SIGHUP, hup);
886 signal(SIGINT , cleanup);
887 signal(SIGQUIT, cleanup);
888 signal(SIGTERM, cleanup);
889 signal(SIGUSR1, pause_mouse);
891 for (i = 0; i < retry; ++i) {
892 if (i > 0)
893 sleep(2);
894 rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK);
895 if (rodent.mfd != -1 || errno != ENOENT)
896 break;
897 }
890
891 rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK);
898 if (rodent.mfd == -1)
899 logerr(1, "unable to open %s", rodent.portname);
900 if (r_identify() == MOUSE_PROTO_UNKNOWN) {
901 logwarnx("cannot determine mouse type on %s", rodent.portname);
902 close(rodent.mfd);
903 rodent.mfd = -1;
904 }
905

--- 33 unchanged lines hidden (view full) ---

939 moused();
940 }
941
942 if (rodent.mfd != -1)
943 close(rodent.mfd);
944 if (rodent.cfd != -1)
945 close(rodent.cfd);
946 rodent.mfd = rodent.cfd = -1;
892 if (rodent.mfd == -1)
893 logerr(1, "unable to open %s", rodent.portname);
894 if (r_identify() == MOUSE_PROTO_UNKNOWN) {
895 logwarnx("cannot determine mouse type on %s", rodent.portname);
896 close(rodent.mfd);
897 rodent.mfd = -1;
898 }
899

--- 33 unchanged lines hidden (view full) ---

933 moused();
934 }
935
936 if (rodent.mfd != -1)
937 close(rodent.mfd);
938 if (rodent.cfd != -1)
939 close(rodent.cfd);
940 rodent.mfd = rodent.cfd = -1;
941 if (rodent.is_removable)
942 exit(0);
947 }
948 /* NOT REACHED */
949
950 exit(0);
951}
952
953/*
954 * Function to calculate linear acceleration.

--- 2476 unchanged lines hidden ---
943 }
944 /* NOT REACHED */
945
946 exit(0);
947}
948
949/*
950 * Function to calculate linear acceleration.

--- 2476 unchanged lines hidden ---