summaryrefslogtreecommitdiff
path: root/usr.sbin/moused
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2000-09-04 18:01:51 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2000-09-04 18:01:51 +0000
commit5f8a6fd664ae8e93d47d04990dc58695ed3f277a (patch)
tree6879cf6717ea044f184df5e747c89ca493af2be2 /usr.sbin/moused
parent715a7b0af8d590e1fcca6a9b8194e726f4e744f2 (diff)
Set reasonable default rate/resolution values for PS/2 mice.
TODO: Still need to reset these values if we detect the mouse going away and coming back (i.e., through the use of a KVM switch). From Jean-Baptiste.Marchand@epita.fr.
Diffstat (limited to 'usr.sbin/moused')
-rw-r--r--usr.sbin/moused/moused.c73
-rw-r--r--usr.sbin/moused/moused.h36
2 files changed, 89 insertions, 20 deletions
diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c
index 8974e980319..3b65231f4c1 100644
--- a/usr.sbin/moused/moused.c
+++ b/usr.sbin/moused/moused.c
@@ -187,7 +187,7 @@ mouse_t mouse = {
proto : P_UNKNOWN,
baudrate : 1200,
old_baudrate : 1200,
- rate : 0,
+ rate : MOUSE_RATE_UNKNOWN,
resolution : MOUSE_RES_UNKNOWN,
zmap: 0,
wmode: 0,
@@ -329,8 +329,6 @@ mouse_fill_mousemode(void)
/* default settings */
mouse.mode.protocol = P_UNKNOWN;
- mouse.mode.rate = -1; /* unknown */
- mouse.mode.resolution = MOUSE_RES_UNKNOWN;
mouse.mode.accelfactor = 0; /* no accel */
if (strcmp(mouse.portname,PMS_DEV) == 0) {
@@ -358,6 +356,47 @@ mouse_fill_mousemode(void)
}
if (mouse.proto != -1)
mouse.mode.protocol = mouse.proto;
+
+ /* resolution */
+
+ switch (mouse.resolution) {
+ case MOUSE_RES_HIGH:
+ case MOUSE_RES_MEDIUMHIGH:
+ case MOUSE_RES_MEDIUMLOW:
+ case MOUSE_RES_LOW:
+ mouse.mode.resolution = mouse.resolution;
+ break;
+ case MOUSE_RES_DEFAULT:
+ case MOUSE_RES_UNKNOWN:
+ /* default to low resolution */
+ mouse.mode.resolution = MOUSE_RES_LOW;
+ break;
+ default:
+ if (mouse.resolution >= 200)
+ mouse.mode.resolution = MOUSE_RES_HIGH;
+ else if (mouse.resolution >= 100)
+ mouse.mode.resolution = MOUSE_RES_MEDIUMHIGH;
+ else if (mouse.resolution >= 50)
+ mouse.mode.resolution = MOUSE_RES_MEDIUMLOW;
+ else mouse.mode.resolution = MOUSE_RES_LOW;
+ }
+
+ /* sample rate */
+
+ if (mouse.rate != MOUSE_RATE_UNKNOWN) {
+ if (mouse.rate >= 200)
+ mouse.mode.rate = MOUSE_RATE_VERY_HIGH;
+ else if (mouse.rate >= 100)
+ mouse.mode.rate = MOUSE_RATE_HIGH;
+ else if (mouse.rate >= 80)
+ mouse.mode.rate = MOUSE_RATE_MEDIUM_HIGH;
+ else if (mouse.rate >= 60)
+ mouse.mode.rate = MOUSE_RATE_MEDIUM_LOW;
+ else if (mouse.rate >= 40)
+ mouse.mode.rate = MOUSE_RATE_LOW;
+ else
+ mouse.mode.rate = MOUSE_RATE_VERY_LOW;
+ }
}
static void
@@ -1010,13 +1049,27 @@ mouse_init(void)
}
break;
- case P_BM:
+ case P_BM:
+ break;
+
case P_PS2:
- if (mouse.rate >= 0)
- mouse.mode.rate = mouse.rate;
- if (mouse.resolution != MOUSE_RES_UNKNOWN)
- mouse.mode.resolution = mouse.resolution;
- /* XXX Rate and resolution are not set ! (pms driver can't) XXX */
+
+ /* now sets the resolution and rate for PS/2 mice */
+
+ /* always sets resolution, to a default value if no value is given */
+
+ c = PS2_SET_RES;
+ write(mouse.mfd, &c, 1);
+ c = mouse.mode.resolution;
+ write(mouse.mfd, &c, 1);
+
+ if (mouse.rate != MOUSE_RATE_UNKNOWN) {
+ c = PS2_SET_RATE;
+ write(mouse.mfd, &c, 1);
+ c = mouse.mode.rate;
+ write(mouse.mfd, &c, 1);
+ }
+
break;
default:
@@ -1868,7 +1921,7 @@ main(int argc, char **argv)
if (strcmp(optarg, "high") == 0)
mouse.resolution = MOUSE_RES_HIGH;
else if (strcmp(optarg, "medium-high") == 0)
- mouse.resolution = MOUSE_RES_HIGH;
+ mouse.resolution = MOUSE_RES_MEDIUMHIGH;
else if (strcmp(optarg, "medium-low") == 0)
mouse.resolution = MOUSE_RES_MEDIUMLOW;
else if (strcmp(optarg, "low") == 0)
diff --git a/usr.sbin/moused/moused.h b/usr.sbin/moused/moused.h
index 1f983a1d8c3..30499b9f05a 100644
--- a/usr.sbin/moused/moused.h
+++ b/usr.sbin/moused/moused.h
@@ -273,12 +273,28 @@ typedef struct {
/* Mouse resolutions */
-#define MOUSE_RES_UNKNOWN (-1)
-#define MOUSE_RES_DEFAULT 0
-#define MOUSE_RES_LOW (-2)
-#define MOUSE_RES_MEDIUMLOW (-3)
-#define MOUSE_RES_MEDIUMHIGH (-4)
-#define MOUSE_RES_HIGH (-5)
+#define MOUSE_RES_DEFAULT 254
+#define MOUSE_RES_UNKNOWN 255
+#define MOUSE_RES_LOW 0
+#define MOUSE_RES_MEDIUMLOW 1
+#define MOUSE_RES_MEDIUMHIGH 2
+#define MOUSE_RES_HIGH 3
+
+/* Mouse report rates */
+
+#define MOUSE_RATE_UNKNOWN 255
+#define MOUSE_RATE_DEFAULT 80
+#define MOUSE_RATE_VERY_LOW 20
+#define MOUSE_RATE_LOW 40
+#define MOUSE_RATE_MEDIUM_LOW 60
+#define MOUSE_RATE_MEDIUM_HIGH 80
+#define MOUSE_RATE_HIGH 100
+#define MOUSE_RATE_VERY_HIGH 200
+
+/* PS/2 rate and resolution */
+
+#define PS2_SET_RATE 0xf3
+#define PS2_SET_RES 0xe8
/* serial PnP ID string */
typedef struct {
@@ -308,8 +324,8 @@ typedef struct mousehw {
typedef struct mousemode {
int protocol; /* MOUSE_PROTO_XXX */
- int rate; /* report rate (per sec), -1 if unknown */
- int resolution; /* MOUSE_RES_XXX, -1 if unknown */
+ unsigned char rate; /* report rate (per sec), -1 if unknown */
+ unsigned char resolution;/* MOUSE_RES_XXX, -1 if unknown */
int accelfactor; /* accelation factor (must be 1 or greater) */
int packetsize; /* the length of the data packet */
unsigned char syncmask[2]; /* sync. data bits in the header byte */
@@ -323,8 +339,8 @@ typedef struct mouse_s {
int proto; /* MOUSE_PROTO_XXX */
int baudrate;
int old_baudrate;
- int rate; /* report rate */
- int resolution; /* MOUSE_RES_XXX or a positive number */
+ unsigned char rate; /* report rate */
+ unsigned char resolution; /* MOUSE_RES_XXX or a positive number */
int zmap; /* MOUSE_{X|Y}AXIS or a button number */
int wmode; /* wheel mode button number */
int mfd; /* mouse file descriptor */