annotate fifo.c @ 9252:b1533eba7231

I haven't read eyck@incubus for 2 years. I do read eyck@ghost.anime.pl
author eyck
date Mon, 03 Feb 2003 14:23:25 +0000
parents 44198b2f42db
children 0397b461f0fb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
113
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
1
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
2 // keyboard:
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
3 static int keyb_fifo_put=-1;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
4 static int keyb_fifo_get=-1;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
5
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
6 static void make_pipe(int* pr,int* pw){
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
7 int temp[2];
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
8 if(pipe(temp)!=0) printf("Cannot make PIPE!\n");
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
9 *pr=temp[0];
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
10 *pw=temp[1];
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
11 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
12
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
13 void mplayer_put_key(int code){
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
14 fd_set rfds;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
15 struct timeval tv;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
16
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
17 /* Watch stdin (fd 0) to see when it has input. */
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
18 FD_ZERO(&rfds);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
19 FD_SET(keyb_fifo_put, &rfds);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
20 tv.tv_sec = 0;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
21 tv.tv_usec = 0;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
22
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
23 //retval = select(keyb_fifo_put+1, &rfds, NULL, NULL, &tv);
3014
16576e05b93a Profiling fix by Artur Skawina <skawina@geocities.com>
atmos4
parents: 113
diff changeset
24 if(select(keyb_fifo_put+1, NULL, &rfds, NULL, &tv)>0){
113
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
25 write(keyb_fifo_put,&code,4);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
26 // printf("*** key event %d sent ***\n",code);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
27 } else {
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
28 // printf("*** key event dropped (FIFO is full) ***\n");
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
29 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
30 }