Implemented controller
This commit is contained in:
parent
a34ceda22c
commit
f494421979
Binary file not shown.
Binary file not shown.
32
src/uxn11.c
32
src/uxn11.c
|
@ -67,6 +67,16 @@ load(Uxn *u, char *filepath)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
redraw(Display *display, Visual *visual, Window window)
|
||||||
|
{
|
||||||
|
XImage *ximage;
|
||||||
|
screen_redraw(&uxn_screen, uxn_screen.pixels);
|
||||||
|
ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width, uxn_screen.height, 32, 0);
|
||||||
|
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, uxn_screen.width, uxn_screen.height);
|
||||||
|
/* XDestroyImage(ximage); */
|
||||||
|
}
|
||||||
|
|
||||||
/* /usr/include/X11/keysymdef.h */
|
/* /usr/include/X11/keysymdef.h */
|
||||||
|
|
||||||
#define XK_Left 0xff51
|
#define XK_Left 0xff51
|
||||||
|
@ -80,13 +90,13 @@ load(Uxn *u, char *filepath)
|
||||||
#define XK_Alt 0xffe9
|
#define XK_Alt 0xffe9
|
||||||
|
|
||||||
void
|
void
|
||||||
processEvent(Display *display, Window window, XImage *ximage, int width, int height)
|
processEvent(Display *display, Visual *visual, Window window)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
XNextEvent(display, &ev);
|
XNextEvent(display, &ev);
|
||||||
switch(ev.type) {
|
switch(ev.type) {
|
||||||
case Expose:
|
case Expose:
|
||||||
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, width, height);
|
redraw(display, visual, window);
|
||||||
break;
|
break;
|
||||||
case KeyPress: {
|
case KeyPress: {
|
||||||
XKeyPressedEvent *e = (XKeyPressedEvent *)&ev;
|
XKeyPressedEvent *e = (XKeyPressedEvent *)&ev;
|
||||||
|
@ -113,6 +123,9 @@ processEvent(Display *display, Window window, XImage *ximage, int width, int hei
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
if(uxn_screen.fg.changed || uxn_screen.bg.changed) {
|
||||||
|
redraw(display, visual, window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -139,11 +152,6 @@ start(Uxn *u)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
redraw(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -161,9 +169,6 @@ main(int argc, char **argv)
|
||||||
if(!uxn_eval(&u, PAGE_PROGRAM))
|
if(!uxn_eval(&u, PAGE_PROGRAM))
|
||||||
return error("Boot", "Failed to start rom.");
|
return error("Boot", "Failed to start rom.");
|
||||||
|
|
||||||
screen_redraw(&uxn_screen, uxn_screen.pixels);
|
|
||||||
|
|
||||||
XImage *ximage;
|
|
||||||
Display *display = XOpenDisplay(NULL);
|
Display *display = XOpenDisplay(NULL);
|
||||||
Visual *visual = DefaultVisual(display, 0);
|
Visual *visual = DefaultVisual(display, 0);
|
||||||
Window window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width, uxn_screen.height, 1, 0, 0);
|
Window window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width, uxn_screen.height, 1, 0, 0);
|
||||||
|
@ -172,15 +177,10 @@ main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width, uxn_screen.height, 32, 0);
|
|
||||||
|
|
||||||
XSelectInput(display, window, ButtonPressMask | ExposureMask | KeyPressMask | KeyReleaseMask);
|
XSelectInput(display, window, ButtonPressMask | ExposureMask | KeyPressMask | KeyReleaseMask);
|
||||||
XMapWindow(display, window);
|
XMapWindow(display, window);
|
||||||
while(1) {
|
while(1) {
|
||||||
processEvent(display, window, ximage, uxn_screen.width, uxn_screen.height);
|
processEvent(display, visual, window);
|
||||||
|
|
||||||
if(uxn_screen.fg.changed || uxn_screen.bg.changed)
|
|
||||||
redraw();
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue