EventGhost and USB-UIRT with RC-6 remote

If you have a question or need help, this is the place to be.

EventGhost and USB-UIRT with RC-6 remote

Postby Naked » Wed Mar 15, 2006 10:34 pm

I'm using EventGhost with USB-UIRT. At first I was a bit puzzled on how I should know what kind of events the remote controller is going to give me - but then I noticed that when I pressed buttons on my remote, I saw events being listed on the left hand pane.

But, those events were different every time I pressed the same key!

So, my question is, how am I supposed to use the events from USB-UIRT. The remote I am using is using the RC-6 protocol - and I have configured it to work with LIRC just fine. How do I make it work with EventGhost? Do I need to write some logic of my own or is there already something that solves my dilemma?
Nuutti Kotivuori
Naked
 
Posts: 4
Joined: Wed Mar 15, 2006 8:57 pm

Postby Bitmonster » Wed Mar 15, 2006 11:05 pm

In the future EG will get an object that can be configured to the keys the user wants, but currently some scripting is needed.

First you need access to the plugin-object you want to modify. This is simply done through a script that is just directly behind the plugin in the autostart macro. Every plugin will set the variable "result" to itself everytime it is "executed" and you can catch this value with a script directly afterwards. In this script you do something like this:
Code: Select all
plugin = eg.result
plugin.Map("412F52F040F1", "Enter")
plugin.Map("4344143C50B1", "Enter")
plugin.Map("412F523450F1", "Down")
plugin.Map("4342416789B1", "Down")
...

So you map two event-codes (without the plugin prefix) to one textual event of your choice. Do this for all keys you need.

You can also fine-tune the repeat time of your remote, to get better "ButtonReleased" handling. Just add the timeout in seconds as a third parameter like:
Code: Select all
plugin = eg.result
plugin.Map("412F52F040F1", "Enter", 0.12)
plugin.Map("4344143C50B1", "Enter", 0.12)
...

Or to be able to modify it more globally, you can of course also do:
Code: Select all
plugin = eg.result
timeout = 0.12
plugin.Map("412F52F040F1", "Enter", timeout)
plugin.Map("4344143C50B1", "Enter", timeout)
...

Now you have to do one of the following to get the script doing its job:
1. restart EG
2. execute the autostart macro manually
3. execute the plugin-item manually and directly after that this script
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Postby Naked » Thu Mar 16, 2006 9:51 am

Okay, great! I will see if this helps.

If the events returned by the remote are too numerous, can I somehow put a function in there that will handle the mapping instead?
Nuutti Kotivuori
Naked
 
Posts: 4
Joined: Wed Mar 15, 2006 8:57 pm

Postby Bitmonster » Thu Mar 16, 2006 12:19 pm

Naked wrote:Okay, great! I will see if this helps.

If the events returned by the remote are too numerous, can I somehow put a function in there that will handle the mapping instead?

No, you would have to build a modified version of the USB-UIRT plugin instead or modify the baseclass. The mapping above is done through a dictonary (it is therefor quite efficient) and is implemented in the baseclass for all "repeating receivers" (eg/RawReceiverPlugin.py).

Might be an idea to implement a special event-filter function-hook there in the future but most receivers (including the USB-UIRT) won't give such toggling events in a consistent programmatically way, so it would seldom be possible to "compute" them out.
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Postby Naked » Thu Mar 16, 2006 6:09 pm

Yes, this helped. There were just two toggling messages for each key press, so it was no trouble.

I was distracted for a bit with your comment of "plugin = eg.result" where as a simple "plugin = result" was needed, but I figured it out soon enough by looking at the code.

I will report more of my findings when I have time to configure this beast some more.
Nuutti Kotivuori
Naked
 
Posts: 4
Joined: Wed Mar 15, 2006 8:57 pm

Postby Bitmonster » Thu Mar 16, 2006 6:18 pm

Naked wrote:I was distracted for a bit with your comment of "plugin = eg.result" where as a simple "plugin = result" was needed, but I figured it out soon enough by looking at the code.

No, in a script eg.result is needed (at least in the future). Python-scripts in EG only get a single variable added to the namespace and this is "eg". This is to avoid name-clashes in scripts. For "Python-Command-Actions" in EG this is a bit different. There you only need "result". If you want to export a name from a script so you can use it globally also in Python-Command-Actions you should write it to eg.Global. For example in a script you can write directly after the plugin:
eg.Global.MyUsbUirt = eg.result
and then you could add Python-Command-Actions everywhere in the tree like:
MyUsbUirt.Map("239867F1", "Left")
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Postby Naked » Sun Mar 19, 2006 5:52 pm

