Help - Search - Members - Calendar
Full Version: foo_lirc plugin
Hydrogenaudio Forums > Hosted Forums > foobar2000 > 3rd Party Plugins - (fb2k)
Pages: 1, 2
levsh
Hello!

I want to announce foo_lirc plugin for controlling the FooBar2000 from a remote control. It is in the alpha stage of the development, but it already has the support for this features:

- configurable LIRC/WinLIRC server address and port
- supported player controls: play, pause, stop, prev.track, next track, track position and volume.

The plugin and its source code is available at SourceForge page, you may download binaries from here:
foo_lirc binary and sources

I'm waiting for comments and list of missing actions wink.gif

Screenshot
seanyseansean
Nice, i'm going to try this with my ATI AIW tonight smile.gif
Johncan
I use IRMan as my IR receiver with a Sony remote. I wish the IRMan worked WinLIRC so I could try out your plugin. Maybe someday IRMan and WinLIRC will be able to "play together." Does anyone know of a plugin that will work with IRMan and Foobar 8?

John
levsh
John, you may try to use the SlyControl (detailed description) program, it supports IRMan devices, and it can work as a WinLIRC server.
Phi
Thanks levsh cool.gif, this should be very handy when I get around to building my UIRT2.
QUOTE
I'm waiting for comments and list of missing actions wink.gif

What I would like to see is the ability to bind a button to any of the possible foobar actions, with an action list similar to the one in core->keyboard shortcuts. This doesn't really fit in with the code you have written already, but I think it would be a nice function to have wink.gif

P.S. About the SDK, I know its possible to get the list of available actions by using service_enum_t on the menu_item class, but I'm not sure whether this would be considered a hack. Is there a more standard way to get the available actions?
dano
thx levsh, it works well for me
yes, Phi's suggestion would be great
seanyseansean
QUOTE(seanyseansean @ Mar 3 2004, 02:52 PM)
Nice, i'm going to try this with my ATI AIW tonight smile.gif

Aha, it works fine. Marvellous job! I agree with the other comments though, it'd be nice to have all the actions available.

I might have a look at that source, too. I've been thinking of implementing a 'predictive text' style method for entering song titles in the playlist search, using the numeric keys on the AIW remote.

ta,

sean
foosion
QUOTE(Phi @ Mar 4 2004, 11:10 AM)
P.S. About the SDK, I know its possible to get the list of available actions by using service_enum_t on the menu_item class, but I'm not sure whether this would be considered a hack. Is there a more standard way to get the available actions?

Using a service_enum for menu_items is a perfectly valid (and standard) way to get a list of the available commands.
Phi
QUOTE(foosion @ Mar 5 2004, 02:10 AM)
QUOTE(Phi @ Mar 4 2004, 11:10 AM)
P.S. About the SDK, I know its possible to get the list of available actions by using service_enum_t on the menu_item class, but I'm not sure whether this would be considered a hack. Is there a more standard way to get the available actions?

Using a service_enum for menu_items is a perfectly valid (and standard) way to get a list of the available commands.

Thanks for the clarification, foosion.

I have some similar code left over from a plugin I worked on for a while (macro commands for foobar) but never released, so I might try to implement this myself if I get some free time over the weekend.
Linkin
thanks a lot for this great plugin! it is exactly what i waited for since i got an ir-reciever. smile.gif
cryptAWD
Thanks for this plugin. This is something I've been looking for. The only thing I'd like to see added at this point would be next/prev playlist.
levsh
QUOTE
P.S. About the SDK, I know its possible to get the list of available actions by using service_enum_t on the menu_item class, but I'm not sure whether this would be considered a hack. Is there a more standard way to get the available actions?


It would be really helpfull if you or someone could drop me an email with a description, sample, or link to the documentation on how to do this. Right now I haven't found a good way for this.

Thanks

P.S. Really strange, I haven't received any email notifications from the forum about the messages in this thread. Any ideas? smile.gif
levsh
QUOTE(Phi @ Mar 4 2004, 02:10 AM)
P.S. About the SDK, I know its possible to get the list of available actions by using service_enum_t on the menu_item class, but I'm not sure whether this would be considered a hack. Is there a more standard way to get the available actions?

