Added Controller/key

This commit is contained in:
neauoire 2022-03-27 14:29:46 -07:00
parent c58fecb85e
commit 91c94af9f8
2 changed files with 4 additions and 0 deletions

BIN
etc/console.rom Normal file

Binary file not shown.

View File

@ -1,6 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "uxn.h" #include "uxn.h"
#include "devices/system.h" #include "devices/system.h"
@ -115,6 +116,7 @@ processEvent(void)
} break; } break;
case KeyPress: { case KeyPress: {
XKeyPressedEvent *e = (XKeyPressedEvent *)&ev; XKeyPressedEvent *e = (XKeyPressedEvent *)&ev;
char buf[7];
if(e->keycode == XKeysymToKeycode(display, XK_Escape)) exit(0); if(e->keycode == XKeysymToKeycode(display, XK_Escape)) exit(0);
if(e->keycode == XKeysymToKeycode(display, XK_Up)) controller_down(devctrl, 0x10); if(e->keycode == XKeysymToKeycode(display, XK_Up)) controller_down(devctrl, 0x10);
if(e->keycode == XKeysymToKeycode(display, XK_Down)) controller_down(devctrl, 0x20); if(e->keycode == XKeysymToKeycode(display, XK_Down)) controller_down(devctrl, 0x20);
@ -124,6 +126,8 @@ processEvent(void)
if(e->keycode == XKeysymToKeycode(display, XK_Alt)) controller_down(devctrl, 0x02); if(e->keycode == XKeysymToKeycode(display, XK_Alt)) controller_down(devctrl, 0x02);
if(e->keycode == XKeysymToKeycode(display, XK_Shift)) controller_down(devctrl, 0x04); if(e->keycode == XKeysymToKeycode(display, XK_Shift)) controller_down(devctrl, 0x04);
if(e->keycode == XKeysymToKeycode(display, XK_Home)) controller_down(devctrl, 0x08); if(e->keycode == XKeysymToKeycode(display, XK_Home)) controller_down(devctrl, 0x08);
XLookupString(e, buf, 7, NULL, NULL);
controller_key(devctrl, buf[0]);
} break; } break;
case KeyRelease: { case KeyRelease: {
XKeyPressedEvent *e = (XKeyPressedEvent *)&ev; XKeyPressedEvent *e = (XKeyPressedEvent *)&ev;