Bitmonster wrote:
Naked wrote:I was distracted for a bit with your comment of "plugin = eg.result" where as a simple "plugin = result" was needed, but I figured it out soon enough by looking at the code.

No, in a script eg.result is needed (at least in the future).


I'm not sure if we are talking about the same thing. I added a new action of type Python Script below the USB-UIRT in the Autostart tree. Then I doubleclicked on the added item and got an editor where I have:

plugin = result

plugin.Map('27DA000F78E4', 'DVD_power')
plugin.Map('253A023CF0E4', 'DVD_power')
...


If I change this to be "plugin = eg.result", I get "AttributeError: 'module' object has no attribute 'result'." If I write "plugin = eg.Global.result", it works again, but that seems to be a bit besides the point of the whole Global thing...

Anyway, the thing works, now I'm trying to work up a good set of actions - I'll write more when I manage to really use this thing.
Nuutti Kotivuori
Naked
 
Posts: 4
Joined: Wed Mar 15, 2006 8:57 pm

Postby Bitmonster » Sun Mar 19, 2006 6:02 pm

Naked wrote:I'm not sure if we are talking about the same thing. I added a new action of type Python Script below the USB-UIRT in the Autostart tree. Then I doubleclicked on the added item and got an editor where I have:
plugin = result

plugin.Map('27DA000F78E4', 'DVD_power')
plugin.Map('253A023CF0E4', 'DVD_power')
...
If I change this to be "plugin = eg.result", I get "AttributeError: 'module' object has no attribute 'result'." If I write "plugin = eg.Global.result", it works again, but that seems to be a bit besides the point of the whole Global thing...

Uhps, you are right. "eg.result" is not there currently. I think I will change this, so that "result" and "eg.result" are both imported/exported. Some versions later I might remove "result" then, because I want to have the script-namespace as tight as possible.
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Postby Bartman » Sat Nov 18, 2006 7:57 pm

This seems to work only on plug-ins based on the RawReceiverPlugin. I just wanted to remap some keyboard events, but i just received "AttributeError: 'Keyboard' object has no attribute 'Map'". It works fine with the USB UIRT plug-in though.
Bartman
Plugin Developer
 
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Postby Bitmonster » Sat Nov 18, 2006 8:11 pm

@Bartman
Yes, you are right that this will only work with plugins that derive from eg.RawReceiverPlugin. I thought about merging most of the functionality of this class with the eg.PluginClass and to introduce an universal event remapping dialog for all plugins. But I'm currently uncertain what the best way would be:
a) Add it as a configuration option to the configuration dialog of every individual plugin.
b) Add it as an action, that you could place into the autostart macro, so you can use as much of these actions as you have plugins.
c) Integrate it as a base function of EG, like the "add plugin dialog" or "add action dialog"

This function should also have a clever wizard to learn new events, to make it easier for the user to merge multiple codes to one event (for problems like RC6 remotes) and to determine the repeat timeout automatically.
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Postby Bartman » Sat Nov 18, 2006 8:19 pm

I thought of it myself and would attach the configuration to the plugin in the autostart option. So i woul prefer action a). I could imagine the list getting quite long, if all mapping of all plug-ins would be displayed together.

A clever way to learn new mappings would be a context menu entry of events in the logger. The user could enter a new string or choose an old one via a combobox.
A nice feature would be if the event in the configuration is renamed or deleted automatically.
Bartman
Plugin Developer
 
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Postby Bitmonster » Sat Nov 18, 2006 8:40 pm

Well, the reason why I'm uncertain to use way a) is exactly the future of the event context. The also needed new "add event dialog" then would have to display all already learned events of all plugins and therefor something like a tree display would be needed. But if this display already shows all events of all plugins, the "remapping dialog" should also display them in the same way to help the user by reusing the same kind of display.

So my current thoughts go more in the direction, that the event remapping is actually an option of the events and not of the plugins. If you then use "add event" you would get the display of all events and the option to remap or learn new ones in the same dialog.
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm


Return to General Support

Who is online

Users browsing this forum: Bing [Bot] and 1 guest