3 reads input from /dev/lircd and will hopefully do something usefull
6 author: hackbard@hackdaworld.org
8 hint: you will need event.{c,h} from my-code repos!
16 #include <sys/types.h>
18 #include <sys/select.h>
19 #include <sys/socket.h>
26 #define LIRCD "/dev/lircd"
28 typedef struct s_priv {
33 int nop(t_event *event,void *ptr) {
37 int act(t_event *event,void *ptr) {
39 t_priv *priv=(t_priv *)ptr;
44 count=read(priv->fd,message,1024);
47 button=strtok(NULL," ");
49 dprintf(2,"pressed button: %s (received %d bytes)\n",button,count);
57 struct sockaddr_un addr;
60 addr.sun_family=AF_UNIX;
61 strcpy(addr.sun_path,LIRCD);
62 priv.fd=socket(AF_UNIX,SOCK_STREAM,0);
63 retval=connect(priv.fd,(struct sockaddr *)&addr,sizeof(addr));
64 printf("connecting to lircd ... %d\n",retval);
66 printf("fd = %d\n",priv.fd);
67 event_init(&(priv.event),2);
68 event_math(priv.fd,&(priv.event),READ,ADD);
69 event_set_timeout(&(priv.event),0,0);
71 // event_start(&priv.event,&priv,act,nop);
72 event_start(&priv.event,&priv,act,nop);