I haven't found any clues or sources of the Keyboard Shortcuts plugin. Correct me if I'm wrong, but from the browsing through strings of the foobar2000.exe binary I came to a conclusion that "Actions" list from the "Keyboard Shortcuts" is actually hardcoded, and not generated dynamicly. It would be great if someone from the development team could tell if I'm right unsure.gif

Anyway, if this is true, the list from the "Keyboard Shorcuts" seems to be a bit too long for a remote control actions, so the list of actions to be toggled remotely is still welcome smile.gif

I'd prefere to move this discussion to the Feature Requests tracker on the sourceforge unsure.gif
Phi
QUOTE(levsh @ Mar 10 2004, 06:39 AM)
QUOTE
P.S. About the SDK, I know its possible to get the list of available actions by using service_enum_t on the menu_item class, but I'm not sure whether this would be considered a hack. Is there a more standard way to get the available actions?


It would be really helpfull if you or someone could drop me an email with a description, sample, or link to the documentation on how to do this. Right now I haven't found a good way for this.

Actually, I went ahead and implemented what I was suggesting a few days ago. It turned into almost a complete rewrite of your plugin. I didn't intend to hijack your plugin idea, but it turned out I had too much spare time on the weekend. unsure.gif I'll post links to what I've done as soon as I can get to my computer at home.

Regarding how to get the list of actions, this is the code I was talking about:
CODE

   service_enum_t<menu_item> e;
   menu_item * i;
   for(i=e.first();i;i = e.next())
   {
    int m,n = i->get_num_items();
    for(m=0; m<n; m++)
    {
     string8 command;
     // You may recognise this as the menu_item::enum_item(n,string_base& out)
     //virtual function you implement when you make your own menu item
     i->enum_item(m,command);
    }
    i->service_release();
   }

service_enum_t is basically a way to enumerate through each instance of a certain object registered using a service_factory_t (or in the menu_item case menu_item_factory)

Hope I made sense there! biggrin.gif
foosion
QUOTE(levsh @ Mar 9 2004, 10:15 PM)
I haven't found any clues or sources of the Keyboard Shortcuts plugin. Correct me if I'm wrong, but from the browsing through strings of the foobar2000.exe binary I came to a conclusion that "Actions" list from the "Keyboard Shortcuts" is actually hardcoded, and not generated dynamicly. It would be great if someone from the development team could tell if I'm right  unsure.gif

The "Keyboard Shortcuts" page in preferences is implemented in the core, and the list of actions is most certainly not hardcoded. As the core also implements a whole batch of commands, the names of these commands will consequently be present in the foobar2000.exe binary.

QUOTE(Phi @ Mar 10 2004, 01:15 AM)
Regarding how to get the list of actions, this is the code I was talking about:

You may want to check the type of the menu item as well, i.e. whether it is a context or main menu command.
Phi
I think I'm finally ready to release my version of the plugin, so here it is...

Plugin: foo_lirc-0.2.zip
Source: foo_lirc-0.2-src.zip

Screenshot for those who are interested.

The main change is inherent support of all foobar main menu commands.
levsh
QUOTE(Phi @ Mar 13 2004, 06:38 AM)

It would be great if you register in sourceforge, I'll give you full permissions on the foolirc project smile.gif, I think it's a good idea to keep everything in one place rolleyes.gif
Phi
QUOTE(levsh @ Mar 14 2004, 08:34 PM)
QUOTE(Phi @ Mar 13 2004, 06:38 AM)

It would be great if you register in sourceforge, I'll give you full permissions on the foolirc project smile.gif, I think it's a good idea to keep everything in one place rolleyes.gif

I agree its a good idea to keep everything in one place, but I'm (still) not too familiar with sourceforge, and I don't think I'll be able to continue development on this plugin now anyhow. Thanks for the offer though. smile.gif

And obviously, you are free to use the -0.2 source however you want wink.gif
levsh
QUOTE(Phi @ Mar 14 2004, 11:41 PM)
QUOTE(levsh @ Mar 14 2004, 08:34 PM)
QUOTE(Phi @ Mar 13 2004, 06:38 AM)

It would be great if you register in sourceforge, I'll give you full permissions on the foolirc project smile.gif, I think it's a good idea to keep everything in one place rolleyes.gif

I agree its a good idea to keep everything in one place, but I'm (still) not too familiar with sourceforge, and I don't think I'll be able to continue development on this plugin now anyhow. Thanks for the offer though. smile.gif

And obviously, you are free to use the -0.2 source however you want wink.gif

