2 #ifndef HAVE_NO_POSIX_SELECT
5 static int keyb_fifo_put
=-1;
6 static int keyb_fifo_get
=-1;
8 static void make_pipe(int* pr
,int* pw
){
10 if(pipe(temp
)!=0) printf("Cannot make PIPE!\n");
15 void mplayer_put_key(int code
){
19 /* Watch stdin (fd 0) to see when it has input. */
21 FD_SET(keyb_fifo_put
, &rfds
);
25 //retval = select(keyb_fifo_put+1, &rfds, NULL, NULL, &tv);
26 if(select(keyb_fifo_put
+1, NULL
, &rfds
, NULL
, &tv
)>0){
27 write(keyb_fifo_put
,&code
,4);
28 // printf("*** key event %d sent ***\n",code);
30 // printf("*** key event dropped (FIFO is full) ***\n");
36 #define KEY_FIFO_SIZE 1024
37 static int key_fifo_data
[KEY_FIFO_SIZE
];
38 static int key_fifo_read
=0;
39 static int key_fifo_write
=0;
41 void mplayer_put_key(int code
){
42 // printf("mplayer_put_key(%d)\n",code);
43 if(((key_fifo_write
+1)%KEY_FIFO_SIZE
)==key_fifo_read
) return; // FIFO FULL!!
44 key_fifo_data
[key_fifo_write
]=code
;
45 key_fifo_write
=(key_fifo_write
+1)%KEY_FIFO_SIZE
;
48 int mplayer_get_key(int fd
){
50 // printf("mplayer_get_key(%d)\n",fd);
51 if(key_fifo_write
==key_fifo_read
) return MP_INPUT_NOTHING
;
52 key
=key_fifo_data
[key_fifo_read
];
53 key_fifo_read
=(key_fifo_read
+1)%KEY_FIFO_SIZE
;
54 // printf("mplayer_get_key => %d\n",key);