Removed controller as Device

This commit is contained in:
neauoire 2022-04-05 09:10:29 -07:00
parent 621308986c
commit 9c34a59741
5 changed files with 23 additions and 22 deletions

View File

@ -22,4 +22,4 @@ fi
echo "Done."
# echo "Running.."
bin/uxn11 ~/roms/catclock.rom
bin/uxn11 ~/roms/left.rom

View File

@ -14,39 +14,39 @@ WITH REGARD TO THIS SOFTWARE.
*/
void
controller_down(Device *d, Uint8 mask)
controller_down(Uxn *u, Uint8 *d, Uint8 mask)
{
if(mask) {
d->dat[2] |= mask;
uxn_eval(d->u, GETVECTOR(d));
d[2] |= mask;
uxn_eval(u, GETVEC(d));
}
}
void
controller_up(Device *d, Uint8 mask)
controller_up(Uxn *u, Uint8 *d, Uint8 mask)
{
if(mask) {
d->dat[2] &= (~mask);
uxn_eval(d->u, GETVECTOR(d));
d[2] &= (~mask);
uxn_eval(u, GETVEC(d));
}
}
void
controller_key(Device *d, Uint8 key)
controller_key(Uxn *u, Uint8 *d, Uint8 key)
{
if(key) {
d->dat[3] = key;
uxn_eval(d->u, GETVECTOR(d));
d->dat[3] = 0x00;
d[3] = key;
uxn_eval(u, GETVEC(d));
d[3] = 0x00;
}
}
void
controller_special(Device *d, Uint8 key)
controller_special(Uxn *u, Uint8 *d, Uint8 key)
{
if(key) {
d->dat[4] = key;
uxn_eval(d->u, GETVECTOR(d));
d->dat[4] = 0x00;
d[4] = key;
uxn_eval(u, GETVEC(d));
d[4] = 0x00;
}
}

View File

@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
void controller_down(Device *d, Uint8 mask);
void controller_up(Device *d, Uint8 mask);
void controller_key(Device *d, Uint8 key);
void controller_special(Device *d, Uint8 key);
void controller_down(Uxn *u, Uint8 *d, Uint8 mask);
void controller_up(Uxn *u, Uint8 *d, Uint8 mask);
void controller_key(Uxn *u, Uint8 *d, Uint8 key);
void controller_special(Uxn *u, Uint8 *d, Uint8 key);

View File

@ -22,6 +22,7 @@ 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])
/* clang-format on */

View File

@ -144,14 +144,14 @@ processEvent(void)
KeySym sym;
char buf[7];
XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
controller_down(devctrl, get_button(sym));
controller_key(devctrl, sym < 0x80 ? sym : buf[0]);
controller_down(devctrl->u, devctrl->dat, get_button(sym));
controller_key(devctrl->u, devctrl->dat, sym < 0x80 ? sym : buf[0]);
} break;
case KeyRelease: {
KeySym sym;
char buf[7];
XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
controller_up(devctrl, get_button(sym));
controller_up(devctrl->u, devctrl->dat, get_button(sym));
} break;
case ButtonPress: {
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;