aboutsummaryrefslogtreecommitdiff
path: root/musw.c
diff options
context:
space:
mode:
Diffstat (limited to 'musw.c')
-rw-r--r--musw.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/musw.c b/musw.c
index 330695d..6b42bf7 100644
--- a/musw.c
+++ b/musw.c
@@ -40,6 +40,7 @@ RFrame screenrf;
Ball bouncer;
Universe *universe;
VModel *needlemdl;
+Channel *kchan;
char winspec[32];
int debug;
@@ -194,6 +195,8 @@ kbdproc(void *)
if(debug)
fprint(2, "kdown %.*lub\n",
sizeof(kdown)*8, kdown);
+
+ nbsendul(kchan, kdown);
}
}
@@ -204,7 +207,7 @@ threadnetrecv(void *arg)
int fd, n;
Ioproc *io;
- fd = *((int*)arg);
+ fd = *(int*)arg;
io = ioproc();
while((n = ioread(io, fd, buf, sizeof buf)) > 0){
@@ -216,6 +219,23 @@ threadnetrecv(void *arg)
closeioproc(io);
}
+void
+threadnetsend(void *arg)
+{
+ uchar buf[1024];
+ int fd, n;
+ ulong kdown;
+
+ fd = *(int*)arg;
+
+ for(;;){
+ kdown = recvul(kchan);
+ n = pack(buf, sizeof buf, "k", kdown);
+ if(write(fd, buf, n) != n)
+ sysfatal("write: %r");
+ }
+}
+
void resize(void);
void
@@ -320,6 +340,7 @@ threadmain(int argc, char *argv[])
screenrf.bx = Vec2(1, 0);
screenrf.by = Vec2(0,-1);
+ kchan = chancreate(sizeof kdown, 1);
proccreate(kbdproc, nil, 4096);
fd = dial(server, nil, nil, nil);
@@ -335,6 +356,7 @@ threadmain(int argc, char *argv[])
universe->star.spr = readsprite("assets/spr/earth.pic", ZP, Rect(0,0,32,32), 5, 20e3);
threadcreate(threadnetrecv, &fd, 4096);
+ threadcreate(threadnetsend, &fd, 4096);
threadcreate(threadresize, mc, 4096);
then = nanosec();