nusb/kb: use a flag to indicate extended code; fix the most unix-friendly key on se/fi kbd layout
This commit is contained in:
parent
d50ca72774
commit
811c3e8d78
1 changed files with 33 additions and 25 deletions
|
@ -56,6 +56,11 @@ struct KDev
|
||||||
* besides wheel and regular up/down report the 4th byte as 1/-1
|
* besides wheel and regular up/down report the 4th byte as 1/-1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* scan codes >= 0x80 are extended (E0 XX)
|
||||||
|
*/
|
||||||
|
#define isext(sc) ((sc) >= 0x80)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* key code to scan code; for the page table used by
|
* key code to scan code; for the page table used by
|
||||||
* the logitech bluetooth keyboard.
|
* the logitech bluetooth keyboard.
|
||||||
|
@ -70,15 +75,15 @@ static char sctab[256] =
|
||||||
[0x28] 0x1c, 0x1, 0xe, 0xf, 0x39, 0xc, 0xd, 0x1a,
|
[0x28] 0x1c, 0x1, 0xe, 0xf, 0x39, 0xc, 0xd, 0x1a,
|
||||||
[0x30] 0x1b, 0x2b, 0x2b, 0x27, 0x28, 0x29, 0x33, 0x34,
|
[0x30] 0x1b, 0x2b, 0x2b, 0x27, 0x28, 0x29, 0x33, 0x34,
|
||||||
[0x38] 0x35, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
|
[0x38] 0x35, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
|
||||||
[0x40] 0x41, 0x42, 0x43, 0x44, 0x57, 0x58, 0x63, 0x46,
|
[0x40] 0x41, 0x42, 0x43, 0x44, 0x57, 0x58, 0xe3, 0x46,
|
||||||
[0x48] 0x77, 0x52, 0x47, 0x49, 0x53, 0x4f, 0x51, 0x4d,
|
[0x48] 0xf7, 0xd2, 0xc7, 0xc9, 0xd3, 0xcf, 0xd1, 0xcd,
|
||||||
[0x50] 0x4b, 0x50, 0x48, 0x45, 0x35, 0x37, 0x4a, 0x4e,
|
[0x50] 0xcb, 0xd0, 0xc8, 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, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
[0xc8] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
[0xd0] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
[0xd0] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
[0xd8] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
[0xd8] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
[0xe0] 0x1d, 0x2a, 0x38, 0x7d, 0x61, 0x36, 0x64, 0x7e,
|
[0xe0] 0x1d, 0x2a, 0xb8, 0xfd, 0xe1, 0x36, 0xe4, 0xfe,
|
||||||
[0xe8] 0x0, 0x0, 0x0, 0x0, 0x0, 0x73, 0x72, 0x71,
|
[0xe8] 0x0, 0x0, 0x0, 0x0, 0x0, 0xf3, 0xf2, 0xf1,
|
||||||
[0xf0] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
[0xf0] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
[0xf8] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
[0xf8] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
};
|
};
|
||||||
|
@ -513,14 +518,18 @@ ptrwork(void* a)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
putscan(int fd, uchar esc, uchar sc)
|
putscan(int fd, uchar sc, uchar up)
|
||||||
{
|
{
|
||||||
uchar s[2] = {SCesc1, 0};
|
uchar s[2] = {SCesc1, 0};
|
||||||
|
|
||||||
s[1] = sc;
|
s[1] = sc&Keymask;
|
||||||
if(esc && sc != 0)
|
if(s[1] == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
s[1] |= up;
|
||||||
|
if(isext(sc))
|
||||||
write(fd, s, 2);
|
write(fd, s, 2);
|
||||||
else if(sc != 0)
|
else
|
||||||
write(fd, s+1, 1);
|
write(fd, s+1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,7 +572,7 @@ repeatproc(void* arg)
|
||||||
Channel *repeatc, *sleepc;
|
Channel *repeatc, *sleepc;
|
||||||
int kbdinfd;
|
int kbdinfd;
|
||||||
ulong l, t;
|
ulong l, t;
|
||||||
uchar esc1, sc;
|
uchar sc;
|
||||||
Alt a[3];
|
Alt a[3];
|
||||||
|
|
||||||
repeatc = f->repeatc;
|
repeatc = f->repeatc;
|
||||||
|
@ -590,13 +599,14 @@ repeatproc(void* arg)
|
||||||
l = recvul(repeatc);
|
l = recvul(repeatc);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
esc1 = l >> 8;
|
|
||||||
sc = l;
|
sc = l;
|
||||||
|
if((l>>8) != 0)
|
||||||
|
sc |= 0x80;
|
||||||
t = Kbdelay;
|
t = Kbdelay;
|
||||||
if(alt(a) == 1){
|
if(alt(a) == 1){
|
||||||
t = Kbrepeat;
|
t = Kbrepeat;
|
||||||
while(alt(a) == 1)
|
while(alt(a) == 1)
|
||||||
putscan(kbdinfd, esc1, sc);
|
putscan(kbdinfd, sc, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sleepc != nil)
|
if(sleepc != nil)
|
||||||
|
@ -612,19 +622,17 @@ stoprepeat(KDev *f)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
startrepeat(KDev *f, uchar esc1, uchar sc)
|
startrepeat(KDev *f, uchar sc)
|
||||||
{
|
{
|
||||||
ulong c;
|
ulong c;
|
||||||
|
|
||||||
if(esc1)
|
if(isext(sc))
|
||||||
c = SCesc1 << 8 | (sc & 0xff);
|
c = SCesc1 << 8 | (sc & 0xff);
|
||||||
else
|
else
|
||||||
c = sc;
|
c = sc;
|
||||||
sendul(f->repeatc, c);
|
sendul(f->repeatc, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define hasesc1(sc) (((sc) >= 0x47) || ((sc) == 0x38))
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine diffs the state with the last known state
|
* This routine diffs the state with the last known state
|
||||||
* and invents the scan codes that would have been sent
|
* and invents the scan codes that would have been sent
|
||||||
|
@ -654,8 +662,8 @@ putkeys(KDev *f, uchar buf[], uchar obuf[], int n, uchar dk)
|
||||||
break;
|
break;
|
||||||
if(j == n && buf[i] != 0){
|
if(j == n && buf[i] != 0){
|
||||||
dk = sctab[buf[i]];
|
dk = sctab[buf[i]];
|
||||||
putscan(fd, hasesc1(dk), dk);
|
putscan(fd, dk, 0);
|
||||||
startrepeat(f, hasesc1(dk), dk);
|
startrepeat(f, dk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +675,7 @@ putkeys(KDev *f, uchar buf[], uchar obuf[], int n, uchar dk)
|
||||||
break;
|
break;
|
||||||
if(j == n && obuf[i] != 0){
|
if(j == n && obuf[i] != 0){
|
||||||
uk = sctab[obuf[i]];
|
uk = sctab[obuf[i]];
|
||||||
putscan(fd, hasesc1(uk), uk|Keyup);
|
putscan(fd, uk, Keyup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(uk && (dk == 0 || dk == uk)){
|
if(uk && (dk == 0 || dk == uk)){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue