Updated lirc driver
This commit is contained in:
+65
-77
@@ -1,107 +1,66 @@
|
|||||||
#include <config.h>
|
/* This is the LCDproc driver for LIRC infrared devices (http://www.lirc.org)
|
||||||
|
|
||||||
|
Copyright (C) 2000, Harald Klein
|
||||||
|
2002, Rene Wagner
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
|
||||||
#include <sys/errno.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <lirc/lirc_client.h>
|
#include <lirc/lirc_client.h>
|
||||||
|
|
||||||
#define __u32 unsigned int
|
#ifdef HAVE_CONFIG_H
|
||||||
#define __u8 unsigned char
|
# include "config.h"
|
||||||
|
#endif
|
||||||
#include "shared/str.h"
|
|
||||||
|
|
||||||
#define NAME_LENGTH 128
|
|
||||||
|
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "lircin.h"
|
#include "lircin.h"
|
||||||
|
|
||||||
|
#include "report.h"
|
||||||
|
|
||||||
char *progname = "lircin";
|
char *progname = "lircin";
|
||||||
|
|
||||||
int fd;
|
static int fd;
|
||||||
char buf[256];
|
|
||||||
struct sockaddr_un addr;
|
|
||||||
|
|
||||||
static struct lirc_config *config;
|
static struct lirc_config *config;
|
||||||
|
|
||||||
// Vars for the server core
|
|
||||||
MODULE_EXPORT char *api_version = API_VERSION;
|
MODULE_EXPORT char *api_version = API_VERSION;
|
||||||
MODULE_EXPORT int stay_in_foreground = 0;
|
MODULE_EXPORT int stay_in_foreground = 0;
|
||||||
MODULE_EXPORT int supports_multiple = 0;
|
MODULE_EXPORT int supports_multiple = 0;
|
||||||
MODULE_EXPORT char *symbol_prefix = "LB216_";
|
MODULE_EXPORT char *symbol_prefix = "lircin_";
|
||||||
|
|
||||||
|
/***********************************************************
|
||||||
//////////////////////////////////////////////////////////////////////////
|
* init() should set up any device-specific stuff, and
|
||||||
////////////////////// Base "class" to derive from ///////////////////////
|
* point all the function pointers.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
|
|
||||||
//void sigterm(int sig)
|
|
||||||
//{
|
|
||||||
// ir_free_commands();
|
|
||||||
// ir_finish();
|
|
||||||
// raise(sig);
|
|
||||||
//}
|
|
||||||
|
|
||||||
MODULE_EXPORT void
|
|
||||||
lircin_close (Driver * drvthis)
|
|
||||||
{
|
|
||||||
lirc_freeconfig (config);
|
|
||||||
lirc_deinit ();
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// Tries to read a character from an input device...
|
|
||||||
//
|
|
||||||
// Return 0 for "nothing available".
|
|
||||||
//
|
|
||||||
MODULE_EXPORT char
|
|
||||||
lircin_getkey (Driver * drvthis)
|
|
||||||
{
|
|
||||||
char key;
|
|
||||||
char *ir, *cmd;
|
|
||||||
|
|
||||||
if (!(ir = lirc_nextir ())) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
if (!(cmd = lirc_ir2char (config, ir)))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
printf ("lirc: \"%s\"\n", cmd);
|
|
||||||
sscanf (cmd, "%c", &key);
|
|
||||||
printf ("\n%c\n", key);
|
|
||||||
free (ir);
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
// init() should set up any device-specific stuff, and
|
|
||||||
// point all the function pointers.
|
|
||||||
MODULE_EXPORT int
|
MODULE_EXPORT int
|
||||||
lircin_init (Driver * drvthis, char *args)
|
lircin_init (Driver *drvthis, char *args)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* assign funktions */
|
|
||||||
|
|
||||||
/* open socket to lirc */
|
/* open socket to lirc */
|
||||||
|
|
||||||
if (-1 == (fd = lirc_init ("lcdd", 1))) {
|
if (-1 == (fd = lirc_init ("lcdd", LIRCIN_VERBOSELY))) {
|
||||||
fprintf (stderr, "no infrared remote support available\n");
|
report( RPT_ERR, "lirc: Could not connect to lircd." );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != lirc_readconfig (NULL, &config, NULL)) {
|
if (0 != lirc_readconfig (NULL, &config, NULL)) {
|
||||||
lirc_deinit ();
|
lirc_deinit ();
|
||||||
|
report( RPT_ERR, "lirc: lirc_readconfig() failed." );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fcntl (fd, F_SETFL, O_NONBLOCK);
|
fcntl (fd, F_SETFL, O_NONBLOCK);
|
||||||
@@ -114,3 +73,32 @@ lircin_init (Driver * drvthis, char *args)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
* Closes the device
|
||||||
|
*/
|
||||||
|
MODULE_EXPORT void
|
||||||
|
lircin_close (Driver *drvthis)
|
||||||
|
{
|
||||||
|
lirc_freeconfig (config);
|
||||||
|
lirc_deinit ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
* Tries to read a character from an input device...
|
||||||
|
*
|
||||||
|
* Return NULL for "nothing available".
|
||||||
|
*/
|
||||||
|
MODULE_EXPORT char *
|
||||||
|
lircin_get_key (Driver *drvthis)
|
||||||
|
{
|
||||||
|
char *code=NULL, *cmd=NULL;
|
||||||
|
|
||||||
|
if ( (lirc_nextcode(&code)==0) && (code!=NULL) ) {
|
||||||
|
if ( (lirc_code2char(config,code,&cmd)==0) && (cmd!=NULL) ) {
|
||||||
|
report (RPT_DEBUG, "lirc: \"%s\"", cmd);
|
||||||
|
}
|
||||||
|
free (code);
|
||||||
|
}
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|||||||
+24
-4
@@ -1,10 +1,30 @@
|
|||||||
|
/* This is the LCDproc driver for LIRC infrared devices (http://www.lirc.org)
|
||||||
|
|
||||||
|
Copyright (C) 2000, Harald Klein
|
||||||
|
2002, Rene Wagner
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef LCD_LIRCIN_H
|
#ifndef LCD_LIRCIN_H
|
||||||
#define LCD_LIRCIN_H
|
#define LCD_LIRCIN_H
|
||||||
|
|
||||||
#include "lcd.h"
|
MODULE_EXPORT int lircin_init (Driver *drvthis, char *args);
|
||||||
|
MODULE_EXPORT void lircin_close (Driver *drvthis);
|
||||||
|
MODULE_EXPORT char * lircin_get_key (Driver *drvthis);
|
||||||
|
|
||||||
MODULE_EXPORT int lircin_init (Driver * drvthis, char *args);
|
#define LIRCIN_VERBOSELY 1
|
||||||
MODULE_EXPORT void lircin_close (Driver * drvthis);
|
|
||||||
MODULE_EXPORT char lircin_getkey (Driver * drvthis);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user