[mythtv-users] Xmame/mythgame patch to enable lirc.
hachuah2000
hachuah2000 at yahoo.com
Sun Jun 6 21:00:08 EDT 2004
Hi,
This is a little off topic, since it's not a patch to
mythtv, but I'd hacked this into xmame last weekend;
and I thought maybe someone else could use it.
It's a patch to enable xmame to accept inputs from
your remote via lirc.
Prerequisites (or what I used):
xmame 0.82.1 - you must be able to make/install this
already. Follow instructions in the readme for this.
lirc-0.7.0pre2 - You will need lirc_client.* files
from this.
Steps:
1. Copy over the lirc_client.c and .h files over to
<work area>/xmame-0.82.1/src/unix
2. Edit the makefile to include linking lirc_client.o;
ie.
COMMON_OBJS = \
$(OBJDIR)/main.o $(OBJDIR)/sound.o \
$(OBJDIR)/keyboard.o $(OBJDIR)/devices.o \
$(OBJDIR)/video.o $(OBJDIR)/mode.o \
$(OBJDIR)/fileio.o $(OBJDIR)/dirio.o
$(OBJDIR)/config.o \
$(OBJDIR)/fronthlp.o $(OBJDIR)/ident.o
$(OBJDIR)/network.o \
$(OBJDIR)/snprintf.o $(OBJDIR)/nec765_dummy.o
$(OBJDIR)/effect.o \
$(OBJDIR)/ticker.o $(OBJDIR)/parallel.o
$(OBJDIR)/fileio_more.o \
$(OBJDIR)/lirc_client.o
3. Edit the patch to point to your lircrc file
4. Patch the devices.c file
5. make xmame
6. The lircrc file currently only supports keyscan
codes. For eg. mine looks like:
begin
prog = xmame
button = stop
config = 1
end
begin
prog = xmame
button = play
config = 25
end
This configures the "stop" key on my remote as Esc and
the "play" key on my remote to play/pause.
Enjoy!
-hachuah2000
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
-------------- next part --------------
27a28,29
> #include <fcntl.h>
> #include "lirc_client.h"
49a52,56
> static struct lirc_config *config;
> static int lirc_pressed = 0;
> static int lirc_scancode;
> #define MIN_LIRC_WAIT 4
>
178c185,186
< if (id >= MAX_PLAYERS)
---
> if (id >= MAX_
> PLAYERS)
346a355,373
> /* initialize lirc */
> /* LIRC stuff */
> int sock;
> int flags;
> sock=lirc_init("xmame",1);
> /* if(lirc_init("xmame",1)==-1) exit(EXIT_FAILURE); */
>
> if(lirc_readconfig("/home/mythtv/.mythtv/lircrc",&config,NULL)==0)
> {
> printf("Success!\n");
> }
> fcntl(sock,F_SETOWN,getpid());
> flags=fcntl(sock,F_GETFL,0);
> if(flags!=-1)
> {
> fcntl(sock,F_SETFL,flags|O_NONBLOCK);
> }
>
>
856a884,914
> char *code;
> char *c;
> int ret;
> /*printf("%s\n","Polling...");*/
> /* Poll lirc */
> lirc_nextcode(&code);
> if (lirc_pressed != 0)
> lirc_pressed++;
> if (code!=NULL)
> {
> while((ret=lirc_code2char(config,code,&c))==0 && c!=NULL)
> {
> printf("Received command \"%s\"\n",c);
> struct xmame_keyboard_event event;
> event.press = 1;
> event.scancode = atoi(c);
> lirc_pressed++;
> lirc_scancode = event.scancode;
> xmame_keyboard_register_event(&event);
> if (lirc_pressed > MIN_LIRC_WAIT)
> {
> event.press = 0;
> event.scancode = lirc_scancode;
> lirc_pressed = 0;
> xmame_keyboard_register_event(&event);
> }
> }
> free(code);
> /* if(ret==-1) break;*/
> }
> /* End lirc poll */
865a924,925
>
>
More information about the mythtv-users
mailing list