Removed mouse as Device
This commit is contained in:
parent
9c34a59741
commit
ab6ce6ba5a
1
build.sh
1
build.sh
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
clang-format -i src/uxn11.c
|
||||
clang-format -i src/devices/*
|
||||
|
||||
echo "Cleaning.."
|
||||
rm -f ./bin/*
|
||||
|
|
|
@ -14,33 +14,33 @@ WITH REGARD TO THIS SOFTWARE.
|
|||
*/
|
||||
|
||||
void
|
||||
mouse_down(Device *d, Uint8 mask)
|
||||
mouse_down(Uxn *u, Uint8 *d, Uint8 mask)
|
||||
{
|
||||
d->dat[6] |= mask;
|
||||
uxn_eval(d->u, GETVECTOR(d));
|
||||
d[6] |= mask;
|
||||
uxn_eval(u, GETVEC(d));
|
||||
}
|
||||
|
||||
void
|
||||
mouse_up(Device *d, Uint8 mask)
|
||||
mouse_up(Uxn *u, Uint8 *d, Uint8 mask)
|
||||
{
|
||||
d->dat[6] &= (~mask);
|
||||
uxn_eval(d->u, GETVECTOR(d));
|
||||
d[6] &= (~mask);
|
||||
uxn_eval(u, GETVEC(d));
|
||||
}
|
||||
|
||||
void
|
||||
mouse_pos(Device *d, Uint16 x, Uint16 y)
|
||||
mouse_pos(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
|
||||
{
|
||||
DEVPOKE16(0x2, x);
|
||||
DEVPOKE16(0x4, y);
|
||||
uxn_eval(d->u, GETVECTOR(d));
|
||||
POKDEV(0x2, x);
|
||||
POKDEV(0x4, y);
|
||||
uxn_eval(u, GETVEC(d));
|
||||
}
|
||||
|
||||
void
|
||||
mouse_scroll(Device *d, Uint16 x, Uint16 y)
|
||||
mouse_scroll(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
|
||||
{
|
||||
DEVPOKE16(0xa, x);
|
||||
DEVPOKE16(0xc, -y);
|
||||
uxn_eval(d->u, GETVECTOR(d));
|
||||
DEVPOKE16(0xa, 0);
|
||||
DEVPOKE16(0xc, 0);
|
||||
POKDEV(0xa, x);
|
||||
POKDEV(0xc, -y);
|
||||
uxn_eval(u, GETVEC(d));
|
||||
POKDEV(0xa, 0);
|
||||
POKDEV(0xc, 0);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|||
WITH REGARD TO THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
void mouse_down(Device *d, Uint8 mask);
|
||||
void mouse_up(Device *d, Uint8 mask);
|
||||
void mouse_pos(Device *d, Uint16 x, Uint16 y);
|
||||
void mouse_scroll(Device *d, Uint16 x, Uint16 y);
|
||||
void mouse_down(Uxn *u, Uint8 *d, Uint8 mask);
|
||||
void mouse_up(Uxn *u, Uint8 *d, Uint8 mask);
|
||||
void mouse_pos(Uxn *u, Uint8 *d, Uint16 x, Uint16 y);
|
||||
void mouse_scroll(Uxn *u, Uint8 *d, Uint16 x, Uint16 y);
|
||||
|
|
|
@ -55,8 +55,8 @@ void
|
|||
system_deo(Device *d, Uint8 port)
|
||||
{
|
||||
switch(port) {
|
||||
case 0x2: d->u->wst = (Stack*)(d->u->ram + (d->dat[port] ? (d->dat[port] * 0x100) : 0x10000)); break;
|
||||
case 0x3: d->u->rst = (Stack*)(d->u->ram + (d->dat[port] ? (d->dat[port] * 0x100) : 0x10100)); break;
|
||||
case 0x2: d->u->wst = (Stack *)(d->u->ram + (d->dat[port] ? (d->dat[port] * 0x100) : 0x10000)); break;
|
||||
case 0x3: d->u->rst = (Stack *)(d->u->ram + (d->dat[port] ? (d->dat[port] * 0x100) : 0x10100)); break;
|
||||
case 0xe: system_inspect(d->u); break;
|
||||
default: system_deo_special(d, port);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,9 @@ typedef unsigned int Uint32;
|
|||
#define DEVPEEK16(o, x) { (o) = (d->dat[(x)] << 8) + d->dat[(x) + 1]; }
|
||||
#define DEVPOKE16(x, y) { d->dat[(x)] = (y) >> 8; d->dat[(x) + 1] = (y); }
|
||||
#define GETVECTOR(d) ((d)->dat[0] << 8 | (d)->dat[1])
|
||||
|
||||
#define GETVEC(d) ((d)[0] << 8 | (d)[1])
|
||||
#define POKDEV(x, y) { d[(x)] = (y) >> 8; d[(x) + 1] = (y); }
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
|
|
|
@ -155,15 +155,15 @@ processEvent(void)
|
|||
} break;
|
||||
case ButtonPress: {
|
||||
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
|
||||
mouse_down(devmouse, 0x1 << (e->button - 1));
|
||||
mouse_down(devmouse->u, devmouse->dat, 0x1 << (e->button - 1));
|
||||
} break;
|
||||
case ButtonRelease: {
|
||||
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
|
||||
mouse_up(devmouse, 0x1 << (e->button - 1));
|
||||
mouse_up(devmouse->u, devmouse->dat, 0x1 << (e->button - 1));
|
||||
} break;
|
||||
case MotionNotify: {
|
||||
XMotionEvent *e = (XMotionEvent *)&ev;
|
||||
mouse_pos(devmouse, e->x, e->y);
|
||||
mouse_pos(devmouse->u, devmouse->dat, e->x, e->y);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue