mirror of
https://github.com/isometimes/rpi4-osdev
synced 2024-11-09 11:50:40 +00:00
examples/wgt18.c working with full mouse movement
This commit is contained in:
parent
95f7cc8baf
commit
d9a0eaa864
3 changed files with 18 additions and 8 deletions
|
@ -35,13 +35,16 @@ bleno.on('advertisingStart', function(error) {
|
|||
|
||||
var ioHook = require('iohook');
|
||||
|
||||
var buf = Buffer.allocUnsafe(1);
|
||||
var obuf = Buffer.allocUnsafe(1);
|
||||
var buf = Buffer.allocUnsafe(4);
|
||||
var obuf = Buffer.allocUnsafe(4);
|
||||
const scrwidth = 1440;
|
||||
const divisor = scrwidth / 160;
|
||||
const scrheight = 900;
|
||||
const divisorx = scrwidth / 320;
|
||||
const divisory = scrheight / 200;
|
||||
|
||||
ioHook.on( 'mousemove', event => {
|
||||
buf.writeUInt8(Math.round(event.x / divisor), 0);
|
||||
buf.writeUInt16LE(Math.round(event.x / divisorx), 0);
|
||||
buf.writeUInt16LE(Math.round(event.y / divisory), 2);
|
||||
|
||||
if (Buffer.compare(buf, obuf)) {
|
||||
e._value = buf;
|
||||
|
|
|
@ -159,18 +159,18 @@ void acl_poll()
|
|||
unsigned char d2 = bt_waitReadByte();
|
||||
|
||||
unsigned int dlen = d1 | (d2 << 8);
|
||||
unsigned char data[dlen];
|
||||
|
||||
if (dlen > 7) {
|
||||
unsigned char data[dlen];
|
||||
for (int i=0;i<dlen;i++) data[i] = bt_waitReadByte();
|
||||
|
||||
unsigned int length = data[0] | (data[1] << 8);
|
||||
unsigned int channel = data[2] | (data[3] << 8);
|
||||
unsigned char opcode = data[4];
|
||||
|
||||
if (thandle == connection_handle && length == 4 && opcode == 0x1b) {
|
||||
|
||||
if (thandle == connection_handle && length == 7 && opcode == 0x1b) {
|
||||
if (channel == 4 && data[5] == 0x2a && data[6] == 0x00) {
|
||||
mx = data[7] * 2;
|
||||
msetxy(data[7] | (data[8] << 8), data[9] | (data[10] << 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +178,12 @@ void acl_poll()
|
|||
}
|
||||
}
|
||||
|
||||
void msetxy (short x, short y)
|
||||
{
|
||||
mx = x;
|
||||
my = y;
|
||||
}
|
||||
|
||||
void mdeinit()
|
||||
{
|
||||
comms_up = 0;
|
||||
|
|
|
@ -154,3 +154,4 @@ void whollowpoly(tpolypoint *vertexlist, short numvertex, short x, short y, shor
|
|||
void wbezier (tpolypoint *rawpts, short numraw, tpolypoint *curvepts, short numcurve);
|
||||
void minit();
|
||||
void mdeinit();
|
||||
void msetxy (short x, short y);
|
||||
|
|
Loading…
Reference in a new issue