Is it ok if I put your version on the Sourceforge myself then?
Phi
QUOTE(levsh @ Mar 15 2004, 11:39 PM)
Is it ok if I put your version on the Sourceforge myself then?

Yes certainly, that was what I was implying but forgot to mention. biggrin.gif
Linkin
Hi,

I am using the columns_ui and if I had the lirc plugin enabled and then close foobar and reopen it i always get this error message:
user posted image
I have to go to preferences and re-enable lirc support to make it work again. It happens always, note that the columns_ui has to be enabled. Is there anything you can do to fix this?

thanks in advance
bleh
No, it's a bug in foo_lirc. The way foo_lirc finds the main window is to do this:
CODE
#define foo_window_class TEXT("{DA7CD0DE-1602-45e6-89A1-C2CA151E008E}")
hMainWindow = FindWindow(foo_window_class, NULL);

That was how it would work in Winamp. However, that only works with the standard user interface, since columns has a different window class. What either Phi or levsh needs to do is to change foo_lirc to use
CODE
hMainWindow = core_api::get_main_window();

They accomplish the same thing, except the bottom one works with user interfaces other than the standard one. In fact, I'm pretty sure the standard UI has a hard-to-recognize window class like that to discourage people from trying to use FindWindow on it.

(edit): Wording changed.
dano
I have the same problem as Linkin, but what I noticed is that if I install another plugin, it works again. But installing another plugin again brings back the problem.
Kind of weird, maybe someone can recompile the plugin with the correct method?
Phi
QUOTE(dano @ May 29 2004, 11:06 AM)
Kind of weird, maybe someone can recompile the plugin with the correct method?

