lirc support

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

Post Reply
Wagz
Rookie
Posts: 12
Joined: Wed Mar 21, 2007 5:20 pm

lirc support

Post by Wagz »

I've been looking for a way to add lirc support to zsnes (as mentioned in this post). I've added some code to the sdllink.c file, and tested it out. It seems to work pretty well. Anyway if you would like it added to the project, I'd be happy to post my changes.

-Wagz
Enclavet

Post by Enclavet »

Could you send me the changes. I am interested in getting this to work.

Either email me at andrewkl at enclavenet.com or post your changes here.

Thanks.
Wagz
Rookie
Posts: 12
Joined: Wed Mar 21, 2007 5:20 pm

No problem

Post by Wagz »

No problem, Enclavet. I've sent the files to your e-mail. Let me know if it works for you and I'll post my changes here. There is really only a few lines of code added to the sdllink.c file in the src/linux directory. I've also included a modified configure.in file to allow the --with-lirc option.

Just so you know, I was only able to test this on a 32-bit Fedora Core 6 box, against the 1.51 version of zsnes.

-Wagz
Enclavet

Post by Enclavet »

Wagz, I tried all the changes and it works to some extent. For me the Ok binded to Enter button does not work. For some reason it windows my zsnes when I press ok. There also some wierd stuff going on when I press up and down on the menus, sometimes it will get stuck on up or down and move up/down continuously. The polling is also very slow sometimes, I must press a button 2-3 times before it registers on the program.

Do you see any of this?

Other than that, very easy to install and it works for me since I am only going to be using it for exiting. Keep up the good work. I might look at the code myself to see if I can fix these issues.

Thanks.
spottedcow

Post by spottedcow »

Wagz, can you send me the code as well? I'd like to integrate lirc with zsnes. I just sent you a PM with my email address.
spottedcow

Post by spottedcow »

Wow Wagz, that was fast... I can't wait to try this myself.

Enclavet, I had some of the same issues getting lirc setup for MythTV. I took a quick look at the zsnes.lircrc file, and I think most of the issues you are seeing can be fixed in that file.

Here's any example to help illustrate:

Code: Select all

begin
prog = zsnes
button = OK
repeat = 3
config = 13 # Enter 
end
The button value needs to match exactly as they are defined in your global lirc remote file where you setup your remote. (Typically /etc/lircd.conf). If OK is not a defined button in that file (under the begin remote, begin codes section), then the zsnes.lirc code will not match up to any key presses. If your lircd.conf file sets up "OK" as "okay" or "ok-button" then the mapping doesn't work. You'll have to modify zsnes.lirc to make sure it maps buttons to the specific values you see in the lircd.conf file that correspond to the button you are pressing.

The other issue about the up and down key seems to be related to the repeat value. When you hold down a button on your remote, the key is transmitted a lot. In fact some remotes will transmit the key several times on one button press just to make sure the receiver sees it. Repeat=3 is a good setting to make sure that the receiver ignores multiple codes for the same button. For some keys (like up and down) you'll need to modify that repeat value to be less to allow multiple key presses to work correctly. You'll need to use some trial and error to get it right, but eventually you will get the remote to do exactly what you want.

This doc should help with some of the other options you can put in the zsnes lircrc config file
http://www.lirc.org/html/configure.html#lircrc_format

Hope this helps.
Last edited by spottedcow on Thu May 03, 2007 7:29 pm, edited 1 time in total.
Wagz
Rookie
Posts: 12
Joined: Wed Mar 21, 2007 5:20 pm

Post by Wagz »

Enclavet wrote:Wagz, I tried all the changes and it works to some extent. For me the Ok binded to Enter button does not work. For some reason it windows my zsnes when I press ok. There also some wierd stuff going on when I press up and down on the menus, sometimes it will get stuck on up or down and move up/down continuously. The polling is also very slow sometimes, I must press a button 2-3 times before it registers on the program.

Do you see any of this?
I believe what spottedcow suggested may help you out with the Ok/Enter Button Issue. The repeat setting may help with you having to press the buttion continuously. My remote repeats the infrared code very quickly so 3 was a good value for me. Try setting it to 1 and see if the movement is better.

When i run zsnes, I am running it without the GUI, however, if I Press OK while I'm setting a Save-state slot it does window the application. I may try a different value than 13 in the .lircrc file (like 271) and see if that helps. For a reference to all of the keycodes you can use, check out the SDL Constants Reference. Anything with an SDLK_ prefix are keycodes. Just click the one you want, and it will take you to the reference with the number you can enter in the .lircrc file.

-Wagz
Wagz
Rookie
Posts: 12
Joined: Wed Mar 21, 2007 5:20 pm

Found issue.

Post by Wagz »

Well, I tried changing the key value in the .lircrc file to 271, and it did not work. Upon further investigation, though, it seems that the keys read in by the lirc code were triggering an 'Alt' keypress. As a temporary work-around, I've forced all lirc input to have no "alternate" keyboard states. This will only affect those that are trying to explicitly set a modifier with a key, which probably won't affect most people.

In any case, add the following to line 234 of the sdllink.c file I sent you, then recompile. It corrected my issue with the OK button.

Code: Select all

 lirc_event.key.keysym.mod = 0x0000;
It is right after the line:

Code: Select all

lirc_event.key.keysym.sym = atoi(c);
This should work temporarily until I'm able to find out why that 'Alt' modifier is being set.

-Wagz
tr0nix

Post by tr0nix »

Hi guys

Any news regarding lirc support? I'm also using zsnes with my media center and this plain irexec-script for killing zsnes via signal is veeeeery dirty.

Regards
Joel
Wagz
Rookie
Posts: 12
Joined: Wed Mar 21, 2007 5:20 pm

Post by Wagz »

I haven't heard anything lately. It looks like there are a few people interested, and more if we talk to people using MythTV and are using zsnes as their game emulator.

In any case, I'll send you the updated source that I've mentioned above. It will have the changes I mentioned in the previous post about line 234. I still haven't figured that issue out yet, but the work-around works fine.

Once you have a chance to try it, let me know how it works for you. I've been running it for 5 months now with no issues.

-Wagz
michiatlnx
New Member
Posts: 3
Joined: Thu Oct 16, 2008 6:48 am

Post by michiatlnx »

Hello Wagz,

with my updated linux distribution i can't compile the old xmacro software.
But I need the lirc support in zsnes (btw i am dumb), is easier to manage with remote control for my family ;)

Can you send me this source code?

I am interested in getting this to work.

Best Regards

michiatlnx
Wagz
Rookie
Posts: 12
Joined: Wed Mar 21, 2007 5:20 pm

Post by Wagz »

I've sent it over to you. Let me know how it works out. Pretty soon this will be moot, since it looks like lirc will be part of the kernel and we won't have to worry much about compiling it into things.

-Wagz
michiatlnx
New Member
Posts: 3
Joined: Thu Oct 16, 2008 6:48 am

Post by michiatlnx »

Hello Wagz,

the lirc support works on my archlinux with the OK workaround, but the use of direction keys (up, down, left, right) starts scrolling in this direction endless, until I double click the key again. It’s look like press and hold the key.

Best Regards

michiatlnx
Wagz
Rookie
Posts: 12
Joined: Wed Mar 21, 2007 5:20 pm

Post by Wagz »

Did you use my included lircrc file or create your own. Also, on the key presses, is it in-game or simply on the menu?
michiatlnx
New Member
Posts: 3
Joined: Thu Oct 16, 2008 6:48 am

Post by michiatlnx »

Hello,

I test with your lircrc also, the problem is in the menu and only the direction keys and it scrolls thru the menus. All other keys work fine.
Post Reply