ref: d28675582f87de011f95780ced1068832fd5ca12
parent: 443cea6f92cb01bd6ff800bbcca0ed7be1ede2f1
author: halfwit <michaelmisch1985@gmail.com>
date: Sat Oct 10 02:56:52 PDT 2020
Start working towards reading/writing
--- a/draw.c
+++ b/draw.c
@@ -75,7 +75,7 @@
static void
x9devRefreshScreen(int x1, int y1, int x2, int y2)
{
- /*
+ /*
Rectangle r;
uchar *p;
int n;
@@ -105,7 +105,7 @@
static void
x9devResize(void)
{
- /*
+ /*
if (getwindow(display, Refnone) < 0)
FatalError("can't reattach to window");
@@ -117,10 +117,10 @@
static int
x9devMouseRead(int *x, int *y, int *b)
{
- char buf[1+4*12];
int n;
- if ((n = c9read(x9di.mouseFd, buf, sizeof buf)) <= 0)
+ /* Magic numbers here are the size of a message from /dev/mouse and its offsets */
+ if((n = x9read(x9di->mouse, 1 + 4 * 12)) <= 0)
return 0;
if (n != 1 + 4 * 12)
@@ -130,9 +130,9 @@
x9devResize();
return 0;
}
- *x = atoi(buf + 1 + 0 * 12) - screen->r.min.x;
- *y = atoi(buf + 1 + 1 * 12) - screen->r.min.y;
- *b = atoi(buf + 1 + 2 * 12);
+ *x = atoi(x9di->mouse->rbuf + 1 + 0 * 12) - screen->r.min.x;
+ *y = atoi(x9di->mouse->rbuf + 1 + 1 * 12) - screen->r.min.y;
+ *b = atoi(x9di->mouse->rbuf + 1 + 2 * 12);
return 1;
}
@@ -144,7 +144,7 @@
static int n = 0;
wchar_t rune;
- if (c9read(x9di.keybdFd, s + n, 1) != 1)
+ if (x9read(x9di->keydb, 1) != 1)
return 0;
rune = s[0];
@@ -171,6 +171,7 @@
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");
@@ -476,4 +477,10 @@
x9checkmod(unsigned int k, DeviceIntPtr pDev)
{
return modmap[k] != 0;
+}
+
+static int
+x9read(C9aux aux, uint32_t count)
+{
+ return c9read(aux->ctx, &aux->tag, aux->f, aux->wroff, 1 + 4 * 12);
}
\ No newline at end of file
--- a/meson.build
+++ b/meson.build
@@ -4,6 +4,7 @@
'c9/c9.c',
'c9/c9.h',
'../../mi/miinitext.c',
+ '../../mi/.mi.h',
'x9dev.h',
'keymap.h',
]
--- a/x9dev.h
+++ b/x9dev.h
@@ -32,29 +32,39 @@
#define XK_PUBLISHING
#include <X11/keysym.h>
#include <X11/keysymdef.h>
-#include "servermd.h"
#define PSZ 8
-#include "fb.h"
+//#include "fb.h"
#include "colormapst.h"
+#include "dix.h"
+#include "exevents.h"
+#include "extinit.h"
#include "gcstruct.h"
-#include "mipointer.h"
+#include "glx_extinit.h"
+#include "input.h"
#include "micmap.h"
-#include "dix.h"
+#include "mipointer.h"
#include "miline.h"
+#include "scrnintstr.h"
+#include "servermd.h"
#include "shadow.h"
#include "xkbsrv.h"
#include "xserver-properties.h"
-#include "exevents.h"
-#include "extinit.h"
+#include "mi.h" /* miEnqueue mieqProcessInputEvents */
+
+/* Our local includes */
#include "keymap.h"
-#include "mi.h"
-#include "glx_extinit.h"
-#include "input.h"
-#include "scrnintstr.h"
#include "c9/c9.h"
-typedef struct x9devInfo x9devInfo;
+typedef struct x9file x9file;
+struct x9file {
+ int f;
+ int flags;
+ uint8_t rdbuf[Msize];
+ uint8_t wrbuf[Msize];
+ uint32_t wroff;
+};
+typedef struct x9devInfo x9devInfo;
struct x9devInfo
{
char *fb;
@@ -63,10 +73,12 @@
int height;
int dpi;
int bpl;
- int mouseFd;
- int keybdFd;
- int consctlFd;
+ C9ctx *ctx;
+ x9file *mouse;
+ x9file *keybd;
+ x9file *cons;
};
+
#define KF 0xF000
#define Kdown 0x80