[Finished] [MP1-4795] Add keyboard support to HID handler (2 Viewers)

Stéphane Lenclud

Retired Team Member
  • Premium Supporter
  • April 29, 2013
    2,576
    1,294
    Home Country
    Germany Germany
    My current "Centarea HID" for the Ortek/Hama uses an AutoHotKey script to give improved usability. It may turn out to be necessary to continue using such a script to circumvent some of the Ortek/Hama weirdness. I will know more when I have used the new support for a while.

    Hopefully there should be no need for AutoHotKey anymore.
     

    azzuro

    Test Group
  • Team MediaPortal
  • May 10, 2007
    9,948
    5,617
    France - IDF
    Home Country
    France France
    I have media function on my keyboard ( play / stop / vol /... ) this rework allow this one to work?
     

    Stéphane Lenclud

    Retired Team Member
  • Premium Supporter
  • April 29, 2013
    2,576
    1,294
    Home Country
    Germany Germany
    I have media function on my keyboard ( play / stop / vol /... ) this rework allow this one to work?
    No, your media keys should have been working just fine before, using HID. Those changes allow normal keyboard keys to be handled through HID thus allowing the use of profiles and modifiers (shift, ctrl, alt, windows). It has also the advantage of unifying our key handling code path. Profiles could then be used to provide full WMC and thus pseudo MCE remote support.
     

    Rick164

    MP Donator
  • Premium Supporter
  • January 7, 2006
    1,335
    1,005
    Home Country
    Netherlands Netherlands
    Will test the latest build this week and report back :) , believe I had one problem with one of my own plugins using the previous build which was with the MP1 OnNewAction function:

    Code:
    public void OnNewAction(Action action)
    {
      string keyChar = KeycodeToChar(action.m_key.KeyChar).ToLower();
      string keyCode = action.m_key.KeyCode.ToString().ToLower();
    
    // Pass the key commands to another handler
      KeyCommandHandler(keyChar, keyCode);
    }

    It would no longer report a keyChar or keyCode almost as if OnNewAction wasn't being called anymore, now with the OnNewAction it was not possible to grab modifiers (shift / control etc..) as well but believe that was a limit imposed by MP1 core.
     
    Last edited:

    Stéphane Lenclud

    Retired Team Member
  • Premium Supporter
  • April 29, 2013
    2,576
    1,294
    Home Country
    Germany Germany
    It would no longer report a keyChar or keyCode almost as if OnNewAction wasn't being called anymore, now with the OnNewAction it was not possible to grab modifiers (shift / control etc..) as well but believe that was a limit imposed by MP1 core.

    Interesting, you would indeed not get such a Key object in your action when using HID keyboard handler.
    May I ask why you need such a Key?
    To me the whole point is that keys are mapped to actions. From an action point of view it should not matter which key did trigger it.
     

    Rick164

    MP Donator
  • Premium Supporter
  • January 7, 2006
    1,335
    1,005
    Home Country
    Netherlands Netherlands
    For that plugin use it to do list actions for instance like:

    Toggle cover
    Reload view
    Load categories

    Some other plugins use it as well like MyAnime I believe and copied it off another a while back but can't remember which one.
    With HID mapping to actions you get limited to a certain set which you need to setup within Mediaportal as well while with keyboard actions you get a bit more choices / freedom as you can just read out the keys without having the user setup anything :) , couple of downsides are that Mediaportal can't read the modifiers and that it passes thru as you can't set something like e.handled = true to cancel other actions used by that key.
    Other than that it's pretty nice to have so hope it's possible to keep it in :)
     

    Stéphane Lenclud

    Retired Team Member
  • Premium Supporter
  • April 29, 2013
    2,576
    1,294
    Home Country
    Germany Germany
    With HID mapping to actions you get limited to a certain set which you need to setup within Mediaportal as well while with keyboard actions you get a bit more choices / freedom as you can just read out the keys without having the user setup anything :) , couple of downsides are that Mediaportal can't read the modifiers and that it passes thru as you can't set something like e.handled = true to cancel other actions used by that key.

    You are indeed limited to the actions defined by MediaPortal. Ideally plug-ins should be able to publish their own actions so that they can be mapped to shortcuts, thus each plug-in would not need to implement its own key mapping system, they could just use the MP1 system. For now and until actions can be published, if your plug-in is interested in the keys it should not use the action handler. It should instead get the keys from the system (WM_INPUT) and possibly use SharpLibHid to parse the message much like Auto3DPlugin does.

    Hard coding shortcuts in plug-in is bad practice :)
     

    Rick164

    MP Donator
  • Premium Supporter
  • January 7, 2006
    1,335
    1,005
    Home Country
    Netherlands Netherlands
    For now and until actions can be published, if your plug-in is interested in the keys it should not use the action handler. It should instead get the keys from the system (WM_INPUT) and possibly use SharpLibHid to parse the message much like Auto3DPlugin does.

    Thanks will check that one out, used on previously but that slowed down keyboard input and had to unhook every time the plugin wasn't in focus so hopefully that library will be better.

    Hard coding shortcuts in plug-in is bad practice :)

    It's optionally configurable in the plugin though but agree it's far from perfect, like you said best solution
    would be published actions by plugins so that the HID handler can read those out and map :)
     
    Last edited:

    Users who are viewing this thread

    Top Bottom