This same hack was fixed in my foo_gestures plugin a while ago (which I also haven't updated for quite some time whistling.gif), but I didn't bother recompiling foo_lirc as I figured noone was using it.

Anyhow, I've now added the change and recompiled for foo-0.8.2. I haven't tested this, but there shouldn't be any problems.

foo_lirc-0.2.1.zip
foo_lirc-0.2.1-src.zip
Linkin
thanks a lot phi! smile.gif
seanyseansean
QUOTE(Phi @ May 29 2004, 07:31 AM)
but I didn't bother recompiling foo_lirc as I figured noone was using it.

Ooooh wrong, I definitely use it with my ATI Remote.

Thanks for the update smile.gif
dano
Thanks for recompiling Phi
But I have a problem with your 0.2 version:
When I use "Playback/Next" or "Playback/Previous" via my remote it will skip one track and go 2 tracks further instead of only one (happens about every second time).
This did not happen with version 0.1, or maybe it is a problem of my remote receiver, it is not working so good anymore sad.gif
Phi
QUOTE(dano @ May 29 2004, 11:00 PM)
When I use "Playback/Next" or "Playback/Previous" via my remote it will skip one track and go 2 tracks further instead of only one (happens about every second time).
This did not happen with version 0.1, or maybe it is a problem of my remote receiver, it is not working so good anymore sad.gif

Hi dano,

This is probably foo_lirc's fault. There is a repeat rate field that WinLirc sends to foo_lirc when you hold down a remote button, but at the moment version 0.2 is ignoring it, so you get the command executed once for each repeat. I guess this is what is happening in your case.

The problem is, since this is actually useful for certain commands (like volume or seek for instance), I can't just ignore repeated presses. Version 0.1 had only a few hardcoded commands, so levsh could specify which commands needed to allow repeats and which didn't. Now that I've added arbitrary commands it becomes a little more complicated.

I'm a little busy studying right now, but when I get time I'll work something out to fix it. I'm thinking a checkbox next to each command that you assign (along the lines of "allow repeats") would probably be the best solution.

QUOTE(seanyseansean @ May 29 2004, 10:35 PM)
Ooooh wrong, I definitely use it with my ATI Remote.

Thanks for the update smile.gif

No Problem. I'm glad people are putting it to good use smile.gif
Phi
QUOTE(Phi @ May 30 2004, 01:00 AM)
The problem is, since this is actually useful for certain commands (like volume or seek for instance), I can't just ignore repeated presses.

Well, I guess I can until I have a better solution...

foo_lirc-no_repeat.zip

This version ignores repeats so it should fix your problems with skipping too many tracks if you can live without sane volume/seek control for a while wink.gif
dano
That's great Phi, thanks for your extra effort. smile.gif
Phi
foo_lirc 0.2.2
  • allows an action to be tagged "repeatable" (holding down a remote button repeats the assigned command)
  • fixes infinite loop bug when LIRC is closed unexpectedly
foo_lirc-0.2.2.zip
foo_lirc-0.2.2-src.zip

Let me know if anything isn't working right.
Safrax
Whenever Foobar 2000 starts up, foo_lirc doesnt automatically connect to the WinLIRC server. I must manually go into the preferences dialog and put a tick in enabled before it will start.
Phi
QUOTE(Safrax @ Jun 27 2004, 01:59 AM)
Whenever Foobar 2000 starts up, foo_lirc doesnt automatically connect to the WinLIRC server.  I must manually go into the preferences dialog and put a tick in enabled before it will start.

Thats what I get for maintaining a component that I don't actually use wink.gif

I'll release a fix in the next few days or so.
Phi
foo_lirc 0.2.3
  • now connects at start-up like it's supposed to
foo_lirc-0.2.3.zip
foo_lirc-0.2.3-src.zip
Linkin
thanks...you're the best biggrin.gif
Phi
QUOTE(Linkin @ Jun 29 2004, 11:05 PM)
thanks...you're the best  biggrin.gif

No problem smile.gif
jay7
ding-ding, bug report here! sad.gif
Well, may be I'm the last man on Earth still using eons ancient W95OSR2, but foo_lirc has problems under this OS-alike.
First, if i close and restart WinLIRC while foo_lirc is enabled and then press 'Connect' - fb2k crashes badly, often with the pitiful w95 huh.gif
If i set `enable` off then on and press 'Connect' - it is ok.
As i can see, that's because of setting a hook in StartLircClient() when StopLircClient was not called and the hook is already hooked. The simplest solution I see is to keep a flag like HookSet and act accordingly not to try set hook twice. rolleyes.gif
That was simple. Now to the sad part:
The plugin does nothing in my case! It configures perfectly, seeing all commands from WinLIRC and highlighting assigned actions. But besides that it does nothing. crying.gif
Spy++ shows those 'DEAD FEED' messages pass to fb2k main window.
It is something with those hooks too, I feel it wink.gif but the only w32 compiler i have is LCC and it knows nothing 'bout C++ so I'm just sitting aside sad.gif
BTW, is all this hooking The Only Right Way, or it can be done more straightly?
slight offtopic
The only reason I keep windows on that ancient box for - fb2k.
Digged the net many times, coudn't find nothing comparable to it.
But don't expect me to buy a new box with bloody XP inside just to control fb2k with remote.
Phi
QUOTE(jay7 @ Aug 2 2004, 04:44 AM)
ding-ding, bug report here!  sad.gif

OH NO!S!1 I'll have a look when I get a chance. Most of my "bugfixes" have just been hacks on existing code, so I'll take the time to rewrite it in the next few days.

QUOTE
BTW, is all this hooking The Only Right Way, or it can be done more straightly?

There are definitely better/easier ways to do it. Posting messages to the main foobar window is pretty dodgy.

PS. come on, at least upgrade to an OS thats still supported by MS tongue.gif
jay7
QUOTE(Phi @ Aug 2 2004, 08:04 AM)
OH NO!S!1 I'll have a look when I get a chance.  Most of my "bugfixes" have just been hacks on existing code, so I'll take the time to rewrite it in the next few days.

Oh, I'm really sorry to bother you, but it's definitely unreal to run MSVC++ on my p1-166. There's no need to rewrite, just several fixes.

QUOTE(Phi @ Aug 2 2004, 08:04 AM)
There are definitely better/easier ways to do it. Posting messages to the main foobar window is pretty dodgy.

Then let's take away all those hooks! smile.gif
patch can be as following, although I can't check it
CODE

*** foo_lirc.cpp.old Tue Jun 29 15:40:42 2004
--- foo_lirc.cpp Tue Aug 03 23:55:22 2004
***************
*** 32,38 ****
 bool config_mode;
 HWND hConfigWindow;
 HWND hMainWindow;
- HHOOK lirc_hook;
 
 static HWND status_wnd;
 
--- 32,37 ----
***************
*** 129,135 ****
    }
    else
    {
!     SendMessage(hMainWindow, WM_REMOTE_KEY, 0xDEAD, 0xFEED);
    }
   }
  }
