Do not pass memory in controller device

This commit is contained in:
Devine Lu Linvega 2024-06-30 21:13:18 -08:00
parent 03328cfc68
commit 776b355ee3
3 changed files with 16 additions and 16 deletions

View File

@ -13,29 +13,29 @@ WITH REGARD TO THIS SOFTWARE.
*/ */
void void
controller_down(Uint8 *d, Uint8 mask) controller_down(Uint8 mask)
{ {
if(mask) { if(mask) {
d[2] |= mask; uxn.dev[0x82] |= mask;
uxn_eval(PEEK2(d)); uxn_eval(PEEK2(&uxn.dev[0x80]));
} }
} }
void void
controller_up(Uint8 *d, Uint8 mask) controller_up(Uint8 mask)
{ {
if(mask) { if(mask) {
d[2] &= (~mask); uxn.dev[0x82] &= (~mask);
uxn_eval(PEEK2(d)); uxn_eval(PEEK2(&uxn.dev[0x80]));
} }
} }
void void
controller_key(Uint8 *d, Uint8 key) controller_key(Uint8 key)
{ {
if(key) { if(key) {
d[3] = key; uxn.dev[0x83] = key;
uxn_eval(PEEK2(d)); uxn_eval(PEEK2(&uxn.dev[0x80]));
d[3] = 0x00; uxn.dev[0x83] = 0;
} }
} }

View File

@ -11,6 +11,6 @@ WITH REGARD TO THIS SOFTWARE.
#define CONTROL_VERSION 1 #define CONTROL_VERSION 1
void controller_down(Uint8 *d, Uint8 mask); void controller_down(Uint8 mask);
void controller_up(Uint8 *d, Uint8 mask); void controller_up(Uint8 mask);
void controller_key(Uint8 *d, Uint8 key); void controller_key(Uint8 key);

View File

@ -158,14 +158,14 @@ emu_event(void)
case XK_F4: emu_restart(boot_rom, 0); break; case XK_F4: emu_restart(boot_rom, 0); break;
case XK_F5: emu_restart(boot_rom, 1); break; case XK_F5: emu_restart(boot_rom, 1); break;
} }
controller_down(&uxn.dev[0x80], get_button(sym)); controller_down(get_button(sym));
controller_key(&uxn.dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]); controller_key(sym < 0x80 ? sym : (Uint8)buf[0]);
} break; } break;
case KeyRelease: { case KeyRelease: {
KeySym sym; KeySym sym;
char buf[7]; char buf[7];
XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0); XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
controller_up(&uxn.dev[0x80], get_button(sym)); controller_up(get_button(sym));
} break; } break;
case ButtonPress: { case ButtonPress: {
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev; XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;