kbd: add "repeat" file to set typematic repeat rate/delay on PS/2 keyboards
This commit is contained in:
parent
47e3c088c9
commit
9014360921
2 changed files with 48 additions and 7 deletions
|
@ -7,15 +7,17 @@ kbd \- pc keyboard driver
|
||||||
|
|
||||||
.B /dev/scancode
|
.B /dev/scancode
|
||||||
.B /dev/leds
|
.B /dev/leds
|
||||||
|
.B /dev/repeat
|
||||||
.fi
|
.fi
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
The
|
The
|
||||||
.I kbd
|
.I kbd
|
||||||
device serves a one-level directory containing the files
|
device serves a one-level directory containing the files
|
||||||
.BR scancode
|
.BR scancode ,
|
||||||
|
.BR leds
|
||||||
and
|
and
|
||||||
.BR leds .
|
.BR repeat .
|
||||||
.PP
|
.PP
|
||||||
Reading the
|
Reading the
|
||||||
.BR scancode
|
.BR scancode
|
||||||
|
@ -29,14 +31,27 @@ file can be only opened once by the hostowner.
|
||||||
.PP
|
.PP
|
||||||
Writing a number to the write-only
|
Writing a number to the write-only
|
||||||
.BR leds
|
.BR leds
|
||||||
file changes the status leds on the keyboard. the value of the
|
file changes the status leds on the keyboard. The value of the
|
||||||
number is the addition of 1, 2 and 4 representing activated
|
number is the addition of 1, 2 and 4 representing activated
|
||||||
Scroll, Num and Caps leds.
|
Scroll, Num and Caps leds.
|
||||||
|
.PP
|
||||||
|
The
|
||||||
|
.BR repeat
|
||||||
|
file sets typematic rate and delay. The value of the number is a
|
||||||
|
bitmask where first 5 bits set the repeat rate (ranging from 0b00000
|
||||||
|
for 30Hz to 0b11111 for 2Hz). Bits 6 and 7 set the delay before the
|
||||||
|
first repeat is activated (ranging from 0b00 for 250Hz to 0b11 for
|
||||||
|
1000Hz).
|
||||||
.SH EXAMPLE
|
.SH EXAMPLE
|
||||||
Set the Scroll and Caps leds:
|
Set the Scroll and Caps leds:
|
||||||
.EX
|
.EX
|
||||||
echo 5 >/dev/leds
|
echo 5 >/dev/leds
|
||||||
.EE
|
.EE
|
||||||
|
.PP
|
||||||
|
Enable fast repeat rate and the least delay:
|
||||||
|
.EX
|
||||||
|
echo 0 >/dev/repeat
|
||||||
|
.EE
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.IR kbdfs (8)
|
.IR kbdfs (8)
|
||||||
.SH SOURCE
|
.SH SOURCE
|
||||||
|
|
|
@ -40,12 +40,14 @@ enum {
|
||||||
Qdir,
|
Qdir,
|
||||||
Qscancode,
|
Qscancode,
|
||||||
Qleds,
|
Qleds,
|
||||||
|
Qrepeat,
|
||||||
};
|
};
|
||||||
|
|
||||||
static Dirtab kbdtab[] = {
|
static Dirtab kbdtab[] = {
|
||||||
".", {Qdir, 0, QTDIR}, 0, 0555,
|
".", {Qdir, 0, QTDIR}, 0, 0555,
|
||||||
"scancode", {Qscancode, 0}, 0, 0440,
|
"scancode", {Qscancode, 0}, 0, 0440,
|
||||||
"leds", {Qleds, 0}, 0, 0220,
|
"leds", {Qleds, 0}, 0, 0220,
|
||||||
|
"repeat", {Qrepeat, 0}, 0, 0220,
|
||||||
};
|
};
|
||||||
|
|
||||||
static Lock i8042lock;
|
static Lock i8042lock;
|
||||||
|
@ -193,6 +195,28 @@ setleds(int leds)
|
||||||
iunlock(&i8042lock);
|
iunlock(&i8042lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setrepeat(int repeat)
|
||||||
|
{
|
||||||
|
if(nokbd)
|
||||||
|
return;
|
||||||
|
|
||||||
|
repeat &= 0x7f;
|
||||||
|
ilock(&i8042lock);
|
||||||
|
for(;;){
|
||||||
|
if(outready() < 0)
|
||||||
|
break;
|
||||||
|
outb(Data, 0xf3); /* `set typematic rate and delay' */
|
||||||
|
if(outready() < 0)
|
||||||
|
break;
|
||||||
|
outb(Data, repeat);
|
||||||
|
if(outready() < 0)
|
||||||
|
break;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
iunlock(&i8042lock);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* keyboard interrupt
|
* keyboard interrupt
|
||||||
*/
|
*/
|
||||||
|
@ -357,16 +381,18 @@ kbdwrite(Chan *c, void *a, long n, vlong)
|
||||||
{
|
{
|
||||||
char tmp[8+1], *p;
|
char tmp[8+1], *p;
|
||||||
|
|
||||||
if(c->qid.path != Qleds)
|
|
||||||
error(Egreg);
|
|
||||||
|
|
||||||
p = tmp + n;
|
p = tmp + n;
|
||||||
if(n >= sizeof(tmp))
|
if(n >= sizeof(tmp))
|
||||||
p = tmp + sizeof(tmp)-1;
|
p = tmp + sizeof(tmp)-1;
|
||||||
memmove(tmp, a, p - tmp);
|
memmove(tmp, a, p - tmp);
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
||||||
|
if(c->qid.path == Qleds)
|
||||||
setleds(atoi(tmp));
|
setleds(atoi(tmp));
|
||||||
|
else if(c->qid.path == Qrepeat)
|
||||||
|
setrepeat(atoi(tmp));
|
||||||
|
else
|
||||||
|
error(Egreg);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue