(original thread) MCE Replacement Plugin v1.0.0 (8 Viewers)

Status
Not open for further replies.

and-81

Retired Team Member
  • Premium Supporter
  • March 7, 2005
    2,257
    183
    Melbourne
    Home Country
    Australia Australia
    new test version (0.2.1.0 & SVN)

    :D Awesome! I'm raising my hand now to volunteer for whatever testing you need...

    I've attached a test version for you to try. I had a quick play with it, but I think you will have a better chance of getting it to work. I've added two new event types, one for GUI_MSG_CLICKED (which should do what you want) and one for GUI_MSG_ITEM_SELECTED (added it during testing, might as well stay).

    IF you need a different event let me know and I'll put it in. I should probably just put in all Gui Messages now that you can match a parameter...

    Give it a try and let me know how you go, if you need changes put in I'll try to accomodate. In my testing I was able to see a GUI_MSG_CLICKED message when I clicked a button in the home screen, but not when I clicked a button in for example the Video module. But maybe you can get it doing what you wanted, if not I'll try to improve it.

    Let me know how you go.

    Cheers,
     

    Topher5000

    Portal Pro
    April 5, 2006
    179
    0
    Incompatible with latest svn

    I was having major problems with jerky tv recordings with 0.2.1.0, so I upgraded to the latest svn. TV recording is working now, but when I try to set up this plugin, MediaPortal says it's incompatible. Is there any chance of it getting updated?
    Edit: DUH! Nevermind!
     

    zombiepig

    Portal Pro
    March 21, 2005
    408
    0
    Melb, Aus
    Home Country
    Give it a try and let me know how you go, if you need changes put in I'll try to accomodate. In my testing I was able to see a GUI_MSG_CLICKED message when I clicked a button in the home screen, but not when I clicked a button in for example the Video module. But maybe you can get it doing what you wanted, if not I'll try to improve it.

    I'm getting the same behaviour - can map a click event for a button if it's in the home screen, but not for any of the music screens. :(
     

    and-81

    Retired Team Member
  • Premium Supporter
  • March 7, 2005
    2,257
    183
    Melbourne
    Home Country
    Australia Australia
    I'll do some more experimentation at my end and see if I can figure something out.

    I'll post back when I have a solution.

    cheers,
     

    and-81

    Retired Team Member
  • Premium Supporter
  • March 7, 2005
    2,257
    183
    Melbourne
    Home Country
    Australia Australia
    Absolutely!

    I didn't include source in the zip file because it's just for testing, but here's the code that handles it:

    static void MapEvent(GUIMessage msg)
    {
    MappedEvent.Events eventType = MappedEvent.GetEventType(msg.Message);

    foreach (MappedEvent mappedEvent in EventMappings)
    {
    if (mappedEvent.EventType == eventType)
    {
    bool matched = true;

    if (mappedEvent.MatchParam)
    {
    string paramValueString = mappedEvent.ParamValue;
    int paramValueInt = -1;
    int.TryParse(mappedEvent.ParamValue, out paramValueInt);
    bool paramValueBool = false;
    bool.TryParse(mappedEvent.ParamValue, out paramValueBool);

    switch (mappedEvent.Param)
    {
    case "Label 1":
    matched = (msg.Label == paramValueString);
    break;
    case "Label 2":
    matched = (msg.Label2 == paramValueString);
    break;
    case "Label 3":
    matched = (msg.Label3 == paramValueString);
    break;
    case "Label 4":
    matched = (msg.Label4 == paramValueString);
    break;
    case "Parameter 1":
    matched = (msg.Param1 == paramValueInt);
    break;
    case "Parameter 2":
    matched = (msg.Param2 == paramValueInt);
    break;
    case "Parameter 3":
    matched = (msg.Param3 == paramValueInt);
    break;
    case "Parameter 4":
    matched = (msg.Param4 == paramValueInt);
    break;
    case "Sender Control ID":
    matched = (msg.SenderControlId == paramValueInt);
    break;
    case "Send To Target Window":
    matched = (msg.SendToTargetWindow == paramValueBool);
    break;
    case "Target Control ID":
    matched = (msg.TargetControlId == paramValueInt);
    break;
    case "Target Window ID":
    matched = (msg.TargetWindowId == paramValueInt);
    break;
    default:
    matched = false;
    break;
    }
    }

    if (!matched)
    continue;

    if (LogVerbose)
    Log.Info("MCEReplacement: Event Mapper - Event \"{0}\"", Enum.GetName(typeof(MappedEvent.Events), eventType));

    string command = mappedEvent.Command;

    if (command.StartsWith(BlastCommandPrefix))
    command = command.Substring(BlastCommandPrefix.Length);

    if (!ProcessCommand(command, BlastPort))
    {
    Log.Error("MCEReplacement: Failed to execute Event Mapper command \"{0}\"", mappedEvent.EventType);
    }
    }
    }
    }

    It's pretty straight forward. GUIMessage is a mediaportal class that is used for sending messages inside the mediaportal code. I compare that against the entries in the event mapper and when there is a match I compare parameters (if required) and then process the command if the paramter matches. It only compares one parameter at the moment, if there becomes a need for more parameters to be matched I'll improve it.

    I'm looking at this code and the mediaportal source trying to figure out a way to do it now... I'll get back to you when I have something.

    Cheers,
     

    and-81

    Retired Team Member
  • Premium Supporter
  • March 7, 2005
    2,257
    183
    Melbourne
    Home Country
    Australia Australia
    Success!

    ok, I've got it working. It's a little bit of mucking around, but nothing serious. And the result is pretty cool and well worth it...

    If you look at this code from inside mediaportal you will see that buttons with a window or an action set will not send a GUIMessage when clicked.

    // If this links to another window go to the window.
    if (_hyperLinkWindowId >= 0)
    {
    GUIWindowManager.ActivateWindow((int)_hyperLinkWindowId);
    return;
    }
    // If this button corresponds to an action generate that action.
    if (ActionID >= 0)
    {
    Action newaction = new Action((Action.ActionType)ActionID, 0, 0);
    GUIGraphicsContext.OnAction(newaction);
    return;
    }

    // button selected.
    if (SubItemCount > 0)
    {
    // if we got subitems, then change the label of the control to the next
    //subitem
    SelectedItem++;
    if (SelectedItem >= SubItemCount) SelectedItem = 0;
    Label = (string)GetSubItem(SelectedItem);
    }

    // send a message to anyone interested
    message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null);
    GUIGraphicsContext.SendMessage(message);

    But if I create a new button in for example My Videos and don't assign an action, just a label, then I can use it to trigger an IR blast in my plugin by using event mapper to match the SenderControlID parameter to the <id> tag on the button.

    Here's a change to the myvideos.xml and to the strings.xml I made and the command I put in the event mapper is shown in the attached image (as well as a screen shot of the extra button in the My Videos screen) ...

    <control>
    <description>Blast IR</description>
    <type>button</type>
    <id>818181</id>
    <label>818181</label>
    </control>

    <string>
    <id>818181</id>
    <value>Blast IR</value>
    </string>

    So give it a try and let me know how you get on. If all goes well I will put this in the next version (the one I've been talking about releasing for a long time now).

    Once the new version is out I will be putting all my efforts into the next evolution of the plugin, which is a pretty big step but will bring some VERY cool new abilities. Like sharing an MCE receiver over a network, and being able to use a program on a network pc to simulate an MCE remote on another computer ... Stay tuned.

    Cheers,
     

    zombiepig

    Portal Pro
    March 21, 2005
    408
    0
    Melb, Aus
    Home Country
    hmmm- i've tried copying your example but still no luck. might it be because the machine i'm testing it on has no mce remote connected?

    i'm testing it with running an external program, btw :p
     

    and-81

    Retired Team Member
  • Premium Supporter
  • March 7, 2005
    2,257
    183
    Melbourne
    Home Country
    Australia Australia
    hmmm- i've tried copying your example but still no luck. might it be because the machine i'm testing it on has no mce remote connected?

    i'm testing it with running an external program, btw :p

    Hmm, those things shouldn't matter. But maybe duplicate my example exactly and go from there ...

    I don't think I made any changes to the source of the plugin that would affect this, but try the attached version anyway, it's my current working copy...
     
    Status
    Not open for further replies.

    Users who are viewing this thread

    Top Bottom