* [9fans] events
@ 2003-02-19 13:23 paurea
2003-02-19 13:56 ` Russ Cox
2003-02-19 21:57 ` Russ Cox
0 siblings, 2 replies; 8+ messages in thread
From: paurea @ 2003-02-19 13:23 UTC (permalink / raw)
To: 9fans
Sorry for the last message. I pressed the Post without noticing...
I am trying to do this Inkey is 4. Stdin is 0. I have noticed two things
1) einit ignores keys others than Emouse and Ekeyboard (I noticed this looking at sources)
2) I don't get the stdin events. Something for us is never printed.
Suggestions?
Gorka
estart(Inkey,Stdin,1); /
einit(Emouse|Ekeyboard|Inkey);
for (;;) {
keyev = event(&gev);
switch(keyev){
case Emouse:
mev=gev.mouse;
if (mev.buttons==2){
goban[pos.x][pos.y]='w';
drawstone(pos,'w');
}
if (mev.buttons==4){
goban[pos.x][pos.y]='d';
drawstone(pos,'d');
}
if (mev.buttons==1) {
goban[pos.x][pos.y]='b';
drawstone(pos,'b');
}
break;
case Ekeyboard:
kbdc=gev.kbdc;
switch(kbdc){
case qkey:
case esckey:
exits(0);
break;
}
break;
case Inkey:
print("something for us...");
readn(Stdin,msg,1);
if(msg[0]!='\n')
break;
readn(Stdin,msg,Msgsz);
pos.x=atoi(&msg[3]);
msg[3]='\0';
pos.y=atoi(&msg[1]);
drawstone(pos,msg[0]);
break;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [9fans] events
2003-02-19 13:23 [9fans] events paurea
@ 2003-02-19 13:56 ` Russ Cox
2003-02-19 14:08 ` paurea
2003-02-19 21:57 ` Russ Cox
1 sibling, 1 reply; 8+ messages in thread
From: Russ Cox @ 2003-02-19 13:56 UTC (permalink / raw)
To: 9fans
> I am trying to do this Inkey is 4. Stdin is 0. I have noticed two things
> 1) einit ignores keys others than Emouse and Ekeyboard (I noticed this looking at sources)
That's okay -- the other keys have been started with estart.
Einit just needs to start the mouse and the keyboard.
> 2) I don't get the stdin events. Something for us is never printed.
Are you reading from a file? Usually stdin is the console
but the keyboard will get at least half those events instead.
Also,
case Inkey:
print("something for us...");
readn(Stdin,msg,1);
this is wrong. The data has already been read
and is in gev.data.
Event != select.
Reading one byte at a time seems like a recipe
for trouble anyway, especially if UTF is involved.
Russ
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [9fans] events
2003-02-19 13:56 ` Russ Cox
@ 2003-02-19 14:08 ` paurea
2003-02-19 14:13 ` Russ Cox
0 siblings, 1 reply; 8+ messages in thread
From: paurea @ 2003-02-19 14:08 UTC (permalink / raw)
To: 9fans
>
> Are you reading from a file? Usually stdin is the console
> but the keyboard will get at least half those events instead.
I wanted to run the program with a pipe to the standard input.
generator|consumer
>
> Also,
> case Inkey:
> print("something for us...");
> readn(Stdin,msg,1);
Yes, I know, but that code isn't executed anyway... I'll take
care of that when something is printed.
>
> Reading one byte at a time seems like a recipe
> for trouble anyway, especially if UTF is involved.
The program gets its input from a pipe from another program
which I have written.
THX.
Gorka
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [9fans] events
2003-02-19 14:08 ` paurea
@ 2003-02-19 14:13 ` Russ Cox
2003-02-19 14:31 ` paurea
0 siblings, 1 reply; 8+ messages in thread
From: Russ Cox @ 2003-02-19 14:13 UTC (permalink / raw)
To: 9fans
While the program is sitting there doing nothing,
you can cat its /proc/pid/fd file to see what the
read offset on the pipe is -- that will tell you
whether the slave process has read any data
from the pipe. If not, your generator program is
not generating.
Russ
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [9fans] events
2003-02-19 14:13 ` Russ Cox
@ 2003-02-19 14:31 ` paurea
0 siblings, 0 replies; 8+ messages in thread
From: paurea @ 2003-02-19 14:31 UTC (permalink / raw)
To: 9fans
> While the program is sitting there doing nothing,
> you can cat its /proc/pid/fd file to see what the
> read offset on the pipe is -- that will tell you
> whether the slave process has read any data
> from the pipe. If not, your generator program is
> not generating.
The data is getting there. I have already checked. I have run
tail -f /tmp/b|goifc on one terminal and
cat >/tmp/b
on another and cat /proc/pid/fd and seen that the |data offset increased.
But nothing got printed. Also changed the print for an exits just in case
something was not getting flushed. Doesn't work either.
Gorka
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [9fans] events
2003-02-19 13:23 [9fans] events paurea
2003-02-19 13:56 ` Russ Cox
@ 2003-02-19 21:57 ` Russ Cox
2003-02-20 11:18 ` paurea
1 sibling, 1 reply; 8+ messages in thread
From: Russ Cox @ 2003-02-19 21:57 UTC (permalink / raw)
To: 9fans
event(2):
>>> Einit must be called first. If the argument to einit has
the Emouse and Ekeyboard bits set, the mouse and keyboard
events will be enabled; in this case, initdraw (see
graphics(2)) must have already been called. The user must
provide a function called eresized to be called whenever the
window in which the process is running has been resized; the
argument new is a flag specifying whether the program must
call getwindow (see graphics(2)) to re-establish a connec-
tion to its window. After resizing (and perhaps calling
getwindow), the global variable screen will be updated to
point to the new window's Image structure.
Your code:
estart(Inkey,Stdin,1); /
einit(Emouse|Ekeyboard|Inkey);
Russ
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [9fans] events
2003-02-19 21:57 ` Russ Cox
@ 2003-02-20 11:18 ` paurea
0 siblings, 0 replies; 8+ messages in thread
From: paurea @ 2003-02-20 11:18 UTC (permalink / raw)
To: 9fans
> event(2):
>
> estart(Inkey,Stdin,1); /
> einit(Emouse|Ekeyboard|Inkey);
>
Thanks a lot!!!. Such a stupid bug!!. When you come here I'll invite you to a
beer ☺.
THX.
Gorka
^ permalink raw reply [flat|nested] 8+ messages in thread
* [9fans] events
@ 2003-02-19 13:20 paurea
0 siblings, 0 replies; 8+ messages in thread
From: paurea @ 2003-02-19 13:20 UTC (permalink / raw)
To: 9fans
I am trying to do this Inkey is 4.
estart(Inkey,Stdin,1); /
einit(Emouse|Ekeyboard|Inkey);
for (;;) {
keyev = event(&gev);
switch(keyev){
case Emouse:
mev=gev.mouse;
if (mev.buttons==2){
goban[pos.x][pos.y]='w';
drawstone(pos,'w');
}
if (mev.buttons==4){
goban[pos.x][pos.y]='d';
drawstone(pos,'d');
}
if (mev.buttons==1) {
goban[pos.x][pos.y]='b';
drawstone(pos,'b');
}
break;
case Ekeyboard:
kbdc=gev.kbdc;
switch(kbdc){
case qkey:
case esckey:
exits(0);
break;
}
break;
case Inkey:
print("something for us...");
readn(Stdin,msg,1);
if(msg[0]!='\n')
break;
readn(Stdin,msg,Msgsz);
pos.x=atoi(&msg[3]);
msg[3]='\0';
pos.y=atoi(&msg[1]);
drawstone(pos,msg[0]);
break;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-02-20 11:18 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-19 13:23 [9fans] events paurea
2003-02-19 13:56 ` Russ Cox
2003-02-19 14:08 ` paurea
2003-02-19 14:13 ` Russ Cox
2003-02-19 14:31 ` paurea
2003-02-19 21:57 ` Russ Cox
2003-02-20 11:18 ` paurea
-- strict thread matches above, loose matches on Subject: below --
2003-02-19 13:20 paurea
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).