--- 128,134 ----
    }
    else
    {
!     g_actions.process_keypress(lirc.key_name);
    }
   }
  }
***************
*** 331,348 ****
 
 static cfg_action g_actions("Assigned actions");
 
- LRESULT CALLBACK LircHook(int nCode, WPARAM wp, LPARAM lp)
- {
-  PCWPSTRUCT msg;
-  msg = (PCWPSTRUCT)lp;
-
-  if (nCode == HC_ACTION && msg->message == WM_REMOTE_KEY &&
-   msg->wParam == 0xDEAD && msg->lParam == 0xFEED)
-  {
-   g_actions.process_keypress(lirc.key_name);
-  }
-  return CallNextHookEx(lirc_hook, nCode, wp, lp);
- }
 
 bool StartLircClient()
 {
--- 330,335 ----
***************
*** 355,366 ****
   return false;
  }
 
-  lirc_hook = SetWindowsHookEx(WH_CALLWNDPROC, LircHook, NULL, GetCurrentThreadId());
-  if(lirc_hook == NULL) {
-   MessageBox(hMainWindow, "Failed to set Hook", szAppName, MB_OK);
-   return false;
-  }
-
  lirc.thread_id = _beginthread(LircClient, 0, &lirc.socket);
  if(lirc.thread_id == -1) {
   MessageBox(NULL, "Failed to create thread, foo_lirc will be disabled.", szAppName, MB_OK);
--- 342,347 ----
***************
*** 371,377 ****
 
 void StopLircClient()
 {
-  UnhookWindowsHookEx(lirc_hook);
  lirc.client_running = false;
 }
 
--- 352,357 ----
Phi
QUOTE(jay7 @ Aug 4 2004, 06:59 AM)
QUOTE(Phi @ Aug 2 2004, 08:04 AM)
OH NO!S!1 I'll have a look when I get a chance.  Most of my "bugfixes" have just been hacks on existing code, so I'll take the time to rewrite it in the next few days.

Oh, I'm really sorry to bother you, but it's definitely unreal to run MSVC++ on my p1-166. There's no need to rewrite, just several fixes.

It's no bother, I've actually already done most of the work.

QUOTE
Then let's take away all those hooks! smile.gif

Well, the whole point of posting messages to the main window (and hooking it to intercept them) was to ensure that process_keypress() (and subsequently, menu_manager::run_command()) was called from the main thread. I'm not sure how mm::run_command() actually works, and whether its safe to call it from the socket thread as you have done here.

Anyway, I've rewritten the code to use an asynchronous socket so this won't be an issue in the next release.
Phi
QUOTE(Phi @ Aug 4 2004, 01:30 PM)
Anyway, I've rewritten the code to use an asynchronous socket so this won't be an issue in the next release.

foo_lirc 0.3
  • big rewrite, should fix bugs mentioned earlier
foo_lirc-0.3.zip
foo_lirc-0.3-src.zip
Linkin
thx Phi

I appreciate your work
Phi
QUOTE(Linkin @ Aug 7 2004, 08:57 PM)
thx Phi

I appreciate your work

No problem smile.gif

foo_lirc 0.3.1
  • added support for "context/now playing" commands
  • minor ui improvements
foo_lirc-0.3.1.zip
foo_lirc-0.3.1-src.zip
jay7
Hooray, it works! smile.gif
grabbed 0.3.1 and now I'm totally satisfied!
skipped 0.3 because of weekend, just didn't give it a try wink.gif
Hooray to Phi! smile.gif
Thanks, really.
SBeaver
How do I set a button to scroll around in the playlist as if I had pressed up/down arrow?

edit: now have the cursor keys of my remote tied to previous/next playlist for right/left and works great. I'll try another program to bind the remote buttons up/down to cursor keys and see if that works better
Phi
Yeah, unfortunately there are no standard commands available in foobar to scroll the playlist up and down.
Betse
I know this is a bump from nowhere, but i really like this plugin.
Greatly appreciated here!
Keep up the good work smile.gif
Spi
wow, i didn't know of foo_lirc > 0.2 ;(
i only checked the sourceforge site.

but now im in need of a version for 0.9 wink.gif
Betse
I've got to support you on that one smile.gif Foobar just isn't complete without it wink.gif
cirrus
Yeah. I really cant live w/o my remote. Anyone know how to fix it / know if there is any new version out?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.