ref: 750075d012181308d87f70177aef650841e836ae
parent: 89d3fbea31517a66d4af97f88966689ff410029e
author: halfwit <michaelmisch1985@gmail.com>
date: Sat Oct 10 03:24:09 PDT 2020
Update to use stdin/stdout and clean up header more
--- a/draw.c
+++ b/draw.c
@@ -41,9 +41,11 @@
#define x9devUnrealizeCursor (void *) NoopDDA
#define x9devRecolorCursor (void *) NoopDDA
#define x9devSetCursorPosition (void *) NoopDDA
+
+static int x9read(C9ctx, x9file, uint32_t);
+
#define e ev.u.u
#define ek ev.u.keyButtonPointer
-
static void
x9devSendKeybdEvent(int k, int t)
{
@@ -120,7 +122,7 @@
int n;
/* Magic numbers here are the size of a message from /dev/mouse and its offsets */
- if((n = x9read(x9di->mouse, 1 + 4 * 12)) <= 0)
+ if((n = x9read(x9di->ctx, x9di->mouse, 1 + 4 * 12)) <= 0)
return 0;
if (n != 1 + 4 * 12)
@@ -144,7 +146,7 @@
static int n = 0;
wchar_t rune;
- if (x9read(x9di->keydb, 1) != 1)
+ if (x9read(x9di->ctx, x9di->keydb, 1) != 1)
return 0;
rune = s[0];
@@ -168,10 +170,7 @@
static void
x9devInfoInit(void)
{
-
- char buf[256];
-
- /* Here we want to open up a new device in /dev/draw */
+ /*
if(initdraw(NULL, 0, "x9dev") < 0)
FatalError("can't open display");
@@ -200,6 +199,7 @@
FatalError("can't open consctl");
if(c9write(x9di.consctlFd, "rawon", 5) != 5)
FatalError("can't set rawon");
+ */
}
static int
@@ -480,7 +480,7 @@
}
static int
-x9read(C9aux aux, uint32_t count)
+x9read(C9ctx ctx, x9file file, uint32_t count)
{
- return c9read(aux->ctx, &aux->tag, aux->f, aux->wroff, 1 + 4 * 12);
+ return c9read(ctx, &file->tag, 0, file->wroff, count);
}
\ No newline at end of file
--- a/x9dev.h
+++ b/x9dev.h
@@ -55,13 +55,17 @@
#include "keymap.h"
#include "c9/c9.h"
+#define Msize 8192
+#define KF 0xF000
+#define Kdown 0x80
+#define NUMFORMATS (sizeof(formats)/sizeof((formats)[0]))
+
typedef struct x9file x9file;
struct x9file {
- int f;
- int flags;
- uint8_t rdbuf[Msize];
- uint8_t wrbuf[Msize];
- uint32_t wroff;
+ uint8_t rdbuf[Msize];
+ uint8_t wrbuf[Msize];
+ uint32_t wroff;
+ C9tag *tag;
};
typedef struct x9devInfo x9devInfo;
@@ -74,15 +78,11 @@
int dpi;
int bpl;
C9ctx *ctx;
+ /* Our three files we care about */
x9file *mouse;
x9file *keybd;
- x9file *cons;
+ x9file *draw;
};
-
-
-#define KF 0xF000
-#define Kdown 0x80
-#define NUMFORMATS (sizeof(formats)/sizeof((formats)[0]))
int debug = 0;