add usb tablet support
This commit is contained in:
parent
ec60da4961
commit
0e5888a0cf
3 changed files with 37 additions and 16 deletions
|
@ -351,6 +351,8 @@ setbuttonmap(char* map)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scmousetrack(int, int, int, ulong);
|
||||||
|
|
||||||
static long
|
static long
|
||||||
mousewrite(Chan *c, void *va, long n, vlong)
|
mousewrite(Chan *c, void *va, long n, vlong)
|
||||||
{
|
{
|
||||||
|
@ -468,6 +470,8 @@ mousewrite(Chan *c, void *va, long n, vlong)
|
||||||
|
|
||||||
if(buf[0] == 'A')
|
if(buf[0] == 'A')
|
||||||
absmousetrack(pt.x, pt.y, b, msec);
|
absmousetrack(pt.x, pt.y, b, msec);
|
||||||
|
else if(buf[0] == 'a')
|
||||||
|
scmousetrack(pt.x, pt.y, b, msec);
|
||||||
else
|
else
|
||||||
mousetrack(pt.x, pt.y, b, msec);
|
mousetrack(pt.x, pt.y, b, msec);
|
||||||
return n;
|
return n;
|
||||||
|
@ -640,6 +644,22 @@ absmousetrack(int x, int y, int b, ulong msec)
|
||||||
mouseredraw();
|
mouseredraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
scmousetrack(int x, int y, int b, ulong msec)
|
||||||
|
{
|
||||||
|
vlong vx, vy;
|
||||||
|
|
||||||
|
if(gscreen==nil)
|
||||||
|
return;
|
||||||
|
|
||||||
|
vx = (vlong)(uint)x * (gscreen->clipr.max.x - gscreen->clipr.min.x);
|
||||||
|
x = (vx + (1<<30) - (~vx>>31&1) >> 31) + gscreen->clipr.min.x;
|
||||||
|
vy = (vlong)(uint)y * (gscreen->clipr.max.y - gscreen->clipr.min.y);
|
||||||
|
y = (vy + (1<<30) - (~vy>>31&1) >> 31) + gscreen->clipr.min.y;
|
||||||
|
|
||||||
|
absmousetrack(x, y, b, msec);
|
||||||
|
}
|
||||||
|
|
||||||
static ulong
|
static ulong
|
||||||
lastms(void)
|
lastms(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,7 @@ enum {
|
||||||
/* HID class subclass protocol ids */
|
/* HID class subclass protocol ids */
|
||||||
PtrCSP = 0x020103, /* mouse.boot.hid */
|
PtrCSP = 0x020103, /* mouse.boot.hid */
|
||||||
HidCSP = 0x000003, /* could be a trackpoint */
|
HidCSP = 0x000003, /* could be a trackpoint */
|
||||||
|
PtrNonBootCSP = 0x020003,
|
||||||
KbdCSP = 0x010103, /* keyboard.boot.hid */
|
KbdCSP = 0x010103, /* keyboard.boot.hid */
|
||||||
|
|
||||||
/* Requests */
|
/* Requests */
|
||||||
|
|
|
@ -55,9 +55,8 @@ struct Hidreport
|
||||||
int b;
|
int b;
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
int absx;
|
|
||||||
int absy;
|
|
||||||
int absz;
|
int absz;
|
||||||
|
u8int abs;
|
||||||
|
|
||||||
int nk;
|
int nk;
|
||||||
uchar k[64];
|
uchar k[64];
|
||||||
|
@ -550,25 +549,21 @@ hidparse(int t, int f, int g[], int l[], int, void *a)
|
||||||
break;
|
break;
|
||||||
case 0x010030:
|
case 0x010030:
|
||||||
if((f & (Fabs|Frel)) == Fabs){
|
if((f & (Fabs|Frel)) == Fabs){
|
||||||
p->x = (v - p->absx);
|
v = ((vlong)(v - g[LogiMin]) << 31) / (g[LogiMax] - g[LogiMin]);
|
||||||
p->absx = v;
|
p->abs = 1;
|
||||||
} else {
|
|
||||||
p->x = v;
|
|
||||||
p->absx += v;
|
|
||||||
}
|
}
|
||||||
|
p->x = v;
|
||||||
break;
|
break;
|
||||||
case 0x010031:
|
case 0x010031:
|
||||||
if((f & (Fabs|Frel)) == Fabs){
|
if((f & (Fabs|Frel)) == Fabs){
|
||||||
p->y = (v - p->absy);
|
v = ((vlong)(v - g[LogiMin]) << 31) / (g[LogiMax] - g[LogiMin]);
|
||||||
p->absy = v;
|
p->abs = 1;
|
||||||
} else {
|
|
||||||
p->y = v;
|
|
||||||
p->absy += v;
|
|
||||||
}
|
}
|
||||||
|
p->y = v;
|
||||||
break;
|
break;
|
||||||
case 0x010038:
|
case 0x010038:
|
||||||
if((f & (Fabs|Frel)) == Fabs){
|
if((f & (Fabs|Frel)) == Fabs){
|
||||||
p->z = (v - p->absz);
|
p->z = v - p->absz;
|
||||||
p->absz = v;
|
p->absz = v;
|
||||||
} else {
|
} else {
|
||||||
p->z = v;
|
p->z = v;
|
||||||
|
@ -632,6 +627,7 @@ readerproc(void* a)
|
||||||
|
|
||||||
p.o = 0;
|
p.o = 0;
|
||||||
p.e = p.p + c;
|
p.e = p.p + c;
|
||||||
|
p.abs = 0;
|
||||||
repparse(f->rep, f->rep+f->nrep, hidparse, &p);
|
repparse(f->rep, f->rep+f->nrep, hidparse, &p);
|
||||||
|
|
||||||
if(p.nk != 0 || nlastk != 0){
|
if(p.nk != 0 || nlastk != 0){
|
||||||
|
@ -684,9 +680,12 @@ readerproc(void* a)
|
||||||
if(p.z != 0)
|
if(p.z != 0)
|
||||||
b |= (p.z > 0) ? 8 : 16;
|
b |= (p.z > 0) ? 8 : 16;
|
||||||
|
|
||||||
if(p.x != 0 || p.y != 0 || p.z != 0 || b != lastb){
|
if(p.abs || p.x != 0 || p.y != 0 || p.z != 0 || b != lastb){
|
||||||
if(debug)
|
if(debug)
|
||||||
fprint(2, "ptr: b=%x m=%x x=%d y=%d z=%d\n", p.b, p.m, p.x, p.y, p.z);
|
if(p.abs)
|
||||||
|
fprint(2, "ptr: b=%x m=%x x=%f y=%f z=%d\n", p.b, p.m, (uint)p.x / 2147483648.0, (uint)p.y / 2147483648.0, p.z);
|
||||||
|
else
|
||||||
|
fprint(2, "ptr: b=%x m=%x x=%d y=%d z=%d\n", p.b, p.m, p.x, p.y, p.z);
|
||||||
|
|
||||||
if(f->minfd < 0){
|
if(f->minfd < 0){
|
||||||
f->minfd = open("/dev/mousein", OWRITE);
|
f->minfd = open("/dev/mousein", OWRITE);
|
||||||
|
@ -694,7 +693,7 @@ readerproc(void* a)
|
||||||
hdfatal(f, "open /dev/mousein");
|
hdfatal(f, "open /dev/mousein");
|
||||||
}
|
}
|
||||||
|
|
||||||
seprint(mbuf, mbuf+sizeof(mbuf), "m%11d %11d %11d", p.x, p.y, b);
|
seprint(mbuf, mbuf+sizeof(mbuf), "%c%11d %11d %11d", "ma"[p.abs], p.x, p.y, b);
|
||||||
write(f->minfd, mbuf, strlen(mbuf));
|
write(f->minfd, mbuf, strlen(mbuf));
|
||||||
|
|
||||||
lastb = b;
|
lastb = b;
|
||||||
|
@ -767,6 +766,7 @@ threadmain(int argc, char* argv[])
|
||||||
switch(ep->iface->csp){
|
switch(ep->iface->csp){
|
||||||
case KbdCSP:
|
case KbdCSP:
|
||||||
case PtrCSP:
|
case PtrCSP:
|
||||||
|
case PtrNonBootCSP:
|
||||||
case HidCSP:
|
case HidCSP:
|
||||||
hdsetup(d, ep);
|
hdsetup(d, ep);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue