Bug 14007 - Cannot intercept IR button presses programatically
: Cannot intercept IR button presses programatically
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: IR
: 7.4.0
: All All
: P1 normal with 1 vote (vote)
: 7.4.0
Assigned To: Andy Grundman
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-09-12 22:35 UTC by Peter Watkins
Modified: 2009-10-05 14:38 UTC (History)
4 users (show)

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Watkins 2009-09-12 22:35:10 UTC
Prior to change 27975, it was possible to intercept or "wrap" all IR button events in a SqueezeCenter plugin with code like

$originalIRCommand = Slim::Control::Request::addDispatch(['ir','_ircode','_time'],[1, 0, 0, \&my_irCommand]);

Now Slim::Hardware::IR bypasses the 'ir' command: the old line

# process IR code
$client->execute(['ir', $entry->{'bytes'}, $entry->{'irTime'}]);

has been changed to

# process IR code
processIR($client, $irCodeBytes, $irTime);

This makes it impractical for plugins to intercept IR events -- with this code change, plugins can merely subscribe to IR nofications; they cannot intercept IR commands. 

Five of my plugins rely on the old behavior and now do not work properly with 7.4, including plugins that have been nominated by users for the Recommended 3rd Party Plugins list. It would be a great help if the core code could switch back to the execute() model.
Comment 1 James Richardson 2009-09-13 09:16:17 UTC
Andy: Your thoughts on this?  I have noticed intermittently on SP devices, the IR not working at all, could this be related?
Comment 2 Andy Grundman 2009-09-13 09:28:47 UTC
Hmm, I changed this because a simple IR press did what I thought was too much work and the use of two events (ir + button) seemed a waste.  Could you instead intercept button events?

James: this is not related to SP.
Comment 3 Peter Watkins 2009-09-13 11:37:51 UTC
Andy, I'll have to check that out; that might be viable for some of my plugins. SaverSwitcher needs the 'ir' hook for its button control feature (quickly tap a numbered button to change screensavers). KidsPlay seems perhaps more popular now, and it might work with 'button', the main issue being whether it can discern what key was pressed. If 'button' sends "dead" for keys in off mode, then I'd need a guarantee that I'd see the 'ir' notification before the 'button' command. If so could note which key was pressed and know how to treat the 'button' command.

Thanks.
Comment 4 Peter Watkins 2009-09-14 21:18:58 UTC
'button' doesn't work well for me. notifyFromArray() must use low-priority timers; even when I modify IR.pm to call notifyFromArray() before processIR(), my plugin doesn't get the 'ir' notification until after the 'button' command fires, which means I cannot reliably tell what button was pressed.

This is a significant problem for me; my plugins become prone to modality problems with 'button'. E.G., if in a mode with a custom mapping, I cannot reliably determine what button was pressed.
Comment 5 Andy Grundman 2009-09-15 04:46:56 UTC
I'll revert the change. :(
Comment 6 SVN Bot 2009-09-15 10:26:00 UTC
 == Auto-comment from SVN commit #28528 to the slim repo by andy ==
 == https://svn.slimdevices.com/slim?view=revision&revision=28528 ==

Fixed bug 14007, revert improved IR event handling because it breaks plugin functionality
Comment 7 James Richardson 2009-10-05 14:38:07 UTC
This bug has been marked as fixed in the 7.4.0 release version of SqueezeBox Server!
    * SqueezeCenter: 28672
    * Squeezebox 2 and 3: 130
    * Transporter: 80
    * Receiver: 65
    * Boom: 50
    * Controller: 7790
    * Radio: 7790  

Please see the Release Notes for all the details: http://wiki.slimdevices.com/index.php/Release_Notes

If you haven't already, please download and install the new version from http://www.logitechsqueezebox.com/support/download-squeezebox-server.html

If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.